/** * Add topic action */ public function actionaddtopic() { if (!Yii::app()->user->checkAccess('op_forum_post_topics')) { throw new CHttpException(403, Yii::t('forum', 'Sorry, You are not allowed to perform that operation.')); } $model = new ForumTopics(); // Did we submit the form? if (isset($_POST['ForumTopics'])) { $model->attributes = $_POST['ForumTopics']; $model->visible = 1; if ($model->save()) { Yii::app()->user->setFlash('success', Yii::t('forum', 'Thank You. Your topic created.')); $this->redirect('index'); } } // Add page breadcrumb and title $this->pageTitle[] = Yii::t('forum', 'Create A Topic'); $this->breadcrumbs[Yii::t('forum', 'Create A Topic')] = ''; // Render $this->render('addtopic', array('model' => $model)); }
public function answer() { $return = array(); $return['success'] = 'fail'; $topic_id = $this->params['topic_id']; $reply_id = $this->params['reply_id']; $level = Session::get('level'); $user_id = Session::get('id'); if (!$user_id) { $return['message'] = Lang::get('forum-only-logged-users'); return $this->return_json($return); } // Get the topic $topic = ForumTopics::find($this->params['topic_id'])[0]; // Get the answer $owner = $topic->user_id; // Check if answered $answered = $topic->status; if ($answered > 0) { $return['message'] = Lang::get('topic-allready-answered'); return $this->return_json($return); } // if userid = session or level > 1 if ($level > 1 || $owner == $user_id) { $topic = new ForumTopics(); $topic->id = $topic_id; $topic->approved_by = $user_id; $topic->last_updated = time(); $topic->status = '1'; $topic->save(); $answer = new ForumAnswers(); $answer->id = $reply_id; $answer->accepted = 1; $answer->last_updated = time(); $answer->save(); $return['success'] = 'ok'; } // if not answered yet return $this->return_json($return); }