diff options
author | plegall <plg@piwigo.org> | 2004-12-04 12:10:17 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2004-12-04 12:10:17 +0000 |
commit | a383f3148cb7c9a23dadbdcd12ede4e1de274af5 (patch) | |
tree | a377701a2aa7da5c43a354ca52457b8a4f946985 /admin/include/functions.php | |
parent | 6fa03e0cca6855e041de004d49e0dd1b03bd644f (diff) |
- change "->" in a beautiful arrow :-) for categories level in admin
- single category management screen updated : commentable and uploadable
properties added, full directory displayed, status and visibility
properties update uses inheritance, user favorite elements check moved to
somewhere else : would be too long to calculate here for too many users
- new admin functions set_cat_visible and set_cat_status : visibility and
status updates can be done in cat_options and cat_modify
- language : differentiate "locked" (state) and "lock" (action)
git-svn-id: http://piwigo.org/svn/trunk@632 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include/functions.php')
-rw-r--r-- | admin/include/functions.php | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index 5b113d9ce..7a12be755 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -990,4 +990,106 @@ SELECT id,uppercats $fields = array('primary' => array('id'), 'update' => array('global_rank')); mass_updates(CATEGORIES_TABLE, $fields, $datas); } + +/** + * change the visible property on a set of categories + * + * @param array categories + * @param string value + * @return void + */ +function set_cat_visible($categories, $value) +{ + if (!in_array($value, array('true', 'false'))) + { + return false; + } + + // unlocking a category => all its parent categories become unlocked + if ($value == 'true') + { + $uppercats = array(); + $query = ' +SELECT uppercats + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', $categories).') +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $uppercats = array_merge($uppercats, + explode(',', $row['uppercats'])); + } + $uppercats = array_unique($uppercats); + + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET visible = \'true\' + WHERE id IN ('.implode(',', $uppercats).') +;'; + pwg_query($query); + } + // locking a category => all its child categories become locked + if ($value == 'false') + { + $subcats = get_subcat_ids($categories); + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET visible = \'false\' + WHERE id IN ('.implode(',', $subcats).') +;'; + pwg_query($query); + } +} + +/** + * change the status property on a set of categories : private or public + * + * @param array categories + * @param string value + * @return void + */ +function set_cat_status($categories, $value) +{ + if (!in_array($value, array('public', 'private'))) + { + return false; + } + + // make public a category => all its parent categories become public + if ($value == 'public') + { + $uppercats = array(); + $query = ' +SELECT uppercats + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', $categories).') +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $uppercats = array_merge($uppercats, + explode(',', $row['uppercats'])); + } + $uppercats = array_unique($uppercats); + + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET status = \'public\' + WHERE id IN ('.implode(',', $uppercats).') +;'; + pwg_query($query); + } + // make a category private => all its child categories become private + if ($value == 'private') + { + $subcats = get_subcat_ids($categories); + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET status = \'private\' + WHERE id IN ('.implode(',', $subcats).') +;'; + pwg_query($query); + } +} ?> |