Changeset 12596
- Timestamp:
- Nov 11, 2011, 11:19:44 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/comments.php
r8728 r12596 49 49 else 50 50 { 51 include_once( PHPWG_ROOT_PATH .'include/functions_comment.inc.php' ); 51 52 check_input_parameter('comments', $_POST, true, PATTERN_ID); 52 53 53 54 if (isset($_POST['validate'])) 54 55 { 55 $query = ' 56 UPDATE '.COMMENTS_TABLE.' 57 SET validated = \'true\' 58 , validation_date = NOW() 59 WHERE id IN ('.implode(',', $_POST['comments']).') 60 ;'; 61 pwg_query($query); 56 validate_user_comment($_POST['comments']); 62 57 63 array_push(64 $page['infos'],65 l10n_dec(66 '%d user comment validated', '%d user comments validated',67 count($_POST['comments'])68 )69 );58 array_push( 59 $page['infos'], 60 l10n_dec( 61 '%d user comment validated', '%d user comments validated', 62 count($_POST['comments']) 63 ) 64 ); 70 65 } 71 66 72 67 if (isset($_POST['reject'])) 73 68 { 74 $query = ' 75 DELETE 76 FROM '.COMMENTS_TABLE.' 77 WHERE id IN ('.implode(',', $_POST['comments']).') 78 ;'; 79 pwg_query($query); 69 delete_user_comment($_POST['comments']); 80 70 81 71 array_push( -
trunk/include/functions_comment.inc.php
r12556 r12596 203 203 * so to avoid a new sql request we add author in where clause 204 204 * 205 * @param comment_id205 * @param int or array of int comment_id 206 206 */ 207 function delete_user_comment($comment_id) { 207 function delete_user_comment($comment_id) 208 { 208 209 $user_where_clause = ''; 209 210 if (!is_admin()) … … 211 212 $user_where_clause = ' AND author_id = \''.$GLOBALS['user']['id'].'\''; 212 213 } 214 215 if (is_array($comment_id)) 216 $where_clause = 'id IN('.implode(',', $comment_id).')'; 217 else 218 $where_clause = 'id = '.$comment_id; 219 213 220 $query = ' 214 221 DELETE FROM '.COMMENTS_TABLE.' 215 WHERE id = '.$comment_id.222 WHERE '.$where_clause. 216 223 $user_where_clause.' 217 224 ;'; 218 225 $result = pwg_query($query); 219 if ($result) { 226 227 if ($result) 228 { 220 229 email_admin('delete', 221 230 array('author' => $GLOBALS['user']['username'], … … 378 387 } 379 388 389 /** 390 * Tries to validate a user comment in the database 391 * @param int or array of int comment_id 392 */ 380 393 function validate_user_comment($comment_id) 381 394 { 395 if (is_array($comment_id)) 396 $where_clause = 'id IN('.implode(',', $comment_id).')'; 397 else 398 $where_clause = 'id = '.$comment_id; 399 382 400 $query = ' 383 401 UPDATE '.COMMENTS_TABLE.' 384 402 SET validated = \'true\' 385 403 , validation_date = NOW() 386 WHERE id = '.$comment_id.'404 WHERE '.$where_clause.' 387 405 ;'; 388 406 pwg_query($query);
Note: See TracChangeset
for help on using the changeset viewer.