From a9e3692027dc767b340242ed18fe7184cbfd883d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 21 May 2009 01:31:29 +0000 Subject: 1) This provides the editting functionality for albums and photos in the organize feature. 2) Remove the tag functionality at this point 3) Added a callback to handle validating conflicting names (only used by organize at this point. 4) Closes #231 --- core/controllers/core_organize.php | 99 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 core/controllers/core_organize.php (limited to 'core/controllers') diff --git a/core/controllers/core_organize.php b/core/controllers/core_organize.php new file mode 100644 index 00000000..99f8b199 --- /dev/null +++ b/core/controllers/core_organize.php @@ -0,0 +1,99 @@ +post("item"); + $item = ORM::factory("item") + ->in("id", $itemids[0]) + ->find(); + access::required("edit", $item); + + $form = core_organize::getGeneralEditForm($item); + if ($form->validate()) { + $orig = clone $item; + $item->title = $form->title->value; + $item->description = $form->description->value; + $item->rename($form->dirname->value); + $item->save(); + + module::event("item_updated", $orig, $item); + + if ($item->is_album()) { + log::success("content", "Updated album", "id\">view"); + $message = t("Saved album %album_title", array("album_title" => $item->title)); + } else { + log::success("content", "Updated photo", "id\">view"); + $message = t("Saved photo %photo_title", array("photo_title" => $item->title)); + } + print json_encode(array("form" => $form->__toString(), "message" => $message)); + } else { + print json_encode(array("form" => $form->__toString())); + } + } + + public function sort() { + access::verify_csrf(); + + $itemids = Input::instance()->post("item"); + $item = ORM::factory("item") + ->in("id", $itemids[0]) + ->find(); + access::required("edit", $item); + + $form = core_organize::getSortEditForm($item); + if ($form->validate()) { + $orig = clone $item; + $item->sort_column = $form->column->value; + $item->sort_order = $form->direction->value; + $item->save(); + + module::event("item_updated", $orig, $item); + + log::success("content", "Updated album", "id\">view"); + $message = t("Saved album %album_title", array("album_title" => $item->title)); + print json_encode(array("form" => $form->__toString(), "message" => $message)); + } else { + print json_encode(array("form" => $form->__toString())); + } + } + + public function reset_general() { + $itemids = Input::instance()->get("item"); + $item = ORM::factory("item") + ->in("id", $itemids[0]) + ->find(); + access::required("edit", $item); + + print core_organize::getGeneralEditForm($item); + } + + public function reset_sort() { + $itemids = Input::instance()->get("item"); + $item = ORM::factory("item") + ->in("id", $itemids[0]) + ->find(); + access::required("edit", $item); + + print core_organize::getSortEditForm($item); + } + +} -- cgit v1.2.3