Moves thread.
@param int $id
@param ModelInterface $forum
@return PodiumResponse
@throws ModelNotFoundException
19491
public function move(int $id, ModelInterface $forum): PodiumResponse
    {
        $threadMover = $this->getMover($id);

        if ($threadMover === null) {
            throw new ModelNotFoundException('Thread of given ID can not be found.');
        }

        $threadMover->prepareForum($forum);

        return $threadMover->move();
    }
261501
public function remove(int $id): PodiumResponse
    {
        $groupRemover = $this->getRemover($id);

        if ($groupRemover === null) {
            throw new ModelNotFoundException('Group of given ID can not be found.');
        }

        return $groupRemover->remove();
    }
188473
public function actionNewThread($cid = null, $fid = null)
    {
        if (!User::can(Rbac::PERM_CREATE_THREAD)) {
            $this->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->redirect(['forum/index']);
        }

        $forum = Forum::find()->where(['id' => $fid, 'category_id' => $cid])->limit(1)->one();
        if (empty($forum)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the forum you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        $model = new Thread();
        $model->scenario = 'new';
        $model->subscribe = 1;
        $preview = false;
        $postData = Yii::$app->request->post();
        if ($model->load($postData)) {
            $model->posts = 0;
            $model->views = 0;
            $model->category_id = $forum->category->id;
            $model->forum_id = $forum->id;
            $model->author_id = User::loggedId();
            if ($model->validate()) {
                if (isset($postData['preview-button'])) {
                    $preview = true;
                } else {
                    if ($model->podiumNew()) {
                        $this->success(Yii::t('podium/flash', 'New thread has been created.'));
                        return $this->redirect([
                            'forum/thread',
                            'cid' => $forum->category->id,
                            'fid' => $forum->id,
                            'id' => $model->id,
                            'slug' => $model->slug
                        ]);
                    }
                    $this->error(Yii::t('podium/flash', 'Sorry! There was an error while creating the thread. Contact administrator about this problem.'));
                }
            }
        }
        return $this->render('new-thread', [
            'preview' => $preview,
            'model' => $model,
            'forum' => $forum,
        ]);
    }
13800
public function archive(int $id): PodiumResponse
    {
        $categoryArchiver = $this->getArchiver($id);

        if ($categoryArchiver === null) {
            throw new ModelNotFoundException('Category of given ID can not be found.');
        }

        return $categoryArchiver->archive();
    }
199212
public function move(string $id, $position): self
    {
        if (is_numeric($position)) {
            return $this->toPosition($id, $position);
        }

        if (starts_with($position, 'before:')) {
            return $this->moveBefore($id, substr($position, 7));
        }

        if (starts_with($position, 'after:')) {
            return $this->moveAfter($id, substr($position, 6));
        }

        throw new Exception("Unknown moving direction: {$position}");
    }
59890
public function removeAnswer(int $answerId): PodiumResponse
    {
        $pollAnswerRemover = $this->getAnswerRemover($answerId);

        if ($pollAnswerRemover === null) {
            throw new ModelNotFoundException('Poll of given ID can not be found.');
        }

        return $pollAnswerRemover->remove();
    }
391312
public static function updateRole($id, $role)
    {
        $activity = static::find()->where(['user_id' => $id])->limit(1)->one();
        if (empty($activity)) {
            Log::error('Cannot update user activity', $id, __METHOD__);
            return;
        }
        $activity->user_role = $role;
        if (!$activity->save()) {
            Log::error('Cannot update user activity', $id, __METHOD__);
            return;
        }
        Podium::getInstance()->podiumCache->delete('forum.lastactive');
    }
503975
public function run($id)
    {
        /** @var ActiveRecord $model */
        $model = new $this->modelClass;

        /*
         * Locate the supplied model, left, right and parent models
         */
        $pkAttribute = $model->getTableSchema()->primaryKey[0];

        /** @var ActiveRecord|NestedSetsBehavior $model */
        $model = $model::find()->where([$pkAttribute => $id])->one();

        if ($model == null) {
            throw new NotFoundHttpException('Node not found');
        }

        $model->deleteWithChildren();

        return null;
    }
364886
public function actionThread($cid = null, $fid = null, $id = null, $slug = null)
    {
        $thread = (new ThreadVerifier([
            'categoryId' => $cid,
            'forumId' => $fid,
            'threadId' => $id,
            'threadSlug' => $slug
        ]))->verify();
        if (empty($thread)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the thread you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        $this->setMetaTags(
            $thread->forum->keywords ?: $thread->forum->category->keywords,
            $thread->forum->description ?: $thread->forum->category->description
        );

        $model = new Post;
        $model->subscribe = 1;
        $dataProvider = $model->search($thread->forum->id, $thread->id);

        return $this->render('thread', [
            'model' => $model,
            'dataProvider' => $dataProvider,
            'thread' => $thread,
        ]);
    }
528894
public function read($id)
    {
        $thread = Thread::find($id);
        if (!$thread) {
            abort(404);
        }

        $thread->markAsRead(Auth::id());
    }
704704
public function run($id)
    {
        /** @var ActiveRecord $model */
        $model = new $this->modelClass;

        /*
         * Locate the supplied model, left, right and parent models
         */
        $pkAttribute = $model->getTableSchema()->primaryKey[0];

        /** @var ActiveRecord|NestedSetsBehavior $model */
        $model = $model::find()->where([$pkAttribute => $id])->one();

        if ($model == null) {
            throw new NotFoundHttpException('Node not found');
        }

        $name = Yii::$app->request->post('name');
        $model->{$this->nameAttribute} = $name;
        if (!$model->validate()) {
            throw new HttpException($model->getFirstError($this->nameAttribute));
        }
        $model->update(true, [$this->nameAttribute]);

        return null;
    }
466962
public function remove(int $id): PodiumResponse
    {
        $threadRemover = $this->getRemover($id);

        if ($threadRemover === null) {
            throw new ModelNotFoundException('Thread of given ID can not be found.');
        }

        return $threadRemover->remove();
    }
102347
public function activateGlobalNotificationsAction(Forum $forum)
    {
        $collection = new ResourceCollection(array($forum->getResourceNode()));

        if (!$this->authorization->isGranted('MODERATE', $collection)) {
            throw new AccessDeniedException($collection->getErrorsForDisplay());
        }

        $this->manager->activateGlobalNotifications($forum);

        return new RedirectResponse(
            $this->generateUrl('claro_forum_categories', array('forum' => $forum->getId()))
        );
    }
984586
public function run($id)
    {
        if ((int)$this->direction === self::UP) {
            return $this->moveUp($id);
        } else {
            return $this->moveDown($id);
        }
    }
888378
public function get_count_discussions_in_forum(forum_entity $forum) : ?int {
        return $this->get_db()->count_records(self::TABLE, [
            'forum' => $forum->get_id()]);
    }
147501
public function updateModeratorForOne($forumId = null)
    {
        try {
            if ((new Query())->from(Mod::tableName())->where([
                    'forum_id' => $forumId,
                    'user_id' => $this->id
                ])->exists()) {
                Podium::getInstance()->db->createCommand()->delete(Mod::tableName(), [
                    'forum_id' => $forumId,
                    'user_id' => $this->id
                ])->execute();
            } else {
                Podium::getInstance()->db->createCommand()->insert(Mod::tableName(), [
                    'forum_id' => $forumId,
                    'user_id' => $this->id
                ])->execute();
            }
            Podium::getInstance()->podiumCache->deleteElement('forum.moderators', $forumId);
            Log::info('Moderator updated', $this->id, __METHOD__);
            return true;
        } catch (Exception $e) {
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
242376
public function remove(int $id): PodiumResponse
    {
        $categoryRemover = $this->getRemover($id);

        if ($categoryRemover === null) {
            throw new ModelNotFoundException('Category of given ID can not be found.');
        }

        return $categoryRemover->remove();
    }