Ignore:
Timestamp:
Mar 19, 2010, 11:25:39 PM (14 years ago)
Author:
plg
Message:

bug 1328: backport the pwg_token on trunk

bug 1329: backport the check_input_parameter on trunk

feature 1026: add pwg_token feature for edit/delete comment. Heavy refactoring
on this feature to make the code simpler and easier to maintain (I hope).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_comment.inc.php

    r5021 r5195  
    171171    $comm['id'] = pwg_db_insert_id(COMMENTS_TABLE);
    172172
    173     if (($comment_action=='validate' and $conf['email_admin_on_comment']) or
    174         ($comment_action!='validate' and $conf['email_admin_on_comment_validation']))
     173    if ($conf['email_admin_on_comment']
     174        or ($conf['email_admin_on_comment_validation'] and 'moderate' == $comment_action))
    175175    {
    176176      include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    177177
    178       $del_url = get_absolute_root_url().'comments.php?delete='.$comm['id'];
     178      $comment_url = get_absolute_root_url().'comments.php?comment_id='.$comm['id'];
    179179
    180180      $keyargs_content = array
     
    183183        get_l10n_args('Comment: %s', stripslashes($comm['content']) ),
    184184        get_l10n_args('', ''),
    185         get_l10n_args('Delete: %s', $del_url)
     185        get_l10n_args('Manage this user comment: %s', $comment_url)
    186186      );
    187187
    188       if ($comment_action!='validate')
     188      if ('moderate' == $comment_action)
    189189      {
    190         $keyargs_content[] =
    191           get_l10n_args('', '');
    192         $keyargs_content[] =
    193           get_l10n_args('Validate: %s',
    194             get_absolute_root_url().'comments.php?validate='.$comm['id']);
     190        $keyargs_content[] = get_l10n_args('', '');
     191        $keyargs_content[] = get_l10n_args('(!) This comment requires validation', '');
    195192      }
    196193
     
    213210 * @param comment_id
    214211 */
    215 
    216212function delete_user_comment($comment_id) {
    217213  $user_where_clause = '';
     
    338334                               );
    339335}
     336
     337function get_comment_author_id($comment_id, $die_on_error=true)
     338{
     339  $query = '
     340SELECT
     341    author_id
     342  FROM '.COMMENTS_TABLE.'
     343  WHERE id = '.$comment_id.'
     344;';
     345  $result = pwg_query($query);
     346  if (pwg_db_num_rows($result) == 0)
     347  {
     348    if ($die_on_error)
     349    {
     350      fatal_error('Unknown comment identifier');
     351    }
     352    else
     353    {
     354      return false;
     355    }
     356  }
     357 
     358  list($author_id) = pwg_db_fetch_row($result);
     359
     360  return $author_id;
     361}
     362
     363function validate_user_comment($comment_id)
     364{
     365  $query = '
     366UPDATE '.COMMENTS_TABLE.'
     367  SET validated = "true"
     368    , validation_date = NOW()
     369  WHERE id = '.$comment_id.'
     370;';
     371  pwg_query($query);
     372}
    340373?>
Note: See TracChangeset for help on using the changeset viewer.