Changeset 3450
- Timestamp:
- Jun 23, 2009, 11:18:16 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/comments.php
r3282 r3450 135 135 136 136 $query = ' 137 SELECT c.id, c.image_id, c.date, c.author, c.content, i.path, i.tn_ext137 SELECT c.id, c.image_id, c.date, c.author, u.username, c.content, i.path, i.tn_ext 138 138 FROM '.COMMENTS_TABLE.' AS c 139 139 INNER JOIN '.IMAGES_TABLE.' AS i 140 140 ON i.id = c.image_id 141 LEFT JOIN '.USERS_TABLE.' AS u 142 ON u.id = c.author_id 141 143 WHERE validated = \'false\' 142 144 ORDER BY c.date DESC … … 152 154 ) 153 155 ); 156 if (empty($row['author_id'])) 157 { 158 $author_name = $row['author']; 159 } 160 else 161 { 162 $author_name = $row['username']; 163 } 154 164 $template->append( 155 165 'comments', … … 160 170 'ID' => $row['id'], 161 171 'TN_SRC' => $thumb, 162 'AUTHOR' => trigger_event('render_comment_author', $ row['author']),172 'AUTHOR' => trigger_event('render_comment_author', $author_name), 163 173 'DATE' => format_date($row['date'], true), 164 174 'CONTENT' => trigger_event('render_comment_content',$row['content']) -
trunk/comments.php
r3445 r3450 101 101 if (isset($_GET['author']) and !empty($_GET['author'])) 102 102 { 103 $page['where_clauses'][] = 'com.author = \''.$_GET['author'].'\''; 103 $page['where_clauses'][] = 104 'u.username = \''.addslashes($_GET['author']).'\' 105 OR author = \''.addslashes($_GET['author']).'\''; 104 106 } 105 107 … … 262 264 263 265 $query = ' 264 SELECT COUNT(DISTINCT( id))266 SELECT COUNT(DISTINCT(com.id)) 265 267 FROM '.IMAGE_CATEGORY_TABLE.' AS ic 266 268 INNER JOIN '.COMMENTS_TABLE.' AS com 267 269 ON ic.image_id = com.image_id 270 LEFT JOIN '.USERS_TABLE.' As u 271 ON u.id = com.author_id 268 272 WHERE '.implode(' 269 273 AND ', $page['where_clauses']).' … … 296 300 , ic.category_id 297 301 , com.author 302 , com.author_id 303 , username 298 304 , com.date 299 305 , com.content 300 306 , com.validated 301 307 FROM '.IMAGE_CATEGORY_TABLE.' AS ic 302 INNER JOIN '.COMMENTS_TABLE.' AS com 308 INNER JOIN '.COMMENTS_TABLE.' AS com 303 309 ON ic.image_id = com.image_id 310 LEFT JOIN '.USERS_TABLE.' AS u 311 ON u.id = com.author_id 304 312 WHERE '.implode(' 305 313 AND ', $page['where_clauses']).' … … 367 375 ); 368 376 369 $author = $comment['author']; 370 if (empty($comment['author'])) 371 { 372 $author = l10n('guest'); 377 if (!empty($comment['author'])) 378 { 379 $author = $comment['author']; 380 if ($author == 'guest') 381 { 382 $author = l10n('guest'); 383 } 384 } 385 else 386 { 387 $author = $comment['username']; 373 388 } 374 389 … … 383 398 ); 384 399 385 if (can_manage_comment('delete', $comment['author ']))400 if (can_manage_comment('delete', $comment['author_id'])) 386 401 { 387 402 $url = get_root_url().'comments.php' … … 392 407 ); 393 408 } 394 if (can_manage_comment('edit', $comment['author ']))409 if (can_manage_comment('edit', $comment['author_id'])) 395 410 { 396 411 $url = get_root_url().'comments.php' -
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.