Changeset 21817 for trunk/include
- Timestamp:
- Mar 24, 2013, 7:46:35 AM (11 years ago)
- Location:
- trunk/include
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r21515 r21817 1712 1712 } 1713 1713 } 1714 1715 /** returns the number of available comments for the connected user */ 1716 function get_nb_available_comments() 1717 { 1718 global $user; 1719 if (!isset($user['nb_available_comments'])) 1720 { 1721 $where = array(); 1722 if ( !is_admin() ) 1723 $where[] = 'validated=\'true\''; 1724 $where[] = get_sql_condition_FandF 1725 ( 1726 array 1727 ( 1728 'forbidden_categories' => 'category_id', 1729 'visible_categories' => 'category_id', 1730 'visible_images' => 'ic.image_id' 1731 ), 1732 '', true 1733 ); 1734 1735 $query = ' 1736 SELECT COUNT(DISTINCT(com.id)) 1737 FROM '.IMAGE_CATEGORY_TABLE.' AS ic 1738 INNER JOIN '.COMMENTS_TABLE.' AS com 1739 ON ic.image_id = com.image_id 1740 WHERE '.implode(' 1741 AND ', $where); 1742 list($user['nb_available_comments']) = pwg_db_fetch_row(pwg_query($query)); 1743 1744 single_update(USER_CACHE_TABLE, 1745 array('nb_available_comments'=>$user['nb_available_comments']), 1746 array('user_id'=>$user['id']) 1747 ); 1748 } 1749 return $user['nb_available_comments']; 1750 } 1751 1714 1752 ?> -
trunk/include/functions_comment.inc.php
r19703 r21817 221 221 ) 222 222 '; 223 224 223 pwg_query($query); 225 226 224 $comm['id'] = pwg_db_insert_id(COMMENTS_TABLE); 225 226 invalidate_user_cache_nb_comments(); 227 227 228 228 if ( ($conf['email_admin_on_comment'] && 'validate' == $comment_action) … … 284 284 $user_where_clause.' 285 285 ;'; 286 $result = pwg_query($query); 287 288 if ($result) 289 { 286 287 if ( pwg_db_changes(pwg_query($query)) ) 288 { 289 invalidate_user_cache_nb_comments(); 290 290 291 email_admin('delete', 291 292 array('author' => $GLOBALS['user']['username'], 292 293 'comment_id' => $comment_id 293 294 )); 294 } 295 296 trigger_action('user_comment_deletion', $comment_id); 295 trigger_action('user_comment_deletion', $comment_id); 296 } 297 297 } 298 298 … … 345 345 if (!url_check_format($comment['website_url'])) 346 346 { 347 array_push($page['errors'], l10n('Your website URL is invalid'));347 $page['errors'][] = l10n('Your website URL is invalid'); 348 348 $comment_action='reject'; 349 349 } … … 394 394 } 395 395 // just mail admin 396 else 396 elseif ($result) 397 397 { 398 398 email_admin('edit', array('author' => $GLOBALS['user']['username'], … … 482 482 pwg_query($query); 483 483 484 invalidate_user_cache_nb_comments(); 484 485 trigger_action('user_comment_validation', $comment_id); 485 486 } 487 488 489 function invalidate_user_cache_nb_comments() 490 { 491 global $user; 492 unset($user['nb_available_comments']); 493 $query = ' 494 UPDATE '.USER_CACHE_TABLE.' 495 SET nb_available_comments = NULL'; 496 pwg_query($query); 497 } 498 486 499 ?> -
trunk/include/functions_tag.inc.php
r19703 r21817 23 23 24 24 25 /** returns the number of available tags for the connected user */ 26 function get_nb_available_tags() 27 { 28 global $user; 29 if (!isset($user['nb_available_tags'])) 30 { 31 $user['nb_available_tags'] = count(get_available_tags()); 32 single_update(USER_CACHE_TABLE, 33 array('nb_available_tags'=>$user['nb_available_tags']), 34 array('user_id'=>$user['id']) 35 ); 36 } 37 return $user['nb_available_tags']; 38 } 39 25 40 /** 26 41 * Tags available. Each return tag is represented as an array with its id, -
trunk/include/menubar.inc.php
r21040 r21817 192 192 } 193 193 194 $block->data['recent_pics'] = 195 array( 196 'URL' => make_index_url(array('section' => 'recent_pics')), 197 'TITLE' => l10n('display most recent photos'), 198 'NAME' => l10n('Recent photos'), 199 ); 200 201 $block->data['recent_cats'] = 202 array( 203 'URL' => make_index_url(array('section' => 'recent_cats')), 204 'TITLE' => l10n('display recently updated albums'), 205 'NAME' => l10n('Recent albums'), 206 ); 207 194 208 $block->data['random'] = 195 209 array( … … 199 213 'REL'=> 'rel="nofollow"' 200 214 ); 201 202 $block->data['recent_pics'] =203 array(204 'URL' => make_index_url(array('section' => 'recent_pics')),205 'TITLE' => l10n('display most recent photos'),206 'NAME' => l10n('Recent photos'),207 );208 209 $block->data['recent_cats'] =210 array(211 'URL' => make_index_url(array('section' => 'recent_cats')),212 'TITLE' => l10n('display recently updated albums'),213 'NAME' => l10n('Recent albums'),214 );215 216 215 217 216 $block->data['calendar'] = … … 247 246 'NAME' => l10n('Tags'), 248 247 'URL'=> get_root_url().'tags.php', 248 'COUNTER' => get_nb_available_tags(), 249 249 ); 250 250 … … 266 266 'NAME'=>l10n('Comments'), 267 267 'URL'=> get_root_url().'comments.php', 268 'COUNTER' => get_nb_available_comments(), 268 269 ); 269 270 }
Note: See TracChangeset
for help on using the changeset viewer.