summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/controllers/items.php2
-rw-r--r--core/models/item.php12
2 files changed, 13 insertions, 1 deletions
diff --git a/core/controllers/items.php b/core/controllers/items.php
index 60b2762f..e5f62db6 100644
--- a/core/controllers/items.php
+++ b/core/controllers/items.php
@@ -25,6 +25,6 @@ class Items_Controller extends REST_Controller {
// differently. We could also just delegate here, but it feels more appropriate
// to have a single canonical resource mapping.
access::required("view", $item);
- return url::redirect("{$item->type}s/$item->id");
+ return url::redirect($item->url());
}
}
diff --git a/core/models/item.php b/core/models/item.php
index a419c2f1..ffdaa7e9 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -103,6 +103,18 @@ class Item_Model extends ORM_MPTT {
}
/**
+ * album: url::site("albums/2")
+ * photo: url::site("photos/3")
+ */
+ public function url() {
+ if ($this->is_album()) {
+ return url::site("albums/$this->id");
+ } else {
+ return url::site("photos/$this->id");
+ }
+ }
+
+ /**
* album: /var/albums/album1/album2
* photo: /var/albums/album1/album2/photo.jpg
*/