Return a comment offset with id $cid from a list of comments of the commentable.

@param int $cid The comment id

@return int The offset of the comment
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)');
    }
609571
public function actionNewForum($cid = null)
    {
        $category = Category::find()->where(['id' => $cid])->limit(1)->one();
        if (empty($category)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find Category with this ID.'));
            return $this->redirect(['admin/categories']);
        }
        $model = new Forum();
        $model->category_id = $category->id;
        $model->visible = 1;
        $model->sort = 0;
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Log::info('Forum added', $model->id, __METHOD__);
            $this->success(Yii::t('podium/flash', 'New forum has been created.'));
            return $this->redirect(['admin/forums', 'cid' => $category->id]);
        }
        return $this->render('forum', [
            'model' => $model,
            'forums' => Forum::find()->where(['category_id' => $category->id])->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])->all(),
            'categories' => Category::find()->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])->all()
        ]);
    }
472674
public function actionDelete($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_DELETE_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']);
        }

        $postData = Yii::$app->request->post('thread');
        if ($postData) {
            if ($postData != $thread->id) {
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the thread.'));
            } else {
                if ($thread->podiumDelete()) {
                    $this->success(Yii::t('podium/flash', 'Thread has been deleted.'));
                    return $this->redirect([
                        'forum/forum',
                        'cid' => $thread->forum->category_id,
                        'id' => $thread->forum->id,
                        'slug' => $thread->forum->slug
                    ]);
                }
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the thread.'));
            }
        }
        return $this->render('delete', ['model' => $thread]);
    }
884245
public function actionGet( $id, $cid, $fid ) {

		// Find Model
		$model	= $this->modelService->getById( $cid );

		// Update/Render if exist
		if( isset( $model ) ) {

			$file = $model->image;

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

			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 ), $errors );
	}
721341
public function get(string $id): ?\BearCMS\Internal\Data2\CommentsThread
    {
        $data = Internal\Data::getValue('bearcms/comments/thread/' . md5($id) . '.json');
        if ($data !== null) {
            return $this->makeCommentsThreadPostFromRawData($data);
        }
        return null;
    }
770265
public function getComments($ip = null)
    {
        $app = App::getInstance();

        $comments = (new CommentManager())
            ->filter("article = %i", array($this->getId()))
            ->filter("active = 1")
            ->filter("spam = 0 ")
            ->values();

        $comments = is_null($comments) ? array() : $comments;

        return $comments;
    }
1246566
public function Get($DiscussionID, $Limit, $Offset = 0) {
      $this->CommentQuery(TRUE, FALSE);
      $this->EventArguments['DiscussionID'] =& $DiscussionID;
      $this->EventArguments['Limit'] =& $Limit;
      $this->EventArguments['Offset'] =& $Offset;
      $this->FireEvent('BeforeGet');
      
      $Page = PageNumber($Offset, $Limit);
      $PageWhere = $this->PageWhere($DiscussionID, $Page, $Limit);
      
      if ($PageWhere) {
         $this->SQL
            ->Where('c.DiscussionID', $DiscussionID);
         
         $this->SQL->Where($PageWhere)->Limit($Limit + 10);
         $this->OrderBy($this->SQL);
      } else {
         // Do an inner-query to force late-loading of comments.
         $Sql2 = clone $this->SQL;
         $Sql2->Reset();
         $Sql2->Select('CommentID')
            ->From('Comment c')
            ->Where('c.DiscussionID', $DiscussionID, TRUE, FALSE)
            ->Limit($Limit, $Offset);
         $this->OrderBy($Sql2);
         $Select = $Sql2->GetSelect();
         
         $Px = $this->SQL->Database->DatabasePrefix;
         $this->SQL->Database->DatabasePrefix = '';
         
         $this->SQL->Join("($Select) c2", "c.CommentID = c2.CommentID");
         $this->SQL->Database->DatabasePrefix = $Px;
         
//         $this->SQL->Limit($Limit, $Offset);
      }
      
      $this->Where($this->SQL);

      $Result = $this->SQL->Get();
      
      Gdn::UserModel()->JoinUsers($Result, array('InsertUserID', 'UpdateUserID'));
      
      $this->SetCalculatedFields($Result);
      
      $this->EventArguments['Comments'] =& $Result;
      $this->FireEvent('AfterGet');
      
      $this->CachePageWhere($Result->Result(), $PageWhere, $DiscussionID, $Page, $Limit);
      
      return $Result;
   }
