Changeset 25084 for trunk


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.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin.php

    r24834 r25084  
    207207if ($conf['activate_comments'])
    208208{
    209   $template->assign('U_PENDING_COMMENTS', $link_start.'comments');
     209  $template->assign('U_COMMENTS', $link_start.'comments');
     210 
     211  // pending comments
     212  $query = '
     213SELECT COUNT(*)
     214  FROM '.COMMENTS_TABLE.'
     215  WHERE validated=\'false\'
     216;';
     217  list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
     218
     219  if ($nb_comments > 0)
     220  {
     221    $template->assign('NB_PENDING_COMMENTS', $nb_comments);
     222  }
    210223}
    211224
  • 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                           |
  • trunk/admin/include/add_core_tabs.inc.php

    r23382 r25084  
    6060     
    6161    case 'comments':
    62       $sheets[''] = array('caption' => l10n('User comments validation'), 'url' => '');
     62      $sheets[''] = array('caption' => l10n('User comments'), 'url' => '');
    6363      break;
    6464     
  • trunk/admin/themes/default/template/admin.tpl

    r23382 r25084  
    7373                                <li><a class="icon-signal" href="{$U_HISTORY_STAT}">{'History'|@translate}</a></li>
    7474                                <li><a class="icon-tools" href="{$U_MAINTENANCE}">{'Maintenance'|@translate}</a></li>
    75 {if isset($U_PENDING_COMMENTS)}
    76                                 <li><a class="icon-chat" href="{$U_PENDING_COMMENTS}">{'Pending Comments'|@translate}</a></li>
     75{if isset($U_COMMENTS)}
     76                                <li><a class="icon-chat" href="{$U_COMMENTS}">{'Comments'|@translate}{if $NB_PENDING_COMMENTS > 0}<span class="adminMenubarCounter" title="{'%d waiting for validation'|translate:$NB_PENDING_COMMENTS}">{$NB_PENDING_COMMENTS}</span>{/if}</a></li>
    7777{/if}
    7878        <li><a class="icon-arrows-cw" href="{$U_UPDATES}">{'Updates'|@translate}</a></li>
  • trunk/admin/themes/default/template/comments.tpl

    r22812 r25084  
    4444{/literal}{/footer_script}
    4545
    46 <h2>{'Pending Comments'|@translate} {$TABSHEET_TITLE}</h2>
     46<h2>{'User comments'|@translate} {$TABSHEET_TITLE}</h2>
     47
     48<p style="text-align:left;margin-left:1em;">
     49  <a href="{$F_ACTION}&amp;filter=all" class="{if $filter == 'all'}commentFilterSelected{/if}">{'All'|@translate}</a> ({$nb_total})
     50  | <a href="{$F_ACTION}&amp;filter=pending" class="{if $filter == 'pending'}commentFilterSelected{/if}">{'Waiting'|@translate}</a> ({$nb_pending})
     51</p>
    4752
    4853{if !empty($comments) }
     
    5863  <div class="comment">
    5964    <a class="illustration" href="{$comment.U_PICTURE}"><img src="{$comment.TN_SRC}"></a>
    60     <p class="commentHeader"><strong>{$comment.AUTHOR}</strong> - <em>{$comment.DATE}</em></p>
     65    <p class="commentHeader">{if $comment.IS_PENDING}<span class="pendingFlag">{'Waiting'|@translate}</span> - {/if}<strong>{$comment.AUTHOR}</strong> - <em>{$comment.DATE}</em></p>
    6166    <blockquote>{$comment.CONTENT}</blockquote>
    6267  </div>
Note: See TracChangeset for help on using the changeset viewer.