RoleModel::getApplicantCount PHP Method

getApplicantCount() public method

Get the current number of applicants waiting to be approved.
public getApplicantCount ( boolean $Force = false ) : integer
$Force boolean Whether or not to force a cache refresh.
return integer Returns the number of applicants or 0 if the registration method isn't set to approval.
    public function getApplicantCount($Force = false)
    {
        if (c('Garden.Registration.Method') != 'Approval') {
            return 0;
        }
        $CacheKey = 'Moderation.ApplicantCount';
        if ($Force) {
            Gdn::cache()->Remove($CacheKey);
        }
        $applicantRoleIDs = static::getDefaultRoles(self::TYPE_APPLICANT);
        $Count = Gdn::cache()->get($CacheKey);
        if ($Count === Gdn_Cache::CACHEOP_FAILURE) {
            $Count = Gdn::sql()->select('u.UserID', 'count', 'UserCount')->from('User u')->join('UserRole ur', 'u.UserID = ur.UserID')->where('ur.RoleID', $applicantRoleIDs)->where('u.Deleted', '0')->get()->value('UserCount', 0);
            Gdn::cache()->store($CacheKey, $Count, array(Gdn_Cache::FEATURE_EXPIRY => 300));
        }
        return $Count;
    }

Usage Example

コード例 #1
0
ファイル: class.usermodel.php プロジェクト: vanilla/vanilla
 /**
  * Get the current number of applicants waiting to be approved.
  *
  * @return int Returns the number of applicants or 0 if the registration method isn't set to approval.
  */
 public function getApplicantCount()
 {
     $roleModel = new RoleModel();
     $result = $roleModel->getApplicantCount();
     return $result;
 }
All Usage Examples Of RoleModel::getApplicantCount