feature 2836: display the number of comments/tags in the menubar

git-svn-id: http://piwigo.org/svn/trunk@21817 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2013-03-24 06:46:35 +00:00
parent 55275efb66
commit ea10c19ac5
6 changed files with 100 additions and 17 deletions
+38
View File
@@ -1711,4 +1711,42 @@ function email_check_format($mail_address)
return (bool)preg_match($regex, $mail_address);
}
}
/** returns the number of available comments for the connected user */
function get_nb_available_comments()
{
global $user;
if (!isset($user['nb_available_comments']))
{
$where = array();
if ( !is_admin() )
$where[] = 'validated=\'true\'';
$where[] = get_sql_condition_FandF
(
array
(
'forbidden_categories' => 'category_id',
'visible_categories' => 'category_id',
'visible_images' => 'ic.image_id'
),
'', true
);
$query = '
SELECT COUNT(DISTINCT(com.id))
FROM '.IMAGE_CATEGORY_TABLE.' AS ic
INNER JOIN '.COMMENTS_TABLE.' AS com
ON ic.image_id = com.image_id
WHERE '.implode('
AND ', $where);
list($user['nb_available_comments']) = pwg_db_fetch_row(pwg_query($query));
single_update(USER_CACHE_TABLE,
array('nb_available_comments'=>$user['nb_available_comments']),
array('user_id'=>$user['id'])
);
}
return $user['nb_available_comments'];
}
?>