From 4328f5e6102b5c052f4f2b660a05dd0fc0ab0e5c Mon Sep 17 00:00:00 2001 From: ck <ck@Proxyb_ck1.ckforum> Date: Mon, 6 Apr 2020 14:17:36 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20badge=20suppl=C3=A9mentaite=20et?= =?UTF-8?q?=20de=20requetes=20li=C3=A9es=20au=20dernier=20post=20et=20trea?= =?UTF-8?q?ds=20adaptation=20du=20code=20(a=20optimiser)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upload/inc/plugins/valck.php | 75 ++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/upload/inc/plugins/valck.php b/upload/inc/plugins/valck.php index 831377b..4d08ff5 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> -- GitLab