Ignore:
Timestamp:
Dec 21, 2013, 5:33:24 PM (10 years ago)
Author:
mistic100
Message:

update for Piwigo 2.6 + code clean

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GuestBook/include/guestbook.inc.php

    r24889 r26065  
    44global $user;
    55
    6 include(GUESTBOOK_PATH . '/include/functions.inc.php');
     6include(GUESTBOOK_PATH . 'include/functions.inc.php');
    77
    88$url_self = empty($page['start']) ? GUESTBOOK_URL : add_url_params(GUESTBOOK_URL, array('start' => $page['start']));
     
    106106// |                                add comment                            |
    107107// +-----------------------------------------------------------------------+
    108 if ( isset( $_POST['content'] ) && (!is_a_guest() || $conf['guestbook']['guest_can_add']))
     108if (isset($_POST['content']) && (!is_a_guest() || $conf['guestbook']['guest_can_add']))
    109109{
    110110  $comm = array(
    111     'author' => trim( @$_POST['author'] ),
    112     'email' => trim( @$_POST['email'] ),
    113     'content' => trim( $_POST['content'] ),
    114     'website' => trim( $_POST['website'] ),
     111    'author' => trim(@$_POST['author']),
     112    'email' => trim(@$_POST['email']),
     113    'content' => trim($_POST['content']),
     114    'website' => trim($_POST['website']),
    115115    'rate' => @$_POST['score'],
    116116   );
     
    123123  {
    124124    case 'moderate':
    125       array_push($page['infos'], l10n('An administrator must authorize your comment before it is visible.') );
     125      $page['infos'][] = l10n('An administrator must authorize your comment before it is visible.');
    126126    case 'validate':
    127       array_push($page['infos'], l10n('Your comment has been registered'));
     127      $page['infos'][] = l10n('Your comment has been registered');
    128128      break;
    129129    case 'reject':
    130130      set_status_header(403);
    131       array_push($page['errors'], l10n('Your comment has NOT been registered because it did not pass the validation rules') );
     131      $template->assign('GB_OPEN', true);
     132      $page['errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules');
    132133      break;
    133134    default:
     
    136137
    137138  // allow plugins to notify what's going on
    138   trigger_action( 'user_comment_insertion',
    139       array_merge($comm, array('action'=>$comment_action) )
     139  trigger_action('user_comment_insertion',
     140      array_merge($comm, array('action'=>$comment_action))
    140141    );
    141142}
     
    145146// +-----------------------------------------------------------------------+
    146147$where_clauses = array('1=1');
    147 if ( !is_admin() )
    148 {
    149   array_push($where_clauses, 'validated = \'true\'');
     148if (!is_admin())
     149{
     150  $where_clauses[] = 'validated = \'true\'';
    150151}
    151152if (isset($_GET['comment_id']))
    152153{
    153   array_push($where_clauses, 'com.id = '.pwg_db_real_escape_string($_GET['comment_id']));
     154  $where_clauses[] = 'com.id = '.pwg_db_real_escape_string($_GET['comment_id']);
    154155}
    155156
     
    161162  WHERE '.implode(' AND ', $where_clauses).'
    162163;';
    163 $row = pwg_db_fetch_assoc( pwg_query( $query ) );
     164$row = pwg_db_fetch_assoc(pwg_query($query));
    164165
    165166// navigation bar creation
     
    178179  );
    179180
    180 $template->assign(
    181   array(
    182     'COMMENT_COUNT' => $row['nb_comments'],
    183     'navbar' => $navigation_bar,
    184     )
    185   );
     181$template->assign(array(
     182  'COMMENT_COUNT' => $row['nb_comments'],
     183  'navbar' => $navigation_bar,
     184  ));
    186185 
    187186if ($row['nb_comments'] > 0)
     
    223222    }
    224223
    225     $tpl_comment =
    226       array(
    227         'ID' => $row['id'],
    228         'AUTHOR' => trigger_event('render_comment_author', $author),
    229         'DATE' => format_date($row['date'], true),
    230         'CONTENT' => trigger_event('render_comment_content',$row['content']),
    231         'WEBSITE' => $row['website'],
     224    $tpl_comment = array(
     225      'ID' => $row['id'],
     226      'AUTHOR' => trigger_event('render_comment_author', $author),
     227      'DATE' => format_date($row['date'], true),
     228      'CONTENT' => trigger_event('render_comment_content', $row['content']),
     229      'WEBSITE' => $row['website'],
    232230      );
    233231     
     
    276274      {
    277275        $tpl_comment['U_VALIDATE'] = add_url_params(
    278                 $url_self,
    279                 array(
    280                   'action' => 'validate_comment',
    281                   'comment_to_validate' => $row['id'],
    282                   'pwg_token' => get_pwg_token(),
    283                   )
    284                 );
     276          $url_self,
     277          array(
     278            'action' => 'validate_comment',
     279            'comment_to_validate' => $row['id'],
     280            'pwg_token' => get_pwg_token(),
     281            )
     282          );
    285283      }
    286284    }
     
    316314
    317315  $template->assign('comment_add',
    318       array(
    319         'F_ACTION' => $url_self,
    320         'KEY' => get_ephemeral_key(3),
    321         'CONTENT' => $content,
    322         'IS_LOGGED' => is_classic_user(),
    323         'AUTHOR' => $author,
    324         'WEBSITE' => $website,
    325         'EMAIL' => $email,
    326         'ACTIVATE_RATING' => $conf['guestbook']['activate_rating'],
    327         'EMAIL_MANDATORY' => $conf['comments_email_mandatory'],
    328       ));
    329 }
    330 
    331 $template->assign('ABS_GUESTBOOK_PATH', realpath(GUESTBOOK_PATH) . '/');
    332 $template->assign('GUESTBOOK_PATH', GUESTBOOK_PATH);
    333 
    334 $template->set_filename('index', realpath(GUESTBOOK_PATH . 'template/guestbook.tpl'));
     316    array(
     317      'F_ACTION' => $url_self,
     318      'KEY' => get_ephemeral_key(3),
     319      'CONTENT' => $content,
     320      'IS_LOGGED' => is_classic_user(),
     321      'AUTHOR' => $author,
     322      'WEBSITE' => $website,
     323      'EMAIL' => $email,
     324      'ACTIVATE_RATING' => $conf['guestbook']['activate_rating'],
     325      'EMAIL_MANDATORY' => $conf['comments_email_mandatory'],
     326    ));
     327}
     328
     329$template->assign(array(
     330  'GUESTBOOK_PATH' => GUESTBOOK_PATH,
     331  'ABS_GUESTBOOK_PATH' => realpath(GUESTBOOK_PATH) . '/',
     332  ));
     333
     334$template->set_filename('guestbook', realpath(GUESTBOOK_PATH . 'template/guestbook.tpl'));
     335$template->assign_var_from_handle('CONTENT', 'guestbook');
Note: See TracChangeset for help on using the changeset viewer.