/**
  * Initialize the fixture.
  */
 protected function setUp()
 {
     parent::setUp();
     // demo article
     $sId = $this->getTestConfig()->getShopEdition() == 'EE' ? '2275' : '2077';
     $sNewId = oxUtilsObject::getInstance()->generateUId();
     $this->oArticle = oxNew('oxArticle');
     $this->oArticle->disableLazyLoading();
     $this->oArticle->Load($sId);
     // making copy
     $this->oArticle->setId($sNewId);
     $this->oArticle->oxarticles__oxweight = new oxField(10, oxField::T_RAW);
     $this->oArticle->oxarticles__oxstock = new oxField(100, oxField::T_RAW);
     $this->oArticle->oxarticles__oxprice = new oxField(19, oxField::T_RAW);
     $this->oArticle->oxarticles__oxstockflag = new oxField(2, oxField::T_RAW);
     $this->oArticle->save();
     // demo category
     $sId = $this->getTestConfig()->getShopEdition() == 'EE' ? '30e44ab82c03c3848.49471214' : '8a142c3e4143562a5.46426637';
     $sNewId = oxUtilsObject::getInstance()->generateUId();
     $this->oCategory = oxNew('oxBase');
     $this->oCategory->Init('oxcategories');
     $this->oCategory->Load($sId);
     // making copy
     $this->oCategory->setId($sNewId);
     $this->oCategory->save();
     // assigning article to category
     $oO2Group = oxNew('oxobject2category');
     $oO2Group->oxobject2category__oxshopid = new oxField($this->getConfig()->getShopId(), oxField::T_RAW);
     $oO2Group->oxobject2category__oxobjectid = new oxField($this->oArticle->getId(), oxField::T_RAW);
     $oO2Group->oxobject2category__oxcatnid = new oxField($this->oCategory->getId(), oxField::T_RAW);
     $oO2Group->save();
     $this->dDefaultVAT = $this->getConfig()->getConfigParam('dDefaultVAT');
     $this->getConfig()->setConfigParam('dDefaultVAT', '99');
 }
Example #2
0
 /**
  * Return export file name
  *
  * @return string
  */
 protected function _getExportFileName()
 {
     $sSessionFileName = oxRegistry::getSession()->getVariable("sExportFileName");
     if (!$sSessionFileName) {
         $sSessionFileName = md5($this->getSession()->getId() . oxUtilsObject::getInstance()->generateUId());
         oxRegistry::getSession()->setVariable("sExportFileName", $sSessionFileName);
     }
     return $sSessionFileName;
 }
Example #3
0
 /**
  * return the ID of active resevations user basket
  *
  * @return string
  */
 protected function _getReservationsId()
 {
     $sId = oxRegistry::getSession()->getVariable('basketReservationToken');
     if (!$sId) {
         $sId = oxUtilsObject::getInstance()->generateUId();
         oxRegistry::getSession()->setVariable('basketReservationToken', $sId);
     }
     return $sId;
 }
 /**
  * Adds theme config value
  *
  * @param string $sShopId        shop id
  * @param string $sThemeName     theme name
  * @param string $sVarName       name
  * @param string $sVarType       type
  * @param string $sVarValue      value
  * @param string $sVarGroup      group
  * @param string $sVarConstrains constrains
  * @param string $iVarPos        position
  */
 protected static function _addThemeConfig($sShopId, $sThemeName, $sVarName, $sVarType, $sVarValue, $sVarGroup, $sVarConstrains, $iVarPos)
 {
     $sOxId = oxUtilsObject::getInstance()->generateUID();
     $sThemeName = 'theme:' . $sThemeName;
     $sConfigSQL = 'INSERT INTO `oxconfig` (`OXID`, `OXSHOPID`, `OXMODULE`, `OXVARNAME`, `OXVARTYPE`, `OXVARVALUE`) VALUES ( ?, ?, ?, ?, ?, ' . $sVarValue . ' )';
     oxDb::getDb()->execute($sConfigSQL, array($sOxId, $sShopId, $sThemeName, $sVarName, $sVarType));
     if (!empty($sVarGroup)) {
         $sConfigDisplaySQL = 'INSERT INTO `oxconfigdisplay` (`OXID`, `OXCFGMODULE`, `OXCFGVARNAME`, `OXGROUPING`, `OXVARCONSTRAINT`, `OXPOS`) VALUES ( ?, ?, ?, ?, ?, ? )';
         oxDb::getDb()->execute($sConfigDisplaySQL, array($sOxId, $sThemeName, $sVarName, $sVarGroup, $sVarConstrains, $iVarPos));
     }
 }
 /**
  * Resets template, language and menu xml cache
  */
 public function resetCache()
 {
     $aTemplates = $this->getModule()->getTemplates();
     $oUtils = oxRegistry::getUtils();
     $oUtils->resetTemplateCache($aTemplates);
     $oUtils->resetLanguageCache();
     $oUtils->resetMenuCache();
     $oUtilsObject = oxUtilsObject::getInstance();
     $oUtilsObject->resetModuleVars();
     $this->_clearApcCache();
 }
Example #6
0
 /**
  * Loads order associated with current PayPal order
  *
  * @return bool
  */
 public function loadPayPalOrder()
 {
     $sOrderId = oxRegistry::getSession()->getVariable("sess_challenge");
     // if order is not created yet - generating it
     if ($sOrderId === null) {
         $sOrderId = oxUtilsObject::getInstance()->generateUID();
         $this->setId($sOrderId);
         $this->save();
         oxRegistry::getSession()->setVariable("sess_challenge", $sOrderId);
     }
     return $this->load($sOrderId);
 }
