Skip to content

Commit

Permalink
bug:2855
Browse files Browse the repository at this point in the history
check "Apply to sub" checkbox if $conf inheritance_by_default is true
add admins to the users granted
optimizations

git-svn-id: http://piwigo.org/svn/trunk@23430 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
flop25 committed Jun 21, 2013
1 parent 231e718 commit 55d91ff
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 39 deletions.
2 changes: 1 addition & 1 deletion admin/cat_perm.php
Expand Up @@ -319,7 +319,7 @@
// +-----------------------------------------------------------------------+
// | sending html code |
// +-----------------------------------------------------------------------+
$template->assign(array('PWG_TOKEN' => get_pwg_token()));
$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'INHERIT' => $conf['inheritance_by_default']));

$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_perm');
?>
76 changes: 39 additions & 37 deletions admin/site_update.php
Expand Up @@ -322,7 +322,7 @@
$granted_grps = array();
while ($row = pwg_db_fetch_assoc($result))
{
if (!is_array ($granted_grps[$row['cat_id']]))
if (!isset($granted_grps[$row['cat_id']]))
{
$granted_grps[$row['cat_id']]=array();
}
Expand All @@ -333,33 +333,7 @@
)
);
}
$insert_granted_grps=array();
foreach ($category_ids as $ids)
{
$parent_id=$db_categories[$ids]['parent'];
while (in_array($parent_id, $category_ids))
{
$parent_id= $db_categories[$parent_id]['parent'];
}
if ($db_categories[$ids]['status']=='private' and !is_null($parent_id))
{
foreach ($granted_grps[$parent_id] as $granted_grp)
{
array_push(
$insert_granted_grps,
array(
'group_id' => $granted_grp,
'cat_id' => $ids
)
);

}
}
}

mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $insert_granted_grps);
}

$query = '
SELECT *
FROM '.USER_ACCESS_TABLE.'
Expand All @@ -368,11 +342,10 @@
$result = pwg_query($query);
if (!empty($result))
{

$granted_users = array();
while ($row = pwg_db_fetch_assoc($result))
{
if (!is_array ($granted_users[$row['cat_id']]))
if (!isset($granted_users[$row['cat_id']]))
{
$granted_users[$row['cat_id']]=array();
}
Expand All @@ -383,15 +356,32 @@
)
);
}
$insert_granted_users=array();
foreach ($category_ids as $ids)
}
$insert_granted_users=array();
$insert_granted_grps=array();
foreach ($category_ids as $ids)
{
$parent_id=$db_categories[$ids]['parent'];
while (in_array($parent_id, $category_ids))
{
$parent_id=$db_categories[$ids]['parent'];
while (in_array($parent_id, $category_ids))
$parent_id= $db_categories[$parent_id]['parent'];
}
if ($db_categories[$ids]['status']=='private' and !is_null($parent_id))
{
if (isset($granted_grps[$parent_id]))
{
$parent_id= $db_categories[$parent_id]['parent'];
foreach ($granted_grps[$parent_id] as $granted_grp)
{
array_push(
$insert_granted_grps,
array(
'group_id' => $granted_grp,
'cat_id' => $ids
)
);
}
}
if ($db_categories[$ids]['status']=='private' and !is_null($parent_id))
if (isset($granted_users[$parent_id]))
{
foreach ($granted_users[$parent_id] as $granted_user)
{
Expand All @@ -404,10 +394,22 @@
);
}
}
foreach (get_admins() as $granted_user)
{
array_push(
$insert_granted_users,
array(
'user_id' => $granted_user,
'cat_id' => $ids
)
);
}
}
mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert_granted_users);
}
}
mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $insert_granted_grps);
$insert_granted_users=array_unique($insert_granted_users, SORT_REGULAR);
mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert_granted_users);
}
else
{
add_permission_on_category($category_ids, get_admins());
Expand Down
2 changes: 1 addition & 1 deletion admin/themes/default/template/cat_perm.tpl
Expand Up @@ -150,7 +150,7 @@ jQuery(document).ready(function() {

<p style="margin:12px;text-align:left;">
<input class="submit" type="submit" value="{'Save Settings'|@translate}" name="submit">
<label id="applytoSubAction" style="display:none;"><input type="checkbox" name="apply_on_sub">{'Apply to sub-albums'|@translate}</label>
<label id="applytoSubAction" style="display:none;"><input type="checkbox" name="apply_on_sub" {if $INHERIT}checked="checked"{/if}>{'Apply to sub-albums'|@translate}</label>
</p>

<input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
Expand Down

0 comments on commit 55d91ff

Please sign in to comment.