aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2011-04-06 08:55:40 +0000
committermistic100 <mistic@piwigo.org>2011-04-06 08:55:40 +0000
commita8b750b8551697dd6f6927dfc2ae9f297d7ed216 (patch)
treee650685e3c8881cc22612446564ec807bbcf9fc0 /include
parent5f7328ed5cf6a628e26f62d460980c5d99b83101 (diff)
bug:2152 Comments revalidation when modified
git-svn-id: http://piwigo.org/svn/trunk@10097 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/functions_comment.inc.php44
-rw-r--r--include/picture_comment.inc.php79
2 files changed, 83 insertions, 40 deletions
diff --git a/include/functions_comment.inc.php b/include/functions_comment.inc.php
index 560a5279b..71aef652d 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_update_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/include/picture_comment.inc.php b/include/picture_comment.inc.php
index e40a11f09..80f33a27e 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -38,52 +38,55 @@ foreach ($related_categories as $category)
}
}
-if ( $page['show_comments'] and isset( $_POST['content'] ) )
+if (!isset($comment_action))
{
- if ( is_a_guest() and !$conf['comments_forall'] )
+ if ( $page['show_comments'] and isset( $_POST['content'] ) )
{
- die ('Session expired');
- }
+ if ( is_a_guest() and !$conf['comments_forall'] )
+ {
+ die ('Session expired');
+ }
- $comm = array(
- 'author' => trim( @$_POST['author'] ),
- 'content' => trim( $_POST['content'] ),
- 'image_id' => $page['image_id'],
- );
+ $comm = array(
+ 'author' => trim( @$_POST['author'] ),
+ 'content' => trim( $_POST['content'] ),
+ 'image_id' => $page['image_id'],
+ );
- include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
+ include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
- $comment_action = insert_user_comment($comm, @$_POST['key'], $infos );
+ $comment_action = insert_user_comment($comm, @$_POST['key'], $infos );
- 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);
- }
+ 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
- );
+ $template->assign(
+ ($comment_action=='reject') ? 'errors' : 'infos',
+ $infos
+ );
- // allow plugins to notify what's going on
- trigger_action( 'user_comment_insertion',
- array_merge($comm, array('action'=>$comment_action) )
- );
-}
-elseif ( isset($_POST['content']) )
-{
- set_status_header(403);
- die('ugly spammer');
+ // allow plugins to notify what's going on
+ trigger_action( 'user_comment_insertion',
+ array_merge($comm, array('action'=>$comment_action) )
+ );
+ }
+ elseif ( isset($_POST['content']) )
+ {
+ set_status_header(403);
+ die('ugly spammer');
+ }
}
if ($page['show_comments'])