includes/template.php
changeset 825 9d5c04c1414f
parent 801 eb8b23f11744
child 832 7152ca0a0ce9
equal deleted inserted replaced
817:880c4b7eb658 825:9d5c04c1414f
   609       $e = $db->sql_query('SELECT approved FROM '.table_prefix.'comments WHERE page_id=\''.$local_page_id.'\' AND namespace=\''.$local_namespace.'\';');
   609       $e = $db->sql_query('SELECT approved FROM '.table_prefix.'comments WHERE page_id=\''.$local_page_id.'\' AND namespace=\''.$local_namespace.'\';');
   610       if ( !$e )
   610       if ( !$e )
   611       {
   611       {
   612         $db->_die();
   612         $db->_die();
   613       }
   613       }
   614       $nc = $db->numrows();
   614       $num_comments = $db->numrows();
   615       $nu = 0;
   615       $approval_counts = array(COMMENT_UNAPPROVED => 0, COMMENT_APPROVED => 0, COMMENT_SPAM => 0);
   616       $na = 0;
       
   617       
   616       
   618       while ( $r = $db->fetchrow() )
   617       while ( $r = $db->fetchrow() )
   619       {  
   618       {  
   620         if ( !$r['approved'] )
   619         $approval_counts[$r['approved']]++;
   621         {
       
   622           $nu++;
       
   623         }
       
   624         else
       
   625         {
       
   626           $na++;
       
   627         }
       
   628       }
   620       }
   629       
   621       
   630       $db->free_result();
   622       $db->free_result();
   631       $n = ( $session->check_acl_scope('mod_comments', $local_namespace) && $perms->get_permissions('mod_comments') ) ? (string)$nc : (string)$na;
   623       // $n = ( $session->check_acl_scope('mod_comments', $local_namespace) && $perms->get_permissions('mod_comments') ) ? (string)$num_comments : (string)$na;
   632       if ( $session->check_acl_scope('mod_comments', $local_namespace) && $perms->get_permissions('mod_comments') && $nu > 0 )
   624       if ( $session->check_acl_scope('mod_comments', $local_namespace) && $perms->get_permissions('mod_comments') && ( $approval_counts[COMMENT_UNAPPROVED] + $approval_counts[COMMENT_SPAM] ) > 0 )
   633       {
   625       {
   634         $subst = array(
   626         $subst = array(
   635             'num_comments' => $nc,
   627             'num_comments' => $num_comments,
   636             'num_unapp' => $nu
   628             'num_app' => $approval_counts[COMMENT_APPROVED],
       
   629             'num_unapp' => $approval_counts[COMMENT_UNAPPROVED],
       
   630             'num_spam' => $approval_counts[COMMENT_SPAM]
   637           );
   631           );
   638         $btn_text = $lang->get('onpage_btn_discussion_unapp', $subst);
   632         $btn_text = $lang->get('onpage_btn_discussion_unapp', $subst);
   639       }
   633       }
   640       else
   634       else
   641       {
   635       {
   642         $subst = array(
   636         $subst = array(
   643           'num_comments' => $nc
   637           'num_comments' => $num_comments
   644         );
   638         );
   645         $btn_text = $lang->get('onpage_btn_discussion', $subst);
   639         $btn_text = $lang->get('onpage_btn_discussion', $subst);
   646       }
   640       }
   647       
   641       
   648       $button->assign_vars(array(
   642       $button->assign_vars(array(