Ignore:
Timestamp:
May 22, 2011, 12:34:18 PM (13 years ago)
Author:
mistic100
Message:

code cleanup

File:
1 edited

Legend:

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

    r10301 r10984  
    44//returns string action to perform on a new comment: validate, moderate, reject
    55if (!function_exists('user_comment_check')) {
    6         function user_comment_check($action, $comment)
    7         {
    8           global $conf,$user;
    9 
    10           if ($action=='reject')
    11                 return $action;
    12 
    13           $my_action = $conf['comment_spam_reject'] ? 'reject':'moderate';
    14 
    15           if ($action==$my_action)
    16                 return $action;
    17 
    18           // we do here only BASIC spam check (plugins can do more)
    19           if ( !is_a_guest() )
    20                 return $action;
    21 
    22           $link_count = preg_match_all( '/https?:\/\//',
    23                 $comment['content'], $matches);
    24 
    25           if ( strpos($comment['author'], 'http://')!==false )
    26           {
    27                 $link_count++;
    28           }
    29 
    30           if ( $link_count>$conf['comment_spam_max_links'] )
    31                 return $my_action;
    32 
    33           return $action;
    34         }
     6  function user_comment_check($action, $comment)
     7  {
     8    global $conf,$user;
     9
     10    if ($action=='reject')
     11    return $action;
     12
     13    $my_action = $conf['comment_spam_reject'] ? 'reject':'moderate';
     14
     15    if ($action==$my_action)
     16    return $action;
     17
     18    // we do here only BASIC spam check (plugins can do more)
     19    if ( !is_a_guest() )
     20    return $action;
     21
     22    $link_count = preg_match_all( '/https?:\/\//',
     23    $comment['content'], $matches);
     24
     25    if ( strpos($comment['author'], 'http://')!==false )
     26    {
     27    $link_count++;
     28    }
     29
     30    if ( $link_count>$conf['comment_spam_max_links'] )
     31    return $my_action;
     32
     33    return $action;
     34  }
    3535}
    3636
     
    231231  $comment_action =
    232232    trigger_event('user_comment_check',
    233                   $comment_action,
    234                   array_merge($comment,
    235                               array('author' => $GLOBALS['user']['username'])
    236                               )
    237                   );
     233      $comment_action,
     234      array_merge($comment,
     235            array('author' => $GLOBALS['user']['username'])
     236            )
     237      );
    238238
    239239  if ( $comment_action!='reject' )
     
    243243    {
    244244      $user_where_clause = '   AND author_id = \''.
    245         $GLOBALS['user']['id'].'\'';
     245  $GLOBALS['user']['id'].'\'';
    246246    }
    247247   
     
    293293    {
    294294      email_admin('edit', array('author' => $GLOBALS['user']['username'],
    295                                 'content' => stripslashes($comment['content'])) );
     295        'content' => stripslashes($comment['content'])) );
    296296    }
    297297  }
     
    301301
    302302if (!function_exists('email_admin')) {
    303         function email_admin($action, $comment)
    304         {
    305           global $conf;
    306 
    307           if (!in_array($action, array('edit', 'delete'))
    308                   or (($action=='edit') and !$conf['email_admin_on_comment_edition'])
    309                   or (($action=='delete') and !$conf['email_admin_on_comment_deletion']))
    310           {
    311                 return;
    312           }
    313 
    314           include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    315 
    316           $keyargs_content = array();
    317           $keyargs_content[] = get_l10n_args('Author: %s', $comment['author']);
    318           if ($action=='delete')
    319           {
    320                 $keyargs_content[] = get_l10n_args('This author removed the comment with id %d',
    321                                                    $comment['comment_id']
    322                                                    );
    323           }
    324           else
    325           {
    326                 $keyargs_content[] = get_l10n_args('This author modified following comment:', '');
    327                 $keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']);
    328           }
    329 
    330           pwg_mail_notification_admins(get_l10n_args('Comment by %s',
    331                                                         $comment['author']),
    332                                            $keyargs_content
    333                                            );
    334         }
     303  function email_admin($action, $comment)
     304  {
     305    global $conf;
     306
     307    if (!in_array($action, array('edit', 'delete'))
     308      or (($action=='edit') and !$conf['email_admin_on_comment_edition'])
     309      or (($action=='delete') and !$conf['email_admin_on_comment_deletion']))
     310    {
     311    return;
     312    }
     313
     314    include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     315
     316    $keyargs_content = array();
     317    $keyargs_content[] = get_l10n_args('Author: %s', $comment['author']);
     318    if ($action=='delete')
     319    {
     320    $keyargs_content[] = get_l10n_args('This author removed the comment with id %d',
     321               $comment['comment_id']
     322               );
     323    }
     324    else
     325    {
     326    $keyargs_content[] = get_l10n_args('This author modified following comment:', '');
     327    $keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']);
     328    }
     329
     330    pwg_mail_notification_admins(get_l10n_args('Comment by %s',
     331              $comment['author']),
     332             $keyargs_content
     333             );
     334  }
    335335}
    336336
Note: See TracChangeset for help on using the changeset viewer.