From 6d006303328909b111a9db1ac4199f0a993adb8b Mon Sep 17 00:00:00 2001 From: plegall Date: Fri, 26 Mar 2010 13:37:20 +0000 Subject: feature 1538: "select all" (+none, +invert) on user comments validation screen. git-svn-id: http://piwigo.org/svn/trunk@5381 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/comments.php | 80 ++++++++++++++++++++---------------------------------- 1 file changed, 29 insertions(+), 51 deletions(-) (limited to 'admin/comments.php') diff --git a/admin/comments.php b/admin/comments.php index 9173107db..394825ec9 100644 --- a/admin/comments.php +++ b/admin/comments.php @@ -38,49 +38,26 @@ check_status(ACCESS_ADMINISTRATOR); // | actions | // +-----------------------------------------------------------------------+ -if (isset($_POST)) +if (!empty($_POST) and !is_adviser()) { - $to_validate = array(); - $to_reject = array(); - - if (isset($_POST['submit']) and !is_adviser()) - { - foreach (explode(',', $_POST['list']) as $comment_id) - { - if (isset($_POST['action-'.$comment_id])) - { - switch ($_POST['action-'.$comment_id]) - { - case 'reject' : - { - array_push($to_reject, $comment_id); - break; - } - case 'validate' : - { - array_push($to_validate, $comment_id); - break; - } - } - } - } - } - else if (isset($_POST['validate-all']) and !empty($_POST['list']) and !is_adviser()) - { - $to_validate = explode(',', $_POST['list']); - } - else if (isset($_POST['reject-all']) and !empty($_POST['list']) and !is_adviser()) + if (empty($_POST['comments'])) { - $to_reject = explode(',', $_POST['list']); + array_push( + $page['errors'], + l10n('Select at least one comment') + ); } - - if (count($to_validate) > 0) + else { - $query = ' + check_input_parameter('comments', $_POST, true, PATTERN_ID); + + if (isset($_POST['validate'])) + { + $query = ' UPDATE '.COMMENTS_TABLE.' SET validated = \'true\' , validation_date = NOW() - WHERE id IN ('.implode(',', $to_validate).') + WHERE id IN ('.implode(',', $_POST['comments']).') ;'; pwg_query($query); @@ -88,27 +65,28 @@ UPDATE '.COMMENTS_TABLE.' $page['infos'], l10n_dec( '%d user comment validated', '%d user comments validated', - count($to_validate) + count($_POST['comments']) ) ); - } + } - if (count($to_reject) > 0) - { - $query = ' + if (isset($_POST['reject'])) + { + $query = ' DELETE FROM '.COMMENTS_TABLE.' - WHERE id IN ('.implode(',', $to_reject).') + WHERE id IN ('.implode(',', $_POST['comments']).') ;'; - pwg_query($query); - - array_push( - $page['infos'], - l10n_dec( - '%d user comment rejected', '%d user comments rejected', - count($to_reject) - ) - ); + pwg_query($query); + + array_push( + $page['infos'], + l10n_dec( + '%d user comment rejected', '%d user comments rejected', + count($_POST['comments']) + ) + ); + } } } -- cgit v1.2.3