aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2011-04-06 19:31:02 +0000
committermistic100 <mistic@piwigo.org>2011-04-06 19:31:02 +0000
commit4fdaeb8308c17a07a0412a56aeb246a3e3432ae5 (patch)
tree3d086cbd94bd0072d9eb799a4c3e0744bde1512f
parent4ad720c22878abefcbc2f9b8870a539783ae2a96 (diff)
merge r10097 & r10122 from trunk
git-svn-id: http://piwigo.org/svn/branches/2.2@10123 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--include/functions_comment.inc.php44
-rw-r--r--picture.php29
2 files changed, 67 insertions, 6 deletions
diff --git a/include/functions_comment.inc.php b/include/functions_comment.inc.php
index 560a5279b..932491520 100644
--- a/include/functions_comment.inc.php
+++ b/include/functions_comment.inc.php
@@ -263,19 +263,59 @@ function update_user_comment($comment, $post_key)
$user_where_clause = ' AND author_id = \''.
$GLOBALS['user']['id'].'\'';
}
+
+ // should the updated comment must be validated
+ if (!$conf['comments_validation'] or is_admin())
+ {
+ $comment_action='validate'; //one of validate, moderate, reject
+ }
+ else
+ {
+ $comment_action='moderate'; //one of validate, moderate, reject
+ }
+
$query = '
UPDATE '.COMMENTS_TABLE.'
SET content = \''.$comment['content'].'\',
- validation_date = now()
+ validated = \''.($comment_action=='validate' ? 'true':'false').'\',
+ validation_date = '.($comment_action=='validate' ? 'NOW()':'NULL').'
WHERE id = '.$comment['comment_id'].
$user_where_clause.'
;';
$result = pwg_query($query);
- if ($result) {
+
+ // mail admin and ask to validate the comment
+ if ($result and $conf['email_admin_on_comment_validation'] and 'moderate' == $comment_action)
+ {
+ include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
+
+ $comment_url = get_absolute_root_url().'comments.php?comment_id='.$comment['comment_id'];
+
+ $keyargs_content = array
+ (
+ get_l10n_args('Author: %s', stripslashes($GLOBALS['user']['username']) ),
+ get_l10n_args('Comment: %s', stripslashes($comment['content']) ),
+ get_l10n_args('', ''),
+ get_l10n_args('Manage this user comment: %s', $comment_url),
+ get_l10n_args('', ''),
+ get_l10n_args('(!) This comment requires validation', ''),
+ );
+
+ pwg_mail_notification_admins
+ (
+ get_l10n_args('Comment by %s', stripslashes($GLOBALS['user']['username']) ),
+ $keyargs_content
+ );
+ }
+ // just mail admin
+ else if ($result)
+ {
email_admin('edit', array('author' => $GLOBALS['user']['username'],
'content' => stripslashes($comment['content'])) );
}
}
+
+ return $comment_action;
}
function email_admin($action, $comment)
diff --git a/picture.php b/picture.php
index 5e58bba9a..d111d5301 100644
--- a/picture.php
+++ b/picture.php
@@ -189,6 +189,8 @@ function default_picture_content($content, $element_info)
// | initialization |
// +-----------------------------------------------------------------------+
+$infos = array();
+
// caching first_rank, last_rank, current_rank in the displayed
// section. This should also help in readability.
$page['first_rank'] = 0;
@@ -331,7 +333,7 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
{
if (!empty($_POST['content']))
{
- update_user_comment(
+ $comment_action = update_user_comment(
array(
'comment_id' => $_GET['comment_to_edit'],
'image_id' => $page['image_id'],
@@ -340,7 +342,28 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
$_POST['key']
);
- redirect($url_self);
+ switch ($comment_action)
+ {
+ case 'moderate':
+ array_push($infos, l10n('An administrator must authorize your comment before it is visible.'));
+ case 'validate':
+ array_push($infos, l10n('Your comment has been registered'));
+ break;
+ case 'reject':
+ set_status_header(403);
+ array_push($infos, l10n('Your comment has NOT been registered because it did not pass the validation rules'));
+ break;
+ default:
+ trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
+ }
+
+ $template->assign(
+ ($comment_action=='reject') ? 'errors' : 'infos',
+ $infos
+ );
+
+ unset($_POST['content']);
+ break;
}
else
{
@@ -834,8 +857,6 @@ if (isset($picture['current']['comment'])
);
}
-$infos = array();
-
// author
if (!empty($picture['current']['author']))
{