/** * Performs the edit action. */ public function edit() { if (!$this->is_allowed_to_edit()) { $this->forbidden(); return; } $id = Request::get_id(); $c_id = Request::get_c_id(); $repo = Glossary::repository(); $item = $repo->find_one_by_id($c_id, $id); $action = $this->url(self::ACTION_EDIT); $form = GlossaryForm::create($action, $item); if ($form->validate()) { $success = $repo->save($item); $message = $success ? get_lang('GlossaryTermUpdated') : get_lang('Error'); $home = $this->url(self::ACTION_DEFAULT); Redirect::go($home); } $data = (object) array(); $data->form = $form; $this->render('edit', $data); }
public function find_by_id() { $c_id = Request::get_c_id(); $id = Request::get_id(); $item = Glossary::repository()->find_one_by_id($c_id, $id); $data = (object) array(); if ($item) { $data->name = $item->name; $data->description = $item->description; } $this->response($success, '', $data); }
/** * Returns an item key. I.e. not a real entity object but an * object with the object keys set up. * * @return object */ public static function get_item_key() { $result = (object) array(); $result->c_id = Request::get_c_id(); $result->id = Request::get_id(); return $result; }