From a383f3148cb7c9a23dadbdcd12ede4e1de274af5 Mon Sep 17 00:00:00 2001 From: plegall Date: Sat, 4 Dec 2004 12:10:17 +0000 Subject: - 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 --- admin/include/functions.php | 102 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'admin/include/functions.php') 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); + } +} ?> -- cgit v1.2.3