Example #7
0
 /**
  * Loads contents info, passes it to Smarty engine and
  * returns name of template file "content_main.tpl".
  *
  * @return string
  */
 public function render()
 {
     $myConfig = $this->getConfig();
     parent::render();
     $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
     // categorie tree
     $oCatTree = oxNew("oxCategoryList");
     $oCatTree->loadList();
     $oContent = oxNew("oxcontent");
     if ($soxId != "-1" && isset($soxId)) {
         // load object
         $oContent->loadInLang($this->_iEditLang, $soxId);
         $oOtherLang = $oContent->getAvailableInLangs();
         if (!isset($oOtherLang[$this->_iEditLang])) {
             // echo "language entry doesn't exist! using: ".key($oOtherLang);
             $oContent->loadInLang(key($oOtherLang), $soxId);
         }
         // remove already created languages
         $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
         if (count($aLang)) {
             $this->_aViewData["posslang"] = $aLang;
         }
         foreach ($oOtherLang as $id => $language) {
             $oLang = new stdClass();
             $oLang->sLangDesc = $language;
             $oLang->selected = $id == $this->_iEditLang;
             $this->_aViewData["otherlang"][$id] = clone $oLang;
         }
         // mark selected
         if ($oContent->oxcontents__oxcatid->value && isset($oCatTree[$oContent->oxcontents__oxcatid->value])) {
             $oCatTree[$oContent->oxcontents__oxcatid->value]->selected = 1;
         }
     } else {
         // create ident to make life easier
         $sUId = oxUtilsObject::getInstance()->generateUId();
         $oContent->oxcontents__oxloadid = new oxField($sUId);
     }
     $this->_aViewData["edit"] = $oContent;
     $this->_aViewData["link"] = "[{ oxgetseourl ident="" . $oContent->oxcontents__oxloadid->value . "" type="oxcontent" }]";
     $this->_aViewData["cattree"] = $oCatTree;
     // generate editor
     $sCSS = "content.tpl.css";
     if ($oContent->oxcontents__oxsnippet->value == '1') {
         $sCSS = null;
     }
     $this->_aViewData["editor"] = $this->_generateTextEditor("100%", 300, $oContent, "oxcontents__oxcontent", $sCSS);
     $this->_aViewData["afolder"] = $myConfig->getConfigParam('aCMSfolder');
     return "content_main.tpl";
 }
 /**
  * Returns text hash
  *
  * @param string $sText User supplie text
  *
  * @return string
  */
 public function getHash($sText = null)
 {
     // inserting captcha record
     $iTime = time() + $this->_iTimeout;
     $sTextHash = $this->getTextHash($sText);
     // if session is started - storing captcha info here
     if ($this->getSession()->isSessionStarted()) {
         $sHash = oxUtilsObject::getInstance()->generateUID();
         oxSession::setVar("aCaptchaHash", array($sHash => array($sTextHash => $iTime)));
     } else {
         $sQ = "insert into oxcaptcha ( oxhash, oxtime ) values ( '{$sTextHash}', '{$iTime}' )";
         oxDb::getDb()->execute($sQ);
         $sHash = oxDb::getDb()->getOne("select LAST_INSERT_ID()");
     }
     return $sHash;
 }
 /**
  * Generates and saves vouchers. Returns number of saved records
  *
  * @param int $iCnt voucher counter offset
  *
  * @return int saved record count
  */
 public function generateVoucher($iCnt)
 {
     $iAmount = abs((int) oxRegistry::getSession()->getVariable("voucherAmount"));
     // creating new vouchers
     if ($iCnt < $iAmount && ($oVoucherSerie = $this->_getVoucherSerie())) {
         if (!$this->_iGenerated) {
             $this->_iGenerated = $iCnt;
         }
         $blRandomNr = (bool) oxRegistry::getSession()->getVariable("randomVoucherNr");
         $sVoucherNr = $blRandomNr ? oxUtilsObject::getInstance()->generateUID() : oxRegistry::getSession()->getVariable("voucherNr");
         $oNewVoucher = oxNew("oxvoucher");
         $oNewVoucher->oxvouchers__oxvoucherserieid = new oxField($oVoucherSerie->getId());
         $oNewVoucher->oxvouchers__oxvouchernr = new oxField($sVoucherNr);
         $oNewVoucher->save();
         $this->_iGenerated++;
     }
     return $this->_iGenerated;
 }
 /**
  * Add article to recommendation list
  *
  * @param string $sOXID Object ID
  * @param string $sDesc recommended article description
  *
  * @return bool
  */
 public function addArticle($sOXID, $sDesc)
 {
     $blAdd = false;
     if ($sOXID) {
         $oDb = oxDb::getDb();
         if (!$oDb->getOne("select oxid from oxobject2list where oxobjectid=" . $oDb->quote($sOXID) . " and oxlistid=" . $oDb->quote($this->getId()))) {
             $sUid = oxUtilsObject::getInstance()->generateUID();
             $sQ = "insert into oxobject2list ( oxid, oxobjectid, oxlistid, oxdesc ) values ( '{$sUid}', " . $oDb->quote($sOXID) . ", " . $oDb->quote($this->getId()) . ", " . $oDb->quote($sDesc) . " )";
             $blAdd = $oDb->execute($sQ);
         }
     }
     return $blAdd;
 }
