Changeset 1598 for trunk/comments.php
- Timestamp:
- Nov 8, 2006, 5:28:30 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/comments.php
r1563 r1598 6 6 // +-----------------------------------------------------------------------+ 7 7 // | branch : BSF (Best So Far) 8 // | file : $ RCSfile$8 // | file : $Id$ 9 9 // | last update : $Date$ 10 10 // | last modifier : $Author$ … … 29 29 // | initialization | 30 30 // +-----------------------------------------------------------------------+ 31 if (!defined('IN_ADMIN')) 32 { 33 define('PHPWG_ROOT_PATH','./'); 34 include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); 35 } 31 define('PHPWG_ROOT_PATH','./'); 32 include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); 36 33 37 34 // +-----------------------------------------------------------------------+ … … 145 142 } 146 143 144 // which status to filter on ? 145 if ( is_admin() ) 146 { 147 $page['status_clause'] = '1=1'; 148 } 149 else 150 { 151 $page['status_clause'] = 'validated="true"'; 152 } 153 154 147 155 // +-----------------------------------------------------------------------+ 148 156 // | comments management | 149 157 // +-----------------------------------------------------------------------+ 150 // comments deletion 151 if (isset($_POST['delete']) and count($_POST['comment_id']) > 0 and is_admin()) 152 { 153 $_POST['comment_id'] = array_map('intval', $_POST['comment_id']);154 $query = '158 if (is_admin() and !is_adviser() ) 159 { 160 if (isset($_GET['delete']) and is_numeric($_GET['delete']) ) 161 {// comments deletion 162 $query = ' 155 163 DELETE FROM '.COMMENTS_TABLE.' 156 WHERE id IN ('.implode(',', $_POST['comment_id']).') 157 ;'; 158 pwg_query($query); 159 } 160 // comments validation 161 if (isset($_POST['validate']) and count($_POST['comment_id']) > 0 162 and is_admin()) 163 { 164 $_POST['comment_id'] = array_map('intval', $_POST['comment_id']); 165 $query = ' 164 WHERE id='.$_GET['delete'].' 165 ;'; 166 pwg_query($query); 167 } 168 169 if (isset($_GET['validate']) and is_numeric($_GET['validate']) ) 170 { // comments validation 171 $query = ' 166 172 UPDATE '.COMMENTS_TABLE.' 167 173 SET validated = \'true\' 168 174 , validation_date = NOW() 169 WHERE id IN ('.implode(',', $_POST['comment_id']).') 170 ;'; 171 pwg_query($query); 175 WHERE id='.$_GET['validate'].' 176 ;'; 177 pwg_query($query); 178 } 172 179 } 173 180 // +-----------------------------------------------------------------------+ … … 299 306 AND '.$page['cat_clause'].' 300 307 AND '.$page['author_clause'].' 301 AND '.$page['keyword_clause']; 308 AND '.$page['keyword_clause'].' 309 AND '.$page['status_clause']; 302 310 if ($user['forbidden_categories'] != '') 303 311 { … … 309 317 list($counter) = mysql_fetch_row(pwg_query($query)); 310 318 311 $url = PHPWG_ROOT_PATH.'comments.php'.get_query_string_diff(array('start')); 319 $url = PHPWG_ROOT_PATH 320 .'comments.php' 321 .get_query_string_diff(array('start','delete','validate')); 312 322 313 323 $navbar = create_navigation_bar($url, … … 335 345 , com.content 336 346 , com.id AS comment_id 347 , com.validated 337 348 FROM '.IMAGE_CATEGORY_TABLE.' AS ic 338 349 INNER JOIN '.COMMENTS_TABLE.' AS com … … 341 352 AND '.$page['cat_clause'].' 342 353 AND '.$page['author_clause'].' 343 AND '.$page['keyword_clause']; 354 AND '.$page['keyword_clause'].' 355 AND '.$page['status_clause']; 344 356 if ($user['forbidden_categories'] != '') 345 357 { … … 358 370 ;'; 359 371 $result = pwg_query($query); 360 while ($row = mysql_fetch_a rray($result))372 while ($row = mysql_fetch_assoc($result)) 361 373 { 362 374 array_push($comments, $row); … … 375 387 ;'; 376 388 $result = pwg_query($query); 377 while ($row = mysql_fetch_a rray($result))389 while ($row = mysql_fetch_assoc($result)) 378 390 { 379 391 $elements[$row['id']] = $row; … … 388 400 ;'; 389 401 $result = pwg_query($query); 390 while ($row = mysql_fetch_a rray($result))402 while ($row = mysql_fetch_assoc($result)) 391 403 { 392 404 $categories[$row['id']] = $row; … … 395 407 foreach ($comments as $comment) 396 408 { 397 // name of the picture398 $name = get_cat_display_name_cache(399 $categories[$comment['category_id']]['uppercats'], null, false);400 $name.= $conf['level_separator'];401 409 if (!empty($elements[$comment['image_id']]['name'])) 402 410 { 403 $name .=$elements[$comment['image_id']]['name'];411 $name=$elements[$comment['image_id']]['name']; 404 412 } 405 413 else 406 414 { 407 $name .=get_name_from_file($elements[$comment['image_id']]['file']);415 $name=get_name_from_file($elements[$comment['image_id']]['file']); 408 416 } 409 417 410 418 // source of the thumbnail picture 411 $thumbnail_src = get_thumbnail_src( 412 $elements[$comment['image_id']]['path'], 413 @$elements[$comment['image_id']]['tn_ext'] 414 ); 419 $thumbnail_src = get_thumbnail_url( $elements[$comment['image_id']] ); 415 420 416 421 // link to the full size picture … … 424 429 ); 425 430 426 $template->assign_block_vars(427 'picture',428 array(429 'TITLE_IMG'=>$name,430 'I_THUMB'=>$thumbnail_src,431 'U_THUMB'=>$url432 ));433 434 431 $author = $comment['author']; 435 432 if (empty($comment['author'])) … … 443 440 'U_PICTURE' => $url, 444 441 'TN_SRC' => $thumbnail_src, 442 'ALT' => $name, 445 443 'AUTHOR' => $author, 446 444 'DATE'=>format_date($comment['date'],'mysql_datetime',true), 447 'CONTENT'=> parse_comment_content($comment['content']),445 'CONTENT'=>trigger_event('render_comment_content',$comment['content']), 448 446 )); 447 448 if ( is_admin() ) 449 { 450 $url = get_root_url().'comments.php'.get_query_string_diff(array('delete','validate')); 451 $template->assign_block_vars( 452 'comment.action_delete', 453 array( 454 'U_DELETE' => add_url_params($url, 455 array('delete'=>$comment['comment_id']) 456 ), 457 )); 458 if ($comment['validated'] != 'true') 459 { 460 $template->assign_block_vars( 461 'comment.action_validate', 462 array( 463 'U_VALIDATE' => add_url_params($url, 464 array('validate'=>$comment['comment_id']) 465 ), 466 )); 467 } 468 } 449 469 } 450 470 } … … 452 472 // | html code display | 453 473 // +-----------------------------------------------------------------------+ 454 if (defined('IN_ADMIN')) 455 { 456 $template->assign_var_from_handle('ADMIN_CONTENT', 'comments'); 457 } 458 else 459 { 460 $template->assign_block_vars('title',array()); 461 $template->parse('comments'); 462 include(PHPWG_ROOT_PATH.'include/page_tail.php'); 463 } 474 $template->assign_block_vars('title',array()); 475 $template->parse('comments'); 476 include(PHPWG_ROOT_PATH.'include/page_tail.php'); 464 477 ?>
Note: See TracChangeset
for help on using the changeset viewer.