aboutsummaryrefslogtreecommitdiffstats
path: root/admin/site_update.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/site_update.php')
-rw-r--r--admin/site_update.php89
1 files changed, 88 insertions, 1 deletions
diff --git a/admin/site_update.php b/admin/site_update.php
index c705d3690..687061449 100644
--- a/admin/site_update.php
+++ b/admin/site_update.php
@@ -266,6 +266,7 @@ SELECT id_uppercat, MAX(rank)+1 AS next_rank
$db_categories[$insert{'id'}] =
array(
'id' => $insert['id'],
+ 'parent' => $parent,
'status' => $insert['status'],
'visible' => $insert['visible'],
'uppercats' => $insert['uppercats'],
@@ -298,11 +299,97 @@ SELECT id_uppercat, MAX(rank)+1 AS next_rank
// add default permissions to categories
$category_ids = array();
+ $category_up = array();
foreach ($inserts as $category)
{
$category_ids[] = $category['id'];
+ $category_up[] = $category['id_uppercat'];
+ }
+ $category_up=implode(',',array_unique($category_up));
+ if ($conf['inheritance_by_default'])
+ {
+ $query = '
+ SELECT *
+ FROM '.GROUP_ACCESS_TABLE.'
+ WHERE cat_id IN ('.$category_up.')
+ ;';
+ $result = pwg_query($query);
+ $granted_grps = array();
+ while ($row = pwg_db_fetch_assoc($result))
+ {
+ if (is_null($granted_grps[$row['cat_id']]))
+ {
+ $granted_grps[$row['cat_id']]=array();
+ }
+ array_push(
+ $granted_grps,
+ array(
+ $row['cat_id'] => array_push($granted_grps[$row['cat_id']],$row['group_id'])
+ )
+ );
+ }
+ $insert_granted_grps=array();
+ foreach ($category_ids as $ids)
+ {
+ $parent=$db_categories[$ids]['parent'];
+ foreach ($granted_grps[$parent] as $granted_grp)
+ {
+ array_push(
+ $insert_granted_grps,
+ array(
+ 'group_id' => $granted_grp,
+ 'cat_id' => $ids
+ )
+ );
+
+ }
+ }
+
+ mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $insert_granted_grps);
+
+ $query = '
+ SELECT *
+ FROM '.USER_ACCESS_TABLE.'
+ WHERE cat_id IN ('.$category_up.')
+ ;';
+ $result = pwg_query($query);
+ $granted_users = array();
+ while ($row = pwg_db_fetch_assoc($result))
+ {
+ if (is_null($granted_users[$row['cat_id']]))
+ {
+ $granted_users[$row['cat_id']]=array();
+ }
+ array_push(
+ $granted_users,
+ array(
+ $row['cat_id'] => array_push($granted_users[$row['cat_id']],$row['user_id'])
+ )
+ );
+ }
+ $insert_granted_users=array();
+ foreach ($category_ids as $ids)
+ {
+ $parent=$db_categories[$ids]['parent'];
+ foreach ($granted_users[$parent] as $granted_user)
+ {
+ array_push(
+ $insert_granted_users,
+ array(
+ 'user_id' => $granted_user,
+ 'cat_id' => $ids
+ )
+ );
+
+ }
+ }
+ mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert_granted_users);
+
+ }
+ else
+ {
+ add_permission_on_category($category_ids, get_admins());
}
- add_permission_on_category($category_ids, get_admins());
}
$counts['new_categories'] = count($inserts);