public static function updateLastData($threadId) { $attributes = []; $attributes['posts'] = new Expression("[[posts]]+:bp0", [":bp0" => 1]); $attributes['last_user_id'] = YiiForum::getIdentity()->id; $attributes['last_user_name'] = YiiForum::getIdentity()->username; $attributes['last_modify_time'] = TTimeHelper::getCurrentTime(); Thread::updateAll($attributes, ['id' => intval($threadId)]); }
public static function updateLastData($boardId, $threadId, $threadTitle, $isThread = True) { $attributes = []; $attributes['modify_time'] = TTimeHelper::getCurrentTime(); if ($isThread) { $attributes['threads'] = new Expression("[[threads]]+:bp0", [":bp0" => 1]); } else { $attributes['posts'] = new Expression("[[posts]]+:bp0", [":bp0" => 1]); } $attributes['user_id'] = YiiForum::getIdentity()->id; $attributes['user_name'] = YiiForum::getIdentity()->username; $attributes['thread_id'] = $threadId; $attributes['thread_title'] = $threadTitle; YiiForum::info($attributes); Board::updateAll($attributes, ['id' => intval($boardId)]); }
public function actionEditPost($id) { if (!YiiForum::checkAuth('post_edit')) { return $this->noPermission(); } YiiForum::checkIsGuest(); $boardId = YiiForum::getGetValue('boardid'); $model = Post::findOne(['id' => $id]); $data = YiiForum::getPostValue('Post'); if ($data == null) { $thread = Thread::findOne(['id' => $model['thread_id']]); $locals = []; $locals['thread'] = $thread; $locals['currentBoard'] = $this->getBoard($boardId); $locals['model'] = $model; return $this->render('edit-post', $locals); } else { $model->load(Yii::$app->request->post()); $model->modify_time = TTimeHelper::getCurrentTime(); $model->save(); return $this->redirect(['view', 'id' => $model->thread_id]); } }