diff options
author | plegall <plg@piwigo.org> | 2004-12-27 14:30:49 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2004-12-27 14:30:49 +0000 |
commit | 7ba15740434b476e8aef0253919f19ba37e07dc7 (patch) | |
tree | 4bba6d6d3e5490189fdc79dee1a51ba6c2e4cb31 /admin/cat_list.php | |
parent | 4c8d18de5b904eddaa900deca20c7d6f7ac928d1 (diff) |
- admin/update : filesystem synchronization process completely
rewritten. How to speed up sync ? by avoiding recursivity !
- admin/update : option to display verbose information details
- admin/update : option to simulate only. No database insert, delete or
update will be made
- bug fixed : in admin/cat_list, if you delete a virtual category, you may
create a gap in the rank list. This gap will generate errors when trying
to move a category on this gap. Fixed by calling ordering and
update_global_rank at category deletion.
- admin/cat_list, only one query to insert a new virtual category (no need
of a second query to update uppercats and global_rank)
- for a given category, even if empty, the representing element must not be
the one of a forbidden category for the current user
- generation time optionnaly displayed on the bottom of each page becomes
more price : number of SQL queries and SQL time added.
git-svn-id: http://piwigo.org/svn/trunk@659 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/cat_list.php')
-rw-r--r-- | admin/cat_list.php | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/admin/cat_list.php b/admin/cat_list.php index 2f7834730..341577a3d 100644 --- a/admin/cat_list.php +++ b/admin/cat_list.php @@ -43,10 +43,10 @@ $navigation = $lang['home']; // request to delete a virtual category if (isset($_GET['delete']) and is_numeric($_GET['delete'])) { - $to_delete_categories = array(); - array_push($to_delete_categories,$_GET['delete']); - delete_categories($to_delete_categories); + delete_categories(array($_GET['delete'])); array_push($infos, $lang['cat_virtual_deleted']); + ordering(); + update_global_rank(); } // request to add a virtual category else if (isset($_POST['submit'])) @@ -76,15 +76,27 @@ SELECT id,uppercats,global_rank,visible,status 'global_rank' => $row['global_rank']); } + // what will be the inserted id ? + $query = ' +SELECT MAX(id)+1 + FROM '.CATEGORIES_TABLE.' +;'; + list($next_id) = mysql_fetch_array(pwg_query($query)); + $insert = array(); + $insert{'id'} = $next_id++; $insert{'name'} = $_POST['virtual_name']; $insert{'rank'} = $_POST['rank']; $insert{'commentable'} = $conf['newcat_default_commentable']; - $insert{'uploadable'} = $conf['newcat_default_uploadable']; + + // a virtual category can't be uploadable + $insert{'uploadable'} = 'false'; if (isset($parent)) { $insert{'id_uppercat'} = $parent{'id'}; + $insert{'uppercats'} = $parent{'uppercats'}.','.$insert{'id'}; + $insert{'global_rank'} = $parent{'global_rank'}.'.'.$insert{'rank'}; // at creation, must a category be visible or not ? Warning : if // the parent category is invisible, the category is automatically // create invisible. (invisible = locked) @@ -112,40 +124,18 @@ SELECT id,uppercats,global_rank,visible,status { $insert{'visible'} = $conf['newcat_default_visible']; $insert{'status'} = $conf['newcat_default_status']; + $insert{'uppercats'} = $insert{'id'}; + $insert{'global_rank'} = $insert{'rank'}; } $inserts = array($insert); // we have then to add the virtual category - $dbfields = array('site_id','name','id_uppercat','rank','commentable', - 'uploadable','visible','status'); + $dbfields = array('id','site_id','name','id_uppercat','rank', + 'commentable','uploadable','visible','status', + 'uppercats','global_rank'); mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts); - - // And last we update the uppercats - $query = ' -SELECT MAX(id) - FROM '.CATEGORIES_TABLE.' -;'; - $my_id = array_pop(mysql_fetch_array(pwg_query($query))); - $query = ' -UPDATE '.CATEGORIES_TABLE; - if (isset($parent)) - { - $query.= " - SET uppercats = CONCAT('".$parent['uppercats']."',',',id) - , global_rank = CONCAT('".$parent['global_rank']."','.',rank)"; - } - else - { - $query.= ' - SET uppercats = id - , global_rank = id'; - } - $query.= ' - WHERE id = '.$my_id.' -;'; - pwg_query($query); array_push($infos, $lang['cat_virtual_added']); } } |