Example #11
0
 /**
  * Initializes call back user.
  *
  * @param array $aPayPalData Callback user data.
  *
  * @return null
  */
 public function initializeUserForCallBackPayPalUser($aPayPalData)
 {
     // setting mode..
     $this->_blCallBackUser = true;
     // setting data..
     $aStreet = $this->_splitShipToStreetPayPalUser($aPayPalData['SHIPTOSTREET']);
     // setting object id as it is requested later while processing user object
     $this->setId(oxUtilsObject::getInstance()->generateUID());
     $this->oxuser__oxstreet = new oxField($aStreet['street']);
     $this->oxuser__oxstreetnr = new oxField($aStreet['streetnr']);
     $this->oxuser__oxcity = new oxField($aPayPalData['SHIPTOCITY']);
     $this->oxuser__oxzip = new oxField($aPayPalData['SHIPTOZIP']);
     $oCountry = oxNew('oxCountry');
     $sCountryId = $oCountry->getIdByCode($aPayPalData["SHIPTOCOUNTRY"]);
     $this->oxuser__oxcountryid = new oxField($sCountryId);
     $sStateId = '';
     if (isset($aPayPalData["SHIPTOSTATE"])) {
         $oState = oxNew('oxState');
         $sStateId = $oState->getIdByCode($aPayPalData["SHIPTOSTATE"], $sCountryId);
     }
     $this->oxuser__oxstateid = new oxField($sStateId);
 }
 /**
  * Executed after test is down
  *
  */
 protected function tearDown()
 {
     //TS2012-06-06
     //deprecated method call
     //overrideGetShopBasePath(null);
     oxTestsStaticCleaner::clean('oxSeoEncoder', '_instance');
     oxTestsStaticCleaner::clean('oxSeoEncoderArticle', '_instance');
     oxTestsStaticCleaner::clean('oxSeoEncoderCategory', '_instance');
     oxTestsStaticCleaner::clean('oxVatSelector', '_instance');
     oxTestsStaticCleaner::clean('oxDiscountList', '_instance');
     oxTestsStaticCleaner::clean('oxUtilsObject', '_aInstanceCache');
     oxTestsStaticCleaner::clean('oxArticle', '_aLoadedParents');
     modInstances::cleanup();
     oxTestModules::cleanUp();
     modOxid::globalCleanup();
     modDB::getInstance()->cleanup();
     $this->getSession()->cleanup();
     $this->getConfig()->cleanup();
     $_SERVER = $this->_aBackup['_SERVER'];
     $_POST = $this->_aBackup['_POST'];
     $_GET = $this->_aBackup['_GET'];
     $_SESSION = $this->_aBackup['_SESSION'];
     $_COOKIE = $this->_aBackup['_COOKIE'];
     $this->_resetRegistry();
     oxUtilsObject::resetClassInstances();
     oxUtilsObject::resetModuleVars();
     parent::tearDown();
 }
 /**
  * insert test user
  */
 private function insertUser()
 {
     $this->testUserId = substr_replace(oxUtilsObject::getInstance()->generateUId(), '_', 0, 1);
     $user = oxNew('oxUser');
     $user->setId($this->testUserId);
     $user->oxuser__oxactive = new oxField('1', oxField::T_RAW);
     $user->oxuser__oxrights = new oxField('user', oxField::T_RAW);
     $user->oxuser__oxshopid = new oxField('oxbaseshop', oxField::T_RAW);
     $user->oxuser__oxusername = new oxField('*****@*****.**', oxField::T_RAW);
     $user->oxuser__oxpassword = new oxField('c630e7f6dd47f9ad60ece4492468149bfed3da3429940181464baae99941d0ffa5562' . 'aaecd01eab71c4d886e5467c5fc4dd24a45819e125501f030f61b624d7d', oxField::T_RAW);
     //password is asdfasdf
     $user->oxuser__oxpasssalt = new oxField('3ddda7c412dbd57325210968cd31ba86', oxField::T_RAW);
     $user->oxuser__oxcustnr = new oxField('666', oxField::T_RAW);
     $user->oxuser__oxfname = new oxField('Bla', oxField::T_RAW);
     $user->oxuser__oxlname = new oxField('Foo', oxField::T_RAW);
     $user->oxuser__oxstreet = new oxField('blafoostreet', oxField::T_RAW);
     $user->oxuser__oxstreetnr = new oxField('123', oxField::T_RAW);
     $user->oxuser__oxcity = new oxField('Hamburg', oxField::T_RAW);
     $user->oxuser__oxcountryid = new oxField('a7c40f631fc920687.20179984', oxField::T_RAW);
     $user->oxuser__oxzip = new oxField('22769', oxField::T_RAW);
     $user->oxuser__oxsal = new oxField('MR', oxField::T_RAW);
     $user->oxuser__oxactive = new oxField('1', oxField::T_RAW);
     $user->oxuser__oxboni = new oxField('1000', oxField::T_RAW);
     $user->oxuser__oxcreate = new oxField('2015-05-20 22:10:51', oxField::T_RAW);
     $user->oxuser__oxregister = new oxField('2015-05-20 22:10:51', oxField::T_RAW);
     $user->oxuser__oxboni = new oxField('1000', oxField::T_RAW);
     $user->save();
     $newId = substr_replace(oxUtilsObject::getInstance()->generateUId(), '_', 0, 1);
     $oDb = oxDb::getDb();
     $sQ = 'insert into `oxobject2delivery` (oxid, oxdeliveryid, oxobjectid, oxtype ) ' . " values ('{$newId}', 'oxidstandard', '" . $this->testUserId . "', 'oxdelsetu')";
     $oDb->execute($sQ);
 }
 /**
  * Adds article to category
  * Creates new list
  */
 public function addArticle()
 {
     $myConfig = $this->getConfig();
     $aArticles = $this->_getActionIds('oxarticles.oxid');
     $sCategoryID = oxRegistry::getConfig()->getRequestParameter('synchoxid');
     $sShopID = $myConfig->getShopId();
     $oDb = oxDb::getDb();
     $sArticleTable = $this->_getViewName('oxarticles');
     // adding
     if (oxRegistry::getConfig()->getRequestParameter('all')) {
         $aArticles = $this->_getAll($this->_addFilter("select {$sArticleTable}.oxid " . $this->_getQuery()));
     }
     if (is_array($aArticles)) {
         $sO2CView = $this->_getViewName('oxobject2category');
         $oNew = oxNew('oxobject2category');
         $myUtilsObject = oxUtilsObject::getInstance();
         $oActShop = $myConfig->getActiveShop();
         $sProdIds = "";
         foreach ($aArticles as $sAdd) {
             // check, if it's already in, then don't add it again
             $sSelect = "select 1 from {$sO2CView} as oxobject2category where oxobject2category.oxcatnid= " . $oDb->quote($sCategoryID) . " and oxobject2category.oxobjectid = " . $oDb->quote($sAdd) . "";
             if ($oDb->getOne($sSelect, false, false)) {
                 continue;
             }
             $oNew->oxobject2category__oxid = new oxField($oNew->setId(md5($sAdd . $sCategoryID . $sShopID)));
             $oNew->oxobject2category__oxobjectid = new oxField($sAdd);
             $oNew->oxobject2category__oxcatnid = new oxField($sCategoryID);
             $oNew->oxobject2category__oxtime = new oxField(time());
             $oNew->save();
             if ($sProdIds) {
                 $sProdIds .= ",";
             }
             $sProdIds .= $oDb->quote($sAdd);
         }
         // updating oxtime values
         $this->_updateOxTime($sProdIds);
         $this->resetArtSeoUrl($aArticles);
         $this->resetCounter("catArticle", $sCategoryID);
     }
 }
