Ignore:
Timestamp:
Oct 22, 2013, 10:39:10 PM (11 years ago)
Author:
plg
Message:

feature 2920 added: change admin screen "pending comments" to "all comments".
Now the administrator can filter on "all" or "pending" with a single click.

In the admin menu, we display the number of pending comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/comments.php

    r25018 r25084  
    9898// +-----------------------------------------------------------------------+
    9999
    100 $list = array();
     100$nb_total = 0;
     101$nb_pending = 0;
    101102
    102103$query = '
    103 SELECT c.id, c.image_id, c.date, c.author, '.
    104 $conf['user_fields']['username'].' AS username, c.content, i.path, i.representative_ext
     104SELECT
     105    COUNT(*) AS counter,
     106    validated
     107  FROM '.COMMENTS_TABLE.'
     108  GROUP BY validated
     109;';
     110$result = pwg_query($query);
     111while ($row = pwg_db_fetch_assoc($result))
     112{
     113  $nb_total+= $row['counter'];
     114
     115  if ('false' == $row['validated'])
     116  {
     117    $nb_pending = $row['counter'];
     118  }
     119}
     120
     121if (!isset($_GET['filter']) and $nb_pending > 0)
     122{
     123  $page['filter'] = 'pending';
     124}
     125else
     126{
     127  $page['filter'] = 'all';
     128}
     129
     130if (isset($_GET['filter']) and 'pending' == $_GET['filter'])
     131{
     132  $page['filter'] = $_GET['filter'];
     133}
     134
     135$template->assign(
     136  array(
     137    'nb_total' => $nb_total,
     138    'nb_pending' => $nb_pending,
     139    'filter' => $page['filter'],
     140    )
     141  );
     142
     143$where_clauses = array('1=1');
     144
     145if ('pending' == $page['filter'])
     146{
     147  $where_clauses[] = 'validated=\'false\'';
     148}
     149
     150$query = '
     151SELECT
     152    c.id,
     153    c.image_id,
     154    c.date,
     155    c.author,
     156    '.$conf['user_fields']['username'].' AS username,
     157    c.content,
     158    i.path,
     159    i.representative_ext,
     160    validated
    105161  FROM '.COMMENTS_TABLE.' AS c
    106162    INNER JOIN '.IMAGES_TABLE.' AS i
     
    108164    LEFT JOIN '.USERS_TABLE.' AS u
    109165      ON u.'.$conf['user_fields']['id'].' = c.author_id
    110   WHERE validated = \'false\'
     166  WHERE '.implode(' AND ', $where_clauses).'
    111167  ORDER BY c.date DESC
    112168;';
     
    136192      'AUTHOR' => trigger_event('render_comment_author', $author_name),
    137193      'DATE' => format_date($row['date'], true),
    138       'CONTENT' => trigger_event('render_comment_content',$row['content'])
     194      'CONTENT' => trigger_event('render_comment_content',$row['content']),
     195      'IS_PENDING' => ('false' == $row['validated']),
    139196      )
    140197    );
     
    143200}
    144201
    145 $template->assign('LIST', implode(',', $list) );
    146 
    147202// +-----------------------------------------------------------------------+
    148203// |                           sending html code                           |
Note: See TracChangeset for help on using the changeset viewer.