summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/access.php
diff options
context:
space:
mode:
authorNathan Kinkade <nkinkade@nkinka.de>2010-12-23 02:12:38 +0000
committerNathan Kinkade <nkinkade@nkinka.de>2010-12-23 02:12:38 +0000
commit5e17a5e7fcb678bd7081bdf8089afec5b25f3aff (patch)
tree9590eae390af1f72b72ddc6500a2566e3558e3bb /modules/gallery/helpers/access.php
parentcf1965957c48b1c88a3913f8167688d03d191cec (diff)
parent032e6fde5f99c3150a4ae70e410ce314d8c3877a (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/helpers/access.php')
-rw-r--r--modules/gallery/helpers/access.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index 0b0dcbc1..4148049a 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -99,8 +99,12 @@ class access_Core {
return true;
}
+ // 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", $item->id, "item_id");
+ $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;
@@ -136,8 +140,12 @@ class access_Core {
* @return boolean
*/
static function group_can($group, $perm_name, $item) {
+ // 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", $item->id, "item_id");
+ $item : model_cache::get("access_cache", $id, "item_id");
+
return $resource->__get("{$perm_name}_{$group->id}") === access::ALLOW;
}
@@ -426,7 +434,7 @@ class access_Core {
$session = Session::instance();
$csrf = $session->get("csrf");
if (empty($csrf)) {
- $csrf = md5(rand());
+ $csrf = random::hash();
$session->set("csrf", $csrf);
}
return $csrf;