aboutsummaryrefslogtreecommitdiffstats
path: root/admin/user_perm.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2011-07-13 14:04:02 +0000
committerplegall <plg@piwigo.org>2011-07-13 14:04:02 +0000
commit7bd96c6da20c4bfc0a7a581b757c594527cf0321 (patch)
tree98e4c99f8c62732a78cb3aecc7987ce4ee8fd78a /admin/user_perm.php
parent424eed990e7b72e9e6453ccb3698a9bdcfd6195d (diff)
simplify code by using new function add_permission_on_category()
git-svn-id: http://piwigo.org/svn/trunk@11729 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/user_perm.php46
1 files changed, 2 insertions, 44 deletions
diff --git a/admin/user_perm.php b/admin/user_perm.php
index 1625942b8..a73f31875 100644
--- a/admin/user_perm.php
+++ b/admin/user_perm.php
@@ -64,51 +64,9 @@ DELETE FROM '.USER_ACCESS_TABLE.'
;';
pwg_query($query);
}
-else if (isset($_POST['trueify'])
- and isset($_POST['cat_false'])
- and count($_POST['cat_false']) > 0)
+else if (isset($_POST['trueify']))
{
- $uppercats = get_uppercat_ids($_POST['cat_false']);
- $private_uppercats = array();
-
- $query = '
-SELECT id
- FROM '.CATEGORIES_TABLE.'
- WHERE id IN ('.implode(',', $uppercats).')
- AND status = \'private\'
-;';
- $result = pwg_query($query);
- while ($row = pwg_db_fetch_assoc($result))
- {
- array_push($private_uppercats, $row['id']);
- }
-
- // retrying to authorize a category which is already authorized may cause
- // an error (in SQL statement), so we need to know which categories are
- // accesible
- $authorized_ids = array();
-
- $query = '
-SELECT cat_id
- FROM '.USER_ACCESS_TABLE.'
- WHERE user_id = '.$page['user'].'
-;';
- $result = pwg_query($query);
-
- while ($row = pwg_db_fetch_assoc($result))
- {
- array_push($authorized_ids, $row['cat_id']);
- }
-
- $inserts = array();
- $to_autorize_ids = array_diff($private_uppercats, $authorized_ids);
- foreach ($to_autorize_ids as $to_autorize_id)
- {
- array_push($inserts, array('user_id' => $page['user'],
- 'cat_id' => $to_autorize_id));
- }
-
- mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $inserts);
+ add_permission_on_category($_POST['cat_false'], $page['user']);
}
// +-----------------------------------------------------------------------+