public function saveForum(Forum $forum = null) { if ($forum == null) { $forum = new Forum(); } $forum->name = Input::get("name"); $forum->description = Input::get("description"); $forum->category_id = Input::get("category"); $forum->sect_id = Input::get("sect") == "NULL" ? null : Input::get("sect"); $forum->clan_id = Input::get("clan") == "NULL" ? null : Input::get("clan"); $forum->background_id = Input::get("background") == "NULL" ? null : Input::get("background"); $forum->read_permission = Input::get("read-permission") == "NULL" ? null : Input::get("read-permission"); $forum->topic_permission = Input::get("topic-permission") == "NULL" ? null : Input::get("topic-permission"); $forum->reply_permission = Input::get("reply-permission") == "NULL" ? null : Input::get("reply-permission"); $forum->is_private = Input::get("private") ? 1 : 0; $forum->show_on_st_todo_list = Input::get("todo_list") ? 1 : 0; $forum->asymmetric_replies = Input::get("asymmetric") ? 1 : 0; $forum->time_limited = Input::get("time-limited") ? 1 : 0; $forum->player_specific_threads = Input::get("player-specific-threads") ? 1 : 0; $forum->position = Input::get("position"); $forum->list_header = trim(Input::get("list-header")); $forum->post_header = trim(Input::get("post-header")); $forum->thread_template = trim(Input::get("thread-template")); $forum->save(); Cache::flush(); return Redirect::to('dashboard/storyteller/manage/forums'); }
/** * Creates a new forum. * If creation is successful, the browser will be redirected to the 'show' page. */ public function actionCreate() { $forum = new Forum(); if (isset($_POST['Forum'])) { $forum->attributes = $_POST['Forum']; if ($forum->save()) { $this->redirect(array('show', ' id' => $forum->id)); } } $this->render('create', array('forum' => $forum)); }
/** * Создает новую модель Форума. * Если создание прошло успешно - перенаправляет на просмотр. * * @return void */ public function actionCreate() { $model = new Forum(); if (($data = Yii::app()->getRequest()->getPost('Forum')) !== null) { $model->setAttributes($data); if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('ForumModule.forum', 'Record was created!')); $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create'])); } } $this->render('create', ['model' => $model]); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Forum(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Forum'])) { $model->attributes = $_POST['Forum']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->ForumID)); } } $this->render('create', array('model' => $model)); }
/** * create action */ public function actionCreate($parentid = null) { $forum = new Forum(); $forum->parent_id = $parentid; // Set default if (isset($_POST['Forum'])) { if (!isset($_POST['YII_CSRF_TOKEN']) || $_POST['YII_CSRF_TOKEN'] != Yii::app()->getRequest()->getCsrfToken()) { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } $forum->attributes = $_POST['Forum']; if ($forum->validate()) { if ((int) $forum->parent_id < 1) { $forum->parent_id = null; } $forum->save(); $this->redirect($this->createUrl("index")); } } $this->render('editforum', array('model' => $forum)); }
/** * Adds a forum assigned to the user when it is created * * @return bool */ public function save(PropelPDO $con = null) { //Check if it's a new user before saving $new = $this->isNew(); $this->setLastActivityAt(time()); //Save and return false on an error if (!parent::save($con)) { return false; } //If it was new... if ($new) { //Create a forum for it $forum = new Forum(); $forum->setName($this->getName()); $forum->setType(Forum::TYPE_USER_FORUM); $forum->setEntityId($this->getId()); //If the forum didn't work if (!$forum->save()) { //Delete the group and return false $this->delete(); return false; } } return true; }
public function edit_topic(Request $request, $matches) { $title = $this->lang->translate('forum.create'); // Get page for updating $id = intval($matches->get('id', $request->get('id'))); // Parent topic $topics = \Forum::as_array(\Forum::find('all', ['conditions' => ['forum_id = 0 AND id <> ?', $id]])); if ($id > 0) { $forum = \Forum::find_by_id($id); $title = $this->lang->translate('forum.editing', $forum->title); } else { $forum = ['title' => $this->lang->translate('page.name'), 'forum_id' => null]; } // Create or update page if ($request->isMethod('post')) { if ($forum instanceof \Forum) { $forum->title = $request->get('title'); $forum->forum_id = $request->get('forum'); $forum->author_id = $this->user->id; } else { $forum = new \Forum(['title' => $request->get('title'), 'forum_id' => $request->get('forum'), 'author_id' => $this->user->id]); } // Updating instance $forum->save(); $forum = $forum->to_array(); return static::json_response(['success' => true, 'message' => $this->lang->translate('form.saved')]); } return $this->view->render('forum/create.twig', ['forum' => $forum, 'title' => $title, 'topics' => $topics]); }