diff options
author | z0rglub <z0rglub@piwigo.org> | 2004-05-28 21:56:07 +0000 |
---|---|---|
committer | z0rglub <z0rglub@piwigo.org> | 2004-05-28 21:56:07 +0000 |
commit | 5643049f239f6472d6019a2f3bce029ed1ef825d (patch) | |
tree | 9a74e101dd6ab7edb925959583f1de57211b4ffb /include | |
parent | 7e465041bfdf14cbbb684bf11f597e3bc8e78980 (diff) |
table user_category dropped
git-svn-id: http://piwigo.org/svn/trunk@423 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/constants.php | 1 | ||||
-rw-r--r-- | include/functions_category.inc.php | 90 | ||||
-rw-r--r-- | include/functions_user.inc.php | 17 |
3 files changed, 60 insertions, 48 deletions
diff --git a/include/constants.php b/include/constants.php index ddc6a639d..fb647d8b3 100644 --- a/include/constants.php +++ b/include/constants.php @@ -51,7 +51,6 @@ define('IMAGES_TABLE', $table_prefix.'images'); define('SESSIONS_TABLE', $table_prefix.'sessions'); define('SITES_TABLE', $table_prefix.'sites'); define('USER_ACCESS_TABLE', $table_prefix.'user_access'); -define('USER_CATEGORY_TABLE', $table_prefix.'user_category'); define('USER_GROUP_TABLE', $table_prefix.'user_group'); define('USERS_TABLE', $table_prefix.'users'); define('WAITING_TABLE', $table_prefix.'waiting'); diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 1a153a08d..fbeff41e9 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -25,6 +25,21 @@ // | USA. | // +-----------------------------------------------------------------------+ +/** + * Provides functions to handle categories. + * + * + */ + +/** + * Is the category accessible to the connected user ? + * + * Note : if the user is not authorized to see this category, page creation + * ends (exit command in this function) + * + * @param int category id to verify + * @return void + */ function check_restrictions( $category_id ) { global $user,$lang; @@ -38,10 +53,23 @@ function check_restrictions( $category_id ) } } -// the check_cat_id function check whether the $cat is a right parameter : -// - $cat is numeric and corresponds to a category in the database -// - $cat equals 'fav' (for favorites) -// - $cat equals 'search' (when the result of a search is displayed) +/** + * Checks whether the argument is a right parameter category id + * + * The argument is a right parameter if corresponds to one of these : + * + * - is numeric and corresponds to a category in the database + * - is equals 'fav' (for favorites) + * - is equals 'search' (when the result of a search is displayed) + * - is equals 'most_visited' + * - is equals 'best_rated' + * - is equals 'recent' + * + * The function fills the global var $page['cat'] and returns nothing + * + * @param mixed category id or special category name + * @return void + */ function check_cat_id( $cat ) { global $page; @@ -78,15 +106,12 @@ function get_user_plain_structure() { global $page,$user; - $infos = array( 'name','id','uc.date_last','nb_images','dir','id_uppercat', - 'rank','site_id','nb_sub_categories','uppercats'); + $infos = array( 'name','id','date_last','nb_images','dir','id_uppercat', + 'rank','site_id','uppercats'); $query = 'SELECT '.implode( ',', $infos ); - $query.= ' FROM '.CATEGORIES_TABLE.' AS c'; -// $query.= ' ,'.PREFIX_TABLE.'user_category AS uc'; - $query.= ' INNER JOIN '.USER_CATEGORY_TABLE.' AS uc'; - $query.= ' ON c.id = uc.category_id'; - $query.= ' WHERE user_id = '.$user['id']; + $query.= ' FROM '.CATEGORIES_TABLE; + $query.= ' WHERE 1 = 1'; // stupid but permit using AND after it ! if ( !$user['expand'] ) { $query.= ' AND (id_uppercat is NULL'; @@ -101,7 +126,6 @@ function get_user_plain_structure() $query.= ' AND id NOT IN '; $query.= '('.$user['forbidden_categories'].')'; } -// $query.= ' AND c.id = uc.category_id'; $query.= ' ORDER BY id_uppercat ASC, rank ASC'; $query.= ';'; @@ -113,15 +137,15 @@ function get_user_plain_structure() foreach ( $infos as $info ) { if ( $info == 'uc.date_last') { - if (empty($row['date_last'])) - { - $category['date_last']= 0; - } - else - { + if ( empty( $row['date_last'] ) ) + { + $category['date_last'] = 0; + } + else + { list($year,$month,$day) = explode( '-', $row['date_last'] ); $category['date_last'] = mktime(0,0,0,$month,$day,$year); - } + } } else if ( isset( $row[$info] ) ) $category[$info] = $row[$info]; else $category[$info] = ''; @@ -233,17 +257,23 @@ function count_user_total_images() return $row['total']; } -// variables : -// $cat['comment'] -// $cat['dir'] -// $cat['dir'] -// $cat['name'] is an array : -// - $cat['name'][0] is the lowest cat name -// and -// - $cat['name'][n] is the most uppercat name findable -// $cat['nb_images'] -// $cat['id_uppercat'] -// $cat['site_id'] +/** + * Retrieve informations about a category in the database + * + * Returns an array with following keys : + * + * - comment + * - dir : directory, might be empty for virtual categories + * - name : an array with indexes from 0 (lowest cat name) to n (most + * uppercat name findable) + * - nb_images + * - id_uppercat + * - site_id + * - + * + * @param int category id + * @return array + */ function get_cat_info( $id ) { $infos = array( 'nb_images','id_uppercat','comment','site_id','galleries_url' diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 400e104c6..983d7e82e 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -153,23 +153,6 @@ function register_user( $login, $password, $password_conf, $query.= ';'; mysql_query ( $query ); } - // 6. has the same categories informations than guest - $query = 'SELECT category_id,date_last,nb_sub_categories'; - $query.= ' FROM '.PREFIX_TABLE.'user_category AS uc'; - $query.= ', '.PREFIX_TABLE.'users AS u'; - $query.= " WHERE u.username = 'guest'"; - $query.= ' AND uc.user_id = u.id'; - $query.= ';'; - $result = mysql_query( $query ); - while( $row = mysql_fetch_array( $result ) ) - { - $query = 'INSERT INTO '.PREFIX_TABLE.'user_category'; - $query.= ' (user_id,category_id,date_last,nb_sub_categories) VALUES'; - $query.= ' ('.$user_id.','.$row['category_id']; - $query.= ",'".$row['date_last']."',".$row['nb_sub_categories'].')'; - $query.= ';'; - mysql_query ( $query ); - } } return $error; } |