Changeset 3450 for trunk/include
- Timestamp:
- Jun 23, 2009, 11:18:16 PM (15 years ago)
- Location:
- trunk/include
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_comment.inc.php
r3445 r3450 92 92 $comm['author'] = 'guest'; 93 93 } 94 $comm['author_id'] = $conf['guest_id']; 94 95 // if a guest try to use the name of an already existing user, he must be 95 96 // rejected … … 110 111 else 111 112 { 112 $comm['author'] = $user['username']; 113 } 113 $comm['author'] = ''; 114 $comm['author_id'] = $user['id']; 115 } 116 114 117 if ( empty($comm['content']) ) 115 118 { // empty comment content … … 135 138 SELECT id FROM '.COMMENTS_TABLE.' 136 139 WHERE date > FROM_UNIXTIME('.$reference_date.') 137 AND author = "'.addslashes($comm['author']).'"';140 AND author_id = '.$comm['author_id']; 138 141 if ( mysql_num_rows( pwg_query( $query ) ) > 0 ) 139 142 { … … 152 155 $query = ' 153 156 INSERT INTO '.COMMENTS_TABLE.' 154 (author, content, date, validated, validation_date, image_id)157 (author, author_id, content, date, validated, validation_date, image_id) 155 158 VALUES ( 156 159 "'.addslashes($comm['author']).'", 160 '.$comm['author_id'].', 157 161 "'.addslashes($comm['content']).'", 158 162 NOW(), … … 167 171 $comm['id'] = mysql_insert_id(); 168 172 169 if 170 ( 171 ($comment_action=='validate' and $conf['email_admin_on_comment']) 172 or 173 ($comment_action!='validate' and $conf['email_admin_on_comment_validation']) 174 ) 173 if (($comment_action=='validate' and $conf['email_admin_on_comment']) or 174 ($comment_action!='validate' 175 and $conf['email_admin_on_comment_validation'])) 175 176 { 176 177 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 177 178 178 $del_url = 179 get_absolute_root_url().'comments.php?delete='.$comm['id']; 180 179 $del_url = get_absolute_root_url().'comments.php?delete='.$comm['id']; 180 181 if (empty($comm['author'])) 182 { 183 $author_name = $user['username']; 184 } 185 else 186 { 187 $author_name = $comm['author']; 188 } 181 189 $keyargs_content = array 182 190 ( 183 get_l10n_args('Author: %s', $ comm['author']),191 get_l10n_args('Author: %s', $author_name), 184 192 get_l10n_args('Comment: %s', $comm['content']), 185 193 get_l10n_args('', ''), … … 198 206 pwg_mail_notification_admins 199 207 ( 200 get_l10n_args('Comment by %s', $ comm['author']),208 get_l10n_args('Comment by %s', $author_name), 201 209 $keyargs_content 202 210 ); … … 219 227 if (!is_admin()) 220 228 { 221 $user_where_clause = ' AND author = \''.$GLOBALS['user']['username'].'\'';229 $user_where_clause = ' AND author_id = \''.$GLOBALS['user']['id'].'\''; 222 230 } 223 231 $query = ' … … 265 273 SELECT id FROM '.COMMENTS_TABLE.' 266 274 WHERE date > FROM_UNIXTIME('.$reference_date.') 267 AND author = "'.$GLOBALS['user']['username'].'"';275 AND author_id = '.$comm['author_id']; 268 276 if ( mysql_num_rows( pwg_query( $query ) ) > 0 ) 269 277 { … … 287 295 if (!is_admin()) 288 296 { 289 $user_where_clause = ' AND author = \''.290 $GLOBALS['user'][' username'].'\'';297 $user_where_clause = ' AND author_id = \''. 298 $GLOBALS['user']['id'].'\''; 291 299 } 292 300 $query = ' -
trunk/include/functions_user.inc.php
r3445 r3450 1203 1203 * @return bool 1204 1204 */ 1205 function can_manage_comment($action, $comment_author )1205 function can_manage_comment($action, $comment_author_id) 1206 1206 { 1207 1207 if (!in_array($action, array('delete','edit'))) { … … 1209 1209 } 1210 1210 return (is_admin() || 1211 (($GLOBALS['user']['username'] == $comment_author) 1211 (($GLOBALS['user']['id'] == $comment_author_id) 1212 && !is_a_guest() 1212 1213 && $GLOBALS['conf'][sprintf('user_can_%s_comment', $action)])); 1213 1214 } -
trunk/include/picture_comment.inc.php
r3446 r3450 129 129 130 130 $query = ' 131 SELECT id,author,date,image_id,content,validated 132 FROM '.COMMENTS_TABLE.' 131 SELECT com.id,author,author_id,username,date,image_id,content,validated 132 FROM '.COMMENTS_TABLE.' AS com 133 LEFT JOIN '.USERS_TABLE.' AS u 134 ON u.id = author_id 133 135 WHERE image_id = '.$page['image_id']. 134 136 $validated_clause.' … … 140 142 while ($row = mysql_fetch_array($result)) 141 143 { 144 if (!empty($row['author'])) 145 { 146 $author = $row['author']; 147 if ($author == 'guest') 148 { 149 $author = l10n('guest'); 150 } 151 } 152 else 153 { 154 $author = $row['username']; 155 } 156 142 157 $tpl_comment = 143 158 array( 144 'AUTHOR' => trigger_event('render_comment_author', 145 empty($row['author']) 146 ? l10n('guest') 147 : $row['author']), 159 'AUTHOR' => trigger_event('render_comment_author', $author), 148 160 149 161 'DATE' => format_date( $row['date'], true), … … 152 164 ); 153 165 154 if (can_manage_comment('delete', $row['author ']))166 if (can_manage_comment('delete', $row['author_id'])) 155 167 { 156 168 $tpl_comment['U_DELETE'] = … … 162 174 ); 163 175 } 164 if (can_manage_comment('edit', $row['author ']))176 if (can_manage_comment('edit', $row['author_id'])) 165 177 { 166 178 $tpl_comment['U_EDIT'] =
Note: See TracChangeset
for help on using the changeset viewer.