aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflop25 <flop25@piwigo.org>2011-08-31 15:12:14 +0000
committerflop25 <flop25@piwigo.org>2011-08-31 15:12:14 +0000
commitded83a19dac48848d97c3aca3ee8da6fad850358 (patch)
tree9863d89f4751153b87d6f3f7b042b824ec6affe7
parenta867fe1e853cb299547f1a856bafc3780cd3615b (diff)
feature:2418
adding an option to apply permission of users to sub-albums changing the name of vars $private_uppercats->$private_cats git-svn-id: http://piwigo.org/svn/trunk@12019 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/cat_perm.php8
-rw-r--r--admin/include/functions.php15
-rw-r--r--admin/themes/default/template/cat_perm.tpl1
3 files changed, 13 insertions, 11 deletions
diff --git a/admin/cat_perm.php b/admin/cat_perm.php
index 961cf9f0f..0b7b0c51a 100644
--- a/admin/cat_perm.php
+++ b/admin/cat_perm.php
@@ -96,11 +96,11 @@ SELECT id
WHERE id IN ('.$cat_ids.')
AND status = \'private\'
;';
- $private_uppercats = array_from_query($query, 'id');
+ $private_cats = array_from_query($query, 'id');
// We must not reinsert already existing lines in group_access table
$granteds = array();
- foreach ($private_uppercats as $cat_id)
+ foreach ($private_cats as $cat_id)
{
$granteds[$cat_id] = array();
}
@@ -108,7 +108,7 @@ SELECT id
$query = '
SELECT group_id, cat_id
FROM '.GROUP_ACCESS_TABLE.'
- WHERE cat_id IN ('.implode(',', $private_uppercats).')
+ WHERE cat_id IN ('.implode(',', $private_cats).')
AND group_id IN ('.implode(',', $_POST['grant_groups']).')
;';
$result = pwg_query($query);
@@ -119,7 +119,7 @@ SELECT group_id, cat_id
$inserts = array();
- foreach ($private_uppercats as $cat_id)
+ foreach ($private_cats as $cat_id)
{
$group_ids = array_diff($_POST['grant_groups'], $granteds[$cat_id]);
foreach ($group_ids as $group_id)
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 8d7a178bd..824a489ea 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -2143,24 +2143,25 @@ function add_permission_on_category($category_ids, $user_ids)
return;
}
- // make sure categories are private and select uppercats
+ // 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));
$query = '
SELECT
id
FROM '.CATEGORIES_TABLE.'
- WHERE id IN ('.implode(',', get_uppercat_ids($category_ids)).')
+ WHERE id IN ('.$cat_ids.')
AND status = \'private\'
;';
- $private_uppercats = array_from_query($query, 'id');
+ $private_cats = array_from_query($query, 'id');
- if (count($private_uppercats) == 0)
+ if (count($private_cats) == 0)
{
return;
}
// We must not reinsert already existing lines in user_access table
$granteds = array();
- foreach ($private_uppercats as $cat_id)
+ foreach ($private_cats as $cat_id)
{
$granteds[$cat_id] = array();
}
@@ -2170,7 +2171,7 @@ SELECT
user_id,
cat_id
FROM '.USER_ACCESS_TABLE.'
- WHERE cat_id IN ('.implode(',', $private_uppercats).')
+ WHERE cat_id IN ('.implode(',', $private_cats).')
AND user_id IN ('.implode(',', $user_ids).')
;';
$result = pwg_query($query);
@@ -2181,7 +2182,7 @@ SELECT
$inserts = array();
- foreach ($private_uppercats as $cat_id)
+ foreach ($private_cats as $cat_id)
{
$grant_to_users = array_diff($user_ids, $granteds[$cat_id]);
diff --git a/admin/themes/default/template/cat_perm.tpl b/admin/themes/default/template/cat_perm.tpl
index 2ad7d20c0..71385a803 100644
--- a/admin/themes/default/template/cat_perm.tpl
+++ b/admin/themes/default/template/cat_perm.tpl
@@ -59,6 +59,7 @@
<li><label><input type="checkbox" name="grant_users[]" value="{$id}"> {$all_users[$id]}</label></li>
{/foreach}
</ul>
+ <label><input type="checkbox" name="apply_on_sub">{'Apply to sub-albums'|@translate}</label>
<input class="submit" type="submit" name="grant_users_submit" value="{'Grant selected users'|@translate}">
</fieldset>