Ignore:
Timestamp:
May 28, 2004, 11:56:07 PM (20 years ago)
Author:
z0rglub
Message:

table user_category dropped

File:
1 edited

Legend:

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

    r395 r423  
    2626// +-----------------------------------------------------------------------+
    2727
     28/**
     29 * Provides functions to handle categories.
     30 *
     31 *
     32 */
     33
     34/**
     35 * Is the category accessible to the connected user ?
     36 *
     37 * Note : if the user is not authorized to see this category, page creation
     38 * ends (exit command in this function)
     39 *
     40 * @param int category id to verify
     41 * @return void
     42 */
    2843function check_restrictions( $category_id )
    2944{
     
    3954}
    4055
    41 // the check_cat_id function check whether the $cat is a right parameter :
    42 //  - $cat is numeric and corresponds to a category in the database
    43 //  - $cat equals 'fav' (for favorites)
    44 //  - $cat equals 'search' (when the result of a search is displayed)
     56/**
     57 * Checks whether the argument is a right parameter category id
     58 *
     59 * The argument is a right parameter if corresponds to one of these :
     60 *
     61 *  - is numeric and corresponds to a category in the database
     62 *  - is equals 'fav' (for favorites)
     63 *  - is equals 'search' (when the result of a search is displayed)
     64 *  - is equals 'most_visited'
     65 *  - is equals 'best_rated'
     66 *  - is equals 'recent'
     67 *
     68 * The function fills the global var $page['cat'] and returns nothing
     69 *
     70 * @param mixed category id or special category name
     71 * @return void
     72 */
    4573function check_cat_id( $cat )
    4674{
     
    79107  global $page,$user;
    80108 
    81   $infos = array( 'name','id','uc.date_last','nb_images','dir','id_uppercat',
    82                   'rank','site_id','nb_sub_categories','uppercats');
     109  $infos = array( 'name','id','date_last','nb_images','dir','id_uppercat',
     110                  'rank','site_id','uppercats');
    83111 
    84112  $query = 'SELECT '.implode( ',', $infos );
    85   $query.= ' FROM '.CATEGORIES_TABLE.' AS c';
    86 //  $query.= ' ,'.PREFIX_TABLE.'user_category AS uc';
    87   $query.= ' INNER JOIN '.USER_CATEGORY_TABLE.' AS uc';
    88   $query.= ' ON c.id = uc.category_id';
    89   $query.= ' WHERE user_id = '.$user['id'];
     113  $query.= ' FROM '.CATEGORIES_TABLE;
     114  $query.= ' WHERE 1 = 1'; // stupid but permit using AND after it !
    90115  if ( !$user['expand'] )
    91116  {
     
    102127    $query.= '('.$user['forbidden_categories'].')';
    103128  }
    104 //  $query.= ' AND c.id = uc.category_id';
    105129  $query.= ' ORDER BY id_uppercat ASC, rank ASC';
    106130  $query.= ';';
     
    114138      if ( $info == 'uc.date_last')
    115139      {
    116             if (empty($row['date_last']))
    117                 {
    118                   $category['date_last']= 0;
    119                 }
    120                 else
    121                 {
     140        if ( empty( $row['date_last'] ) )
     141        {
     142          $category['date_last'] = 0;
     143        }
     144        else
     145        {
    122146          list($year,$month,$day) = explode( '-', $row['date_last'] );
    123147          $category['date_last'] = mktime(0,0,0,$month,$day,$year);
    124                 }
     148        }
    125149      }
    126150      else if ( isset( $row[$info] ) ) $category[$info] = $row[$info];
     
    234258}
    235259
    236 // variables :
    237 // $cat['comment']
    238 // $cat['dir']
    239 // $cat['dir']
    240 // $cat['name'] is an array :
    241 //      - $cat['name'][0] is the lowest cat name
    242 //      and
    243 //      - $cat['name'][n] is the most uppercat name findable
    244 // $cat['nb_images']
    245 // $cat['id_uppercat']
    246 // $cat['site_id']
     260/**
     261 * Retrieve informations about a category in the database
     262 *
     263 * Returns an array with following keys :
     264 *
     265 *  - comment
     266 *  - dir : directory, might be empty for virtual categories
     267 *  - name : an array with indexes from 0 (lowest cat name) to n (most
     268 *           uppercat name findable)
     269 *  - nb_images
     270 *  - id_uppercat
     271 *  - site_id
     272 *  -
     273 *
     274 * @param int category id
     275 * @return array
     276 */
    247277function get_cat_info( $id )
    248278{
Note: See TracChangeset for help on using the changeset viewer.