Form validation cal;back to validate currency selection

@param string $sCode the currency code

@return bool
@throws \Nails\Common\Exception\FactoryException
15773
public function _callbackValidCurrency($sCode)
    {
        $oFormValidation = Factory::service('FormValidation');
        $oFormValidation->set_message('_callbackValidCurrency', 'Invalid currency.');

        $oCurrency = Factory::service('Currency', 'nails/module-currency');
        $aEnabled  = $oCurrency->getAllEnabled();

        foreach ($aEnabled as $oCurrency) {
            if ($oCurrency->code === $sCode) {
                return true;
            }
        }

        return false;
    }
542141
public static function getByCode(string $code): ?Currency
    {
        $currencies = Currency::get();

        /** @var Currency $currency */
        $currency = $currencies->where("code", $code)->first();
        return $currency;
    }
169925
public static function checkCurrency($currency, $allowedCurrencies = null)
    {
        $currencies = self::$_defaultAllowedCurrencies;
        if (isset($allowedCurrencies) && is_array($allowedCurrencies)) {
            $currencies = $allowedCurrencies;
        }

        if ($currency == null || $currency == '') {
            throw new HpsInvalidRequestException(
                HpsExceptionCodes::MISSING_CURRENCY,
                'Currency cannot be none',
                'currency'
            );
        } else if (!in_array(strtolower($currency), $currencies)) {
            throw new HpsInvalidRequestException(
                HpsExceptionCodes::INVALID_CURRENCY,
                "'".strtolower($currency)."' is not a supported currency",
                'currency'
            );
        }
    }
501585
public function validate() {

		if ($this->getCurrency() === null) {
			throw new ValidationException("'currency' can't be null", 'currency', $this);
		}
		if ($this->getProduct() === null) {
			throw new ValidationException("'product' can't be null", 'product', $this);
		}
	}
1354563
public static function getValue($sCode, $sDefaultValue = null)
    {
        if (empty($sCode)) {
            return $sDefaultValue;
        }

        //Get settings object
        $obSettings = static::where('item', static::SETTINGS_CODE)->first();
        if (empty($obSettings)) {
            return static::get($sCode, $sDefaultValue);
        }

        $sValue = $obSettings->$sCode;
        if (empty($sValue)) {
            return $sDefaultValue;
        }

        return $sValue;
    }
669639
public function getIdByCode($sCode)
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        return $oDb->getOne("select oxid from oxcountry where oxisoalpha2 = " . $oDb->quote($sCode));
    }
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;
    }
1049409
protected function getCurrencyCodeAttribute()
    {
        if (empty($this->sActiveCurrency)) {
            return CurrencyHelper::instance()->getActiveCurrencyCode();
        }

        $sResult = CurrencyHelper::instance()->getCurrencyCode($this->sActiveCurrency);
        $this->sActiveCurrency = null;

        return $sResult;
    }
1032061
public function validateToken($sCode, $bGenerateNewPw)
    {
        if (empty($sCode)) {
            return false;
        }

        // --------------------------------------------------------------------------

        $oDb = Factory::service('Database');
        $oDb->select('id, group_id, forgotten_password_code');
        $oDb->like('forgotten_password_code', ':' . $sCode, 'before');
        $oResult = $oDb->get(NAILS_DB_PREFIX . 'user');

        // --------------------------------------------------------------------------

        if ($oResult->num_rows() != 1) {
            return false;
        }

        // --------------------------------------------------------------------------

        $oUser = $oResult->row();
        $aCode = explode(':', $oUser->forgotten_password_code);

        // --------------------------------------------------------------------------

        //  Check that the link is still valid
        if (time() > $aCode[0]) {

            return 'EXPIRED';

        } else {

            //  Valid hash and hasn't expired.
            $aOut            = [];
            $aOut['user_id'] = $oUser->id;

            //  Generate a new password?
            if ($bGenerateNewPw) {

                $aOut['password'] = $this->generate($oUser->group_id);

                if (empty($aOut['password'])) {
                    //  This should never happen, but just in case.
                    return false;
                }

                $oHash = $this->generateHash($oUser->group_id, $aOut['password']);

                if (!$oHash) {
                    //  Again, this should never happen, but just in case.
                    return false;
                }

                // --------------------------------------------------------------------------

                $aData['password']                = $oHash->password;
                $aData['password_md5']            = $oHash->password_md5;
                $aData['password_engine']         = $oHash->engine;
                $aData['salt']                    = $oHash->salt;
                $aData['temp_pw']                 = true;
                $aData['forgotten_password_code'] = null;

                $oDb->where('forgotten_password_code', $oUser->forgotten_password_code);
                $oDb->set($aData);
                $oDb->update(NAILS_DB_PREFIX . 'user');
            }
        }

        return $aOut;
    }
