Ignore:
Timestamp:
Nov 4, 2012, 3:59:38 PM (11 years ago)
Author:
mistic100
Message:

update with Piwigo 2.5 features (website url, email, mandatory email and username)

File:
1 edited

Legend:

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

    r15999 r18927  
    3939    if ( empty($comm['author']) )
    4040    {
     41      if ($conf['comments_author_mandatory'])
     42      {
     43        array_push($infos, l10n('Username is mandatory') );
     44        $comment_action='reject';
     45      }
    4146      $comm['author'] = 'guest';
    4247    }
     
    7580  }
    7681 
     82  // website
     83  if (!empty($comm['website_url']))
     84  {
     85    if (!preg_match('/^https?/i', $comm['website_url']))
     86    {
     87      $comm['website_url'] = 'http://'.$comm['website_url'];
     88    }
     89    if (!url_check_format($comm['website_url']))
     90    {
     91      array_push($infos, l10n('Your website URL is invalid'));
     92      $comment_action='reject';
     93    }
     94  }
     95 
     96  // email
     97  if (empty($comm['email']))
     98  {
     99    if (!empty($user['email']))
     100    {
     101      $comm['email'] = $user['email'];
     102    }
     103    else if ($conf['comments_email_mandatory'])
     104    {
     105      array_push($infos, l10n('Email address is missing. Please specify an email address.') );
     106      $comment_action='reject';
     107    }
     108  }
     109  else if (!email_check_format($comm['email']))
     110  {
     111    array_push($infos, l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));
     112    $comment_action='reject';
     113  }
     114 
    77115  // anonymous id = ip address
    78116  $ip_components = explode('.', $comm['ip']);
     
    116154    $query = '
    117155INSERT INTO '.COA_TABLE.'
    118   (author, author_id, content, date, validated, validation_date, category_id)
     156  (author, author_id, anonymous_id, content, date, validated, validation_date, category_id, website_url, email)
    119157  VALUES (
    120158    \''.$comm['author'].'\',
    121159    '.$comm['author_id'].',
     160    \''.$comm['anonymous_id'].'\',
    122161    \''.$comm['content'].'\',
    123162    NOW(),
    124163    \''.($comment_action=='validate' ? 'true':'false').'\',
    125164    '.($comment_action=='validate' ? 'NOW()':'NULL').',
    126     '.$comm['category_id'].'
     165    '.$comm['category_id'].',
     166    '.(!empty($comm['website_url']) ? '\''.$comm['website_url'].'\'' : 'NULL').',
     167    '.(!empty($comm['email']) ? '\''.$comm['email'].'\'' : 'NULL').'
    127168  )
    128169';
     
    142183      (
    143184        get_l10n_args('Author: %s', stripslashes($comm['author']) ),
     185        get_l10n_args('Email: %s', stripslashes($comm['email']) ),
    144186        get_l10n_args('Comment: %s', stripslashes($comm['content']) ),
    145187        get_l10n_args('', ''),
Note: See TracChangeset for help on using the changeset viewer.