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/functions_comment.inc.php

    r17351 r18164  
    9292    if ( empty($comm['author']) )
    9393    {
     94      if ($conf['comments_author_mandatory'])
     95      {
     96        array_push($infos, l10n('Username is mandatory') );
     97        $comment_action='reject';
     98      }
    9499      $comm['author'] = 'guest';
    95100    }
     
    129134 
    130135  // website
    131   if ( !empty($comm['website_url']) and !preg_match('/^https?/i', $comm['website_url']) )
    132   {
    133     $comm['website_url'] = 'http://'.$comm['website_url'];
    134   }
    135   if ( !empty($comm['website_url']) and !url_check_format($comm['website_url']) )
    136   {
    137     array_push($infos, l10n('Your website URL is invalid'));
     136  if (!empty($comm['website_url']))
     137  {
     138    if (!preg_match('/^https?/i', $comm['website_url']))
     139    {
     140      $comm['website_url'] = 'http://'.$comm['website_url'];
     141    }
     142    if (!url_check_format($comm['website_url']))
     143    {
     144      array_push($infos, l10n('Your website URL is invalid'));
     145      $comment_action='reject';
     146    }
     147  }
     148 
     149  // email
     150  if (empty($comm['email']))
     151  {
     152    if (!empty($user['email']))
     153    {
     154      $comm['email'] = $user['email'];
     155    }
     156    else if ($conf['comments_email_mandatory'])
     157    {
     158      array_push($infos, l10n('Email address is missing. Please specify an email address.') );
     159      $comment_action='reject';
     160    }
     161  }
     162  else if (!email_check_format($comm['email']))
     163  {
     164    array_push($infos, l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));
    138165    $comment_action='reject';
    139166  }
     
    180207    $query = '
    181208INSERT INTO '.COMMENTS_TABLE.'
    182   (author, author_id, anonymous_id, content, date, validated, validation_date, image_id, website_url)
     209  (author, author_id, anonymous_id, content, date, validated, validation_date, image_id, website_url, email)
    183210  VALUES (
    184211    \''.$comm['author'].'\',
     
    190217    '.($comment_action=='validate' ? 'NOW()':'NULL').',
    191218    '.$comm['image_id'].',
    192     '.(!empty($comm['website_url']) ? '\''.$comm['website_url'].'\'' : 'NULL').'
     219    '.(!empty($comm['website_url']) ? '\''.$comm['website_url'].'\'' : 'NULL').',
     220    '.(!empty($comm['email']) ? '\''.$comm['email'].'\'' : 'NULL').'
    193221  )
    194222';
     
    208236      (
    209237        get_l10n_args('Author: %s', stripslashes($comm['author']) ),
     238        get_l10n_args('Email: %s', stripslashes($comm['email']) ),
    210239        get_l10n_args('Comment: %s', stripslashes($comm['content']) ),
    211240        get_l10n_args('', ''),
Note: See TracChangeset for help on using the changeset viewer.