138109
public function getByCode($sCode)
    {
        $aLanguages = $this->getAll();
        return !empty($aLanguages[$sCode]) ? $aLanguages[$sCode] : false;
    }
893181
protected function getCurrency($currencyCode, $locale)
    {
        if (!isset($this->currencies[$currencyCode][$locale])) {
            try {
                $currency = $this->currencyRepository->get($currencyCode, $locale);
            } catch (UnknownCurrencyException $e) {
                // The requested currency was not found. Fall back
                // to a dummy object to show just the currency code.
                $currency = new Currency([
                   'currency_code' => $currencyCode,
                   'name' => $currencyCode,
                   'numeric_code' => '000',
                   'locale' => $locale,
                ]);
            }
            $this->currencies[$currencyCode][$locale] = $currency;
        }

        return $this->currencies[$currencyCode][$locale];
    }
1095359
public static function getCurrencySymbol($isocode) {
		return empty(self::$currencySymbols[$isocode])?$isocode:self::$currencySymbols[$isocode];
	}
1143595
public function validateCode($code)
    {
        $coupon = $this->_controller->getRepository()->find(array('code' => $code));

        if ($coupon && !$coupon->expired()) {
            $discount = $coupon->discount * 100;
            $this->setMessage(AnTranslator::sprintf('COM-SUBSCRIPTIONS-VALID-COUPON', $discount));
            return true;
        } else {
            $this->setMessage(AnTranslator::_('COM-SUBSCRIPTIONS-INVALID-COUPON'));
            return false;
        }
    }
1167903
public function validate(&$error = null)
    {
        if (!$this->isCountryCodeValid()) {
            $error = 'IBAN country code not valid or not supported';
        } elseif (!$this->isLengthValid()) {
            $error = 'IBAN length is invalid';
        } elseif (!$this->isFormatValid()) {
            $error = 'IBAN format is invalid';
        } elseif (!$this->isChecksumValid()) {
            $error = 'IBAN checksum is invalid';
        } else {
            $error = '';
            return true;
        }

        return false;
    }
751903
protected static function countryCurrencyFormatter($countryCode)
    {
        $localeCode = Locale::countryLocaleCode($countryCode);

        return new \NumberFormatter($localeCode, \NumberFormatter::CURRENCY);
    }
1360758
public function canDelete($code)
    {
        $code = strtoupper($code);

        if ($code == $this->getDefault()) {
            return false;
        }

        $currencies = $this->config->select('currencies', array());

        if (!isset($currencies[$code])) {
            return false;
        }

        $sql = 'SELECT NOT EXISTS (SELECT currency FROM orders WHERE currency=:code)
                AND NOT EXISTS (SELECT currency FROM price_rule WHERE currency=:code)
                AND NOT EXISTS (SELECT currency FROM product WHERE currency=:code)';

        return (bool) $this->db->fetchColumn($sql, array('code' => $code));
    }
500153
public function translate( $sCode, $blUseModulePrefix = true )
    {
        if ( $blUseModulePrefix ) {
            $sCode = 'PAYMORROW_' . $sCode;
        }

        return oxRegistry::getLang()->translateString( $sCode, oxRegistry::getLang()->getBaseLanguage(), false );
    }