public function actionNewPost() { if (!YiiForum::checkAuth('post_add')) { return $this->noPermission(); } YiiForum::checkIsGuest(); $post = new Post(); $threadId = YiiForum::getGetValue('threadid'); $data = YiiForum::getPostValue('Post'); if ($data == null) { $thread = Thread::findOne(['id' => $threadId]); $locals = []; $locals['thread'] = $thread; $locals['currentBoard'] = $this->getBoard($thread['board_id']); $locals['model'] = $post; return $this->render('new-post', $locals); } $boardId = $data['board_id']; $threadId = $data['thread_id']; $threadTitle = $data['thread_title']; $post->thread_id = $threadId; $post->user_id = YiiForum::getIdentity()->id; $post->user_name = YiiForum::getIdentity()->username; $post->title = isset($data['title']) ? $data['title'] : ''; $post->body = $data['body']; $post->create_time = TTimeHelper::getCurrentTime(); $post->modify_time = TTimeHelper::getCurrentTime(); $post->supports = 0; $post->againsts = 0; $post->floor = 0; $post->note = ''; if ($post->save()) { Thread::updateLastData($threadId); Board::updateLastData($boardId, $threadId, $threadTitle, false); } return $this->redirect(['view', 'id' => $threadId]); }