aboutsummaryrefslogtreecommitdiffstats
path: root/admin/cat_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/cat_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 'admin/cat_perm.php')
-rw-r--r--admin/cat_perm.php45
1 files changed, 2 insertions, 43 deletions
diff --git a/admin/cat_perm.php b/admin/cat_perm.php
index dfcde962a..84a8d5784 100644
--- a/admin/cat_perm.php
+++ b/admin/cat_perm.php
@@ -143,50 +143,9 @@ DELETE
;';
pwg_query($query);
}
-else if (isset($_POST['grant_users_submit'])
- and isset($_POST['grant_users'])
- and count($_POST['grant_users']) > 0)
+else if (isset($_POST['grant_users_submit']))
{
- $query = '
-SELECT id
- FROM '.CATEGORIES_TABLE.'
- WHERE id IN ('.implode(',', get_uppercat_ids(array($page['cat']))).')
- AND status = \'private\'
-;';
- $private_uppercats = array_from_query($query, 'id');
-
- // We must not reinsert already existing lines in user_access table
- $granteds = array();
- foreach ($private_uppercats as $cat_id)
- {
- $granteds[$cat_id] = array();
- }
-
- $query = '
-SELECT user_id, cat_id
- FROM '.USER_ACCESS_TABLE.'
- WHERE cat_id IN ('.implode(',', $private_uppercats).')
- AND user_id IN ('.implode(',', $_POST['grant_users']).')
-;';
- $result = pwg_query($query);
- while ($row = pwg_db_fetch_assoc($result))
- {
- array_push($granteds[$row['cat_id']], $row['user_id']);
- }
-
- $inserts = array();
-
- foreach ($private_uppercats as $cat_id)
- {
- $user_ids = array_diff($_POST['grant_users'], $granteds[$cat_id]);
- foreach ($user_ids as $user_id)
- {
- array_push($inserts, array('user_id' => $user_id,
- 'cat_id' => $cat_id));
- }
- }
-
- mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $inserts);
+ add_permission_on_category($page['cat'], $_POST['grant_users']);
}
// +-----------------------------------------------------------------------+