Changeset 14528 for extensions/Comments_on_Albums/include/coa_albums.php
- Timestamp:
- Apr 29, 2012, 5:09:28 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Comments_on_Albums/include/coa_albums.php
r12618 r14528 27 27 case 'edit_comment' : 28 28 { 29 check_pwg_token();30 31 29 include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions 32 33 30 check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID); 34 35 31 $author_id = get_comment_author_id_albums($_GET['comment_to_edit']); 36 32 … … 39 35 if (!empty($_POST['content'])) 40 36 { 37 check_pwg_token(); 41 38 $comment_action = update_user_comment_albums( 42 39 array( … … 48 45 ); 49 46 50 $infos = array(); 51 47 $perform_redirect = false; 52 48 switch ($comment_action) 53 49 { 54 50 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.'); 56 52 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; 58 55 break; 59 56 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; 62 59 break; 63 60 default: … … 65 62 } 66 63 67 $template->assign( 68 ($comment_action=='reject') ? 'errors' : 'infos', 69 $infos 70 ); 71 64 if ($perform_redirect) 65 { 66 redirect($url_self); 67 } 72 68 unset($_POST['content']); 73 break;74 69 } 75 70 else 76 71 { 77 72 $edit_comment = $_GET['comment_to_edit']; 78 break;79 73 } 74 break; 80 75 } 81 76 } … … 84 79 check_pwg_token(); 85 80 86 include_once(COA_PATH.'include/functions_comment.inc.php'); 81 include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions 87 82 88 83 check_input_parameter('comment_to_delete', $_GET, false, PATTERN_ID); … … 101 96 check_pwg_token(); 102 97 103 include_once(COA_PATH.'include/functions_comment.inc.php'); 98 include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions 104 99 105 100 check_input_parameter('comment_to_validate', $_GET, false, PATTERN_ID); … … 116 111 } 117 112 } 113 118 114 119 115 // +-----------------------------------------------------------------------+ … … 133 129 ); 134 130 135 include_once(COA_PATH.'include/functions_comment.inc.php'); 131 include_once(COA_PATH.'include/functions_comment.inc.php'); // custom fonctions 136 132 137 $comment_action = insert_user_comment_albums($comm, @$_POST['key'], $ infos);133 $comment_action = insert_user_comment_albums($comm, @$_POST['key'], $page['infos']); 138 134 139 135 switch ($comment_action) 140 136 { 141 137 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.')); 143 139 case 'validate': 144 array_push($ infos, l10n('Your comment has been registered'));140 array_push($page['infos'], l10n('Your comment has been registered')); 145 141 break; 146 142 case 'reject': 147 143 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')); 149 145 break; 150 146 default: 151 147 trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING); 152 148 } 153 154 $template->assign(155 ($comment_action=='reject') ? 'errors' : 'infos',156 $infos157 );158 149 159 150 // allow plugins to notify what's going on … … 161 152 array_merge($comm, array('action'=>$comment_action) ) 162 153 ); 163 154 155 $template->assign('DISPLAY_COMMENTS_BLOCK', true); 164 156 } 165 157 else if (isset($_POST['content'])) … … 194 186 $row = pwg_db_fetch_assoc(pwg_query($query)); 195 187 196 // navigation bar creation, c ustom again188 // navigation bar creation, can't use $_GET['start'] because used by thumbnails navigation bar 197 189 if (isset($_GET['start_comments'])) 198 190 { … … 203 195 $page['start_comments'] = 0; 204 196 } 205 include_once(COA_PATH.'include/functions.inc.php'); 197 include_once(COA_PATH.'include/functions.inc.php'); // custom fonctions 206 198 207 199 $navigation_bar = create_comment_navigation_bar( … … 221 213 if ($row['nb_comments'] > 0) 222 214 { 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 223 227 // get comments 224 228 $query = ' … … 237 241 WHERE category_id = '.$category['id'].' 238 242 '.$validated_clause.' 239 ORDER BY date ASC243 ORDER BY date '.$comments_order.' 240 244 LIMIT '.$conf['nb_comment_page'].' OFFSET '.$page['start_comments'].' 241 245 ;'; … … 285 289 'action' => 'edit_comment', 286 290 'comment_to_edit' => $row['id'], 287 'pwg_token' => get_pwg_token(),288 291 ) 289 292 ); 290 293 if (isset($edit_comment) and ($row['id'] == $edit_comment)) 291 294 { 295 $tpl_comment['IN_EDIT'] = true; 292 296 $key = get_ephemeral_key(2, $category['id']); 293 $tpl_comment['IN_EDIT'] = true;294 297 $tpl_comment['KEY'] = $key; 295 298 $tpl_comment['CONTENT'] = $row['content']; 299 $tpl_comment['PWG_TOKEN'] = get_pwg_token(); 296 300 } 297 301 } … … 331 335 $content = htmlspecialchars(stripslashes($comm['content'])); 332 336 } 333 $template->assign( 334 'comment_add', 337 $template->assign('comment_add', 335 338 array( 336 339 'F_ACTION' => $url_self, … … 343 346 344 347 // 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 )); 351 352 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)); 357 358 } 358 359 else 359 360 { 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)); 392 362 } 393 363 }
Note: See TracChangeset
for help on using the changeset viewer.