summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-02-14 22:25:12 +0000
committerBharat Mediratta <bharat@menalto.com>2009-02-14 22:25:12 +0000
commit2ee995fcc7e3a8550417a3c78d562d7187497475 (patch)
tree0c7744073ef2a10627e0078732ec35f41efbaf13 /core
parent2ec347a3ae7290c67051fed30395a9050ca66d06 (diff)
If the page number is out of range, redirect to the nearest page.
This fixes a bug where deleting the last photo on a page would take you to a 404.
Diffstat (limited to 'core')
-rw-r--r--core/controllers/albums.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/controllers/albums.php b/core/controllers/albums.php
index 39946e60..4ceb323d 100644
--- a/core/controllers/albums.php
+++ b/core/controllers/albums.php
@@ -41,10 +41,13 @@ class Albums_Controller extends Items_Controller {
$page = $this->input->get("page", "1");
$children_count = $album->viewable()->children_count();
$offset = ($page - 1) * $page_size;
+ $max_pages = max(ceil($children_count / $page_size), 1);
// Make sure that the page references a valid offset
- if ($page < 1 || $page > max(ceil($children_count / $page_size), 1)) {
- Kohana::show_404();
+ if ($page < 1) {
+ url::redirect("albums/$album->id");
+ } else if ($page > $max_pages) {
+ url::redirect("albums/$album->id?page=$max_pages");
}
$template = new Theme_View("page.html", "album");