Changeset 1081


Ignore:
Timestamp:
Mar 15, 2006, 3:26:25 AM (18 years ago)
Author:
rvelices
Message:

feature 262: new user cached information nb_total_pictures

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/category.php

    r1072 r1081  
    213213$template->assign_vars(
    214214  array(
    215   'NB_PICTURE' => count_user_total_images(),
     215  'NB_PICTURE' => $user['nb_total_images'],
    216216  'TITLE' => $template_title,
    217217  'USERNAME' => $user['username'],
  • trunk/include/functions_category.inc.php

    r1061 r1081  
    105105
    106106/**
    107  * returns the total number of elements viewable in the gallery by the
    108  * connected user
    109  *
    110  * @return int
    111  */
    112 function count_user_total_images()
    113 {
    114   global $user;
    115 
    116   $query = '
    117 SELECT COUNT(DISTINCT(image_id)) as total
    118   FROM '.IMAGE_CATEGORY_TABLE.'
    119   WHERE category_id NOT IN ('.$user['forbidden_categories'].')
    120 ;';
    121   list($total) = mysql_fetch_array(pwg_query($query));
    122 
    123   return $total;
    124 }
    125 
    126 /**
    127107 * Retrieve informations about a category in the database
    128108 *
  • trunk/include/functions_user.inc.php

    r1079 r1081  
    189189        calculate_permissions($userdata['id'], $userdata['status']);
    190190
     191      $query = '
     192SELECT COUNT(DISTINCT(image_id)) as total
     193  FROM '.IMAGE_CATEGORY_TABLE.'
     194  WHERE category_id NOT IN ('.$userdata['forbidden_categories'].')
     195;';
     196      list($userdata['nb_total_images']) = mysql_fetch_array(pwg_query($query));
     197
    191198      // update user cache
    192199      $query = '
     
    198205      $query = '
    199206INSERT INTO '.USER_CACHE_TABLE.'
    200   (user_id,need_update,forbidden_categories)
     207  (user_id,need_update,forbidden_categories,nb_total_images)
    201208  VALUES
    202   ('.$userdata['id'].',\'false\',\''.$userdata['forbidden_categories'].'\')
     209  ('.$userdata['id'].',\'false\',\''
     210  .$userdata['forbidden_categories'].'\','.$userdata['nb_total_images'].')
    203211;';
    204212      pwg_query($query);
  • trunk/install/phpwebgallery_structure.sql

    r1078 r1081  
    261261  `need_update` enum('true','false') NOT NULL default 'true',
    262262  `forbidden_categories` text,
     263  `nb_total_images` mediumint(8),
    263264  PRIMARY KEY  (`user_id`)
    264265) TYPE=MyISAM;
Note: See TracChangeset for help on using the changeset viewer.