/** * Update new forum */ public function action_update() { Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Topic'))); $topic = new Model_Topic($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) { $forum_parents[$parent['id']] = $parent['name']; } $this->template->content = View::factory('oc-panel/pages/forum/topic', array('topic' => $topic, 'forum_parents' => $forum_parents)); if ($_POST) { $topic->title = core::post('title'); $topic->id_forum = core::post('id_forum'); $topic->description = core::post('description'); if (core::post('seotitle') != $topic->seotitle) { $topic->seotitle = $topic->gen_seotitle(core::post('seotitle')); } if (core::post('status') == 'on') { $topic->status = 1; } else { $topic->status = 0; } try { $topic->save(); Alert::set(Alert::SUCCESS, __('Topic is updated.')); } catch (Exception $e) { Alert::set(Alert::ERROR, $e->getMessage()); } HTTP::redirect(Route::url('oc-panel', array('controller' => 'topic', 'action' => 'index'))); } }
public function actionCreate($params) { $store = $this->getStorage(); $view = $this->ajaxView(); $topic = new Model_Topic($store); $topic->title = $_GET["title"]; $topic->name = $_GET["name"]; $topic->owner = $this->getAuthorizator()->getUser()->getId(); $topic->group = $this->getAuthorizator()->getUser()->group; $view->title = $topic->title; $view->name = $topic->name; if ($errors = $topic->validate()) { $view->error = "validation failed"; $view->errors = $errors; } else { $view->state = "created"; try { $topic->save(); $view->id = $topic->getId(); } catch (Exception $e) { $view->state = "failed"; $view->error = $e->getMessage(); } } return $view; }
/** * Edit Topic * * @param integer $topic Topic ID * @param array $changes Changes * @return bool */ public function edit($topic, $changes) { $new = new Model_Topic(); $new->assignIdentifier($topic); $new->fromArray($changes); try { $new->save(); } catch (Doctrine_Exception $e) { return $e->getMessage(); } return true; }
public function action_new() { $this->check_login(); /* @var Model_User $cu */ $cu = $this->get_current_user(); if ($cu->submit < 1) { throw new Exception_Page(__('common.submit_before_topic')); } if ($this->request->is_post()) { $topic = new Model_Topic(); $topic->title = $this->get_post('title'); $topic->author_id = $cu->user_id; $topic->cid = intval($this->get_post('cid')); $topic->pid = intval($this->get_post('pid')); $topic->save(); $reply = new Model_Reply(); $reply->topic_id = $topic->tid; $reply->content = $this->get_raw_post('content'); $reply->author_id = $cu->user_id; $reply->save(); $this->redirect("/discuss/topic/{$topic->tid}"); } $this->view = 'discuss/edit'; $this->template_data['title'] = __('discuss.edit.new_topic'); }