Changeset 3475 for extensions/CommentEditor/classes/ce_plugin.class.php
- Timestamp:
- Jun 30, 2009, 9:05:35 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/CommentEditor/classes/ce_plugin.class.php
r3473 r3475 1 1 <?php 2 /* $Id: ce_plugin.class.php,v 1.1 2 2009/06/29 11:43:18Criss Exp $ */2 /* $Id: ce_plugin.class.php,v 1.13 2009/06/30 19:01:50 Criss Exp $ */ 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 … … 65 65 } 66 66 global $template, $conf, $user; 67 if ((!is_a_guest() and ($user[$conf['user_fields']['username']] == $author)) 67 if ((!is_a_guest() 68 and ($user[$conf['user_fields']['username']] == $author)) 68 69 or is_admin()) { 69 70 $key = count($template->get_template_vars('comments')); … … 94 95 $comments[$key]['DATE'] .= $this->getEditUrl($current_id); 95 96 $comments[$key]['DATE'] .= '">'; 96 $comments[$key]['DATE'] .= l10n('c omment_edit_tool');97 $comments[$key]['DATE'] .= l10n('ce_edit_tool'); 97 98 $comments[$key]['DATE'] .= '</a>'; 98 99 } … … 129 130 function doAction() { 130 131 $comment_id = ""; 131 $action = $this->isCommentEdit($ _SERVER['QUERY_STRING'], $comment_id);132 $action = $this->isCommentEdit($comment_id); 132 133 switch ($action) { 133 134 case CE_ACTION_EDIT: … … 139 140 break; 140 141 case CE_ACTION_ERROR: 141 $infos = array('c omment_edit_forbidden');142 $infos = array('ce_edit_forbidden'); 142 143 $this->displayError($infos); 143 144 break; … … 152 153 } 153 154 154 function isCommentEdit($p_query_string, &$p_comment_id) { 155 $params = split('\&', $p_query_string); 155 function isCommentEdit(&$p_comment_id) { 156 156 $action = CE_ACTION_NONE; 157 157 $comment_id = ""; 158 foreach ($params as $current_param) { 159 $key_value = split('=', $current_param); 160 if (isset($key_value[1])) { 161 if (CE_ACTION == $key_value[0] && CE_ACTION_NONE == $action) { 162 switch ($key_value[1]) { 163 case CE_ACTION_EDIT: 164 case CE_ACTION_UPDATE: 165 $action = $key_value[1]; 166 break; 167 default: 168 } 169 } 170 if (CE_ID == $key_value[0]) { 171 $comment_id = $key_value[1]; 172 } 158 if (isset($_GET[CE_ACTION])) { 159 switch ($_GET[CE_ACTION]) { 160 case CE_ACTION_EDIT: 161 case CE_ACTION_UPDATE: 162 $action = $_GET[CE_ACTION]; 163 break; 164 default: 173 165 } 166 } 167 if (isset($_GET[CE_ID])) { 168 $comment_id = $_GET[CE_ID]; 174 169 } 175 170 if (CE_ACTION_EDIT == $action) { … … 200 195 if (!$this->isEditAllowed($comment)) { 201 196 // Not allowed 202 array_push($infos, 'c omment_edit_forbidden');197 array_push($infos, 'ce_edit_forbidden'); 203 198 $this->displayError($infos); 204 199 return; … … 211 206 if ((!isset($_POST['ce_commentid'])) or 212 207 (!isset($_POST['ce_imageid']))) { 213 array_push($infos, 'c omment_access_invalid');208 array_push($infos, 'ce_access_invalid'); 214 209 $this->displayError($infos); 215 210 return; 216 211 } 217 212 if (!is_numeric($_POST['ce_imageid'])) { 218 array_push($infos, 'c omment_access_invalid');213 array_push($infos, 'ce_access_invalid'); 219 214 $this->displayError($infos); 220 215 return; … … 223 218 224 219 if (!$this->isEditAllowed($comment)) { 225 array_push($infos, 'c omment_edit_forbidden');220 array_push($infos, 'ce_edit_forbidden'); 226 221 $this->displayError($infos); 227 222 return; … … 229 224 $image_id = $comment->getInfo('image_id'); 230 225 if (intval($_POST['ce_imageid']) != intval($image_id)) { 231 array_push($infos, 'c omment_access_invalid');226 array_push($infos, 'ce_access_invalid'); 232 227 $this->displayError($infos); 233 228 return; … … 255 250 $conf['anti-flood_time'] = 0; 256 251 257 $comment_action = update_user_comment($comment_array, @$_POST['key'], $infos ); 252 $comment_action = update_user_comment($comment_array, 253 @$_POST['key'], 254 $infos ); 258 255 259 256 // Reactivate anti-flood system … … 271 268 break; 272 269 default: 273 trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING); 270 trigger_error('Invalid comment action '.$comment_action, 271 E_USER_WARNING); 274 272 } 275 273 276 274 // allow plugins to notify what's going on 277 275 trigger_action( 'user_comment_insertion', 278 array_merge($comment_array, array('action'=>$comment_action))); 276 array_merge($comment_array, array('action'=> 277 $comment_action))); 279 278 if ($comment_action=='reject') { 280 279 $this->displayError($infos); … … 329 328 'TYPE' => $p_type, 330 329 'IMG' => $p_image, 331 'TITLE' => l10n( $p_type),330 'TITLE' => l10n('ce_'.$p_type), 332 331 'MSG' => $messages 333 332 ); 334 333 335 334 global $template; 336 if ("" == $template->get_template_vars('U_HOME')) { 337 $template->assign('U_HOME', make_index_url()); 338 } 339 $template->set_filenames(array('ce_message'=>$this->getTemplate('message.tpl'))); 335 336 $ce_exit = array( 337 'URL' => $this->getBaseUrl(), 338 'TITLE' => 'ce_close_message_title', 339 'ALT' => 'ce_close_message_alt', 340 'IMG' => CE_CLOSE_IMG 341 ); 342 $template->assign('ce_exit', $ce_exit); 343 $template->set_filenames( array('ce_message'=> 344 $this->getTemplate('message.tpl'))); 340 345 $template->block_html_head( '', 341 346 '<link rel="stylesheet" type="text/css" href="' … … 347 352 } 348 353 349 $template->assign(' message', $message_array);354 $template->assign('ce_message', $message_array); 350 355 $old_begin = $template->get_template_vars($begin); 351 356 $template->assign($begin, $template->parse('ce_message', true)); … … 374 379 'AUTHOR' => $p_comment->getInfo('author'), 375 380 'IMAGE' => $p_comment->getInfo('image_id'), 376 'DISABLED' => !is_admin(), 377 'USERS' => CE_Comment::getUsers(), 378 'F_ACTION' => $this->getUpdateUrl(), 379 'FREEAUTHOR'=> ($p_comment->isKnownAuthor())?'':'checked="checked"' 381 'F_ACTION' => $this->getUpdateUrl() 380 382 ); 381 if ("" == $template->get_template_vars('U_HOME')) { 382 $template->assign('U_HOME', make_index_url()); 383 } 384 $template->assign('comment', $tpl_comment); 385 $old_begin = $template->get_template_vars($begin); 386 $template->assign($begin, $template->parse('ce_edit', true)); 387 $template->concat($begin, $old_begin); 383 384 if (is_admin()) { 385 $tpl_comment['USERS'] = CE_Comment::getUsers(); 386 $tpl_comment['FREEAUTHOR'] = ($p_comment->isKnownAuthor())? 387 '':CE_CHECKED; 388 } 389 390 $additional_toolbar = ""; 391 $additional_toolbar = trigger_event('comment_editor_toolbar', 392 $additional_toolbar); 393 if ("" != $additional_toolbar) { 394 $tpl_comment['TOOLBAR'] = $additional_toolbar; 395 } 396 397 $ce_exit = array( 398 'URL' => $this->getBaseUrl(), 399 'TITLE' => 'ce_close_editor_title', 400 'ALT' => 'ce_close_editor_alt', 401 'IMG' => CE_CLOSE_IMG 402 ); 403 $template->assign('ce_exit', $ce_exit); 404 405 $template->assign('comment_editor', $tpl_comment); 406 $old_begin = $template->get_template_vars($begin); 407 $template->assign($begin, $template->parse('ce_edit', true)); 408 $template->concat($begin, $old_begin); 388 409 } 389 410 … … 414 435 } 415 436 416 function get EditUrl($comment_id) {437 function getBaseUrl() { 417 438 $url = get_root_url() . $this->getScriptName() . '.php'; 418 439 $url .= get_query_string_diff(array(CE_ACTION, CE_ID)); 440 return $url; 441 } 442 443 function getEditUrl($comment_id) { 444 $url = $this->getBaseUrl(); 419 445 $url = add_url_params($url, 420 446 array( … … 427 453 428 454 function getUpdateUrl() { 429 $url = get_root_url() . $this->getScriptName() .'.php'; 430 $url .= get_query_string_diff(array(CE_ACTION, CE_ID)); 455 $url = $this->getBaseUrl(); 431 456 $url = add_url_params($url, 432 457 array(
Note: See TracChangeset
for help on using the changeset viewer.