diff options
Diffstat (limited to 'modules/gallery/helpers/access.php')
-rw-r--r-- | modules/gallery/helpers/access.php | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index bfe02b3c..4148049a 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -99,15 +99,12 @@ class access_Core { return true; } - /* - We do this for cache reasons - if you check n photos in an album, it makes more sense - to check the album permissions once and let the cache deal with that, rather than check - every item individually and generate cache misses. - */ - $id = ($item->type == 'album') ? $item->id : $item->parent_id; + // Use the nearest parent album (including the current item) so that we take advantage + // of the cache when checking many items in a single album. + $id = ($item->type == "album") ? $item->id : $item->parent_id; $resource = $perm_name == "view" ? $item : model_cache::get("access_cache", $id, "item_id"); - + foreach ($user->groups() as $group) { if ($resource->__get("{$perm_name}_{$group->id}") === access::ALLOW) { return true; @@ -143,15 +140,12 @@ class access_Core { * @return boolean */ static function group_can($group, $perm_name, $item) { - /* - We do this for cache reasons - if you check n photos in an album, it makes more sense - to check the album permissions once and let the cache deal with that, rather than check - every item individually and generate cache misses. - */ - $id = ($item->type == 'album') ? $item->id : $item->parent_id; + // Use the nearest parent album (including the current item) so that we take advantage + // of the cache when checking many items in a single album. + $id = ($item->type == "album") ? $item->id : $item->parent_id; $resource = $perm_name == "view" ? $item : model_cache::get("access_cache", $id, "item_id"); - + return $resource->__get("{$perm_name}_{$group->id}") === access::ALLOW; } |