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/coa_albums.php

    r14528 r18927  
    22/* Code adapted from include/picture_comment.inc.php and picture.php */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     4
     5global $conf, $user;
    46
    57// +-----------------------------------------------------------------------+
     
    122124    die('Session expired');
    123125  }
    124 
     126 
    125127  $comm = array(
    126128    'author' => trim( @$_POST['author'] ),
    127129    'content' => trim( $_POST['content'] ),
     130    'website_url' => trim( $_POST['website_url'] ),
     131    'email' => trim( @$_POST['email'] ),
    128132    'category_id' => $category['id'],
    129   );
     133   );
    130134
    131135  include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions
    132136 
    133   $comment_action = insert_user_comment_albums($comm, @$_POST['key'], $page['infos']);
     137  $comment_action = insert_user_comment_albums($comm, @$_POST['key'], $page['errors']);
    134138
    135139  switch ($comment_action)
     
    231235    com.author,
    232236    com.author_id,
    233     '.$conf['user_fields']['username'].' AS username,
     237    u.'.$conf['user_fields']['username'].' AS username,
     238    u.'.$conf['user_fields']['email'].' AS user_email,
     239    com.email,
    234240    com.date,
     241    com.website_url,
    235242    com.category_id,
    236243    com.content,
     
    248255    while ($row = pwg_db_fetch_assoc($result))
    249256    {
    250       // author
    251       if (!empty($row['author']))
    252       {
    253         $author = $row['author'];
    254         if ($author == 'guest')
    255         {
    256           $author = l10n('guest');
    257         }
    258       }
    259       else
    260       {
    261         $author = stripslashes($row['username']);
     257      if ($row['author'] == 'guest')
     258      {
     259        $row['author'] = l10n('guest');
     260      }
     261     
     262      $email = null;
     263      if (!empty($row['user_email']))
     264      {
     265        $email = $row['user_email'];
     266      }
     267      else if (!empty($row['email']))
     268      {
     269        $email = $row['email'];
    262270      }
    263271     
     
    265273      $tpl_comment = array(
    266274        'ID' => $row['id'],
    267         'AUTHOR' => trigger_event('render_comment_author', $author),
     275        'AUTHOR' => trigger_event('render_comment_author', $row['author']),
    268276        'DATE' => format_date($row['date'], true),
     277        'WEBSITE_URL' => $row['website_url'],
    269278        'CONTENT' => trigger_event('render_comment_content', $row['content'], 'album'),
    270279        );
     
    300309        }
    301310      }
    302       if (is_admin() AND $row['validated'] != 'true')
    303       {
    304         $tpl_comment['U_VALIDATE'] = add_url_params(
    305           $url_self,
    306           array(
    307             'action' => 'validate_comment',
    308             'comment_to_validate' => $row['id'],
    309             'pwg_token' => get_pwg_token(),
    310             )
    311           );
     311      if (is_admin())
     312      {
     313        $tpl_comment['EMAIL'] = $email;
     314       
     315        if ($row['validated'] != 'true')
     316        {
     317          $tpl_comment['U_VALIDATE'] = add_url_params(
     318            $url_self,
     319            array(
     320              'action' => 'validate_comment',
     321              'comment_to_validate' => $row['id'],
     322              'pwg_token' => get_pwg_token(),
     323              )
     324            );
     325        }
    312326      }
    313327     
     
    330344  {
    331345    $key = get_ephemeral_key(3, $category['id']);
    332     $content = null;
    333     if ('reject'===@$comment_action)
    334     {
    335       $content = htmlspecialchars(stripslashes($comm['content']));
    336     }
     346   
    337347    $template->assign('comment_add',
    338348      array(
    339         'F_ACTION' => $url_self,
    340         'KEY' => $key,
    341         'CONTENT' => $content,
    342         'SHOW_AUTHOR' => !is_classic_user(),
     349        'F_ACTION' =>         $url_self,
     350        'KEY' =>              $key,
     351        'CONTENT' =>          stripslashes(@$_POST['content']),
     352        'SHOW_AUTHOR' =>      !is_classic_user(),
     353        'AUTHOR_MANDATORY' => $conf['comments_author_mandatory'],
     354        'AUTHOR' =>           stripslashes(@$_POST['author']),
     355        'WEBSITE_URL' =>      stripslashes(@$_POST['website_url']),
     356        'SHOW_EMAIL' =>       !is_classic_user() or empty($user['email']),
     357        'EMAIL_MANDATORY' =>  $conf['comments_email_mandatory'],
     358        'EMAIL' =>            stripslashes(@$_POST['email']),
    343359        )
    344360      );
Note: See TracChangeset for help on using the changeset viewer.