Show
Ignore:
Timestamp:
04/29/12 17:09:28 (13 months ago)
Author:
mistic100
Message:

update for 2.4
delete useless admin page
now compatible with RV Thumb Scroller

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • extensions/Comments_on_Albums/include/coa_albums.php

    r12618 r14528  
    2727    case 'edit_comment' :  
    2828    { 
    29       check_pwg_token(); 
    30        
    3129      include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions 
    32        
    3330      check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID); 
    34        
    3531      $author_id = get_comment_author_id_albums($_GET['comment_to_edit']); 
    3632 
     
    3935        if (!empty($_POST['content']))  
    4036        { 
     37          check_pwg_token(); 
    4138          $comment_action = update_user_comment_albums( 
    4239            array( 
     
    4845            ); 
    4946           
    50           $infos = array(); 
    51            
     47          $perform_redirect = false; 
    5248          switch ($comment_action) 
    5349          { 
    5450            case 'moderate': 
    55               array_push($infos, l10n('An administrator must authorize your comment before it is visible.')); 
     51              $_SESSION['page_infos'][] = l10n('An administrator must authorize your comment before it is visible.'); 
    5652            case 'validate': 
    57               array_push($infos, l10n('Your comment has been registered')); 
     53              $_SESSION['page_infos'][] = l10n('Your comment has been registered'); 
     54              $perform_redirect = true; 
    5855              break; 
    5956            case 'reject': 
    60               set_status_header(403); 
    61               array_push($infos, l10n('Your comment has NOT been registered because it did not pass the validation rules')); 
     57              $_SESSION['page_errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules'); 
     58              $perform_redirect = true; 
    6259              break; 
    6360            default: 
     
    6562          } 
    6663 
    67           $template->assign( 
    68               ($comment_action=='reject') ? 'errors' : 'infos', 
    69               $infos 
    70             ); 
    71  
     64          if ($perform_redirect) 
     65          { 
     66            redirect($url_self); 
     67          } 
    7268          unset($_POST['content']); 
    73           break; 
    7469        }  
    7570        else  
    7671        { 
    7772          $edit_comment = $_GET['comment_to_edit']; 
    78           break; 
    7973        } 
     74        break; 
    8075      } 
    8176    } 
     
    8479      check_pwg_token(); 
    8580       
    86       include_once(COA_PATH.'include/functions_comment.inc.php'); 
     81      include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions 
    8782       
    8883      check_input_parameter('comment_to_delete', $_GET, false, PATTERN_ID); 
     
    10196      check_pwg_token(); 
    10297       
    103       include_once(COA_PATH.'include/functions_comment.inc.php'); 
     98      include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions 
    10499       
    105100      check_input_parameter('comment_to_validate', $_GET, false, PATTERN_ID); 
     
    116111  } 
    117112} 
     113 
    118114 
    119115// +-----------------------------------------------------------------------+ 
     
    133129  ); 
    134130 
    135   include_once(COA_PATH.'include/functions_comment.inc.php'); 
     131  include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions 
    136132   
    137   $comment_action = insert_user_comment_albums($comm, @$_POST['key'], $infos); 
     133  $comment_action = insert_user_comment_albums($comm, @$_POST['key'], $page['infos']); 
    138134 
    139135  switch ($comment_action)  
    140136  { 
    141137    case 'moderate': 
    142       array_push($infos, l10n('An administrator must authorize your comment before it is visible.')); 
     138      array_push($page['infos'], l10n('An administrator must authorize your comment before it is visible.')); 
    143139    case 'validate': 
    144       array_push($infos, l10n('Your comment has been registered')); 
     140      array_push($page['infos'], l10n('Your comment has been registered')); 
    145141      break; 
    146142    case 'reject': 
    147143      set_status_header(403); 
    148       array_push($infos, l10n('Your comment has NOT been registered because it did not pass the validation rules')); 
     144      array_push($page['errors'], l10n('Your comment has NOT been registered because it did not pass the validation rules')); 
    149145      break; 
    150146    default: 
    151147      trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING); 
    152148  } 
    153  
    154   $template->assign( 
    155       ($comment_action=='reject') ? 'errors' : 'infos', 
    156       $infos 
    157     ); 
    158149     
    159150  // allow plugins to notify what's going on 
     
    161152      array_merge($comm, array('action'=>$comment_action) ) 
    162153    ); 
    163    
     154     
     155  $template->assign('DISPLAY_COMMENTS_BLOCK', true); 
    164156}  
    165157else if (isset($_POST['content']))  
     
    194186  $row = pwg_db_fetch_assoc(pwg_query($query)); 
    195187 
    196   // navigation bar creation, custom again 
     188  // navigation bar creation, can't use $_GET['start'] because used by thumbnails navigation bar 
    197189  if (isset($_GET['start_comments']))  
    198190  { 
     
    203195    $page['start_comments'] = 0; 
    204196  } 
    205   include_once(COA_PATH.'include/functions.inc.php'); 
     197  include_once(COA_PATH.'include/functions.inc.php'); // custom fonctions 
    206198 
    207199  $navigation_bar = create_comment_navigation_bar( 
     
    221213  if ($row['nb_comments'] > 0)  
    222214  { 
     215    // comments order (get, session, conf) 
     216    if (!empty($_GET['comments_order']) && in_array(strtoupper($_GET['comments_order']), array('ASC', 'DESC'))) 
     217    { 
     218      pwg_set_session_var('comments_order', $_GET['comments_order']); 
     219    } 
     220    $comments_order = pwg_get_session_var('comments_order', $conf['comments_order']); 
     221 
     222    $template->assign(array( 
     223      'COMMENTS_ORDER_URL' => add_url_params( duplicate_index_url(), array('comments_order'=> ($comments_order == 'ASC' ? 'DESC' : 'ASC') ) ), 
     224      'COMMENTS_ORDER_TITLE' => $comments_order == 'ASC' ? l10n('Show latest comments first') : l10n('Show oldest comments first'), 
     225      )); 
     226       
    223227    // get comments 
    224228    $query = ' 
     
    237241  WHERE category_id = '.$category['id'].' 
    238242    '.$validated_clause.' 
    239   ORDER BY date ASC 
     243  ORDER BY date '.$comments_order.' 
    240244  LIMIT '.$conf['nb_comment_page'].' OFFSET '.$page['start_comments'].' 
    241245;'; 
     
    285289            'action' => 'edit_comment', 
    286290            'comment_to_edit' => $row['id'], 
    287             'pwg_token' => get_pwg_token(), 
    288291            ) 
    289292          ); 
    290293        if (isset($edit_comment) and ($row['id'] == $edit_comment))  
    291294        { 
     295          $tpl_comment['IN_EDIT'] = true; 
    292296          $key = get_ephemeral_key(2, $category['id']); 
    293           $tpl_comment['IN_EDIT'] = true; 
    294297          $tpl_comment['KEY'] = $key; 
    295298          $tpl_comment['CONTENT'] = $row['content']; 
     299          $tpl_comment['PWG_TOKEN'] = get_pwg_token(); 
    296300        } 
    297301      } 
     
    331335      $content = htmlspecialchars(stripslashes($comm['content'])); 
    332336    } 
    333     $template->assign( 
    334       'comment_add',  
     337    $template->assign('comment_add',  
    335338      array( 
    336339        'F_ACTION' => $url_self, 
     
    343346   
    344347  // template 
    345   $template->assign( 
    346     array( 
    347       'COA_PATH' => COA_PATH, // for css 
    348       'COA_ABSOLUTE_PATH' => dirname(__FILE__) .'/../', // for template 
    349       ) 
    350     ); 
     348  $template->assign(array( 
     349    'COA_PATH' => COA_PATH, // for css 
     350    'COA_ABSOLUTE_PATH' => dirname(__FILE__) .'/../', // for template 
     351    )); 
    351352   
    352   global $user; 
    353   if ( $is_simple = strstr($user['theme'], 'simple') !== false or strstr($user['theme'], 'stripped') !== false ) 
    354   { 
    355     $template->assign('IS_SIMPLE', $is_simple); 
    356     $template->set_filename('comments_on_albums', dirname(__FILE__) .'/../template/albums_simple.tpl'); 
     353  $template->set_filename('comments_on_albums', dirname(__FILE__) .'/../template/albums.tpl'); 
     354  if (isset($pwg_loaded_plugins['rv_tscroller']) AND count($page['navigation_bar']) != 0) 
     355  { 
     356    $template->assign('COMMENTS_ON_TOP', true); 
     357    $template->concat('PLUGIN_INDEX_CONTENT_BEGIN', $template->parse('comments_on_albums', true)); 
    357358  } 
    358359  else 
    359360  { 
    360     $template->set_filename('comments_on_albums', dirname(__FILE__) .'/../template/albums.tpl'); 
    361   } 
    362   $template->concat('PLUGIN_INDEX_CONTENT_END', $template->parse('comments_on_albums', true)); 
    363    
    364   if (isset($infos)) 
    365   { 
    366     $template->set_prefilter('index', 'coa_messages'); 
    367   } 
    368    
    369   function coa_messages($content, &$smarty)  
    370   { 
    371     $replacement = ' 
    372 {if !empty($errors)} 
    373 <div class="errors"> 
    374   <ul> 
    375     {foreach from=$errors item=error} 
    376     <li>{$error}</li> 
    377     {/foreach} 
    378   </ul> 
    379 </div> 
    380 {/if} 
    381 {if !empty($infos)} 
    382 <div class="infos"> 
    383   <ul> 
    384     {foreach from=$infos item=info} 
    385     <li>{$info}</li> 
    386     {/foreach} 
    387   </ul> 
    388 </div> 
    389 {/if}'; 
    390  
    391     return str_replace('{$MENUBAR}', $replacement.'{$MENUBAR}', $content); 
     361    $template->concat('PLUGIN_INDEX_CONTENT_END', $template->parse('comments_on_albums', true)); 
    392362  } 
    393363}