summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-07-17 08:14:08 -0700
committerBharat Mediratta <bharat@menalto.com>2009-07-17 08:14:08 -0700
commit8a6556b30bc34d69284df6246f4010a8835f3bc2 (patch)
tree7d0b5374bba65973c2231083bc5d93ad31f4ccfc /modules/gallery/helpers
parent0f766b149d0cee7af664f2321fddc6f04cda70ac (diff)
Fix a bug where moved items don't properly inherit permissions from
their new target. After each move, recalculate the permissions for the new parent's hierarchy. Fixes ticket #552
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/access.php15
-rw-r--r--modules/gallery/helpers/gallery_event.php4
2 files changed, 19 insertions, 0 deletions
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index c48f0b79..5dd1e465 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -244,6 +244,21 @@ class access_Core {
}
/**
+ * Recalculate the permissions for a given item and its hierarchy. $item must be an album.
+ */
+ static function recalculate_permissions($item) {
+ 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);
+ } else {
+ self::_update_access_non_view_cache($group, $perm->name, $item);
+ }
+ }
+ }
+ }
+
+ /**
* Register a permission so that modules can use it.
*
* @param string $name The internal name for for this permission
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 2f3a64d3..1cd96372 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -35,6 +35,10 @@ class gallery_event_Core {
access::delete_item($item);
}
+ static function item_moved($item, $old_parent) {
+ access::recalculate_permissions($item->parent());
+ }
+
static function user_login($user) {
// If this user is an admin, check to see if there are any post-install tasks that we need
// to run and take care of those now.