Skip to content

Commit

Permalink
Merge pull request #467 from taarraas/master
Browse files Browse the repository at this point in the history
show next picture after delete instead of returning to album view

Fixes #2102
  • Loading branch information
bharat committed Mar 20, 2014
2 parents fb82ea4 + ab43632 commit ee5d080
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions modules/gallery/controllers/quick.php
Expand Up @@ -95,7 +95,7 @@ public function delete($id) {
$msg = t("Deleted photo <b>%title</b>", array("title" => html::purify($item->title)));
}

$parent = $item->parent();
$redirect = $item->parent(); // redirect to this item, if current item was deleted

if ($item->is_album()) {
// Album delete will trigger deletes for all children. Do this in a batch so that we can be
Expand All @@ -104,6 +104,20 @@ public function delete($id) {
$item->delete();
batch::stop();
} else {
$where = array(array("type", "!=", "album")); // evaluate redirect item before delete of current item
$position = item::get_position($item, $where);
if ($position > 1) {
list ($previous_item, $ignore, $next_item) =
$item->parent()->viewable()->children(3, $position - 2, $where);
} else {
$previous_item = null;
list ($next_item) = $item->parent()->viewable()->children(1, $position, $where);
}
if ($next_item) {
$redirect = $next_item;
} else if ($previous_item) {
$redirect = $previous_item;
}
$item->delete();
}
message::success($msg);
Expand All @@ -113,7 +127,7 @@ public function delete($id) {
$from_id != $id /* deleted the item we were viewing */) {
json::reply(array("result" => "success", "reload" => 1));
} else {
json::reply(array("result" => "success", "location" => $parent->url()));
json::reply(array("result" => "success", "location" => $redirect->url()));
}
}

Expand Down

0 comments on commit ee5d080

Please sign in to comment.