diff options
author | mamouneyya <mamoun.diraneyya@gmail.com> | 2010-09-20 04:30:34 +0300 |
---|---|---|
committer | mamouneyya <mamoun.diraneyya@gmail.com> | 2010-09-20 04:30:34 +0300 |
commit | ce80259d6939e43aaea34eba7bea4b2a602a5019 (patch) | |
tree | 7ca81d874b62c5a2c0244657aa903d565a7e6b04 /modules/gallery/helpers/access.php | |
parent | ba950bec0c84a1467aa2545ca815d5af7b0b002b (diff) | |
parent | 93d1a8103e757a87fb006f2389f0ee24497367a7 (diff) |
Merge remote branch 'gallery3/master'
Diffstat (limited to 'modules/gallery/helpers/access.php')
-rw-r--r-- | modules/gallery/helpers/access.php | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index 86ea9572..52a36298 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -263,15 +263,15 @@ class access_Core { } /** - * Recalculate the permissions for a given item and its hierarchy. $item must be an album. + * Recalculate the permissions for an album's hierarchy. */ - static function recalculate_permissions($item) { + static function recalculate_album_permissions($album) { foreach (self::_get_all_groups() as $group) { foreach (ORM::factory("permission")->find_all() as $perm) { if ($perm->name == "view") { - self::_update_access_view_cache($group, $item); + self::_update_access_view_cache($group, $album); } else { - self::_update_access_non_view_cache($group, $perm->name, $item); + self::_update_access_non_view_cache($group, $perm->name, $album); } } } @@ -279,6 +279,28 @@ class access_Core { } /** + * Recalculate the permissions for a single photo. + */ + static function recalculate_photo_permissions($photo) { + $parent = $photo->parent(); + $parent_access_cache = ORM::factory("access_cache")->where("item_id", "=", $parent->id)->find(); + $photo_access_cache = ORM::factory("access_cache")->where("item_id", "=", $photo->id)->find(); + foreach (self::_get_all_groups() as $group) { + foreach (ORM::factory("permission")->find_all() as $perm) { + $field = "{$perm->name}_{$group->id}"; + if ($perm->name == "view") { + $photo->$field = $parent->$field; + } else { + $photo_access_cache->$field = $parent_access_cache->$field; + } + } + } + $photo_access_cache->save(); + $photo->save(); + model_cache::clear(); + } + + /** * Register a permission so that modules can use it. * * @param string $name The internal name for for this permission |