Creating the thread of given category ID and forum ID.
@param int $cid category ID
@param int $fid forum ID
@return string|Response
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,
        ]);
    }
353174
public function actionMove($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']);
        }

        if (!User::can(Rbac::PERM_MOVE_THREAD, ['item' => $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 = Yii::$app->request->post('forum');
        if ($forum) {
            if (!is_numeric($forum) || $forum < 1 || $forum == $thread->forum->id) {
                $this->error(Yii::t('podium/flash', 'You have to select the new forum.'));
            } else {
                if ($thread->podiumMoveTo($forum)) {
                    $this->success(Yii::t('podium/flash', 'Thread has been moved.'));
                    return $this->redirect([
                        'forum/thread',
                        'cid' => $thread->forum->category->id,
                        'fid' => $thread->forum->id,
                        'id' => $thread->id,
                        'slug' => $thread->slug
                    ]);
                }
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while moving the thread.'));
            }
        }

        $categories = Category::find()->orderBy(['name' => SORT_ASC]);
        $forums = Forum::find()->orderBy(['name' => SORT_ASC]);
        $list = [];
        $options = [];
        foreach ($categories->each() as $cat) {
            $catlist = [];
            foreach ($forums->each() as $for) {
                if ($for->category_id == $cat->id) {
                    $catlist[$for->id] = (User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $for]) ? '* ' : '')
                                        . Html::encode($cat->name)
                                        . ' &raquo; '
                                        . Html::encode($for->name);
                    if ($for->id == $thread->forum->id) {
                        $options[$for->id] = ['disabled' => true];
                    }
                }
            }
            $list[Html::encode($cat->name)] = $catlist;
        }
        return $this->render('move', [
            'model' => $thread,
            'list' => $list,
            'options' => $options
        ]);
    }
79375
public function getEditionByID($cID)
    {
        if (!$this->hasConnectionError()) {
            $fileService = new File();
            $appVersion = Config::get('concrete.version');
            $cfToken = Marketplace::getSiteToken();
            $path = Config::get('concrete.urls.newsflow') . '/' . DISPATCHER_FILENAME . '/?_ccm_view_external=1&appVersion=' . $appVersion . '&cID=' . rawurlencode($cID) . '&cfToken=' . rawurlencode($cfToken);
            $response = $fileService->getContents($path);
            $ni = new NewsflowItem();
            $obj = $ni->parseResponse($response);

            return $obj;
        }

        return false;
    }
329822
private function &getEntryForGuid( $guid )
	{
		if ( ! isset( $this->uniqueFactIds[ $guid ] ) )
		{
			return false;
		}

		// Get the element
		$facts = $this->getElement( $this->uniqueFactIds[ $guid ] );

		// And find the entry with the corresponding guid
		foreach ( $facts as $key => &$entry )
		{
			if ( $entry['guid'] == $guid ) return $entry;
		}

		return false;
	}
