Ignore:
Timestamp:
Apr 9, 2011, 6:40:27 PM (13 years ago)
Author:
mistic100
Message:

compatibility with 'rv_tscroller' & comments revalidation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Comments_on_Albums/include/functions_comment.inc.php

    r9634 r10213  
    217217 * @param content
    218218 */
    219 
    220219function update_user_comment_albums($comment, $post_key)
     220{
     221  global $conf;
     222
     223  $comment_action = 'validate';
     224
     225  if ( !verify_ephemeral_key($post_key, $comment['image_id']) )
     226  {
     227    $comment_action='reject';
     228  }
     229
     230  // perform more spam check
     231  $comment_action =
     232    trigger_event('user_comment_check',
     233                  $comment_action,
     234                  array_merge($comment,
     235                              array('author' => $GLOBALS['user']['username'])
     236                              )
     237                  );
     238
     239  if ( $comment_action!='reject' )
     240  {
     241    $user_where_clause = '';
     242    if (!is_admin())
     243    {
     244      $user_where_clause = '   AND author_id = \''.
     245        $GLOBALS['user']['id'].'\'';
     246    }
     247   
     248    // should the updated comment must be validated
     249    if (!$conf['comments_validation'] or is_admin())
     250    {
     251      $comment_action='validate'; //one of validate, moderate, reject
     252    }
     253    else
     254    {
     255      $comment_action='moderate'; //one of validate, moderate, reject
     256    }
     257
     258    $query = '
     259UPDATE '.COA_TABLE.'
     260  SET content = \''.$comment['content'].'\',
     261      validated = \''.($comment_action=='validate' ? 'true':'false').'\',
     262      validation_date = '.($comment_action=='validate' ? 'NOW()':'NULL').'
     263  WHERE id = '.$comment['comment_id'].
     264$user_where_clause.'
     265;';
     266    $result = pwg_query($query);
     267   
     268    // mail admin and ask to validate the comment
     269    if ($result and $conf['email_admin_on_comment_validation'] and 'moderate' == $comment_action)
     270    {
     271      include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     272
     273      $comment_url = get_absolute_root_url().'comments.php?display_mode=albums&comment_id='.$comment['comment_id'];
     274
     275      $keyargs_content = array
     276      (
     277        get_l10n_args('Author: %s', stripslashes($GLOBALS['user']['username']) ),
     278        get_l10n_args('Comment: %s', stripslashes($comment['content']) ),
     279        get_l10n_args('', ''),
     280        get_l10n_args('Manage this user comment: %s', $comment_url),
     281        get_l10n_args('', ''),
     282        get_l10n_args('(!) This comment requires validation', ''),
     283      );
     284
     285      pwg_mail_notification_admins
     286      (
     287        get_l10n_args('Comment by %s', stripslashes($GLOBALS['user']['username']) ),
     288        $keyargs_content
     289      );
     290    }
     291    // just mail admin
     292    else if ($result)
     293    {
     294      email_admin('edit', array('author' => $GLOBALS['user']['username'],
     295                                'content' => stripslashes($comment['content'])) );
     296    }
     297  }
     298 
     299  return $comment_action;
     300}
     301
     302/* function update_user_comment_albums($comment, $post_key)
    221303{
    222304  global $conf;
     
    259341    }
    260342  }
    261 }
     343}*/
    262344
    263345if (!function_exists('email_admin')) {
Note: See TracChangeset for help on using the changeset viewer.