diff options
-rw-r--r-- | activate.php | 2 | ||||
-rw-r--r-- | pages/photos/album/view.php | 2 | ||||
-rw-r--r-- | pages/photos/image/upload.php | 5 | ||||
-rw-r--r-- | start.php | 35 | ||||
-rw-r--r-- | views/default/forms/photos/admin/settings.php | 12 |
5 files changed, 22 insertions, 34 deletions
diff --git a/activate.php b/activate.php index 25d34338c..86706d9a6 100644 --- a/activate.php +++ b/activate.php @@ -41,8 +41,6 @@ $defaults = array( 'album_river_view' => 'set', 'image_sizes' => $image_sizes, - - 'grp_perm_override' => true, ); foreach ($defaults as $name => $value) { diff --git a/pages/photos/album/view.php b/pages/photos/album/view.php index 39816b299..cef3647ee 100644 --- a/pages/photos/album/view.php +++ b/pages/photos/album/view.php @@ -32,7 +32,7 @@ elgg_push_breadcrumb($album->getTitle()); $content = elgg_view_entity($album, array('full_view' => true)); -if ($album->canWriteToContainer()) { +if ($album->getContainerEntity()->canWriteToContainer()) { elgg_register_menu_item('title', array( 'name' => 'upload', 'href' => 'photos/upload/' . $album->getGUID(), diff --git a/pages/photos/image/upload.php b/pages/photos/image/upload.php index 526972a35..7d9db5ed8 100644 --- a/pages/photos/image/upload.php +++ b/pages/photos/image/upload.php @@ -21,14 +21,15 @@ if (elgg_get_plugin_setting('uploader', 'tidypics') != "disabled") { } $album = get_entity($album_guid); -if (!$album || !$album->canEdit()) { +if (!$album) { // @todo // throw warning and forward to previous page forward(REFERER); } -if (!$album->canEdit()) { +if (!$album->getContainerEntity()->canWriteToContainer()) { // @todo have to be able to edit album to upload photos + forward(REFERER); } // set page owner based on container (user or group) @@ -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(); + } } } diff --git a/views/default/forms/photos/admin/settings.php b/views/default/forms/photos/admin/settings.php index 5c71e24f6..f4bafce78 100644 --- a/views/default/forms/photos/admin/settings.php +++ b/views/default/forms/photos/admin/settings.php @@ -105,18 +105,6 @@ echo '</table>'; echo '</div>'; -// Group albums -echo '<h3>' . elgg_echo('tidypics:settings:heading:groups') . '</h3>'; -echo '<div>'; -$checked = $plugin->grp_perm_override ? 'checked' : false; -echo elgg_view('input/checkbox', array( - 'name' => "params[grp_perm_override]", - 'value' => true, - 'checked' => (bool)$plugin->grp_perm_override, -)); -echo ' ' . elgg_echo("tidypics:settings:grp_perm_override"); -echo '</div>'; - echo elgg_view('input/submit', array('value' => elgg_echo("save"))); |