aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-05-28 21:56:07 +0000
committerz0rglub <z0rglub@piwigo.org>2004-05-28 21:56:07 +0000
commit5643049f239f6472d6019a2f3bce029ed1ef825d (patch)
tree9a74e101dd6ab7edb925959583f1de57211b4ffb /admin
parent7e465041bfdf14cbbb684bf11f597e3bc8e78980 (diff)
table user_category dropped
git-svn-id: http://piwigo.org/svn/trunk@423 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/include/functions.php173
-rw-r--r--admin/update.php5
2 files changed, 0 insertions, 178 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 84b81e66f..7bc3e52eb 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -275,12 +275,6 @@ function delete_user( $user_id )
$query.= ';';
mysql_query( $query );
- // destruction of the categories informations linked with the user
- $query = 'DELETE FROM '.PREFIX_TABLE.'user_category';
- $query.= ' WHERE user_id = '.$user_id;
- $query.= ';';
- mysql_query( $query );
-
// destruction of the user
$query = 'DELETE FROM '.USERS_TABLE;
$query.= ' WHERE id = '.$user_id;
@@ -631,61 +625,6 @@ function get_all_subcats_ids( $category_id )
}
/**
- * prepares the query to update the table user_category
- *
- * Prepares the query (global variable $values) to update table
- * user_category : for a couple (user,category) the number of sub-categories
- * and the last date of the category (all sub-categories taken into
- * account). It also calls function update_uppercats for each category. The
- * function is recursive.
- *
- * @param array $categories
- * @return void
- */
-function update_user_category( $categories )
-{
- global $page,$user_restrictions,$value_num,$values;
-
- foreach ( $categories as $category ) {
- // recursive call
- update_user_category( $category['subcats'] );
- // 1. update the table user_category
- foreach ( $user_restrictions as $user_id => $restrictions ) {
- // if the category is forbidden to this user, go to next user
- if ( in_array( $category['id'], $restrictions ) ) continue;
-
- // how many sub_categories for this user ?
- $user_subcats = array_diff(
- $page['plain_structure'][$category['id']]['direct_subcats_ids'],
- $restrictions );
- $user_nb_subcats = count( array_unique( $user_subcats ) );
- // last date of the category
- $user_all_subcats = array_unique( array_diff(
- $page['plain_structure'][$category['id']]['all_subcats_ids'],
- $restrictions ) );
-
- $query = 'SELECT MAX(date_last) AS last_date';
- $query.= ' FROM '.CATEGORIES_TABLE;
- $query.= ' WHERE id IN ('.$category['id'];
- if ( count( $user_all_subcats ) > 0 )
- $query.= ','.implode( ',', $user_all_subcats );
- $query.= ')';
- $query.= ';';
- $row = mysql_fetch_array( mysql_query( $query ) );
-
- // insert a new line in database
- if ( $value_num++ > 0 ) $values.= ', ';
- else $values.= ' ';
- $values.= '('.$user_id.",".$category['id'];
- if ( isset( $row['last_date'] ) ) $values.= ",'".$row['last_date']."'";
- else $values.= ',NULL';
- $values.= ','.$user_nb_subcats.')';
- }
- update_uppercats( $category['id'] );
- }
-}
-
-/**
* updates the column categories.uppercats
*
* @param int $category_id
@@ -798,118 +737,6 @@ function get_user_restrictions( $user_id, $user_status,
}
/**
- * finalizes operation for user_category table update
- *
- * This function is called by synchronization_*. It creates the
- * $page['plain_structure'] and $page['structure'], get the SQL query to
- * update user_category, clean user_category, and finally update the
- * table. The users updates depends on the global array $user_restrictions.
- *
- * @return void
- */
-function synchronize()
-{
- global $user_restrictions,$page,$values;
-
- update_user_category( $page['structure'] );
-
- // cleaning user_category table for users to update
- foreach( $user_restrictions as $user_id => $restrictions ) {
- $query = 'DELETE';
- $query.= ' FROM '.USER_CATEGORY_TABLE;
- $query.= ' WHERE user_id = '.$user_id;
- $query.= ';';
- mysql_query( $query );
- }
-
- $query = 'INSERT INTO '.USER_CATEGORY_TABLE;
- $query.= ' (user_id,category_id,date_last,nb_sub_categories) VALUES ';
- $query.= $values;
- $query.= ';';
- mysql_query( $query );
-}
-
-/**
- * synchronizes all users calculated informations
- *
- * fills global array $user_restrictions with all users and related
- * restrictions before calling synchronize.
- *
- * @return void
- */
-function synchronize_all_users()
-{
- global $user_restrictions,$page;
-
- $page['plain_structure'] = get_plain_structure();
- $page['structure'] = create_structure( '' );
-
- $user_restrictions = array();
-
- $query = 'SELECT id';
- $query.= ' FROM '.USERS_TABLE;
- $query.= ';';
- $result = mysql_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
- {
- $user_restrictions[$row['id']] = update_user_restrictions( $row['id'] );
- }
- synchronize();
-}
-
-/**
- * synchronizes 1 user calculated informations
- *
- * fills global array $user_restrictions with the user id and its related
- * restrictions before calling synchronize.
- *
- * @param int $user_id
- * @return void
- */
-function synchronize_user( $user_id )
-{
- global $user_restrictions,$page;
-
- $page['plain_structure'] = get_plain_structure();
- $page['structure'] = create_structure( '' );
-
- $user_restrictions = array();
- $user_restrictions[$user_id] = update_user_restrictions( $user_id );
- synchronize();
-}
-
-/**
- * synchronizes all users (belonging to the group) calculated informations
- *
- * fills global array $user_restrictions with all users and related
- * restrictions before calling synchronize.
- *
- * @return void
- */
-function synchronize_group( $group_id )
-{
- global $user_restrictions,$page;
-
- $page['plain_structure'] = get_plain_structure();
- $page['structure'] = create_structure( '' );
-
- $user_restrictions = array();
-
- $query = 'SELECT id';
- $query.= ' FROM '.USERS_TABLE;
- $query.= ', '.USER_GROUP_TABLE;
- $query.= ' WHERE group_id = '.$group_id;
- $query.= ' AND id = user_id';
- $query.= ';';
- $result = mysql_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
- {
- $user_restrictions[$row['id']] = update_user_restrictions( $row['id'] );
- }
- synchronize();
-}
-
-/**
* updates the calculated data users.forbidden_categories, it includes
* sub-categories of the direct forbidden categories
*
diff --git a/admin/update.php b/admin/update.php
index db8790bdf..e77dd2c72 100644
--- a/admin/update.php
+++ b/admin/update.php
@@ -763,11 +763,6 @@ if ( isset( $_GET['update'] )
ordering('NULL');
$end = get_moment();
echo get_elapsed_time( $start, $end ).' for update_category( all )<br />';
-
- $start = get_moment();
- synchronize_all_users();
- $end = get_moment();
- echo get_elapsed_time( $start, $end ).' for synchronize_all_users<br />';
}
//----------------------------------------------------------- sending html code
$template->assign_var_from_handle('ADMIN_CONTENT', 'update');