Changeset 813 for branches/branch-1_4


Ignore:
Timestamp:
Aug 15, 2005, 3:05:29 PM (19 years ago)
Author:
plg
Message:
  • bug 135 : "Count of total number of pictures". Correction reported from development branch.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_4/include/functions_category.inc.php

    r785 r813  
    156156}
    157157
     158/**
     159 * returns the total number of elements viewable in the gallery by the
     160 * connected user
     161 *
     162 * @return int
     163 */
    158164function count_user_total_images()
    159165{
    160166  global $user;
    161167
    162   $query = 'SELECT SUM(nb_images) AS total';
    163   $query.= ' FROM '.CATEGORIES_TABLE;
    164   if ( count( $user['restrictions'] ) > 0 )
    165     $query.= ' WHERE id NOT IN ('.$user['forbidden_categories'].')';
    166   $query.= ';';
     168  $query = '
     169SELECT COUNT(DISTINCT(image_id)) as total
     170  FROM '.IMAGE_CATEGORY_TABLE;
     171  if (count($user['restrictions']) > 0)
     172  {
     173    $query.= '
     174  WHERE category_id NOT IN ('.$user['forbidden_categories'].')';
     175  }
     176  $query.= '
     177;';
    167178 
    168   $row = mysql_fetch_array( pwg_query( $query ) );
    169 
    170   if ( !isset( $row['total'] ) ) $row['total'] = 0;
    171   return $row['total'];
     179  $row = mysql_fetch_array(pwg_query($query));
     180
     181  return isset($row['total']) ? $row['total'] : 0;
    172182}
    173183
Note: See TracChangeset for help on using the changeset viewer.