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);
}
}