Example #15
0
 /**
  * Executes parent::render(), if basket is empty - redirects to main page
  * and exits the script (oxorder::validateOrder()). Loads and passes payment
  * info to template engine. Refreshes basket articles info by additionally loading
  * each article object (oxorder::getProdFromBasket()), adds customer addressing/delivering
  * data (oxorder::getDelAddressInfo()) and delivery sets info (oxorder::getShipping()).
  * Returns name of template to render order::_sThisTemplate.
  *
  * @return string
  */
 public function render()
 {
     if ($this->getIsOrderStep()) {
         $oBasket = $this->getBasket();
         $myConfig = $this->getConfig();
         if ($myConfig->getConfigParam('blPsBasketReservationEnabled')) {
             $this->getSession()->getBasketReservations()->renewExpiration();
             if (!$oBasket || $oBasket && !$oBasket->getProductsCount()) {
                 oxUtils::getInstance()->redirect($myConfig->getShopHomeURL() . 'cl=basket', true, 302);
             }
         }
         // can we proceed with ordering ?
         $oUser = $this->getUser();
         if (!$oUser && ($oBasket && $oBasket->getProductsCount() > 0)) {
             oxUtils::getInstance()->redirect($myConfig->getShopHomeURL() . 'cl=basket', false, 302);
         } elseif (!$oBasket || !$oUser || $oBasket && !$oBasket->getProductsCount()) {
             oxUtils::getInstance()->redirect($myConfig->getShopHomeURL(), false, 302);
         }
         // payment is set ?
         if (!$this->getPayment()) {
             // redirecting to payment step on error ..
             oxUtils::getInstance()->redirect($myConfig->getShopCurrentURL() . '&cl=payment', true, 302);
         }
     }
     parent::render();
     // reload blocker
     if (!oxSession::getVar('sess_challenge')) {
         oxSession::setVar('sess_challenge', oxUtilsObject::getInstance()->generateUID());
     }
     return $this->_sThisTemplate;
 }
Example #16
0
 /**
  * Copying accessoires assignments
  *
  * @param string $sOldId Id from old article
  * @param string $sNewId Id from new article
  */
 protected function _copyAccessoires($sOldId, $sNewId)
 {
     $myUtilsObject = oxUtilsObject::getInstance();
     $oDb = oxDb::getDb();
     $sQ = "select oxobjectid from oxaccessoire2article where oxarticlenid= " . $oDb->quote($sOldId);
     $oRs = $oDb->execute($sQ);
     if ($oRs !== false && $oRs->recordCount() > 0) {
         while (!$oRs->EOF) {
             $sUId = $myUtilsObject->generateUid();
             $sId = $oRs->fields[0];
             $sSql = "insert into oxaccessoire2article (oxid, oxobjectid, oxarticlenid) " . "VALUES (" . $oDb->quote($sUId) . ", " . $oDb->quote($sId) . ", " . $oDb->quote($sNewId) . ") ";
             $oDb->execute($sSql);
             $oRs->moveNext();
         }
     }
 }
