aboutsummaryrefslogtreecommitdiffstats
path: root/admin/cat_perm.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-10-30 20:01:54 +0000
committermistic100 <mistic@piwigo.org>2013-10-30 20:01:54 +0000
commita1f414324b740551f32c88c52da280fb8c59c858 (patch)
treece144c4d769573c194131226a6a9c58ad34a4afd /admin/cat_perm.php
parentdf6718f3f868b226328ff292f2b5d13f054850ea (diff)
remove hardly understandable code with usage of INGORE keyword in SQL query
git-svn-id: http://piwigo.org/svn/trunk@25243 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/cat_perm.php')
-rw-r--r--admin/cat_perm.php46
1 files changed, 10 insertions, 36 deletions
diff --git a/admin/cat_perm.php b/admin/cat_perm.php
index 1c3904016..d8f3694e7 100644
--- a/admin/cat_perm.php
+++ b/admin/cat_perm.php
@@ -98,42 +98,11 @@ DELETE
{
$cat_ids = array_merge($cat_ids, get_subcat_ids(array($page['cat'])));
}
-
- $query = '
-SELECT id
- FROM '.CATEGORIES_TABLE.'
- WHERE id IN ('.implode(',', $cat_ids).')
- 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))
- {
- $granteds[ $row['cat_id'] ][] = $row['group_id'];
- }
-
- $inserts = array();
- foreach ($private_cats as $cat_id)
+ $inserts = array();
+ foreach ($cat_ids as $cat_id)
{
- $group_ids = array_diff($grant_groups, $granteds[$cat_id]);
- foreach ($group_ids as $group_id)
+ foreach ($grant_groups as $group_id)
{
$inserts[] = array(
'group_id' => $group_id,
@@ -141,8 +110,13 @@ SELECT
);
}
}
-
- 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)
+ );
}
//