diff options
Diffstat (limited to 'admin/cat_perm.php')
-rw-r--r-- | admin/cat_perm.php | 61 |
1 files changed, 20 insertions, 41 deletions
diff --git a/admin/cat_perm.php b/admin/cat_perm.php index ad9ff1a05..71653d9ec 100644 --- a/admin/cat_perm.php +++ b/admin/cat_perm.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | // +-----------------------------------------------------------------------+ @@ -98,7 +98,7 @@ DELETE { $cat_ids = array_merge($cat_ids, get_subcat_ids(array($page['cat']))); } - + $query = ' SELECT id FROM '.CATEGORIES_TABLE.' @@ -106,46 +106,25 @@ SELECT id AND status = \'private\' ;'; $private_cats = array_from_query($query, 'id'); - - // We must not reinsert already existing lines in group_access table - $granteds = array(); - foreach ($private_cats as $cat_id) - { - $granteds[$cat_id] = array(); - } - - $query = ' -SELECT - group_id, - cat_id - FROM '.GROUP_ACCESS_TABLE.' - WHERE cat_id IN ('.implode(',', $private_cats).') - AND group_id IN ('.implode(',', $grant_groups).') -;'; - $result = pwg_query($query); - while ($row = pwg_db_fetch_assoc($result)) - { - array_push($granteds[$row['cat_id']], $row['group_id']); - } - - $inserts = array(); + $inserts = array(); foreach ($private_cats as $cat_id) { - $group_ids = array_diff($grant_groups, $granteds[$cat_id]); - foreach ($group_ids as $group_id) + foreach ($grant_groups as $group_id) { - array_push( - $inserts, - array( - 'group_id' => $group_id, - 'cat_id' => $cat_id - ) + $inserts[] = array( + 'group_id' => $group_id, + 'cat_id' => $cat_id ); } } - - mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $inserts); + + mass_inserts( + GROUP_ACCESS_TABLE, + array('group_id','cat_id'), + $inserts, + array('ignore'=>true) + ); } // @@ -190,7 +169,7 @@ DELETE } } - array_push($page['infos'], l10n('Album updated successfully')); + $page['infos'][] = l10n('Album updated successfully'); } // +-----------------------------------------------------------------------+ @@ -272,11 +251,11 @@ SELECT user_id, group_id $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { - if (!isset($granted_groups[$row['group_id']])) + if (!isset($granted_groups[ $row['group_id'] ])) { - $granted_groups[$row['group_id']] = array(); + $granted_groups[ $row['group_id'] ] = array(); } - array_push($granted_groups[$row['group_id']], $row['user_id']); + $granted_groups[ $row['group_id'] ][] = $row['user_id']; } $user_granted_by_group_ids = array(); @@ -302,7 +281,7 @@ SELECT user_id, group_id { if (in_array($user_id, $user_granted_indirect_ids)) { - array_push($group_usernames, $users[$user_id]); + $group_usernames[] = $users[$user_id]; } } @@ -319,7 +298,7 @@ SELECT user_id, group_id // +-----------------------------------------------------------------------+ // | sending html code | // +-----------------------------------------------------------------------+ -$template->assign(array('PWG_TOKEN' => get_pwg_token())); +$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'INHERIT' => $conf['inheritance_by_default'])); $template->assign_var_from_handle('ADMIN_CONTENT', 'cat_perm'); ?> |