diff --git a/upload/inc/plugins/valck.php b/upload/inc/plugins/valck.php index 831377b933f487d0780b28b9f8bbe4a542da3514..4d08ff5d66f8713486c60712d80f534ed926d4c9 100755 --- a/upload/inc/plugins/valck.php +++ b/upload/inc/plugins/valck.php @@ -40,33 +40,68 @@ function valck_run() { global $mybb, $lang, $db, $valck_run; - // requete pour le badge message aujourdui - if($mybb->get_input('days', MyBB::INPUT_INT) < 1) - { - $days = 1; - } - else - { - $days = $mybb->get_input('days', MyBB::INPUT_INT); - } - $datecut = TIME_NOW-(86400*$days); + // requete pour les nouveaux messages like getdaily + // Get number of new posts, threads + // via https://community.mybb.com/thread-140350-post-1182934.html#pid1182934 + // requete pour le badge message aujourdui + if($mybb->get_input('days', MyBB::INPUT_INT) < 1) + { + $days = 1; + } + else + { + $days = $mybb->get_input('days', MyBB::INPUT_INT); + } + $datecut = TIME_NOW-(86400*$days); + + $sql = "SELECT count(*) FROM `".TABLE_PREFIX."threads` where lastpost >= ".$datecut." ORDER BY `tid` DESC"; + $query = $db->query("SELECT count(*) as count FROM `" . TABLE_PREFIX . "threads` where lastpost >= ".$datecut." ORDER BY `tid` DESC"); + $newposts = $db->fetch_field($query, "count"); + $db->free_result($query); + // fin requete message aujourdui + + + if ($newposts > 0) { + // Get new treads - nouveau sujet like search getnew + // If there aren't any new posts, there is no point in wasting two more queries + $query = $db->simple_select("threads", "COUNT(tid) AS newthreads", "visible=1 AND dateline>'".$mybb->user['lastvisit']."' $unviewwhere"); + $newthreads = $db->fetch_field($query, "newthreads"); + } else { + $newthreads = 0; + } - $sql = "SELECT count(*) FROM `".TABLE_PREFIX."threads` where lastpost >= ".$datecut." ORDER BY `tid` DESC"; - $query = $db->query("SELECT count(*) as count FROM `" . TABLE_PREFIX . "threads` where lastpost >= ".$datecut." ORDER BY `tid` DESC"); - $count = $db->fetch_field($query, "count"); - $db->free_result($query); - // fin requete message aujourdui - - - - // le code pour le forum $valck_run = <<<EOT <li> <div class="w-25 p-2"> <a href="{$mybb->settings['bburl']}/search.php?action=getdaily"> <h5><span data-toggle="tooltip" title="{$lang->welcome_todaysposts}" - class="align-middle badge badge-primary badge-pill shadow">{$count}</span></h5> + class="align-middle badge badge-primary badge-pill shadow">{$newposts}</span></h5> + </a> + </div> +</li> +<li> + <div class="w-25 p-2"> + <a href="{$mybb->settings['bburl']}/search.php?action=getnew"> + <h5><span data-toggle="tooltip" title="{$lang->welcome_newposts}" + class="align-middle badge badge-success badge-pill shadow">{$newthreads}</span></h5> + </a> + </div> +</li> +<li class="nav-divider"></li> +<li> + <div class="w-25 p-2"> + <a href="{$mybb->settings['bburl']}/private.php"> + <h5><span data-toggle="tooltip" title="Message privé non lu!" + class="align-middle badge badge-warning badge-pill shadow">{$mybb->user['pms_unread']}</span></h5> + </a> + </div> +</li> +<li> + <div class="w-25 p-2"> + <a href="{$mybb->settings['bburl']}/private.php"> + <h5><span data-toggle="tooltip" title="Tous les messages Privés" + class="align-middle badge badge-info badge-pill shadow">{$mybb->user['totalpms']}</span></h5> </a> </div> </li>