Changeset 3622 for trunk/include
- Timestamp:
- Jul 18, 2009, 12:30:42 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_user.inc.php
r3450 r3622 248 248 $query.= ' 249 249 FROM '.USERS_TABLE.' 250 WHERE '.$conf['user_fields']['id'].' = \''.$user_id.'\' 251 ;'; 250 WHERE '.$conf['user_fields']['id'].' = \''.$user_id.'\''; 252 251 253 252 $row = mysql_fetch_array(pwg_query($query)); … … 259 258 FROM '.USER_INFOS_TABLE.' AS ui LEFT JOIN '.USER_CACHE_TABLE.' AS uc 260 259 ON ui.user_id = uc.user_id 261 WHERE ui.user_id = \''.$user_id.'\' 262 ;'; 260 WHERE ui.user_id = \''.$user_id.'\''; 263 261 $result = pwg_query($query); 264 262 if (mysql_num_rows($result) > 0) … … 321 319 $userdata['image_access_list'] = implode(',',$forbidden_ids); 322 320 323 update_user_cache_categories($userdata);324 321 325 322 $query = ' … … 327 324 FROM '.IMAGE_CATEGORY_TABLE.' 328 325 WHERE category_id NOT IN ('.$userdata['forbidden_categories'].') 329 AND image_id '.$userdata['image_access_type'].' ('.$userdata['image_access_list'].') 330 ;'; 326 AND image_id '.$userdata['image_access_type'].' ('.$userdata['image_access_list'].')'; 331 327 list($userdata['nb_total_images']) = mysql_fetch_array(pwg_query($query)); 328 329 330 // now we update user cache categories 331 $user_cache_cats = get_computed_categories($userdata, null); 332 if ( !is_admin($userdata['status']) ) 333 { // for non admins we forbid categories with no image (feature 1053) 334 $forbidden_ids = array(); 335 foreach ($user_cache_cats as $cat_id => $cat) 336 { 337 if ($cat['count_images']==0) 338 { 339 array_push($forbidden_ids, $cat_id); 340 unset( $user_cache_cats[$cat_id] ); 341 } 342 } 343 if ( !empty($forbidden_ids) ) 344 { 345 if ( empty($userdata['forbidden_categories']) ) 346 { 347 $userdata['forbidden_categories'] = implode(',', $forbidden_ids); 348 } 349 else 350 { 351 $userdata['forbidden_categories'] .= ','.implode(',', $forbidden_ids); 352 } 353 } 354 } 355 356 // delete user cache 357 $query = ' 358 DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.' 359 WHERE user_id = '.$userdata['id']; 360 pwg_query($query); 361 362 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 363 mass_inserts 364 ( 365 USER_CACHE_CATEGORIES_TABLE, 366 array 367 ( 368 'user_id', 'cat_id', 369 'date_last', 'max_date_last', 'nb_images', 'count_images', 'count_categories' 370 ), 371 $user_cache_cats 372 ); 373 332 374 333 375 // update user cache 334 376 $query = ' 335 377 DELETE FROM '.USER_CACHE_TABLE.' 336 WHERE user_id = '.$userdata['id'].' 337 ;'; 378 WHERE user_id = '.$userdata['id']; 338 379 pwg_query($query); 339 380 … … 346 387 .$userdata['cache_update_time'].',\'' 347 388 .$userdata['forbidden_categories'].'\','.$userdata['nb_total_images'].',"' 348 .$userdata['image_access_type'].'","'.$userdata['image_access_list'].'") 349 ;'; 389 .$userdata['image_access_type'].'","'.$userdata['image_access_list'].'")'; 350 390 pwg_query($query); 351 391 } … … 644 684 645 685 /** 646 * update data of user_cache_categories647 *648 * @param array userdata649 * @return null650 */651 function update_user_cache_categories($userdata)652 {653 // delete user cache654 $query = '655 DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'656 WHERE user_id = '.$userdata['id'].'657 ;';658 pwg_query($query);659 660 $cats = get_computed_categories($userdata, null);661 662 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');663 mass_inserts664 (665 USER_CACHE_CATEGORIES_TABLE,666 array667 (668 'user_id', 'cat_id',669 'date_last', 'max_date_last', 'nb_images', 'count_images', 'count_categories'670 ),671 $cats672 );673 }674 675 /**676 686 * returns user identifier thanks to his name, false if not found 677 687 * … … 1203 1213 * @return bool 1204 1214 */ 1205 function can_manage_comment($action, $comment_author_id) 1215 function can_manage_comment($action, $comment_author_id) 1206 1216 { 1207 1217 if (!in_array($action, array('delete','edit'))) { 1208 1218 return false; 1209 1219 } 1210 return (is_admin() || 1211 (($GLOBALS['user']['id'] == $comment_author_id) 1220 return (is_admin() || 1221 (($GLOBALS['user']['id'] == $comment_author_id) 1212 1222 && !is_a_guest() 1213 1223 && $GLOBALS['conf'][sprintf('user_can_%s_comment', $action)]));
Note: See TracChangeset
for help on using the changeset viewer.