aboutsummaryrefslogtreecommitdiffstats
path: root/admin/update.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2004-11-23 22:31:24 +0000
committerplegall <plg@piwigo.org>2004-11-23 22:31:24 +0000
commitf0fcd1eedc26c0d36b6b0556b9f53124ba9f889f (patch)
tree0502dbd43c04199ec2ba45913985fee86793491a /admin/update.php
parent5197779bba12db45508becc910d5886d77f3675d (diff)
- global categories' options : instead of N horizontal tabs on a single
page, N options in the left menu (but the same backend) - categories.global_rank : new calculated field. It gives a global rank of the category among all others (updated during ordering) - category.php page : menu is generated faster thanks to categories.global_rank, recursivity becomes useless :-) - new function to display select box with a set of categories : display_select_cat_wrapper - cat_options : instead of using 1 multiselect for true/false items, using 1 multiselect for true, and another one for false. The form provides buttons with arrows to switch categories from one multiselect to another - deletion of obsolete function display_categories (working with the old template system) - deletion of obsolete functions get_user_plain_structure, create_user_structure, get_user_subcat_ids, update_structure, count_images : useless thanks to global_rank git-svn-id: http://piwigo.org/svn/trunk@614 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/update.php55
1 files changed, 38 insertions, 17 deletions
diff --git a/admin/update.php b/admin/update.php
index 10813349e..ac364e465 100644
--- a/admin/update.php
+++ b/admin/update.php
@@ -37,12 +37,13 @@ define('CURRENT_DATE', date('Y-m-d'));
// +-----------------------------------------------------------------------+
/**
- * order categories (update categories.rank database field)
+ * order categories (update categories.rank and global_rank database fields)
*
* the purpose of this function is to give a rank for all categories
* (insides its sub-category), even the newer that have none at te
* beginning. For this, ordering function selects all categories ordered by
- * rank ASC then name ASC for each uppercat.
+ * rank ASC then name ASC for each uppercat. It also updates the global rank
+ * which is able to order any two categorie in the whole tree
*
* @returns void
*/
@@ -71,6 +72,35 @@ UPDATE '.CATEGORIES_TABLE.'
;';
pwg_query($query);
}
+ // global rank update
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET global_rank = rank
+ WHERE id_uppercat IS NULL
+;';
+ pwg_query($query);
+
+ $query = '
+SELECT DISTINCT(id_uppercat)
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id_uppercat IS NOT NULL
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ $query = '
+SELECT global_rank
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id = '.$row['id_uppercat'].'
+;';
+ list($uppercat_global_rank) = mysql_fetch_array(pwg_query($query));
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET global_rank = CONCAT(\''.$uppercat_global_rank.'\', \'.\', rank)
+ WHERE id_uppercat = '.$row['id_uppercat'].'
+;';
+ pwg_query($query);
+ }
}
function insert_local_category($id_uppercat)
@@ -571,23 +601,14 @@ if (!isset($_POST['submit']))
$template->assign_block_vars('introduction', array());
$query = '
-SELECT id
+SELECT id,name,uppercats,global_rank
FROM '.CATEGORIES_TABLE.'
- WHERE site_id != 1
+ WHERE site_id = 1
;';
- $result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
- {
- array_push($user['restrictions'], $row['id']);
- }
- $user['forbidden_categories'] = implode(',', $user['restrictions']);
- $user['expand'] = true;
- $structure = create_user_structure('');
- display_select_categories($structure,
- '&nbsp;',
- array(),
- 'introduction.category_option',
- array());
+ display_select_cat_wrapper($query,
+ array(),
+ 'introduction.category_option',
+ false);
}
// +-----------------------------------------------------------------------+
// | synchronize files |