From 66dd3f3f5f14bb0ba6d2c7ef83b5b612d5ee2e30 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 15 Mar 2014 15:04:14 -0300 Subject: Squashed 'mod/lightbox/' content from commit a83b8d8 git-subtree-dir: mod/lightbox git-subtree-split: a83b8d89691c31b4568f47790fb40d0bc962aca5 --- actions/lightbox/edit.php | 91 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 actions/lightbox/edit.php (limited to 'actions') diff --git a/actions/lightbox/edit.php b/actions/lightbox/edit.php new file mode 100644 index 000000000..6ee49e671 --- /dev/null +++ b/actions/lightbox/edit.php @@ -0,0 +1,91 @@ + 0) { + $new_album = false; +} + +if ($new_album) { + + $album = new LightboxPluginAlbum(); + +} else { + // load original album object + $album = new LightboxPluginAlbum($guid); + + // user must be able to edit album + if (!$album->guid || !$album->canEdit()) { + register_error(elgg_echo('lightbox:noaccess')); + forward(REFERER); + } + + if (!$title) { + // user blanked title, but we need one + $title = $album->title; + } +} + +$album->title = $title; +$album->description = $desc; +$album->access_id = $access_id; +$album->container_guid = $container_guid; +$album->tags = string_to_tag_array($tags); + +$guid = $album->save(); + +// lightbox saved so clear sticky form +elgg_clear_sticky_form('lightbox:album'); + + +// handle results differently for new albums and album updates +if ($new_album) { + if ($guid && $album->attachImages($images)) { + system_message(elgg_echo("lightbox:saved")); + add_to_river('river/object/album/create', 'create', elgg_get_logged_in_user_guid(), $album->guid); + forward("photos/edit/images/$guid"); + } else { + // failed to save album object - nothing we can do about this + lightbox_delete_image_inputs($images); + register_error(elgg_echo("lightbox:save:failed")); + if (get_entity($container_guid)->getType() == 'group') { + forward("photos/group/$container->guid/all"); + } else { + forward("photos/owner/$container->username"); + } + } + + + +} else { + if ($guid) { + system_message(elgg_echo("lightbox:saved")); + } else { + lightbox_delete_image_inputs($images); + register_error(elgg_echo("lightbox:save:failed")); + } + + forward($album->getURL()); +} -- cgit v1.2.3