diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-12-13 20:06:20 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-12-13 20:06:20 +0000 |
commit | af8c74f6125478450072fd105d54172dcba1bf8e (patch) | |
tree | 81016a51efe591f0c421a85c101bd664837b3307 /core | |
parent | d480778108d431b26a2e3413814380943d2d804d (diff) |
Fix a bug where parent permissions were not getting inherited to newly
created albums and photos.
Diffstat (limited to 'core')
-rw-r--r-- | core/helpers/access.php | 5 | ||||
-rw-r--r-- | core/tests/Access_Helper_Test.php | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/core/helpers/access.php b/core/helpers/access.php index 3fb7548d..badd9b0a 100644 --- a/core/helpers/access.php +++ b/core/helpers/access.php @@ -250,6 +250,10 @@ class access_Core { * @return void */ public static function add_item($item) { + $access_intent = ORM::factory("access_intent", $item->id); + if ($access_intent->loaded) { + throw new Exception("@todo ITEM_ALREADY_ADDED $item->id"); + } $access_intent = ORM::factory("access_intent"); $access_intent->item_id = $item->id; $access_intent->save(); @@ -269,6 +273,7 @@ class access_Core { } } } + $item->save(); $access_cache->save(); } diff --git a/core/tests/Access_Helper_Test.php b/core/tests/Access_Helper_Test.php index 7f5aa656..9b08b2cd 100644 --- a/core/tests/Access_Helper_Test.php +++ b/core/tests/Access_Helper_Test.php @@ -81,6 +81,23 @@ class Access_Helper_Test extends Unit_Test_Case { $item->delete(); } + public function new_photos_inherit_parent_permissions_test() { + $root = ORM::factory("item", 1); + + $album = ORM::factory("item"); + $album->type = "album"; + $album->add_to_parent($root); + access::add_item($album); + access::allow(group::everybody(), "view", $album); + + $photo = ORM::factory("item"); + $photo->type = "photo"; + $photo->add_to_parent($album); + access::add_item($photo); + + $this->assert_true($photo->__get("view_" . group::everybody()->id)); + } + public function can_allow_deny_and_reset_intent_test() { $root = ORM::factory("item", 1); $item = ORM::factory("item")->add_to_parent($root); |