aboutsummaryrefslogtreecommitdiffstats
path: root/admin/comments.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/comments.php')
-rw-r--r--admin/comments.php118
1 files changed, 94 insertions, 24 deletions
diff --git a/admin/comments.php b/admin/comments.php
index 6d3fcc507..2740d772a 100644
--- a/admin/comments.php
+++ b/admin/comments.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -28,9 +28,19 @@ if (!defined('PHPWG_ROOT_PATH'))
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+if (isset($_GET['start']) and is_numeric($_GET['start']))
+{
+ $page['start'] = $_GET['start'];
+}
+else
+{
+ $page['start'] = 0;
+}
+
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok |
// +-----------------------------------------------------------------------+
+
check_status(ACCESS_ADMINISTRATOR);
// +-----------------------------------------------------------------------+
@@ -41,10 +51,7 @@ if (!empty($_POST))
{
if (empty($_POST['comments']))
{
- array_push(
- $page['errors'],
- l10n('Select at least one comment')
- );
+ $page['errors'][] = l10n('Select at least one comment');
}
else
{
@@ -55,12 +62,9 @@ if (!empty($_POST))
{
validate_user_comment($_POST['comments']);
- array_push(
- $page['infos'],
- l10n_dec(
- '%d user comment validated', '%d user comments validated',
- count($_POST['comments'])
- )
+ $page['infos'][] = l10n_dec(
+ '%d user comment validated', '%d user comments validated',
+ count($_POST['comments'])
);
}
@@ -68,12 +72,9 @@ if (!empty($_POST))
{
delete_user_comment($_POST['comments']);
- array_push(
- $page['infos'],
- l10n_dec(
- '%d user comment rejected', '%d user comments rejected',
- count($_POST['comments'])
- )
+ $page['infos'][] = l10n_dec(
+ '%d user comment rejected', '%d user comments rejected',
+ count($_POST['comments'])
);
}
}
@@ -106,18 +107,75 @@ $tabsheet->assign();
// | comments display |
// +-----------------------------------------------------------------------+
-$list = array();
+$nb_total = 0;
+$nb_pending = 0;
+
+$query = '
+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
+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
+ LIMIT '.$page['start'].', '.$conf['comments_page_nb_comments'].'
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
@@ -144,14 +202,26 @@ 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']),
)
);
- array_push($list, $row['id']);
+ $list[] = $row['id'];
}
-$template->assign('LIST', implode(',', $list) );
+// +-----------------------------------------------------------------------+
+// | navigation bar |
+// +-----------------------------------------------------------------------+
+
+$navbar = create_navigation_bar(
+ get_root_url().'admin.php'.get_query_string_diff(array('start')),
+ ('pending' == $page['filter'] ? $nb_pending : $nb_total),
+ $page['start'],
+ $conf['comments_page_nb_comments']
+ );
+
+$template->assign('navbar', $navbar);
// +-----------------------------------------------------------------------+
// | sending html code |