diff options
author | plegall <plg@piwigo.org> | 2013-10-22 20:39:10 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2013-10-22 20:39:10 +0000 |
commit | fac62f863dceea47f90027c9404604ec74c559d3 (patch) | |
tree | 3b014552b96aed3bac301aeef8fea9bf907a456c | |
parent | ad6c3fd5661db2aa5aa21f7c1e661576f202fd02 (diff) |
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.
git-svn-id: http://piwigo.org/svn/trunk@25084 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | admin.php | 15 | ||||
-rw-r--r-- | admin/comments.php | 69 | ||||
-rw-r--r-- | admin/include/add_core_tabs.inc.php | 2 | ||||
-rw-r--r-- | admin/themes/default/template/admin.tpl | 4 | ||||
-rw-r--r-- | admin/themes/default/template/comments.tpl | 9 |
5 files changed, 86 insertions, 13 deletions
@@ -206,7 +206,20 @@ $template->assign( if ($conf['activate_comments']) { - $template->assign('U_PENDING_COMMENTS', $link_start.'comments'); + $template->assign('U_COMMENTS', $link_start.'comments'); + + // pending comments + $query = ' +SELECT COUNT(*) + FROM '.COMMENTS_TABLE.' + WHERE validated=\'false\' +;'; + list($nb_comments) = pwg_db_fetch_row(pwg_query($query)); + + if ($nb_comments > 0) + { + $template->assign('NB_PENDING_COMMENTS', $nb_comments); + } } // any photo in the caddie? diff --git a/admin/comments.php b/admin/comments.php index 637790353..e22771a78 100644 --- a/admin/comments.php +++ b/admin/comments.php @@ -97,17 +97,73 @@ $tabsheet->assign(); // | comments display | // +-----------------------------------------------------------------------+ -$list = array(); +$nb_total = 0; +$nb_pending = 0; $query = ' -SELECT c.id, c.image_id, c.date, c.author, '. -$conf['user_fields']['username'].' AS username, c.content, i.path, i.representative_ext +SELECT + COUNT(*) AS counter, + validated + FROM '.COMMENTS_TABLE.' + GROUP BY validated +;'; +$result = pwg_query($query); +while ($row = pwg_db_fetch_assoc($result)) +{ + $nb_total+= $row['counter']; + + if ('false' == $row['validated']) + { + $nb_pending = $row['counter']; + } +} + +if (!isset($_GET['filter']) and $nb_pending > 0) +{ + $page['filter'] = 'pending'; +} +else +{ + $page['filter'] = 'all'; +} + +if (isset($_GET['filter']) and 'pending' == $_GET['filter']) +{ + $page['filter'] = $_GET['filter']; +} + +$template->assign( + array( + 'nb_total' => $nb_total, + 'nb_pending' => $nb_pending, + 'filter' => $page['filter'], + ) + ); + +$where_clauses = array('1=1'); + +if ('pending' == $page['filter']) +{ + $where_clauses[] = 'validated=\'false\''; +} + +$query = ' +SELECT + c.id, + c.image_id, + c.date, + c.author, + '.$conf['user_fields']['username'].' AS username, + c.content, + i.path, + i.representative_ext, + validated FROM '.COMMENTS_TABLE.' AS c INNER JOIN '.IMAGES_TABLE.' AS i ON i.id = c.image_id LEFT JOIN '.USERS_TABLE.' AS u ON u.'.$conf['user_fields']['id'].' = c.author_id - WHERE validated = \'false\' + WHERE '.implode(' AND ', $where_clauses).' ORDER BY c.date DESC ;'; $result = pwg_query($query); @@ -135,15 +191,14 @@ while ($row = pwg_db_fetch_assoc($result)) 'TN_SRC' => $thumb, 'AUTHOR' => trigger_event('render_comment_author', $author_name), 'DATE' => format_date($row['date'], true), - 'CONTENT' => trigger_event('render_comment_content',$row['content']) + 'CONTENT' => trigger_event('render_comment_content',$row['content']), + 'IS_PENDING' => ('false' == $row['validated']), ) ); $list[] = $row['id']; } -$template->assign('LIST', implode(',', $list) ); - // +-----------------------------------------------------------------------+ // | sending html code | // +-----------------------------------------------------------------------+ diff --git a/admin/include/add_core_tabs.inc.php b/admin/include/add_core_tabs.inc.php index fcb87ca82..443775d38 100644 --- a/admin/include/add_core_tabs.inc.php +++ b/admin/include/add_core_tabs.inc.php @@ -59,7 +59,7 @@ function add_core_tabs($sheets, $tab_id) break; case 'comments': - $sheets[''] = array('caption' => l10n('User comments validation'), 'url' => ''); + $sheets[''] = array('caption' => l10n('User comments'), 'url' => ''); break; case 'configuration': diff --git a/admin/themes/default/template/admin.tpl b/admin/themes/default/template/admin.tpl index 782b9a0d1..bb46a3a70 100644 --- a/admin/themes/default/template/admin.tpl +++ b/admin/themes/default/template/admin.tpl @@ -72,8 +72,8 @@ jQuery(document).ready(function(){ldelim} {/if} <li><a class="icon-signal" href="{$U_HISTORY_STAT}">{'History'|@translate}</a></li> <li><a class="icon-tools" href="{$U_MAINTENANCE}">{'Maintenance'|@translate}</a></li> -{if isset($U_PENDING_COMMENTS)} - <li><a class="icon-chat" href="{$U_PENDING_COMMENTS}">{'Pending Comments'|@translate}</a></li> +{if isset($U_COMMENTS)} + <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> {/if} <li><a class="icon-arrows-cw" href="{$U_UPDATES}">{'Updates'|@translate}</a></li> </ul> diff --git a/admin/themes/default/template/comments.tpl b/admin/themes/default/template/comments.tpl index 82fe169db..908ffbe49 100644 --- a/admin/themes/default/template/comments.tpl +++ b/admin/themes/default/template/comments.tpl @@ -43,7 +43,12 @@ jQuery(document).ready(function(){ }); {/literal}{/footer_script} -<h2>{'Pending Comments'|@translate} {$TABSHEET_TITLE}</h2> +<h2>{'User comments'|@translate} {$TABSHEET_TITLE}</h2> + +<p style="text-align:left;margin-left:1em;"> + <a href="{$F_ACTION}&filter=all" class="{if $filter == 'all'}commentFilterSelected{/if}">{'All'|@translate}</a> ({$nb_total}) + | <a href="{$F_ACTION}&filter=pending" class="{if $filter == 'pending'}commentFilterSelected{/if}">{'Waiting'|@translate}</a> ({$nb_pending}) +</p> {if !empty($comments) } <form method="post" action="{$F_ACTION}" id="pendingComments"> @@ -57,7 +62,7 @@ jQuery(document).ready(function(){ <td> <div class="comment"> <a class="illustration" href="{$comment.U_PICTURE}"><img src="{$comment.TN_SRC}"></a> - <p class="commentHeader"><strong>{$comment.AUTHOR}</strong> - <em>{$comment.DATE}</em></p> + <p class="commentHeader">{if $comment.IS_PENDING}<span class="pendingFlag">{'Waiting'|@translate}</span> - {/if}<strong>{$comment.AUTHOR}</strong> - <em>{$comment.DATE}</em></p> <blockquote>{$comment.CONTENT}</blockquote> </div> </td> |