Changeset 21817 for trunk/include/functions.inc.php
- Timestamp:
- Mar 24, 2013, 7:46:35 AM (12 years ago)
- File:
-
- 1 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 ?>
Note: See TracChangeset
for help on using the changeset viewer.