Ignore:
Timestamp:
Sep 23, 2012, 11:34:30 AM (12 years ago)
Author:
mistic100
Message:

feature 2754: Add "Email" field for user comments + mandatory "Author"

File:
1 edited

Legend:

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

    r17351 r18164  
    5050    'content' => trim( $_POST['content'] ),
    5151    'website_url' => trim( $_POST['website_url'] ),
     52    'email' => trim( @$_POST['email'] ),
    5253    'image_id' => $page['image_id'],
    5354   );
     
    5556  include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
    5657
    57   $comment_action = insert_user_comment($comm, @$_POST['key'], $page['infos']);
     58  $comment_action = insert_user_comment($comm, @$_POST['key'], $page['errors']);
    5859
    5960  switch ($comment_action)
     
    144145    author,
    145146    author_id,
    146     '.$conf['user_fields']['username'].' AS username,
     147    u.'.$conf['user_fields']['email'].' AS user_email,
    147148    date,
    148149    image_id,
    149150    website_url,
     151    com.email,
    150152    content,
    151153    validated
     
    162164    while ($row = pwg_db_fetch_assoc($result))
    163165    {
    164       if (!empty($row['author']))
    165       {
    166         $author = $row['author'];
    167         if ($author == 'guest')
    168         {
    169           $author = l10n('guest');
    170         }
    171       }
    172       else
    173       {
    174         $author = stripslashes($row['username']);
     166      if ($row['author'] == 'guest')
     167      {
     168        $row['author'] = l10n('guest');
     169      }
     170     
     171      $email = null;
     172      if (!empty($row['user_email']))
     173      {
     174        $email = $row['user_email'];
     175      }
     176      else if (!empty($row['email']))
     177      {
     178        $email = $row['email'];
    175179      }
    176180
     
    178182        array(
    179183          'ID' => $row['id'],
    180           'AUTHOR' => trigger_event('render_comment_author', $author),
     184          'AUTHOR' => trigger_event('render_comment_author', $row['author']),
    181185          'DATE' => format_date($row['date'], true),
    182186          'CONTENT' => trigger_event('render_comment_content',$row['content']),
     
    216220      if (is_admin())
    217221      {
     222        $tpl_comment['EMAIL'] = $email;
     223       
    218224        if ($row['validated'] != 'true')
    219225        {
     
    245251  {
    246252    $key = get_ephemeral_key(3, $page['image_id']);
    247     $content = $author = $website_url = '';
    248     if ('reject'===@$comment_action)
    249     {
    250       $content = htmlspecialchars( stripslashes($comm['content']) );
    251       $author = htmlspecialchars( stripslashes($comm['author']) );
    252       $website_url = htmlspecialchars( stripslashes($comm['website_url']) );
    253     }
     253   
    254254    $template->assign('comment_add',
    255255        array(
    256           'F_ACTION' => $url_self,
    257           'KEY' => $key,
    258           'CONTENT' => $content,
    259           'SHOW_AUTHOR' => !is_classic_user(),
    260           'AUTHOR' => $author ,
    261           'WEBSITE_URL' => $website_url,
     256          'F_ACTION' =>         $url_self,
     257          'KEY' =>              $key,
     258          'CONTENT' =>          stripslashes(@$_POST['content']),
     259          'SHOW_AUTHOR' =>      !is_classic_user(),
     260          'AUTHOR_MANDATORY' => $conf['comments_author_mandatory'],
     261          'AUTHOR' =>           stripslashes(@$_POST['author']),
     262          'WEBSITE_URL' =>      stripslashes(@$_POST['website_url']),
     263          'SHOW_EMAIL' =>       !is_classic_user() or empty($user['email']),
     264          'EMAIL_MANDATORY' =>  $conf['comments_email_mandatory'],
     265          'EMAIL' =>            stripslashes(@$_POST['email']),
    262266        ));
    263267  }
Note: See TracChangeset for help on using the changeset viewer.