Ignore:
Timestamp:
Nov 11, 2011, 11:21:58 AM (12 years ago)
Author:
mistic100
Message:

merge r12596 from trunk: feature 2500: make 'validate_user_comment' and 'delete_user_comment' working with array

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.3/include/functions_comment.inc.php

    r12557 r12597  
    203203 * so to avoid a new sql request we add author in where clause
    204204 *
    205  * @param comment_id
     205 * @param int or array of int comment_id
    206206 */
    207 function delete_user_comment($comment_id) {
     207function delete_user_comment($comment_id)
     208{
    208209  $user_where_clause = '';
    209210  if (!is_admin())
     
    211212    $user_where_clause = '   AND author_id = \''.$GLOBALS['user']['id'].'\'';
    212213  }
     214 
     215  if (is_array($comment_id))
     216    $where_clause = 'id IN('.implode(',', $comment_id).')';
     217  else
     218    $where_clause = 'id = '.$comment_id;
     219   
    213220  $query = '
    214221DELETE FROM '.COMMENTS_TABLE.'
    215   WHERE id = '.$comment_id.
     222  WHERE '.$where_clause.
    216223$user_where_clause.'
    217224;';
    218225  $result = pwg_query($query);
    219   if ($result) {
     226 
     227  if ($result)
     228  {
    220229    email_admin('delete',
    221230                array('author' => $GLOBALS['user']['username'],
     
    378387}
    379388
     389/**
     390 * Tries to validate a user comment in the database
     391 * @param int or array of int comment_id
     392 */
    380393function validate_user_comment($comment_id)
    381394{
     395  if (is_array($comment_id))
     396    $where_clause = 'id IN('.implode(',', $comment_id).')';
     397  else
     398    $where_clause = 'id = '.$comment_id;
     399   
    382400  $query = '
    383401UPDATE '.COMMENTS_TABLE.'
    384402  SET validated = \'true\'
    385403    , validation_date = NOW()
    386   WHERE id = '.$comment_id.'
     404  WHERE '.$where_clause.'
    387405;';
    388406  pwg_query($query);
Note: See TracChangeset for help on using the changeset viewer.