diff options
author | cash <cash.costello@gmail.com> | 2012-01-02 17:49:31 -0500 |
---|---|---|
committer | cash <cash.costello@gmail.com> | 2012-01-02 17:49:31 -0500 |
commit | be94a34e652571eb61c3e306abfb7cce673823d7 (patch) | |
tree | 0984ee2d4735bc98a97c90ebfb40e206bc039d4f /start.php | |
parent | 55bbbaef6a06d4177dcaa32cee94095db0ae4042 (diff) | |
download | elgg-be94a34e652571eb61c3e306abfb7cce673823d7.tar.gz elgg-be94a34e652571eb61c3e306abfb7cce673823d7.tar.bz2 |
fixed group albums
Diffstat (limited to 'start.php')
-rw-r--r-- | start.php | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -63,6 +63,10 @@ function tidypics_init() { // RSS extensions for embedded media elgg_extend_view('extensions/xmlns', 'extensions/photos/xmlns'); + // allow group members add photos to group albums + elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'tidypics_group_permission_override'); + elgg_register_plugin_hook_handler('permissions_check:metadata', 'object', 'tidypics_group_permission_override'); + /* @@ -71,11 +75,6 @@ function tidypics_init() { //register_elgg_event_handler('pagesetup', 'system', 'tidypics_submenus'); - - if (get_plugin_setting('grp_perm_override', 'tidypics') != "disabled") { - register_plugin_hook('permissions_check', 'object', 'tidypics_permission_override'); - } - // Register for notifications register_notification_object('object', 'album', elgg_echo('tidypics:newalbum')); register_plugin_hook('notify:entity:message', 'object', 'tidypics_notify_message'); @@ -327,7 +326,10 @@ function tidypics_entity_menu_setup($hook, $type, $return, $params) { } /** - * Override permissions for group albums and images + * Override permissions for group albums + * + * 1. To write to a container (album) you must be able to write to the owner of the container (odd) + * 2. We also need to change metadata on the album * * @param string $hook * @param string $type @@ -335,18 +337,17 @@ function tidypics_entity_menu_setup($hook, $type, $return, $params) { * @param array $params * @return mixed */ -function tidypics_permission_override($hook, $type, $result, $params) { - $entity = $params['entity']; - $user = $params['user']; - - if ($entity->subtype == get_subtype_id('object', 'album')) { - // test that the user can edit the container - return can_write_to_container(0, $entity->container_guid); - } +function tidypics_group_permission_override($hook, $type, $result, $params) { + if (get_input('action') == 'photos/image/upload') { + if (isset($params['container'])) { + $album = $params['container']; + } else { + $album = $params['entity']; + } - if ($entity->subtype == get_subtype_id('object', 'image')) { - // test that the user can edit the container - return can_write_to_container(0, $entity->container_guid); + if (elgg_instanceof($album, 'object', 'album')) { + return $album->getContainerEntity()->canWriteToContainer(); + } } } |