aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorflop25 <flop25@piwigo.org>2014-08-17 20:01:10 +0000
committerflop25 <flop25@piwigo.org>2014-08-17 20:01:10 +0000
commitf1f806b8a313329536a56ebf5885bbc511c245ae (patch)
treebf1a579f969462a60dca2667e64397499da03389 /admin
parent321068447279208f127b48044ca28dac464d86ca (diff)
feature:732
unlock sub-albums git-svn-id: http://piwigo.org/svn/trunk@29229 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/cat_modify.php6
-rw-r--r--admin/include/functions.php10
-rw-r--r--admin/themes/default/template/cat_modify.tpl2
3 files changed, 13 insertions, 5 deletions
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index ae9ff5497..a3c34ada5 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -136,7 +136,11 @@ if (isset($_POST['submit']))
// retrieve cat infos before continuing (following updates are expensive)
$cat_info = get_cat_info($_GET['cat_id']);
- if ($cat_info['visible'] != get_boolean( $_POST['visible'] ) )
+ if ($_POST['visible']=='true_sub')
+ {
+ set_cat_visible(array($_GET['cat_id']), true, true);
+ }
+ elseif ($cat_info['visible'] != get_boolean( $_POST['visible'] ) )
{
set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
}
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 737f6af65..1ad514a13 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -644,8 +644,9 @@ SELECT id, id_uppercat, uppercats, rank, global_rank
*
* @param int[] $categories
* @param boolean|string $value
+ * @param boolean $unlock_child optional default false
*/
-function set_cat_visible($categories, $value)
+function set_cat_visible($categories, $value, $unlock_child = false)
{
if ( ($value = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)) === null )
{
@@ -656,11 +657,14 @@ function set_cat_visible($categories, $value)
// unlocking a category => all its parent categories become unlocked
if ($value)
{
- $uppercats = get_uppercat_ids($categories);
+ $cats = get_uppercat_ids($categories);
+ if ($unlock_child) {
+ $cats = array_merge($cats, get_subcat_ids($categories));
+ }
$query = '
UPDATE '.CATEGORIES_TABLE.'
SET visible = \'true\'
- WHERE id IN ('.implode(',', $uppercats).')';
+ WHERE id IN ('.implode(',', $cats).')';
pwg_query($query);
}
// locking a category => all its child categories become locked
diff --git a/admin/themes/default/template/cat_modify.tpl b/admin/themes/default/template/cat_modify.tpl
index 6e97fc65f..52f47d90f 100644
--- a/admin/themes/default/template/cat_modify.tpl
+++ b/admin/themes/default/template/cat_modify.tpl
@@ -117,7 +117,7 @@ categoriesCache.selectize(jQuery('[data-selectize=categories]'), {
<p>
<strong>{'Lock'|@translate}</strong>
<br>
- {html_radios name='visible' values=['true','false'] output=['No'|translate,'Yes'|translate] selected=$CAT_VISIBLE}
+ {html_radios name='visible' values=['true','true_sub','false'] output=['No'|translate,'No and unlock sub-albums'|translate,'Yes'|translate] selected=$CAT_VISIBLE}
</p>
{if isset($CAT_COMMENTABLE)}