Ignore:
Timestamp:
Mar 24, 2013, 7:46:35 AM (11 years ago)
Author:
rvelices
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r21515 r21817  
    17121712  }
    17131713}
     1714
     1715/** returns the number of available comments for the connected user */
     1716function 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 = '
     1736SELECT 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
    17141752?>
Note: See TracChangeset for help on using the changeset viewer.