aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/picture_comment.inc.php24
-rw-r--r--picture.php17
2 files changed, 38 insertions, 3 deletions
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index 2682d9dab..9a120e355 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -118,11 +118,20 @@ SELECT COUNT(*) AS nb_comments
if ($row['nb_comments'] > 0)
{
+ if ( !is_admin() )
+ {
+ $validated_clause = ' AND validated = \'true\'';
+ }
+ else
+ {
+ $validated_clause = '';
+ }
+
$query = '
-SELECT id,author,date,image_id,content
+SELECT id,author,date,image_id,content,validated
FROM '.COMMENTS_TABLE.'
- WHERE image_id = '.$page['image_id'].'
- AND validated = \'true\'
+ WHERE image_id = '.$page['image_id'].
+$validated_clause.'
ORDER BY date ASC
LIMIT '.$page['start'].', '.$conf['nb_comment_page'].'
;';
@@ -152,6 +161,15 @@ SELECT id,author,date,image_id,content
'comment_to_delete'=>$row['id']
)
);
+ if ($row['validated'] != 'true')
+ {
+ $tpl_comment['U_VALIDATE'] =
+ add_url_params($url_self,
+ array('action' => 'validate_comment',
+ 'comment_to_validate' => $row['id']
+ )
+ );
+ }
}
$template->append('comments', $tpl_comment);
}
diff --git a/picture.php b/picture.php
index 5aac74be7..fd42536b2 100644
--- a/picture.php
+++ b/picture.php
@@ -322,6 +322,23 @@ DELETE FROM '.COMMENTS_TABLE.'
redirect($url_self);
}
+ case 'validate_comment' :
+ {
+ if (isset($_GET['comment_to_validate'])
+ and is_numeric($_GET['comment_to_validate'])
+ and is_admin() and !is_adviser() )
+ {
+ $query = '
+UPDATE '.COMMENTS_TABLE.'
+ SET validated = \'true\'
+ , validation_date = NOW()
+ WHERE id='.$_GET['comment_to_validate'].'
+;';
+ pwg_query( $query );
+ }
+ redirect($url_self);
+ }
+
}
}