Exemplo n.º 1
0
 /**
  * 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');
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 /**
  * 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));
     }
 }
Exemplo n.º 5
0
 /**
  * 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();
 }
Exemplo n.º 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);
 }
Exemplo n.º 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";
 }
Exemplo n.º 8
0
 /**
  * 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;
 }
Exemplo n.º 9
0
 /**
  * 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;
 }
Exemplo n.º 10
0
 /**
  * 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;
 }
Exemplo n.º 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);
 }
 /**
  * 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);
 }
Exemplo n.º 13
0
 /**
  * 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);
     }
 }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
0
 * (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
     */
Exemplo n.º 16
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;
 }
Exemplo n.º 17
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;
}
Exemplo n.º 18
0
 /**
  * Initialize the fixture.
  *
  * @return null
  */
 protected function setUp()
 {
     parent::setUp();
     oxDb::getDb()->execute('delete from oxuserbaskets');
     oxDb::getDb()->execute('delete from oxuserbasketitems');
     $this->getConfig()->setConfigParam('blPerfNoBasketSaving', true);
     $sId = $this->getTestConfig()->getShopEdition() == 'EE' ? '2275' : '2077';
     $sNewId = oxUtilsObject::getInstance()->generateUId();
     oxTestModules::addFunction('oxarticle', 'getLink( $iLang = null, $blMain = false  )', '{return "htpp://link_for_article/".$this->getId();}');
     $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();
     // making category
     $sCatId = oxUtilsObject::getInstance()->generateUId();
     $this->oCategory = oxNew('oxCategory');
     $this->oCategory->setId($sCatId);
     $this->oCategory->oxcategories__oxparentid = new oxField('oxrootid', oxField::T_RAW);
     $this->oCategory->oxcategories__oxrootid = new oxField($sCatId, oxField::T_RAW);
     $this->oCategory->oxcategories__oxactive = new oxField(1, oxField::T_RAW);
     $this->oCategory->oxcategories__oxshopid = new oxField($this->getConfig()->getShopId(), oxField::T_RAW);
     $this->oCategory->oxcategories__oxtitle = new oxField('Test category 1', oxField::T_RAW);
     $this->oCategory->save();
     // assigning article to category
     $oArt2Cat = oxNew("oxobject2category");
     $oArt2Cat->oxobject2category__oxobjectid = new oxField($sNewId, oxField::T_RAW);
     $oArt2Cat->oxobject2category__oxcatnid = new oxField($sCatId, oxField::T_RAW);
     $oArt2Cat->save();
     // making select list
     $this->oSelList = oxNew('oxselectlist');
     $this->oSelList->oxselectlist__oxshopid = new oxField($this->getConfig()->getShopId(), oxField::T_RAW);
     $this->oSelList->oxselectlist__oxtitle = new oxField('Test title', oxField::T_RAW);
     $this->oSelList->oxselectlist__oxident = new oxField('Test ident', oxField::T_RAW);
     $this->oSelList->oxselectlist__oxvaldesc = new oxField('Test valdesc__@@', oxField::T_RAW);
     $this->oSelList->save();
     // assigning select list
     $oNewGroup = oxNew("oxBase");
     $oNewGroup->init("oxobject2selectlist");
     $oNewGroup->oxobject2selectlist__oxobjectid = new oxField($this->oArticle->getId(), oxField::T_RAW);
     $oNewGroup->oxobject2selectlist__oxselnid = new oxField($this->oSelList->getId(), oxField::T_RAW);
     $oNewGroup->oxobject2selectlist__oxsort = new oxField(0, oxField::T_RAW);
     $oNewGroup->save();
     // few discounts
     $this->aDiscounts[0] = oxNew("oxBase");
     $this->aDiscounts[0]->init("oxdiscount");
     $this->aDiscounts[0]->setId('testdiscount0');
     $this->aDiscounts[0]->oxdiscount__oxshopid = new oxField($this->getConfig()->getShopId(), oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxactive = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxtitle = new oxField('Test discount 0', oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxamount = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxamountto = new oxField(99999, oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxprice = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxpriceto = new oxField(99999, oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxaddsumtype = new oxField("itm", oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxaddsum = new oxField(50, oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxitmartid = new oxField('xxx', oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxitmamount = new oxField(2, oxField::T_RAW);
     $this->aDiscounts[0]->oxdiscount__oxitmmultiple = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[0]->save();
     $this->aDiscounts[1] = oxNew("oxBase");
     $this->aDiscounts[1]->init("oxdiscount");
     $this->aDiscounts[1]->setId('testdiscount1');
     $this->aDiscounts[1]->oxdiscount__oxshopid = new oxField($this->getConfig()->getShopId(), oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxactive = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxtitle = new oxField('Test discount 1', oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxamount = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxamountto = new oxField(99999, oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxprice = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxpriceto = new oxField(99999, oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxaddsumtype = new oxField("itm", oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxaddsum = new oxField(50, oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxitmartid = new oxField('xxx', oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxitmamount = new oxField(2, oxField::T_RAW);
     $this->aDiscounts[1]->oxdiscount__oxitmmultiple = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[1]->save();
     $this->aDiscounts[2] = oxNew("oxBase");
     $this->aDiscounts[2]->init("oxdiscount");
     $this->aDiscounts[2]->setId('testdiscount2');
     $this->aDiscounts[2]->oxdiscount__oxshopid = new oxField($this->getConfig()->getShopId(), oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxactive = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxtitle = new oxField('Test discount 2', oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxamount = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxamountto = new oxField(99999, oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxprice = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxpriceto = new oxField(99999, oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxaddsumtype = new oxField("itm", oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxaddsum = new oxField(50, oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxitmartid = new oxField('yyy', oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxitmamount = new oxField(2, oxField::T_RAW);
     $this->aDiscounts[2]->oxdiscount__oxitmmultiple = new oxField(1, oxField::T_RAW);
     $this->aDiscounts[2]->save();
     // assigning discounts
     $oDisc2Art = oxNew("oxBase");
     $oDisc2Art->init("oxobject2discount");
     $oDisc2Art->setId("_dsci1");
     $oDisc2Art->oxobject2discount__oxdiscountid = new oxField($this->aDiscounts[0]->getId(), oxField::T_RAW);
     $oDisc2Art->oxobject2discount__oxobjectid = new oxField($sNewId, oxField::T_RAW);
     $oDisc2Art->oxobject2discount__oxtype = new oxField('oxarticles', oxField::T_RAW);
     $oDisc2Art->save();
     $oDisc2Art = oxNew("oxBase");
     $oDisc2Art->init("oxobject2discount");
     $oDisc2Art->setId("_dsci2");
     $oDisc2Art->oxobject2discount__oxdiscountid = new oxField($this->aDiscounts[1]->getId(), oxField::T_RAW);
     $oDisc2Art->oxobject2discount__oxobjectid = new oxField($sNewId, oxField::T_RAW);
     $oDisc2Art->oxobject2discount__oxtype = new oxField('oxarticles', oxField::T_RAW);
     $oDisc2Art->save();
     // adding variant for article
     $sNewVarId = oxUtilsObject::getInstance()->generateUId();
     $this->oVariant = oxNew('oxArticle');
     $this->oVariant->disableLazyLoading();
     $this->oVariant->Load($sNewId);
     $this->oVariant->setId($sNewVarId);
     $this->oVariant->oxarticles__oxparentid = new oxField($sNewId, oxField::T_RAW);
     $this->oVariant->save();
     $this->oArticle = oxNew('oxArticle');
     $this->oArticle->disableLazyLoading();
     $this->oArticle->Load($sNewId);
     // inserting vouchers
     $this->oVoucherSerie = oxNew('oxvoucherserie');
     $this->oVoucherSerie->oxvoucherseries__oxshopid = new oxField($this->getConfig()->getShopId(), oxField::T_RAW);
     $this->oVoucherSerie->oxvoucherseries__oxserienr = new oxField('_xxx', oxField::T_RAW);
     $this->oVoucherSerie->oxvoucherseries__oxdiscount = new oxField(10.0, oxField::T_RAW);
     $this->oVoucherSerie->oxvoucherseries__oxdiscounttype = new oxField('absolute', oxField::T_RAW);
     $this->oVoucherSerie->oxvoucherseries__oxallowsameseries = new oxField(1, oxField::T_RAW);
     $this->oVoucherSerie->oxvoucherseries__oxallowotherseries = new oxField(1, oxField::T_RAW);
     $this->oVoucherSerie->oxvoucherseries__oxallowuseanother = new oxField(1, oxField::T_RAW);
     $this->oVoucherSerie->oxvoucherseries__oxminimumvalue = new oxField(10.0, oxField::T_RAW);
     $this->oVoucherSerie->save();
     for ($i = 0; $i < 4; $i++) {
         $oVoucher = oxNew('oxvoucher');
         $oVoucher->oxvouchers__oxreserved = new oxField(0, oxField::T_RAW);
         $oVoucher->oxvouchers__oxvouchernr = new oxField(md5(uniqid(rand(), true)), oxField::T_RAW);
         $oVoucher->oxvouchers__oxvoucherserieid = new oxField($this->oVoucherSerie->getId(), oxField::T_RAW);
         $oVoucher->save();
         $this->aVouchers[$oVoucher->oxvouchers__oxvouchernr->value] = $oVoucher;
     }
     // creating delivery address
     $this->oDelAdress = oxNew('oxBase');
     $this->oDelAdress->Init('oxaddress');
     $this->oDelAdress->oxaddress__oxcountryid = new oxField('_xxx', oxField::T_RAW);
     $this->oDelAdress->save();
     // creating card
     $this->oCard = oxNew('oxwrapping');
     $this->oCard->oxwrapping__oxtype = new oxField("CARD", oxField::T_RAW);
     $this->oCard->oxwrapping__oxname = new oxField("Test card", oxField::T_RAW);
     $this->oCard->oxwrapping__oxprice = new oxField(10, oxField::T_RAW);
     $this->oCard->save();
     // creating wrap paper
     $this->oWrap = oxNew('oxwrapping');
     $this->oWrap->oxwrapping__oxtype = new oxField("WRAP", oxField::T_RAW);
     $this->oWrap->oxwrapping__oxname = new oxField("Test card", oxField::T_RAW);
     $this->oWrap->oxwrapping__oxprice = new oxField(5, oxField::T_RAW);
     $this->oWrap->save();
     // enabling stock control
     $this->getConfig()->setConfigParam('blUseStock', true);
     $this->getConfig()->setConfigParam('blVariantParentBuyable', true);
     oxRegistry::get("oxDiscountList")->forceReload();
     $sName = $this->getName();
     if ($sName == 'testBasketCalculationWithSpecUseCaseDescribedAbove' || $sName == 'testBasketCalculationWithSpecUseCaseDescribedAboveJustDiscountIsAppliedByPrice' || $sName == 'testUpdateBasketTwoProductsWithSameSelectionList') {
         $this->_prepareDataForTestBasketCalculationWithSpecUseCaseDescribedAbove();
     }
     $this->blPerfLoadSelectLists = $this->getConfig()->getConfigParam('bl_perfLoadSelectLists');
     //empty oxuserbasket
     oxDb::getDb()->execute('delete from oxuserbaskets');
     oxDb::getDb()->execute('delete from oxuserbasketitems');
 }
Exemplo n.º 19
0
 /**
  * initialize new session challenge token
  */
 protected function _initNewSessionChallenge()
 {
     $this->setVariable('sess_stoken', sprintf('%X', crc32(oxUtilsObject::getInstance()->generateUID())));
 }
Exemplo n.º 20
0
 /**
  * Testing the correct (#2133)
  */
 public function testGetVoucherByNrUsedOrderId()
 {
     // Create new voucher
     $sVoucherNr = '_test_testGetVoucherByNrUsedOrderId';
     $oNewVoucher = oxNew("oxvoucher");
     $oNewVoucher->oxvouchers__oxvouchernr = new oxField($sVoucherNr);
     $oNewVoucher->oxvouchers__oxvoucherserieid = new oxField($this->_aSerieOxid[0]);
     $oNewVoucher->setId('_test_testGetVoucherByNrUsedOrderId');
     $oNewVoucher->save();
     $oNewVoucher = oxNew('oxvoucher');
     $oNewVoucher->getVoucherByNr($sVoucherNr);
     $oNewVoucher->oxvouchers__oxorderid = new oxField(oxUtilsObject::getInstance()->generateUID());
     $oNewVoucher->save();
     $oNewVoucher = oxNew('oxvoucher');
     try {
         $oNewVoucher->getVoucherByNr($sVoucherNr);
     } catch (oxVoucherException $oEx) {
         return;
         // OK
     }
     $this->fail();
 }
Exemplo n.º 21
0
 /**
  * Copies base shop config variables to current
  *
  * @param oxshop $shop new shop object
  */
 protected function _copyConfigVars($shop)
 {
     $config = $this->getConfig();
     $utilsObject = oxUtilsObject::getInstance();
     $db = oxDb::getDb();
     $nonCopyVars = $this->_getNonCopyConfigVars();
     $selectShopConfigurationQuery = "select oxvarname, oxvartype,\n            DECODE( oxvarvalue, " . $db->quote($config->getConfigParam('sConfigKey')) . ") as oxvarvalue, oxmodule\n            from oxconfig where oxshopid = '1'";
     $shopConfiguration = $db->execute($selectShopConfigurationQuery);
     if ($shopConfiguration != false && $shopConfiguration->recordCount() > 0) {
         while (!$shopConfiguration->EOF) {
             $configName = $shopConfiguration->fields[0];
             if (!in_array($configName, $nonCopyVars)) {
                 $newId = $utilsObject->generateUID();
                 $insertNewConfigQuery = "insert into oxconfig\n                        (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue, oxmodule) values ( '{$newId}', " . $db->quote($shop->getId()) . ", " . $db->quote($shopConfiguration->fields[0]) . ", " . $db->quote($shopConfiguration->fields[1]) . ",  ENCODE( " . $db->quote($shopConfiguration->fields[2]) . ", '" . $config->getConfigParam('sConfigKey') . "')" . ", " . $db->quote($shopConfiguration->fields[3]) . " )";
                 $db->execute($insertNewConfigQuery);
             }
             $shopConfiguration->moveNext();
         }
     }
     $inheritAll = $shop->oxshops__oxisinherited->value ? "true" : "false";
     $multiShopTables = $config->getConfigParam('aMultiShopTables');
     foreach ($multiShopTables as $multishopTable) {
         $config->saveShopConfVar("bool", 'blMallInherit_' . strtolower($multishopTable), $inheritAll, $shop->oxshops__oxid->value);
     }
 }
 /**
  * Returns pdf export state - can export or not
  *
  * @return bool
  */
 public function canExport()
 {
     $blCan = false;
     //V #529: check if PDF invoice module is active
     if (oxUtilsObject::getInstance()->isModuleActive('oxorder', 'myorder')) {
         $oDb = oxDb::getDb();
         $sOrderId = $this->getEditObjectId();
         $sTable = getViewName("oxorderarticles");
         $sQ = "select count(oxid) from {$sTable} where oxorderid = " . $oDb->quote($sOrderId) . " and oxstorno = 0";
         $blCan = (bool) $oDb->getOne($sQ);
     }
     return $blCan;
 }
Exemplo n.º 23
0
 /**
  * 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);
 }
Exemplo n.º 24
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;
}
Exemplo n.º 25
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);
         }
     }
 }
Exemplo n.º 26
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);
         }
     }
 }
Exemplo n.º 27
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();
         }
     }
 }
 /**
  * Adds article to chosen category
  *
  * @return null
  */
 public function addcat()
 {
     $myConfig = $this->getConfig();
     $oDb = oxDb::getDb();
     $aAddCat = $this->_getActionIds('oxcategories.oxid');
     $soxId = oxConfig::getParameter('synchoxid');
     $sShopID = $myConfig->getShopId();
     $sO2CView = $this->_getViewName('oxobject2category');
     // adding
     if (oxConfig::getParameter('all')) {
         $sCategoriesTable = $this->_getViewName('oxcategories');
         $aAddCat = $this->_getAll($this->_addFilter("select {$sCategoriesTable}.oxid " . $this->_getQuery()));
     }
     if (isset($aAddCat) && is_array($aAddCat)) {
         $oDb = oxDb::getDb();
         $oNew = oxNew('oxbase');
         $oNew->init('oxobject2category');
         $myUtilsObj = oxUtilsObject::getInstance();
         foreach ($aAddCat 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($sAdd) . " and oxobject2category.oxobjectid = " . $oDb->quote($soxId) . " ";
             if ($oDb->getOne($sSelect)) {
                 continue;
             }
             $oNew->setId($myUtilsObj->generateUID());
             $oNew->oxobject2category__oxobjectid = new oxField($soxId);
             $oNew->oxobject2category__oxcatnid = new oxField($sAdd);
             $oNew->oxobject2category__oxtime = new oxField(time());
             $oNew->save();
         }
         $this->_updateOxTime($soxId);
         $this->resetArtSeoUrl($soxId);
         $this->resetContentCache();
     }
 }
Exemplo n.º 29
0
 /**
  * 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();
         }
     }
 }
 /**
  * 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());
 }