From a1f414324b740551f32c88c52da280fb8c59c858 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Wed, 30 Oct 2013 20:01:54 +0000 Subject: 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 --- admin/cat_perm.php | 46 ++++++++++------------------------------------ 1 file changed, 10 insertions(+), 36 deletions(-) (limited to 'admin') 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) + ); } // -- cgit v1.2.3