From 98fce83de5f772482382bfabdbcd94c25ecdbb1a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 7 Jun 2010 22:23:46 -0700 Subject: Add a "convert_ids" parameter to Item_Model::as_restful_array(), which we can turn on with a query parameter. --- modules/gallery/models/item.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'modules/gallery/models') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 409ed3cc..dfcbdd70 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -924,17 +924,21 @@ class Item_Model extends ORM_MPTT { /** * Same as ORM::as_array() but convert id fields into their RESTful form. */ - public function as_restful_array() { + public function as_restful_array($convert_ids=true) { // Convert item ids to rest URLs for consistency $data = $this->as_array(); - if ($tmp = $this->parent()) { - $data["parent"] = rest::url("item", $tmp); - } - unset($data["parent_id"]); - if ($tmp = $this->album_cover()) { - $data["album_cover"] = rest::url("item", $tmp); + + if ($convert_ids) { + if ($tmp = $this->parent()) { + $data["parent"] = rest::url("item", $tmp); + } + unset($data["parent_id"]); + + if ($tmp = $this->album_cover()) { + $data["album_cover"] = rest::url("item", $tmp); + } + unset($data["album_cover_item_id"]); } - unset($data["album_cover_item_id"]); if (access::can("view_full", $this) && $this->is_photo()) { $data["file_url"] = $this->file_url(true); -- cgit v1.2.3