1112356
public static function CIDToLID( string $cid )
   {

      // If $cid is not defined by 2 characters in range a-zA-Z it returns FALSE
      if ( ! \preg_match( '~^[A-Za-z]{2}$~', $cid ) )
      {
          return false;
      }

      // Switch the CID to lower case
      $cidUpper = \strtoupper( $cid );

      // Find it
      foreach ( self::$LanguageCountries as $lid => $data )
      {
         // Return it if found
         if ( \in_array( $cidUpper, $data ) )
         {
            return $lid;
         }
      }

      // Return false if not found
      return false;

   }
171301
public function get_params($cid) {
        global $DB;
        $params = array();

        $records = $DB->get_records('badge_criteria_param', array('critid' => $cid));
        foreach ($records as $rec) {
            $arr = explode('_', $rec->name);
            $params[$arr[1]][$arr[0]] = $rec->value;
        }

        return $params;
    }
1231625
public function actionForums($cid = null)
    {
        $model = Category::find()->where(['id' => $cid])->limit(1)->one();
        if (empty($model)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find Category with this ID.'));
            return $this->redirect(['admin/categories']);
        }
        return $this->render('forums', [
            'model' => $model,
            'categories' => Category::find()->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])->all(),
            'forums' => Forum::find()->where(['category_id' => $model->id])->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])->all()
        ]);
    }
384804
def get_comments(self, commentable_type, id_):
    
    return _get_request(_COM.format(c_api=_C_API_BEGINNING,
                                            ct=commentable_type,
                                            id_=id_,
                                            api=_API_VERSION,
                                            at=self.access_token))
215541
public function offsetGet($id)
    {
        $value = parent::offsetGet($id);

        if (is_object($value)) {
            $this->initialize($value);
        }

        return $value;
    }
1347785
public function actionReport($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 (User::can(Rbac::PERM_UPDATE_POST, ['item' => $post])) {
            $this->info(Yii::t('podium/flash', "You don't have to report this post since you are allowed to modify it."));
            return $this->redirect([
                'forum/edit',
                'cid' => $post->forum->category->id,
                'fid' => $post->forum->id,
                'tid' => $post->thread->id,
                'pid' => $post->id
            ]);
        }

        if ($post->author_id == User::loggedId()) {
            $this->info(Yii::t('podium/flash', 'You can not report your own post. Please contact the administrator or moderators if you have got any concerns regarding your post.'));
            return $this->redirect([
                'forum/thread',
                'cid' => $post->forum->category->id,
                'fid' => $post->forum->id,
                'id' => $post->thread->id,
                'slug' => $post->thread->slug
            ]);
        }

        $model = new Message();
        $model->scenario = 'report';
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            if ($model->podiumReport($post)) {
                $this->success(Yii::t('podium/flash', 'Thank you for your report. The moderation team will take a look at this post.'));
                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 notifying the moderation team. Contact administrator about this problem.'));
        }
        return $this->render('report', ['model' => $model, 'post' => $post]);
    }
690790
public static function formSelector($cid = 0) {
		if($cid == 0 && FE_USER_LOGGED_IN) {
			$user = \FrontendUser::getInstance();
			$cid = $user->course;
		}
		static::courseList();
		$course = static::$arrCourses[$cid];
		
		if($course['grade'] <= 10) {
			return $course['formSelector'];
		}
		else return 0;
		return false;
	}
451236
public function run( $cid ) {

		if( isset( $this->model ) ) {

			$modelLocation = $this->modelLocationService->getById( $cid );

			if( isset( $modelLocation ) && $modelLocation->isParentValid( $this->model->id, $this->parentType ) ) {

				$location = $modelLocation->model;

				$adata	= $location->getAttributeArray( $this->returnAttributes );
				$data	= [ 'cid' => $cid, 'location' => $adata, 'type' => $modelLocation->type ];

				// 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 ) );
	}
159412
public function GetIDData($CommentID) {
      $this->FireEvent('BeforeGetIDData');
      $this->CommentQuery(FALSE); // FALSE supresses FireEvent
      return $this->SQL
         ->Where('c.CommentID', $CommentID)
         ->Get();
   }
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;
    }