/** * Create new forum */ public function action_update() { Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit forum'))); $forum = new Model_Forum($this->request->param('id')); $get_all = Model_Forum::get_all(); //get all forums to build forum parents in select $forum_parents = array(); foreach ($get_all[0] as $parent) { if ($parent['id'] != $forum->id_forum) { $forum_parents[$parent['id']] = $parent['name']; } } if ($_POST and $forum->loaded()) { $forum->name = core::post('name'); $forum->id_forum_parent = core::post('id_forum_parent'); $forum->description = core::post('description'); if (core::post('seoname') != $forum->seoname) { $forum->seoname = $forum->gen_seoname(core::post('seoname')); } try { $forum->update(); Core::delete_cache(); Alert::set(Alert::SUCCESS, __('Forum is updated.')); HTTP::redirect(Route::url('oc-panel', array('controller' => 'forum', 'action' => 'index'))); } catch (Exception $e) { Alert::set(Alert::ERROR, $e->getMessage()); HTTP::redirect(Route::url('oc-panel', array('controller' => 'forum', 'action' => 'index'))); } } else { $this->template->content = View::factory('oc-panel/pages/forum/update', array('forum_parents' => $forum_parents, 'forum' => $forum)); } }