684675
public function run( $cid, $fid ) {

		$model		= $this->model;
		$gallery	= $this->galleryService->getById( $cid );

		if( isset( $gallery ) && ( $this->direct || $gallery->belongsTo( $model->modelContent ) ) ) {

			$modelFile = $this->modelFileService->getFirstByParentModelId( $gallery->id, CoreGlobal::TYPE_GALLERY, $fid );

			if( isset( $modelFile ) && $modelFile->isParentValid( $gallery->id, CoreGlobal::TYPE_GALLERY ) ) {

				$file = $modelFile->model;

				$data = [
					'mid' => $modelFile->id, 'fid' => $file->id,
					'name' => $file->name, 'extension' => $file->extension,
					'title' => $file->title, 'caption' => $file->caption,
					'altText' => $file->altText, 'link' => $file->link, 'description' => $file->description,
					'url' => $file->getFileUrl()
				];

				if( $file->type == 'image' ) {

					$data[ 'mediumUrl' ]	= $file->getMediumUrl();
					$data[ 'thumbUrl' ]		= $file->getThumbUrl();
				}

				// Trigger Ajax Success
				return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
			}
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
186923
public function getCommentOffset($cid)
    {
        $this->getRepository()->getStore()->execute('set @i = 0');
        $query = clone $this->comments->getQuery();

        return $query->where('@col(id) < '.(int) $cid)->fetchValue('MAX(@i := @i + 1)');
    }
302581
public function loadById($pId)
    {
        if (! $pId instanceof Id) {
            $id = new Id($pId);
        } else {
            $id = $pId;
        }

        return $this->_loadByAttribute(static::IDFIELD, $id->getOrig());
    }
146181
public function actionForum($cid = null, $id = null, $slug = null, $toggle = null)
    {
        $filters = Yii::$app->session->get('forum-filters');
        if (in_array(strtolower($toggle), ['new', 'edit', 'hot', 'pin', 'lock', 'all'])) {
            if (strtolower($toggle) == 'all') {
                $filters = null;
            } else {
                $filters[strtolower($toggle)] = empty($filters[strtolower($toggle)]) || $filters[strtolower($toggle)] == 0 ? 1 : 0;
            }
            Yii::$app->session->set('forum-filters', $filters);
            return $this->redirect([
                'forum/forum',
                'cid' => $cid,
                'id' => $id,
                'slug' => $slug
            ]);
        }

        $forum = Forum::verify($cid, $id, $slug, $this->module->user->isGuest);
        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']);
        }

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

        return $this->render('forum', [
            'model' => $forum,
            'filters' => $filters
        ]);
    }
1282850
public static function setFdToCoId(int $fd)
    {
        $cid = self::getCoroutineId();

        self::$map[$cid] = $fd;
    }
280549
public static function getByID($fID)
    {
        return $fID ? Application::getFacadeApplication()->make(EntityManagerInterface::class)->find(FileEntity::class, $fID) : null;
    }
599846
public function getAllThreadIdsForUser($uid) {
    $query = 'SELECT DISTINCT(thread.id), MAX(thread.updated) ' .
      'FROM {private_message_threads} AS thread ' .
      'JOIN {private_message_thread__members} AS member ' .
      'ON member.entity_id = thread.id AND member.members_target_id = :uid ' .
      'JOIN {private_message_thread__private_messages} AS thread_messages ' .
      'ON thread_messages.entity_id = thread.id ' .
      'JOIN {private_messages} AS messages ' .
      'ON messages.id = thread_messages.private_messages_target_id ' .
      'JOIN {private_message_thread__last_delete_time} AS thread_delete_time ' .
      'ON thread_delete_time.entity_id = thread.id ' .
      'JOIN {pm_thread_delete_time} as owner_delete_time ' .
      'ON owner_delete_time.id = thread_delete_time.last_delete_time_target_id AND owner_delete_time.owner = :uid ' .
      'WHERE owner_delete_time.delete_time <= messages.created ';
    $vars = [':uid' => $uid];

    $query .= 'GROUP BY thread.id ORDER BY MAX(thread.updated) DESC, thread.id';

    $thread_ids = $this->database->query(
      $query,
      $vars
    )->fetchCol();

    return is_array($thread_ids) ? $thread_ids : [];
  }
1137300
public function clientList($cid = null, $cldbid = null, $resolve = FALSE)
  {
    return $this->getParent()->channelGroupClientList($this->getId(), $cid, $cldbid, $resolve);
  }
896628
public function channelPermList($cid, $permsid = FALSE)
  {
    return $this->execute("channelpermlist", array("cid" => $cid, $permsid ? "-permsid" : null))->toAssocArray($permsid ? "permsid" : "permid");
  }
1796
public static function findPublishedByPid($pid)
    {
        $t = static::getTableAlias();
        $columns = ["$t.pid=?"];
        $values = [$pid];

        if (!BE_USER_LOGGED_IN) {
            $columns[] = "$t.published=?";
            $values[] = 1;
        }

        return static::findBy($columns, $values, ['order' => "$t.sorting"]);
    }
1063654
public function actionDeletepost($cid = null, $fid = null, $tid = null, $pid = null)
    {
        $post = Post::verify($cid, $fid, $tid, $pid);
        if (empty($post)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        if ($post->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $post->thread])) {
            $this->info(Yii::t('podium/flash', 'This thread is locked.'));
            return $this->redirect([
                'forum/thread',
                'cid' => $post->forum->category->id,
                'fid' => $post->forum->id,
                'id' => $post->thread->id,
                'slug' => $post->thread->slug
            ]);
        }

        if (!User::can(Rbac::PERM_DELETE_OWN_POST, ['post' => $post]) && !User::can(Rbac::PERM_DELETE_POST, ['item' => $post])) {
            $this->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->redirect(['forum/index']);
        }

        $postData = Yii::$app->request->post('post');
        if ($postData) {
            if ($postData != $post->id) {
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the post.'));
            } else {
                if ($post->podiumDelete()) {
                    $this->success(Yii::t('podium/flash', 'Post has been deleted.'));
                    if (Thread::find()->where(['id' => $post->thread->id])->exists()) {
                        return $this->redirect([
                            'forum/forum',
                            'cid' => $post->forum->category->id,
                            'id' => $post->forum->id,
                            'slug' => $post->forum->slug
                        ]);
                    }
                    return $this->redirect([
                        'forum/thread',
                        'cid' => $post->forum->category->id,
                        'fid' => $post->forum->id,
                        'id' => $post->thread->id,
                        'slug' => $post->thread->slug
                    ]);
                }
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the post.'));
            }
        }
        return $this->render('deletepost', ['model' => $post]);
    }
893214
public function detailFunctionaryAction(string $aID, string $fID)
    {
        $this->checkStaticTemplateIsIncluded();
        $this->checkSettings();

        $this->slotExtendedAssignMultiple([
            self::VIEW_VARIABLE_ASSOCIATION_ID => $aID,
            self::VIEW_VARIABLE_FUNCTIONARY_ID => $fID
        ], __CLASS__, __FUNCTION__);

        return $this->view->render();
    }
850048
public function my_getUidInfo($uid)
    {
        $node_name = $this->searchUid($uid);
        if ($node_name) {
            if (!isset($this->client[$node_name])) return null;
            $token = $this->client[$node_name]->getUidInfo($uid);
            $fdInfo = $this->client[$node_name]->getTokenResult($token);
            return $fdInfo;
        }
        return null;
    }