/**
  * Returns oxInputValidator instance
  *
  * @return oxInputValidator
  */
 static function getInstance()
 {
     if (defined('OXID_PHP_UNIT')) {
         if (($oClassMod = modInstances::getMod(__CLASS__)) && is_object($oClassMod)) {
             return $oClassMod;
         } else {
             $inst = oxNew('oxInputValidator');
             modInstances::addMod(__CLASS__, $inst);
             return $inst;
         }
     }
     if (!isset(self::$_instance)) {
         // allow modules
         self::$_instance = oxNew('oxInputValidator');
     }
     return self::$_instance;
 }
示例#2
0
 /**
  * Checks if user passed VAT id is valid. Exception is thrown
  * if id is not valid
  *
  * @param array $aInvAddress user input array
  *
  * @depracated use oxInputValidator::checkVatId() instead
  *
  * @return null
  */
 protected function _checkVatId($aInvAddress)
 {
     oxInputValidator::getInstance()->checkVatId($this, $aInvAddress);
 }
 /**
  * Sets item amount and weight which depends on amount
  * ( oxbasketitem::dAmount, oxbasketitem::dWeight )
  *
  * @param double $dAmount    amount
  * @param bool   $blOverride overide current amoutn or not
  * @param string $sItemKey   item key
  *
  * @throws oxOutOfStockException, oxArticleInputException
  *
  * @return null
  */
 public function setAmount($dAmount, $blOverride = true, $sItemKey = null)
 {
     try {
         //validating amount
         $dAmount = oxInputValidator::getInstance()->validateBasketAmount($dAmount);
     } catch (oxArticleInputException $oEx) {
         $oEx->setArticleNr($this->getProductId());
         $oEx->setProductId($this->getProductId());
         // setting additional information for excp and then rethrowing
         throw $oEx;
     }
     $oArticle = $this->getArticle();
     // setting default
     $iOnStock = true;
     if ($blOverride) {
         $this->_dAmount = $dAmount;
     } else {
         $this->_dAmount += $dAmount;
     }
     // checking for stock
     if ($this->getStockCheckStatus() == true) {
         $dArtStockAmount = $this->getSession()->getBasket()->getArtStockInBasket($oArticle->getId(), $sItemKey);
         $iOnStock = $oArticle->checkForStock($this->_dAmount, $dArtStockAmount);
         if ($iOnStock !== true) {
             if ($iOnStock === false) {
                 // no stock !
                 $this->_dAmount = 0;
             } else {
                 // limited stock
                 $this->_dAmount = $iOnStock;
                 $blOverride = true;
             }
         }
     }
     // calculating general weight
     $this->_dWeight = $oArticle->oxarticles__oxweight->value * $this->_dAmount;
     if ($iOnStock !== true) {
         $oEx = oxNew('oxOutOfStockException');
         $oEx->setMessage('EXCEPTION_OUTOFSTOCK_OUTOFSTOCK');
         $oEx->setArticleNr($oArticle->oxarticles__oxartnum->value);
         $oEx->setProductId($oArticle->getProductId());
         $oEx->setRemainingAmount($this->_dAmount);
         throw $oEx;
     }
 }
 /**
  * Function checks if loaded payment is valid to current basket
  *
  * @param array  $aDynvalue    dynamical value (in this case oxidcreditcard and oxiddebitnote are checked only)
  * @param string $sShopId      id of current shop
  * @param oxuser $oUser        the current user
  * @param double $dBasketPrice the current basket price (oBasket->dprice)
  * @param string $sShipSetId   the current ship set
  *
  * @return bool true if payment is valid
  */
 public function isValidPayment($aDynvalue, $sShopId, $oUser, $dBasketPrice, $sShipSetId)
 {
     $myConfig = $this->getConfig();
     if ($this->oxpayments__oxid->value == 'oxempty') {
         // inactive or blOtherCountryOrder is off
         if (!$this->oxpayments__oxactive->value || !$myConfig->getConfigParam("blOtherCountryOrder")) {
             $this->_iPaymentError = -2;
             return false;
         }
         if (count(oxDeliverySetList::getInstance()->getDeliverySetList($oUser, $oUser->getActiveCountry()))) {
             $this->_iPaymentError = -3;
             return false;
         }
         return true;
     }
     if (!oxInputValidator::getInstance()->validatePaymentInputData($this->oxpayments__oxid->value, $aDynvalue)) {
         $this->_iPaymentError = 1;
         return false;
     }
     $oCur = $myConfig->getActShopCurrencyObject();
     $dBasketPrice = $dBasketPrice / $oCur->rate;
     if ($sShipSetId) {
         $aPaymentList = oxPaymentList::getInstance()->getPaymentList($sShipSetId, $dBasketPrice, $oUser);
         if (!array_key_exists($this->getId(), $aPaymentList)) {
             $this->_iPaymentError = -3;
             return false;
         }
     } else {
         $this->_iPaymentError = -2;
         return false;
     }
     return true;
 }
示例#5
0
 /**
  * Returns input field validation error array (if available)
  *
  * @return array
  */
 public function getFieldValidationErrors()
 {
     return oxInputValidator::getInstance()->getFieldValidationErrors();
 }