summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers/albums.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-12-31 17:21:19 -0800
committerBharat Mediratta <bharat@menalto.com>2009-12-31 17:21:19 -0800
commit20bd09ff004816ae152a2f890a24dc5e85741fac (patch)
tree5eb58b7e9cbb23faffb2aeaffe0aff7e87b56918 /modules/gallery/controllers/albums.php
parenta018e6235f09dd727b07f24801a8f237e07b3260 (diff)
A more thorough fix for #745 and #940. Stop using the referer to
guess how to send the user back. Instead, proxy the originating item id through the edit forms so that we can tell exactly what page we were on when we began editing. If we were viewing the item, then redirect to its new url (in case it changed) to fix ticket #745. But if we were viewing some other item, then just stay on the current page to fix #940. The page_type approach didn't work because you'd have the same "collection" page_type when doing a context menu edit for an album.
Diffstat (limited to 'modules/gallery/controllers/albums.php')
-rw-r--r--modules/gallery/controllers/albums.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 2134a419..2eeefdf1 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -157,8 +157,6 @@ class Albums_Controller extends Items_Controller {
}
if ($valid) {
- $watching_album = $album->url() != ($location = parse_url(request::referrer(), PHP_URL_PATH));
-
$album->title = $form->edit_item->title->value;
$album->description = $form->edit_item->description->value;
$album->sort_column = $form->edit_item->sort_order->column->value;
@@ -174,9 +172,13 @@ class Albums_Controller extends Items_Controller {
message::success(t("Saved album %album_title",
array("album_title" => html::purify($album->title))));
- print json_encode(
- array("result" => "success",
- "location" => $watching_album ? $location : $album->url()));
+ if ($form->from_id->value == $album->id) {
+ // Use the new url; it might have changed.
+ print json_encode(array("result" => "success", "location" => $album->url()));
+ } else {
+ // Stay on the same page
+ print json_encode(array("result" => "success"));
+ }
} else {
print json_encode(
array("result" => "error",