mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-28 04:09:56 +03:00
mistakenly removed status check in previous commit + same thing for users
git-svn-id: http://piwigo.org/svn/trunk@25244 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
a1f414324b
commit
c64eb85452
2 changed files with 26 additions and 36 deletions
|
@ -99,8 +99,16 @@ DELETE
|
||||||
$cat_ids = array_merge($cat_ids, get_subcat_ids(array($page['cat'])));
|
$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');
|
||||||
|
|
||||||
$inserts = array();
|
$inserts = array();
|
||||||
foreach ($cat_ids as $cat_id)
|
foreach ($private_cats as $cat_id)
|
||||||
{
|
{
|
||||||
foreach ($grant_groups as $group_id)
|
foreach ($grant_groups as $group_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2255,12 +2255,16 @@ function add_permission_on_category($category_ids, $user_ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure categories are private and select uppercats or subcats
|
// make sure categories are private and select uppercats or subcats
|
||||||
$cat_ids = (isset($_POST['apply_on_sub'])) ? implode(',', get_subcat_ids($category_ids)).",".implode(',', get_uppercat_ids($category_ids)) : implode(',', get_uppercat_ids($category_ids));
|
$cat_ids = get_uppercat_ids($category_ids);
|
||||||
|
if (isset($_POST['apply_on_sub']))
|
||||||
|
{
|
||||||
|
$cat_ids = array_merge($cat_ids, get_subcat_ids($category_ids));
|
||||||
|
}
|
||||||
|
|
||||||
$query = '
|
$query = '
|
||||||
SELECT
|
SELECT id
|
||||||
id
|
|
||||||
FROM '.CATEGORIES_TABLE.'
|
FROM '.CATEGORIES_TABLE.'
|
||||||
WHERE id IN ('.$cat_ids.')
|
WHERE id IN ('.implode(',', $cat_ids).')
|
||||||
AND status = \'private\'
|
AND status = \'private\'
|
||||||
;';
|
;';
|
||||||
$private_cats = array_from_query($query, 'id');
|
$private_cats = array_from_query($query, 'id');
|
||||||
|
@ -2270,34 +2274,10 @@ SELECT
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We must not reinsert already existing lines in user_access table
|
|
||||||
$granteds = array();
|
|
||||||
foreach ($private_cats as $cat_id)
|
|
||||||
{
|
|
||||||
$granteds[$cat_id] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = '
|
|
||||||
SELECT
|
|
||||||
user_id,
|
|
||||||
cat_id
|
|
||||||
FROM '.USER_ACCESS_TABLE.'
|
|
||||||
WHERE cat_id IN ('.implode(',', $private_cats).')
|
|
||||||
AND user_id IN ('.implode(',', $user_ids).')
|
|
||||||
;';
|
|
||||||
$result = pwg_query($query);
|
|
||||||
while ($row = pwg_db_fetch_assoc($result))
|
|
||||||
{
|
|
||||||
$granteds[ $row['cat_id'] ][] = $row['user_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$inserts = array();
|
$inserts = array();
|
||||||
|
|
||||||
foreach ($private_cats as $cat_id)
|
foreach ($private_cats as $cat_id)
|
||||||
{
|
{
|
||||||
$grant_to_users = array_diff($user_ids, $granteds[$cat_id]);
|
foreach ($user_ids as $user_id)
|
||||||
|
|
||||||
foreach ($grant_to_users as $user_id)
|
|
||||||
{
|
{
|
||||||
$inserts[] = array(
|
$inserts[] = array(
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
|
@ -2306,10 +2286,12 @@ SELECT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($inserts) > 0)
|
mass_inserts(
|
||||||
{
|
USER_ACCESS_TABLE,
|
||||||
mass_inserts(USER_ACCESS_TABLE, array_keys($inserts[0]), $inserts);
|
array('user_id','cat_id'),
|
||||||
}
|
$inserts,
|
||||||
|
array('ignore'=>true)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue