Get a continent by it's code
@param  string $sCode The continents code
@return mixed         stdClass on success, false on failure
557709
public function getContinentByCode($sCode)
    {
        $aContinents = $this->getAll();

        return ! empty($aContinents[$sCode]) ? $aContinents[$sCode] : false;
    }
1361951
public function CreateNewVoucher($sCode = null)
    {
        if (is_null($sCode)) {
            $bCodeUnique = false;
            $dMaxTry = 15;
            $sCode = '';
            while (!$bCodeUnique && $dMaxTry > 0) {
                --$dMaxTry;
                $sCode = TdbShopVoucher::GenerateVoucherCode();
                $query = "SELECT * FROM `shop_voucher` WHERE `code` = '".MySqlLegacySupport::getInstance()->real_escape_string($sCode)."'";
                $tRes = MySqlLegacySupport::getInstance()->query($query);
                if (0 == MySqlLegacySupport::getInstance()->num_rows($tRes)) {
                    $bCodeUnique = true;
                }
            }
        }
        $aData = array('shop_voucher_series_id' => $this->id, 'code' => $sCode, 'datecreated' => date('Y-m-d H:i:s'));
        $oVoucher = TdbShopVoucher::GetNewInstance();
        $oVoucher->LoadFromRow($aData);
        $oVoucher->AllowEditByAll();
        $oVoucher->Save();

        return $oVoucher;
    }
731016
protected function getIdCountryFromCache($iso2Code, $iso3Code)
    {
        if ($iso2Code !== null && isset($this->idCountryCache[$iso2Code])) {
            return $this->idCountryCache[$iso2Code];
        }

        if ($iso3Code !== null && isset($this->idCountryCache[$iso3Code])) {
            return $this->idCountryCache[$iso3Code];
        }

        return false;
    }
655224
public static function get($code)
  {
    if (array_key_exists($code, self::$translations)) {
      return self::$translations[$code];
    }
    return sprintf('[%s]', $code);
  }
862947
public static function get_scorm_scoes($scormid, $organization = '') {
        global $DB;

        $params = self::validate_parameters(self::get_scorm_scoes_parameters(),
                                            array('scormid' => $scormid, 'organization' => $organization));

        $scoes = array();
        $warnings = array();

        $scorm = $DB->get_record('scorm', array('id' => $params['scormid']), '*', MUST_EXIST);
        $cm = get_coursemodule_from_instance('scorm', $scorm->id);

        $context = context_module::instance($cm->id);
        self::validate_context($context);

        // Check settings / permissions to view the SCORM.
        scorm_require_available($scorm, true, $context);

        if (!$scoes = scorm_get_scoes($scorm->id, $params['organization'])) {
            // Function scorm_get_scoes return false, not an empty array.
            $scoes = array();
        } else {
            $scoreturnstructure = self::get_scorm_scoes_returns();
            foreach ($scoes as $sco) {
                $extradata = array();
                foreach ($sco as $element => $value) {
                    // Check if the element is extra data (not a basic SCO element).
                    if (!isset($scoreturnstructure->keys['scoes']->content->keys[$element])) {
                        $extradata[] = array(
                            'element' => $element,
                            'value' => $value
                        );
                    }
                }
                $sco->extradata = $extradata;
            }
        }

        $result = array();
        $result['scoes'] = $scoes;
        $result['warnings'] = $warnings;
        return $result;
    }
256189
public static function getCodeFromTimezone($sTimezone)
    {
        $aAbbreviations = \DateTimeZone::listAbbreviations();
        foreach ($aAbbreviations as $sCode => $aValues) {
            foreach ($aValues as $aValue) {
                if ($aValue['timezone_id'] == $sTimezone) {
                    return strtoupper($sCode);
                }
            }
        }

        return false;
    }
393408
public function getStandardRate($countryCode)
    {
        $country = $this->getCountry($countryCode);
        if (!is_null($country)) {
            return $country->getStandardRate();
        }

        return null;
    }
559612
function getGeocode($address) {
        if(empty($address))
            return false;
        $_geocode = false;  
        if(($_geocode = $this->getCache($address)) === false) {
        	if(($_geocode = $this->geoGetCoords($address)) !== false) {
            	$this->putCache($address, $_geocode['lon'], $_geocode['lat']);
            }
        }
        return $_geocode;
    }
934335
public function get() {

		$v =& self::$_lPoolDataChange[$this->_sConfig][$this->_mID];

		if (!is_array($v)) {

			$o = $this->_coll();

			$aOrig = $o->findOne([static::$_mKey => $this->_mID]) ?: FALSE;

			$bNeedInit = !is_array($aOrig);
			if (!$bNeedInit) {
				unset($aOrig[static::$_mKey]);
			}

			self::$_lPoolData[$this->_sConfig][$this->_mID] = $aOrig;

			if ($bNeedInit) {
				$v = $this->_init();
			} else {
				$v = $aOrig;
			}

			$v = $this->_format($v);
		}

		return $v;
	}
323176
public function getAuthorizationCode($code)
    {
        $code = $this->getObjectByType('code_table',$code);

        return is_null($code) ? false : $code;
    }
20555
public static function findByCountryAndCode($country, $code)
    {
        $country = is_object($country) ? $country->id : $country;

        return ProvinceProxy::byCountry($country)
                            ->where('code', $code)
                            ->take(1)
                            ->get()
                            ->first();
    }
129575
public function getParkingRate($countryCode)
    {
        $country = $this->getCountry($countryCode);
        if (!is_null($country)) {
            return $country->getParkingRate();
        }

        return null;
    }
661054
public function getLocaleByCode($code)
    {
        $locales = $this->getLocales();
        if (array_key_exists($code, $locales)) {
            return $locales[$code];
        }
    }
962225
public function getMetadataForRegion($regionCode)
    {
        if (!$this->isValidRegionCode($regionCode)) {
            return null;
        }

        return $this->metadataSource->getMetadataForRegion($regionCode);
    }
48090
public function getCurrencyCode($sCurrencyCode)
    {
        $obCurrency = $this->obCurrencyList->where('code', $sCurrencyCode)->first();
        if (empty($obCurrency)) {
            return null;
        }

        return $obCurrency->code;
    }
417598
private function getCountryByCode($code)
    {
        // Check if country exist in cache.
        if (array_key_exists($code, $this->countries)) {
            return $this->countries[$code];
        }
        // Fetch country.
        $country = $this->manager->getRepository(static::$countryEntityName)->findOneBy(['code' => $code]);
        if (!$country) {
            throw new \Doctrine\ORM\EntityNotFoundException('code = ' . $code);
        }
        // Add country to cache.
        $this->countries[$code] = $country;

        return $country;
    }
1033183
public function mfaDeviceCodeValidate($iUserId, $sCode)
    {
        //  Get the user's secret
        $oSecret = $this->mfaDeviceSecretGet($iUserId);

        if (!$oSecret) {
            $this->setError('Invalid User');
            return false;
        }

        //  Has the code been used before?
        $oDb = Factory::service('Database');
        $oDb->where('secret_id', $oSecret->id);
        $oDb->where('code', $sCode);

        if ($oDb->count_all_results(NAILS_DB_PREFIX . 'user_auth_two_factor_device_code')) {
            $this->setError('Code has already been used.');
            return false;
        }

        //  Tidy up codes so that they only contain digits
        $sCode = preg_replace('/[^\d]/', '', $sCode);

        //  New instance of the authenticator
        $oGoogleAuth = new GoogleAuthenticator();
        $checkCode   = $oGoogleAuth->checkCode($oSecret->secret, $sCode);

        if ($checkCode) {

            //  Log the code so it can't be used again
            $oDb->set('secret_id', $oSecret->id);
            $oDb->set('code', $sCode);
            $oDb->set('used', 'NOW()', false);

            $oDb->insert(NAILS_DB_PREFIX . 'user_auth_two_factor_device_code');

            return true;

        } else {
            return false;
        }
    }