Changeset 10123


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

merge r10097 & r10122 from trunk

Location:
branches/2.2
Files:
2 edited

Legend:

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

    r8728 r10123  
    264264        $GLOBALS['user']['id'].'\'';
    265265    }
     266   
     267    // should the updated comment must be validated
     268    if (!$conf['comments_validation'] or is_admin())
     269    {
     270      $comment_action='validate'; //one of validate, moderate, reject
     271    }
     272    else
     273    {
     274      $comment_action='moderate'; //one of validate, moderate, reject
     275    }
     276
    266277    $query = '
    267278UPDATE '.COMMENTS_TABLE.'
    268279  SET content = \''.$comment['content'].'\',
    269       validation_date = now()
     280      validated = \''.($comment_action=='validate' ? 'true':'false').'\',
     281      validation_date = '.($comment_action=='validate' ? 'NOW()':'NULL').'
    270282  WHERE id = '.$comment['comment_id'].
    271283$user_where_clause.'
    272284;';
    273285    $result = pwg_query($query);
    274     if ($result) {
     286   
     287    // mail admin and ask to validate the comment
     288    if ($result and $conf['email_admin_on_comment_validation'] and 'moderate' == $comment_action)
     289    {
     290      include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     291
     292      $comment_url = get_absolute_root_url().'comments.php?comment_id='.$comment['comment_id'];
     293
     294      $keyargs_content = array
     295      (
     296        get_l10n_args('Author: %s', stripslashes($GLOBALS['user']['username']) ),
     297        get_l10n_args('Comment: %s', stripslashes($comment['content']) ),
     298        get_l10n_args('', ''),
     299        get_l10n_args('Manage this user comment: %s', $comment_url),
     300        get_l10n_args('', ''),
     301        get_l10n_args('(!) This comment requires validation', ''),
     302      );
     303
     304      pwg_mail_notification_admins
     305      (
     306        get_l10n_args('Comment by %s', stripslashes($GLOBALS['user']['username']) ),
     307        $keyargs_content
     308      );
     309    }
     310    // just mail admin
     311    else if ($result)
     312    {
    275313      email_admin('edit', array('author' => $GLOBALS['user']['username'],
    276314                                'content' => stripslashes($comment['content'])) );
    277315    }
    278316  }
     317 
     318  return $comment_action;
    279319}
    280320
  • branches/2.2/picture.php

    r9073 r10123  
    190190// +-----------------------------------------------------------------------+
    191191
     192$infos = array();
     193
    192194// caching first_rank, last_rank, current_rank in the displayed
    193195// section. This should also help in readability.
     
    332334        if (!empty($_POST['content']))
    333335        {
    334           update_user_comment(
     336          $comment_action = update_user_comment(
    335337            array(
    336338              'comment_id' => $_GET['comment_to_edit'],
     
    341343            );
    342344
    343           redirect($url_self);
     345          switch ($comment_action)
     346          {
     347            case 'moderate':
     348              array_push($infos, l10n('An administrator must authorize your comment before it is visible.'));
     349            case 'validate':
     350              array_push($infos, l10n('Your comment has been registered'));
     351              break;
     352            case 'reject':
     353              set_status_header(403);
     354              array_push($infos, l10n('Your comment has NOT been registered because it did not pass the validation rules'));
     355              break;
     356            default:
     357              trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
     358          }
     359         
     360          $template->assign(
     361              ($comment_action=='reject') ? 'errors' : 'infos',
     362              $infos
     363            );
     364           
     365          unset($_POST['content']);
     366          break;
    344367        }
    345368        else
     
    835858}
    836859
    837 $infos = array();
    838 
    839860// author
    840861if (!empty($picture['current']['author']))
Note: See TracChangeset for help on using the changeset viewer.