Example #17
0
 /**
  * add object to be returned from oxNew for a class
  *
  * @param string $sClassName
  * @param object $oObject
  *
  * @return null
  */
 public static function addModuleObject($sClassName, $oObject)
 {
     oxRegistry::set($sClassName, null);
     oxUtilsObject::setClassInstance($sClassName, $oObject);
     /*
     $sClassName = strtolower($sClassName);
     if (!self::$_oOrigOxUtilsObj) {
         self::$_oOrigOxUtilsObj = oxUtilsObject::getInstance();
         self::addFunction('oxUtilsObject', 'oxNew($class)', '{return oxTestModules::getModuleObject($class);}');
     }
     self::$_aModuleMap[$sClassName] = $oObject;
     */
 }
Example #18
0
 /**
  * Checks for external images and embeds them to email message if possible
  *
  * @param string $sImageDir       Images directory url
  * @param string $sImageDirNoSSL  Images directory url (no SSL)
  * @param string $sDynImageDir    Path to Dyn images
  * @param string $sAbsImageDir    Absolute path to images
  * @param string $sAbsDynImageDir Absolute path to Dyn images
  *
  * @return null
  */
 protected function _includeImages($sImageDir = null, $sImageDirNoSSL = null, $sDynImageDir = null, $sAbsImageDir = null, $sAbsDynImageDir = null)
 {
     $sBody = $this->getBody();
     if (preg_match_all('/<\\s*img\\s+[^>]*?src[\\s]*=[\\s]*[\'"]?([^[\'">]]+|.*?)?[\'">]/i', $sBody, $matches, PREG_SET_ORDER)) {
         $oFileUtils = oxUtilsFile::getInstance();
         $blReSetBody = false;
         // preparing imput
         $sDynImageDir = $oFileUtils->normalizeDir($sDynImageDir);
         $sImageDir = $oFileUtils->normalizeDir($sImageDir);
         $sImageDirNoSSL = $oFileUtils->normalizeDir($sImageDirNoSSL);
         if (is_array($matches) && count($matches)) {
             $aImageCache = array();
             $myUtils = oxUtils::getInstance();
             $myUtilsObject = oxUtilsObject::getInstance();
             $oImgGenerator = oxNew("oxDynImgGenerator");
             foreach ($matches as $aImage) {
                 $image = $aImage[1];
                 $sFileName = '';
                 if (strpos($image, $sDynImageDir) === 0) {
                     $sFileName = $oFileUtils->normalizeDir($sAbsDynImageDir) . str_replace($sDynImageDir, '', $image);
                 } elseif (strpos($image, $sImageDir) === 0) {
                     $sFileName = $oFileUtils->normalizeDir($sAbsImageDir) . str_replace($sImageDir, '', $image);
                 } elseif (strpos($image, $sImageDirNoSSL) === 0) {
                     $sFileName = $oFileUtils->normalizeDir($sAbsImageDir) . str_replace($sImageDirNoSSL, '', $image);
                 }
                 if ($sFileName && !@is_readable($sFileName)) {
                     $sFileName = $oImgGenerator->getImagePath($sFileName);
                 }
                 if ($sFileName) {
                     $sCId = '';
                     if (isset($aImageCache[$sFileName]) && $aImageCache[$sFileName]) {
                         $sCId = $aImageCache[$sFileName];
                     } else {
                         $sCId = $myUtilsObject->generateUID();
                         $sMIME = $myUtils->oxMimeContentType($sFileName);
                         if ($sMIME == 'image/jpeg' || $sMIME == 'image/gif' || $sMIME == 'image/png') {
                             if ($this->addEmbeddedImage($sFileName, $sCId, "image", "base64", $sMIME)) {
                                 $aImageCache[$sFileName] = $sCId;
                             } else {
                                 $sCId = '';
                             }
                         }
                     }
                     if ($sCId && $sCId == $aImageCache[$sFileName]) {
                         if ($sReplTag = str_replace($image, 'cid:' . $sCId, $aImage[0])) {
                             $sBody = str_replace($aImage[0], $sReplTag, $sBody);
                             $blReSetBody = true;
                         }
                     }
                 }
             }
         }
         if ($blReSetBody) {
             $this->setBody($sBody);
         }
     }
 }
 public function getActiveModuleChain($aClassChain)
 {
     return parent::getActiveModuleChain($aClassChain);
 }
Example #20
0
 /**
  * initialize new session challenge token
  */
 protected function _initNewSessionChallenge()
 {
     $this->setVariable('sess_stoken', sprintf('%X', crc32(oxUtilsObject::getInstance()->generateUID())));
 }
 * (at your option) any later version.
 *
 * OXID eShop Community Edition is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OXID eShop Community Edition.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @link      http://www.oxid-esales.com
 * @copyright (C) OXID eSales AG 2003-2014
 * @version   OXID eShop CE
 */
require_once 'oxerptype.php';
$sArticleClass = oxUtilsObject::getInstance()->getClassName('oxarticle');
eval("class oxErpArticle450_parent extends {$sArticleClass} {};");
/**
 * article class, used inside erp for 4.5.0 eShop version
 * hotfixe for article long description saving (bug#0002741)
 */
