Changeset 3439 for extensions/CommentEditor
- Timestamp:
- Jun 22, 2009, 2:30:31 PM (15 years ago)
- Location:
- extensions/CommentEditor
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/CommentEditor/classes/ce_plugin.class.php
r3434 r3439 1 1 <?php 2 /* $Id: ce_plugin.class.php,v 1. 6 2009/06/18 21:02:12Criss Exp $ */2 /* $Id: ce_plugin.class.php,v 1.7 2009/06/22 12:25:04 Criss Exp $ */ 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 … … 10 10 class CE_Plugin { 11 11 12 var $comments_ids; 12 13 private static $url_prefix = null; 13 14 … … 22 23 /* ** Trigger management ** */ 23 24 /* ************************ */ 25 26 /** 27 * Update comment ID array 28 */ 29 function render_comment_content($content) { 30 $author = null; 31 $id = null; 32 switch (script_basename()) { 33 case "comments": 34 global $comment; 35 $author = $comment['author']; 36 $id = $comment['comment_id']; 37 break; 38 case "picture": 39 global $row; 40 $author = $row['author']; 41 $id = $row['id']; 42 break; 43 default: 44 // Not in right script 45 return $content; 46 } 47 global $template, $user; 48 if ((!is_a_guest() and ($user['username'] == $author)) 49 or is_admin()) { 50 $key = count($template->get_template_vars('comments')); 51 $this->comments_ids[$key] = $id; 52 } 53 return $content; 54 } 24 55 25 56 /** … … 29 60 function loc_begin_page_header() { 30 61 global $template; 31 $all_comments = &$template->get_template_vars('comments'); 32 for ($i=0; $i < count($all_comments) ; $i++) { 33 if (isset($all_comments[$i]) and is_array($all_comments[$i])) { 34 $comment = &$all_comments[$i]; 35 if (isset($comment['U_DELETE'])) { 36 $comment['U_ID'] = $this->getCommentId($comment['U_DELETE']); 37 $comment['DATE'] .= ' - <a href="' . $this->getEditUrlPrefix(); 38 $comment['DATE'] .= $comment['U_ID'] . '">'; 39 $comment['DATE'] .= 'Edit'; 40 $comment['DATE'] .= '</a>'; 41 } 62 $comments = $template->get_template_vars('comments'); 63 if (!isset($comments) or (null == $comments)) { 64 // No comment... 65 return; 66 } 67 foreach ($comments as $key => $value) { 68 if (isset($this->comments_ids[$key])) { 69 // User allowed to have edit link 70 $comments[$key]['U_ID'] = $this->comments_ids[$key]; 71 $comments[$key]['DATE'] .= ' - <a href="' . $this->getEditUrlPrefix(); 72 $comments[$key]['DATE'] .= $comments[$key]['U_ID'] . '">'; 73 $comments[$key]['DATE'] .= 'Edit'; 74 $comments[$key]['DATE'] .= '</a>'; 42 75 } 43 76 } 77 $template->assign('comments', $comments); 44 78 } 45 79 … … 108 142 109 143 function isEditAllowed($p_comment) { 110 if (FALSE == $p_comment->getInfo()) { 144 if ((FALSE == $p_comment->getInfo()) or 145 is_a_guest()) { 111 146 return false; 112 147 } -
extensions/CommentEditor/include/ce_common.inc.php
r3436 r3439 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 5 define('CE_VERSION', '1.0. e');5 define('CE_VERSION', '1.0.f'); 6 6 define('CE_INCLUDE_DIR', 'include/'); 7 7 define('CE_CLASSES_DIR', 'classes/'); -
extensions/CommentEditor/main.inc.php
r3436 r3439 1 1 <?php 2 /* $Id: main.inc.php,v 1. 6 2009/06/18 21:02:12Criss Exp $ */2 /* $Id: main.inc.php,v 1.8 2009/06/22 12:25:04 Criss Exp $ */ 3 3 /* 4 4 Plugin Name: Comment Editor 5 Version: 1.0. e5 Version: 1.0.f 6 6 Description: Allow to edit comment 7 7 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=296 … … 11 11 12 12 /** History ** 13 14 2009-06-22 1.0.f 15 Add edit link for author even if he's not an admin 16 Code cleanup 13 17 14 18 2009-06-18 1.0.e … … 36 40 37 41 $ce_plugin = new CE_Plugin(); 42 add_event_handler( 'render_comment_content', 43 array(&$ce_plugin, 'render_comment_content')); 38 44 add_event_handler( 'loc_begin_page_header', 39 45 array(&$ce_plugin, 'loc_begin_page_header'));
Note: See TracChangeset
for help on using the changeset viewer.