class oxErpArticle450 extends oxErpArticle450_parent
{
    /**
     * Sets article parameter
     *
     * @param string $sName  name of parameter to set
     * @param mixed  $sValue parameter value
     *
     * @return null
     */
Example #22
0
 /**
  * Sets module information variable. The variable is set statically and is not saved for future.
  *
  * @param string $sModuleVarName Configuration array name
  * @param array  $aValues        Module name values
  */
 public function setModuleVar($sModuleVarName, $aValues)
 {
     if (is_null($aValues)) {
         self::$_aModuleVars = null;
     } else {
         self::$_aModuleVars[$sModuleVarName] = $aValues;
     }
     $this->_setToCache($sModuleVarName, $aValues);
 }
 /**
  * Updates or adds new shop configuration parameters to DB.
  * Arrays must be passed not serialized, serialized values are supported just for backward compatibility.
  *
  * @param string $sVarType Variable Type
  * @param string $sVarName Variable name
  * @param mixed  $sVarVal  Variable value (can be string, integer or array)
  * @param string $sShopId  Shop ID, default is current shop
  * @param string $sModule  Module name (empty for base options)
  *
  * @return null
  */
 public function saveShopConfVar($sVarType, $sVarName, $sVarVal, $sShopId = null, $sModule = '')
 {
     switch ($sVarType) {
         case 'arr':
         case 'aarr':
             if (is_array($sVarVal)) {
                 $sValue = serialize($sVarVal);
             } else {
                 // Deprecated functionality
                 $sValue = $sVarVal;
                 $sVarVal = unserialize($sVarVal);
             }
             break;
         case 'bool':
             //config param
             $sVarVal = ($sVarVal == 'true' || $sVarVal) && $sVarVal && strcasecmp($sVarVal, "false");
             //db value
             $sValue = $sVarVal ? "1" : "";
             break;
         default:
             $sValue = $sVarVal;
             break;
     }
     if (!$sShopId) {
         $sShopId = $this->getShopId();
     }
     // Update value only for current shop
     if ($sShopId == $this->getShopId()) {
         $this->setConfigParam($sVarName, $sVarVal);
     }
     $oDb = oxDb::getDb(true);
     $sShopIdQuoted = $oDb->quote($sShopId);
     $sModuleQuoted = $oDb->quote($sModule);
     $sVarNameQuoted = $oDb->quote($sVarName);
     $sVarTypeQuoted = $oDb->quote($sVarType);
     $sVarValueQuoted = $oDb->quote($sValue);
     $sConfigKeyQuoted = $oDb->quote($this->getConfigParam('sConfigKey'));
     $sNewOXIDdQuoted = $oDb->quote(oxUtilsObject::getInstance()->generateUID());
     $sQ = "delete from oxconfig where oxshopid = {$sShopIdQuoted} and oxvarname = {$sVarNameQuoted} and oxmodule = {$sModuleQuoted}";
     $oDb->execute($sQ);
     $sQ = "insert into oxconfig (oxid, oxshopid, oxmodule, oxvarname, oxvartype, oxvarvalue)\n               values({$sNewOXIDdQuoted}, {$sShopIdQuoted}, {$sModuleQuoted}, {$sVarNameQuoted}, {$sVarTypeQuoted}, ENCODE( {$sVarValueQuoted}, {$sConfigKeyQuoted}) )";
     $oDb->execute($sQ);
 }
 /**
  * Test case for oepaypalexpresscheckoutdispatcher::getExpressCheckoutDetails()
  */
 public function testGetExpressCheckoutDetailsChangedOrderTotal()
 {
     $data = array('TOKEN' => 'EC-3KM09768MH0883231', 'BILLINGAGREEMENTACCEPTEDSTATUS' => '0', 'CHECKOUTSTATUS' => 'PaymentActionNotInitiated', 'TIMESTAMP' => '2016-02-15T14:12:43Z', 'CORRELATIONID' => '397ac1846e235', 'ACK' => 'Success', 'VERSION' => '84.0', 'BUILD' => '18308778', 'EMAIL' => '*****@*****.**', 'PAYERID' => 'XXXXXXXXYYYYY', 'PAYERSTATUS' => 'verified', 'FIRSTNAME' => 'Max', 'LASTNAME' => 'Muster', 'COUNTRYCODE' => 'DE', 'SHIPTONAME' => 'Erna Helvetia', 'SHIPTOSTREET' => 'Dorfstrasse 117', 'SHIPTOCITY' => 'Oberbuchsiten', 'SHIPTOZIP' => '4625', 'SHIPTOCOUNTRYCODE' => 'CH', 'SHIPTOCOUNTRYNAME' => 'Switzerland', 'ADDRESSSTATUS' => 'Unconfirmed', 'CURRENCYCODE' => 'EUR', 'AMT' => '29.90', 'ITEMAMT' => '29.90', 'SHIPPINGAMT' => '0.00', 'HANDLINGAMT' => '0.00', 'TAXAMT' => '0.00', 'CUSTOM' => 'Your order at PayPal Testshop in the amount of 29,90 EUR', 'DESC' => 'Your order at PayPal Testshop in the amount of 29,90 EUR', 'INSURANCEAMT' => '0.00', 'SHIPDISCAMT' => '0.00', 'INSURANCEOPTIONOFFERED' => 'false', 'L_NAME0' => 'Kuyichi leather belt JEVER', 'L_NUMBER0' => '3503', 'L_QTY0' => '1', 'L_TAXAMT0' => '0.00', 'L_AMT0' => '29.90', 'L_ITEMWEIGHTVALUE0' => '   0.00000', 'L_ITEMLENGTHVALUE0' => '   0.00000', 'L_ITEMWIDTHVALUE0' => '   0.00000', 'L_ITEMHEIGHTVALUE0' => '   0.00000', 'SHIPPINGCALCULATIONMODE' => 'FlatRate', 'INSURANCEOPTIONSELECTED' => 'false', 'SHIPPINGOPTIONISDEFAULT' => 'true', 'SHIPPINGOPTIONAMOUNT' => '0.00', 'SHIPPINGOPTIONNAME' => 'Standard', 'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR', 'PAYMENTREQUEST_0_AMT' => '29.90', 'PAYMENTREQUEST_0_ITEMAMT' => '29.90', 'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00', 'PAYMENTREQUEST_0_HANDLINGAMT' => '0.00', 'PAYMENTREQUEST_0_TAXAMT' => '0.00', 'PAYMENTREQUEST_0_CUSTOM' => 'Your order at PayPal Testshop in the amount of 29,90 EUR', 'PAYMENTREQUEST_0_DESC' => 'Your order at PayPal Testshop in the amount of 29,90 EUR', 'PAYMENTREQUEST_0_INSURANCEAMT' => '0.00', 'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00', 'PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED' => 'false', 'PAYMENTREQUEST_0_SHIPTONAME' => 'Erna Helvetia', 'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Dorfstrasse 117', 'PAYMENTREQUEST_0_SHIPTOCITY' => 'Oberbuchsiten', 'PAYMENTREQUEST_0_SHIPTOZIP' => '4625', 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'CH', 'PAYMENTREQUEST_0_SHIPTOCOUNTRYNAME' => 'Switzerland', 'PAYMENTREQUEST_0_ADDRESSSTATUS' => 'Unconfirmed', 'L_PAYMENTREQUEST_0_NAME0' => 'Kuyichi leather belt JEVER', 'L_PAYMENTREQUEST_0_NUMBER0' => '3503', 'L_PAYMENTREQUEST_0_QTY0' => '1', 'L_PAYMENTREQUEST_0_TAXAMT0' => '0.00', 'L_PAYMENTREQUEST_0_AMT0' => '29.90', 'L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE0' => '   0.00000', 'L_PAYMENTREQUEST_0_ITEMLENGTHVALUE0' => '   0.00000', 'L_PAYMENTREQUEST_0_ITEMWIDTHVALUE0' => '   0.00000', 'L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE0' => '   0.00000', 'PAYMENTREQUESTINFO_0_ERRORCODE' => '0');
     oxRegistry::set('oxVatSelector', new modOxVatSelector());
     $article = oxNew('oxarticle');
     $article->disableLazyLoading();
     $article->setId(substr_replace(oxUtilsObject::getInstance()->generateUId(), '_', 0, 1));
     $article->oxarticles__oxprice = new oxField('8.0', oxField::T_RAW);
     $article->oxarticles__oxartnum = new oxField('666-T-V', oxField::T_RAW);
     $article->oxarticles__oxactive = new oxField('1', oxField::T_RAW);
     $article->save();
     $basket = oxNew('oxBasket');
     $basket->addToBasket($article->getId(), 1);
     //8 EUR
     $this->getSession()->setBasket($basket);
     $details = oxNew('oePayPalResponseGetExpressCheckoutDetails');
     $details->setData($data);
     $payPalService = $this->getMock('oePayPalService', array('getExpressCheckoutDetails'));
     $payPalService->expects($this->any())->method('getExpressCheckoutDetails')->will($this->returnValue($details));
     $proxy = $this->getProxyClassName('oePayPalExpressCheckoutDispatcher');
     $dispatcher = $this->getMock($proxy, array('getPayPalCheckoutService', '_isPayPalPaymentValid'));
     $dispatcher->expects($this->any())->method('_isPayPalPaymentValid')->will($this->returnValue(true));
     $dispatcher->expects($this->any())->method('getPayPalCheckoutService')->will($this->returnValue($payPalService));
     $utilsView = $this->getMock('oxUtilsView', array('addErrorToDisplay'));
     $utilsView->expects($this->once())->method('addErrorToDisplay')->with($this->equalTo('OEPAYPAL_ORDER_TOTAL_HAS_CHANGED'));
     oxTestModules::addModuleObject('oxUtilsView', $utilsView);
     $this->assertSame('basket', $dispatcher->getExpressCheckoutDetails());
     $this->getSession()->setUser(null);
     // make sure we get the desired active user
     //proceed in normal checkout
     $basket = $this->getSession()->getBasket();
     //verify basket calculation results
     $basket->calculateBasket(true);
     $this->assertSame(6.72, $basket->getNettoSum());
     $this->assertSame(6.72, $basket->getBruttoSum());
     //no VAT for Switzerland
     //Change to german address, verify VAT for Germany is charged
     $this->changeUser();
     //during regular checkout, shop will work with a new instance of oxVatSelector
     //Make sure we use one with clean cache here
     oxRegistry::get('oxVatSelector')->cleanInstanceCache();
     $basket = $this->getSession()->getBasket();
     $basket->calculateBasket(true);
     $this->assertSame(6.72, $basket->getNettoSum());
     $this->assertSame(8.0, $basket->getBruttoSum());
 }
Example #25
0
 /**
  * Form id getter. This id used to prevent double guestbook, review entry submit
  *
  * @return string
  */
 public function getFormId()
 {
     if ($this->_sFormId === null) {
         $this->_sFormId = oxUtilsObject::getInstance()->generateUId();
         oxRegistry::getSession()->setVariable('sessionuformid', $this->_sFormId);
     }
     return $this->_sFormId;
 }
Example #26
0
/**
 * Creates and returns new object. If creation is not available, dies and outputs
 * error message.
 *
 * @param string $sClassName Name of class
 *
 * @throws oxSystemComponentException in case that class does not exists
 *
 * @return object
 */
function oxNew($sClassName)
{
    startProfile('oxNew');
    $aArgs = func_get_args();
    $oRes = call_user_func_array(array(oxUtilsObject::getInstance(), "oxNew"), $aArgs);
    stopProfile('oxNew');
    return $oRes;
}
 /**
  * Resests instance cache
  *
  * @param string $sClassName class name in the cache
  *
  * @return null;
  */
 public function resetInstanceCache($sClassName = null)
 {
     if ($sClassName && isset(self::$_aInstanceCache[$sClassName])) {
         unset(self::$_aInstanceCache[$sClassName]);
         return;
     }
     //looping due to possible memory "leak".
     if (is_array(self::$_aInstanceCache)) {
         foreach (self::$_aInstanceCache as $sKey => $oInstance) {
             unset(self::$_aInstanceCache[$sKey]);
         }
     }
     self::$_aInstanceCache = array();
 }
Example #28
0
/**
 * Creates and returns new object. If creation is not available, dies and outputs
 * error message.
 *
 * @param string $className Name of class
 * @param mixed ...$args constructor arguments
 * @throws oxSystemComponentException in case that class does not exists
 *
 * @return object
 */
function oxNew($className)
{
    startProfile('oxNew');
    $arguments = func_get_args();
    $object = call_user_func_array(array(oxUtilsObject::getInstance(), "oxNew"), $arguments);
    stopProfile('oxNew');
    return $object;
}
 /**
  * Assigns attribute to variant
  *
  * @param array $aMDVariants article ids with selectionlist values
  * @param array $aSelTitle   selection list titles
  *
  * @return null
  */
 public function assignVarToAttribute($aMDVariants, $aSelTitle)
 {
     $myLang = oxLang::getInstance();
     $aConfLanguages = $myLang->getLanguageIds();
     $sAttrId = $this->_getAttrId($aSelTitle[0]);
     if (!$sAttrId) {
         $sAttrId = $this->_createAttribute($aSelTitle);
     }
     foreach ($aMDVariants as $sVarId => $oValue) {
         if (strpos($sVarId, "mdvar_") === 0) {
             foreach ($oValue as $sId) {
                 //var_dump($sVarId, $oAttribute->oxattribute__oxid->value);
                 $sVarId = substr($sVarId, 6);
                 $oNewAssign = oxNew("oxbase");
                 $oNewAssign->init("oxobject2attribute");
                 $sNewId = oxUtilsObject::getInstance()->generateUID();
                 if ($oNewAssign->load($sId)) {
                     $oNewAssign->oxobject2attribute__oxobjectid = new oxField($sVarId);
                     $oNewAssign->setId($sNewId);
                     $oNewAssign->save();
                 }
             }
         } else {
             $oNewAssign = oxNew("oxi18n");
             $oNewAssign->setEnableMultilang(false);
             $oNewAssign->init("oxobject2attribute");
             $oNewAssign->oxobject2attribute__oxobjectid = new oxField($sVarId);
             $oNewAssign->oxobject2attribute__oxattrid = new oxField($sAttrId);
             foreach ($aConfLanguages as $sKey => $sLang) {
                 $sPrefix = $myLang->getLanguageTag($sKey);
                 $oNewAssign->{'oxobject2attribute__oxvalue' . $sPrefix} = new oxField($oValue[$sKey]->name);
             }
             $oNewAssign->save();
         }
     }
 }
Example #30
0
 /**
  * Add module settings to database.
  *
  * @param array  $aModuleSettings Module settings array
  * @param string $sModuleId       Module id
  */
 protected function _addModuleSettings($aModuleSettings, $sModuleId)
 {
     $this->_removeNotUsedSettings($aModuleSettings, $sModuleId);
     $oConfig = $this->getConfig();
     $sShopId = $oConfig->getShopId();
     $oDb = oxDb::getDb();
     if (is_array($aModuleSettings)) {
         foreach ($aModuleSettings as $aValue) {
             $sOxId = oxUtilsObject::getInstance()->generateUId();
             $sModule = 'module:' . $sModuleId;
             $sName = $aValue["name"];
             $sType = $aValue["type"];
             $sValue = is_null($oConfig->getConfigParam($sName)) ? $aValue["value"] : $oConfig->getConfigParam($sName);
             $sGroup = $aValue["group"];
             $sConstraints = "";
             if ($aValue["constraints"]) {
                 $sConstraints = $aValue["constraints"];
             } elseif ($aValue["constrains"]) {
                 $sConstraints = $aValue["constrains"];
             }
             $iPosition = $aValue["position"] ? $aValue["position"] : 1;
             $oConfig->setConfigParam($sName, $sValue);
             $oConfig->saveShopConfVar($sType, $sName, $sValue, $sShopId, $sModule);
             $sDeleteSql = "DELETE FROM `oxconfigdisplay` WHERE OXCFGMODULE=" . $oDb->quote($sModule) . " AND OXCFGVARNAME=" . $oDb->quote($sName);
             $sInsertSql = "INSERT INTO `oxconfigdisplay` (`OXID`, `OXCFGMODULE`, `OXCFGVARNAME`, `OXGROUPING`, `OXVARCONSTRAINT`, `OXPOS`) " . "VALUES ('{$sOxId}', " . $oDb->quote($sModule) . ", " . $oDb->quote($sName) . ", " . $oDb->quote($sGroup) . ", " . $oDb->quote($sConstraints) . ", " . $oDb->quote($iPosition) . ")";
             $oDb->execute($sDeleteSql);
             $oDb->execute($sInsertSql);
         }
     }
 }