/**
  * Saves main orders configuration parameters.
  *
  * @return string
  */
 public function save()
 {
     parent::save();
     $soxId = $this->getEditObjectId();
     $aParams = oxConfig::getParameter("editval");
     // shopid
     $sShopID = oxSession::getVar("actshop");
     $aParams['oxorder__oxshopid'] = $sShopID;
     $oOrder = oxNew("oxorder");
     if ($soxId != "-1") {
         $oOrder->load($soxId);
     } else {
         $aParams['oxorder__oxid'] = null;
     }
     $oOrder->assign($aParams);
     $aDynvalues = oxConfig::getParameter("dynvalue");
     if (isset($aDynvalues)) {
         // #411 Dodger
         $oPayment = oxNew("oxuserpayment");
         $oPayment->load($oOrder->oxorder__oxpaymentid->value);
         $oPayment->oxuserpayments__oxvalue->setValue(oxUtils::getInstance()->assignValuesToText($aDynvalues));
         $oPayment->save();
     }
     // keeps old delivery cost
     $oOrder->reloadDelivery(false);
     // keeps old discount
     $oOrder->reloadDiscount(false);
     $oOrder->recalculateOrder();
     // set oxid if inserted
     $this->setEditObjectId($oOrder->getId());
 }
 /**
  * Validates email
  * address. If email is wrong - returns false and exits. If email
  * address is OK - creates prcealarm object and saves it
  * (oxpricealarm::save()). Sends pricealarm notification mail
  * to shop owner.
  *
  * @return  bool    false on error
  */
 public function addme()
 {
     $myConfig = $this->getConfig();
     $myUtils = oxUtils::getInstance();
     //control captcha
     $sMac = oxConfig::getParameter('c_mac');
     $sMacHash = oxConfig::getParameter('c_mach');
     $oCaptcha = oxNew('oxCaptcha');
     if (!$oCaptcha->pass($sMac, $sMacHash)) {
         $this->_iPriceAlarmStatus = 2;
         return;
     }
     $aParams = oxConfig::getParameter('pa');
     if (!isset($aParams['email']) || !$myUtils->isValidEmail($aParams['email'])) {
         $this->_iPriceAlarmStatus = 0;
         return;
     }
     $oCur = $myConfig->getActShopCurrencyObject();
     // convert currency to default
     $dPrice = $myUtils->currency2Float($aParams['price']);
     $oAlarm = oxNew("oxpricealarm");
     $oAlarm->oxpricealarm__oxuserid = new oxField(oxSession::getVar('usr'));
     $oAlarm->oxpricealarm__oxemail = new oxField($aParams['email']);
     $oAlarm->oxpricealarm__oxartid = new oxField($aParams['aid']);
     $oAlarm->oxpricealarm__oxprice = new oxField($myUtils->fRound($dPrice, $oCur));
     $oAlarm->oxpricealarm__oxshopid = new oxField($myConfig->getShopId());
     $oAlarm->oxpricealarm__oxcurrency = new oxField($oCur->name);
     $oAlarm->oxpricealarm__oxlang = new oxField(oxLang::getInstance()->getBaseLanguage());
     $oAlarm->save();
     // Send Email
     $oEmail = oxNew('oxemail');
     $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification($aParams, $oAlarm);
 }
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * File: insert.oxid_newbasketitem.php
 * Type: string, html
 * Name: newbasketitem
 * Purpose: Used for tracking in econda, etracker etc.
 * -------------------------------------------------------------
 *
 * @param array  $params  params
 * @param Smarty &$smarty clever simulation of a method
 *
 * @return string
 */
function smarty_insert_oxid_newbasketitem($params, &$smarty)
{
    $myConfig = oxConfig::getInstance();
    $aTypes = array('0' => 'none', '1' => 'message', '2' => 'popup', '3' => 'basket');
    $iType = $myConfig->getConfigParam('iNewBasketItemMessage');
    // If corect type of message is expected
    if ($iType && $params['type'] && $params['type'] != $aTypes[$iType]) {
        return '';
    }
    //name of template file where is stored message text
    $sTemplate = $params['tpl'] ? $params['tpl'] : 'inc_newbasketitem.snippet.tpl';
    //allways render for ajaxstyle popup
    $blRender = $params['ajax'] && $iType == 2;
    //fetching article data
    $oNewItem = oxSession::getVar('_newitem');
    $oBasket = oxSession::getInstance()->getBasket();
    if ($oNewItem) {
        // loading article object here because on some system passing article by session couses problems
        $oNewItem->oArticle = oxNew('oxarticle');
        $oNewItem->oArticle->Load($oNewItem->sId);
        // passing variable to template with unique name
        $smarty->assign('_newitem', $oNewItem);
        // deleting article object data
        oxSession::deleteVar('_newitem');
        $blRender = true;
    }
    // returning generated message content
    if ($blRender) {
        return $smarty->fetch($sTemplate);
    }
}
示例#4
0
 protected function _getFileName()
 {
     $sFileName = '';
     if (oxSession::hasVar('debugPHP') && oxSession::getVar('debugPHP') !== true) {
         $sFileName = oxSession::getVar('debugPHP');
     }
     return $sFileName .= isAdmin() ? '_admin' : '_shop';
 }
 /**
  * log the given message
  *
  * @param string $message
  * @param string $debuginfo
  */
 public function log($message, $debuginfo)
 {
     if (oxConfig::getInstance()->getShopConfVar('PAYMILL_ACTIVATE_LOGGING')) {
         $logging = oxNew('paymill_logging');
         $logging->assign(array('identifier' => oxSession::getInstance()->getVar('paymill_identifier'), 'debug' => $debuginfo, 'message' => $message, 'date' => date('Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime())));
         $logging->save();
     }
 }
 /**
  * Performs full view update
  *
  * @return mixed
  */
 public function updateViews()
 {
     //preventing edit for anyone except malladmin
     if (oxSession::getVar("malladmin")) {
         oxDb::getInstance()->updateViews();
         $this->_aViewData["blViewSuccess"] = true;
     }
 }
 /**
  * return page errors array
  *
  * @return array
  */
 protected function _getErrors()
 {
     $aErrors = oxSession::getVar('Errors');
     if (null === $aErrors) {
         $aErrors = array();
     }
     return $aErrors;
 }
 /**
  * Creates shop object, passes shop data to Smarty engine and returns name of
  * template file "dyn_adbutler.tpl".
  *
  * @return string
  */
 public function render()
 {
     parent::render();
     $oShop = oxNew("oxshop");
     $oShop->load(oxSession::getVar("actshop"));
     $this->_aViewData["edit"] = $oShop;
     return "dyn_adbutler.tpl";
 }
 /**
  * Testing initiation of the received payment information.
  */
 public function testInit()
 {
     $oView = new bz_barzahlen_thankyou();
     $oView->init();
     $this->assertEquals('', $oView->getInfotextOne());
     oxSession::setVar('barzahlenInfotextOne', 'Hallo <b>Welt</b>! <a href="http://www.barzahlen.de">Bar zahlen</a> Infütöxt Äinß');
     $oView->init();
     $this->assertEquals('Hallo <b>Welt</b>! <a href="http://www.barzahlen.de">Bar zahlen</a> Infütöxt Äinß', $oView->getInfotextOne());
 }
 /**
  * Checks if the license key update is allowed.
  *
  * @return bool
  */
 protected function _canUpdate()
 {
     $myConfig = $this->getConfig();
     $blIsMallAdmin = oxSession::getVar('malladmin');
     if (!$blIsMallAdmin) {
         return false;
     }
     if ($myConfig->isDemoShop()) {
         return false;
     }
     return true;
 }
示例#11
0
 /**
  * Class constructor, assigns template file name passed by URL
  * or stored in session ("tpl", "infotpl").
  *
  * Template variables:
  * <b>tpl</b>
  *
  * Session variables:
  * <b>infotpl</b>
  */
 public function info()
 {
     // assign template name
     $sTplName = oxConfig::getParameter('tpl');
     $sTplName = $sTplName ? $sTplName : oxSession::getVar('infotpl');
     if ($sTplName) {
         // security fix so that you cant access files from outside template dir
         $sTplName = basename($sTplName);
         oxSession::setVar('infotpl', $sTplName);
     }
     $this->_sThisTemplate = $sTplName;
 }
function getViewName($sTable, $iLangId = null, $sShopId = null)
{
    $myConfig = oxRegistry::getConfig();
    // Benutzergruppe aus Moduleinstellungen auslesen bis CE 4.8.9 !!!
    // ab CE 4.9.0 ist die Funktion oxConfig::getInstance() nicht mehr verfügbar!!
    $vtec_GruppenID = oxConfig::getInstance()->getConfigParam('vtec_spezialgruppe');
    // Ab CE 4.9.0 gilt dieser Eintrag! Obigen Code bitte auskommentieren!!!
    /* $vtec_GruppenID = oxRegistry::getConfig()->getConfigParam('vtec_spezialgruppe'); */
    // Ansicht...
    $sVtecAnsicht = $sTable;
    //This config option should only be used in emergency case.
    //Originally it was planned for the case when admin area is not reached due to the broken views.
    if (!$myConfig->getConfigParam('blSkipViewUsage')) {
        $sViewSfx = "";
        $sAnsichtSfx = "";
        // neue Ansichtsendung
        $blIsMultiLang = in_array($sTable, oxRegistry::getLang()->getMultiLangTables());
        if ($iLangId != -1 && $blIsMultiLang) {
            $oLang = oxRegistry::getLang();
            $iLangId = $iLangId !== null ? $iLangId : oxRegistry::getLang()->getBaseLanguage();
            $sAbbr = $oLang->getLanguageAbbr($iLangId);
            $sViewSfx .= "_" . $sAbbr;
        }
        if ($sVtecAnsicht == "oxarticles") {
            $ox_User_ID = oxSession::getVar("usr");
            // bis CE 4.8.9
            /* $ox_User_ID = oxRegistry::getSession()->getVariable("usr"); */
            // ab CE 4.9.0, obigen Code auskommentieren!!
            $ox_User = oxNew("oxUser");
            $ox_User->load($ox_User_ID);
            if (!$ox_User->isAdmin()) {
                $oxGruppen = $ox_User->getUserGroups();
                $vtecInSpezGruppe = false;
                foreach ($oxGruppen as $oxGruppe) {
                    if ($oxGruppe->getId() == $vtec_GruppenID) {
                        $vtecInSpezGruppe = true;
                    }
                }
                if (!$vtecInSpezGruppe) {
                    $sAnsichtSfx = "_vsg";
                }
            }
        }
        if ($sViewSfx || ($iLangId == -1 || $sShopId == -1) && $blIsMultiLang) {
            return "oxv_" . $sTable . $sViewSfx . $sAnsichtSfx;
        }
    }
    return $sTable;
}
示例#13
0
 /**
  * Executes parent method parent::render() and returns name of template
  * file "shop.tpl".
  *
  * @return string
  */
 public function render()
 {
     parent::render();
     $sCurrentAdminShop = oxSession::getVar("currentadminshop");
     if (!$sCurrentAdminShop) {
         if (oxSession::getVar("malladmin")) {
             $sCurrentAdminShop = "oxbaseshop";
         } else {
             $sCurrentAdminShop = oxSession::getVar("actshop");
         }
     }
     $this->_aViewData["currentadminshop"] = $sCurrentAdminShop;
     oxSession::setVar("currentadminshop", $sCurrentAdminShop);
     return "shop.tpl";
 }
示例#14
0
 /**
  * return the user which is owner of the wish list
  *
  * @return object | bool
  */
 public function getWishUser()
 {
     if ($this->_oWishUser === null) {
         $this->_oWishUser = false;
         $sUserId = oxConfig::getParameter('wishid') ? oxConfig::getParameter('wishid') : oxSession::getVar('wishid');
         if ($sUserId) {
             $oUser = oxNew('oxuser');
             if ($oUser->load($sUserId)) {
                 // passing wishlist information
                 $this->_oWishUser = $oUser;
                 // store this one to session
                 oxSession::setVar('wishid', $sUserId);
             }
         }
     }
     return $this->_oWishUser;
 }
 /**
  * @overload
  */
 public function executePayment($dAmount, &$oOrder)
 {
     if (!in_array($oOrder->oxorder__oxpaymenttype->rawValue, array("paymill_cc", "paymill_elv"))) {
         return parent::executePayment($dAmount, $oOrder);
     }
     if (oxSession::hasVar('paymill_token')) {
         $this->_token = oxSession::getVar('paymill_token');
     } else {
         oxUtilsView::getInstance()->addErrorToDisplay("No Token was provided");
         oxUtils::getInstance()->redirect($this->getConfig()->getSslShopUrl() . 'index.php?cl=payment', false);
     }
     $this->getSession()->setVar("paymill_identifier", time());
     $this->_apiUrl = paymill_util::API_ENDPOINT;
     $this->_iLastErrorNo = null;
     $this->_sLastError = null;
     $this->_initializePaymentProcessor($dAmount, $oOrder);
     if ($this->_getPaymentShortCode($oOrder->oxorder__oxpaymenttype->rawValue) === 'cc') {
         $this->_paymentProcessor->setPreAuthAmount((int) oxSession::getVar('paymill_authorized_amount'));
     }
     $this->_loadFastCheckoutData();
     $this->_existingClientHandling($oOrder);
     if ($this->_token === 'dummyToken') {
         $prop = 'paymill_fastcheckout__paymentid_' . $this->_getPaymentShortCode($oOrder->oxorder__oxpaymenttype->rawValue);
         $this->_paymentProcessor->setPaymentId($this->_fastCheckoutData->{$prop}->rawValue);
     }
     $result = $this->_paymentProcessor->processPayment();
     $this->log($result ? 'Payment results in success' : 'Payment results in failure', null);
     if ($result) {
         $saveData = array('oxid' => $oOrder->oxorder__oxuserid->rawValue, 'clientid' => $this->_paymentProcessor->getClientId());
         if (oxConfig::getInstance()->getShopConfVar('PAYMILL_ACTIVATE_FASTCHECKOUT')) {
             $paymentColumn = 'paymentID_' . strtoupper($this->_getPaymentShortCode($oOrder->oxorder__oxpaymenttype->rawValue));
             $saveData[$paymentColumn] = $this->_paymentProcessor->getPaymentId();
         }
         $this->_fastCheckoutData->assign($saveData);
         $this->_fastCheckoutData->save();
         if (oxConfig::getInstance()->getShopConfVar('PAYMILL_SET_PAYMENTDATE')) {
             $this->_setPaymentDate($oOrder);
         }
         // set transactionId to session for updating the description after order execute
         $transactionId = $this->_paymentProcessor->getTransactionId();
         $this->getSession()->setVar('paymillPgTransId', $transactionId);
     } else {
         oxUtilsView::getInstance()->addErrorToDisplay($this->_getErrorMessage($this->_paymentProcessor->getErrorCode()));
     }
     return $result;
 }
 /**
  * Does Export line by line on position iCnt
  *
  * @param integer $iCnt export position
  *
  * @return bool
  */
 public function nextTick($iCnt)
 {
     $iExportedItems = $iCnt;
     $blContinue = false;
     if ($oArticle = $this->getOneArticle($iCnt, $blContinue)) {
         $myConfig = oxConfig::getInstance();
         $oSmarty = oxUtilsView::getInstance()->getSmarty();
         $oSmarty->assign("sCustomHeader", oxSession::getVar("sExportCustomHeader"));
         $oSmarty->assign_by_ref("linenr", $iCnt);
         $oSmarty->assign_by_ref("article", $oArticle);
         $oSmarty->assign("spr", $myConfig->getConfigParam('sCSVSign'));
         $oSmarty->assign("encl", $myConfig->getConfigParam('sGiCsvFieldEncloser'));
         $this->write($oSmarty->fetch("genexport.tpl", $this->getViewId()));
         return ++$iExportedItems;
     }
     return $blContinue;
 }
 /**
  * Executes parent method parent::render(), creates oxnewsletter object
  * and passes it's data to Smarty engine, returns name of template file
  * "newsletter_preview.tpl".
  *
  * @return string
  */
 public function render()
 {
     parent::render();
     $soxId = $this->getEditObjectId();
     if ($soxId != "-1" && isset($soxId)) {
         // load object
         $oNewsletter = oxNew("oxnewsletter");
         $oNewsletter->load($soxId);
         $this->_aViewData["edit"] = $oNewsletter;
         // user
         $sUserID = oxSession::getVar("auth");
         // assign values to the newsletter and show it
         $oNewsletter->prepare($sUserID, $this->getConfig()->getConfigParam('bl_perfLoadAktion'));
         $this->_aViewData["previewhtml"] = $oNewsletter->getHtmlText();
         $this->_aViewData["previewtext"] = $oNewsletter->getPlainText();
     }
     return "newsletter_preview.tpl";
 }
 /**
  * Saves newsletter HTML format text.
  *
  * @return string
  */
 public function save()
 {
     $myConfig = $this->getConfig();
     $soxId = $this->getEditObjectId();
     $aParams = oxConfig::getParameter("editval");
     // shopid
     $sShopID = oxSession::getVar("actshop");
     $aParams['oxnewsletter__oxshopid'] = $sShopID;
     $oNewsletter = oxNew("oxnewsletter");
     if ($soxId != "-1") {
         $oNewsletter->load($soxId);
     } else {
         $aParams['oxnewsletter__oxid'] = null;
     }
     $oNewsletter->assign($aParams);
     $oNewsletter->save();
     // set oxid if inserted
     $this->setEditObjectId($oNewsletter->getId());
 }
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * File: insert.oxid_newbasketitem.php
 * Type: string, html
 * Name: newbasketitem
 * Purpose: Used for tracking in econda, etracker etc.
 * -------------------------------------------------------------
 *
 * @param array  $params  params
 * @param Smarty &$smarty clever simulation of a method
 *
 * @return string
 */
function smarty_insert_oxid_fblogin($params, &$smarty)
{
    $myConfig = oxConfig::getInstance();
    $oView = $myConfig->getActiveView();
    if (!$myConfig->getConfigParam("bl_showFbConnect")) {
        return;
    }
    // user logged in using facebook account so showing additional
    // popup about connecting facebook user id to existing shop account
    $oFb = oxFb::getInstance();
    if ($oFb->isConnected() && $oFb->getUser()) {
        //name of template
        $sTemplate = 'inc/popup_fblogin.tpl';
        // checking, if Facebeook User Id was successfully added
        if (oxSession::getVar('_blFbUserIdUpdated')) {
            $sTemplate = 'inc/popup_fblogin_msg.tpl';
            oxSession::deleteVar('_blFbUserIdUpdated');
        }
        return $smarty->fetch($sTemplate);
    }
}
 /**
  * Calls parent::render, sets admin help url
  *
  * @return string
  */
 public function render()
 {
     $sReturn = parent::render();
     $oLang = oxLang::getInstance();
     // generate help link
     $myConfig = $this->getConfig();
     $sDir = $myConfig->getConfigParam('sShopDir') . '/documentation/admin';
     $iLang = 1;
     $sAbbr = $oLang->getLanguageAbbr($oLang->getTplLanguage());
     if ($sAbbr == "de") {
         $iLang = 0;
     }
     if (is_dir($sDir)) {
         $sDir = $myConfig->getConfigParam('sShopURL') . 'documentation/admin';
     } else {
         $oShop = $this->_getEditShop(oxSession::getVar('actshop'));
         //$sDir = "http://docu.oxid-esales.com/PE/{$oShop->oxshops__oxversion->value}/" . $myConfig->getConfigParam( 'iAdminLanguage' ) . '/admin';
         $sDir = "http://docu.oxid-esales.com/PE/{$oShop->oxshops__oxversion->value}/" . $iLang . '/admin';
     }
     $this->_aViewData['sHelpURL'] = $sDir;
     return $sReturn;
 }
 /**
  * Saves guestbook record changes.
  *
  * @return null
  */
 public function save()
 {
     parent::save();
     $soxId = $this->getEditObjectId();
     $aParams = oxConfig::getParameter("editval");
     // checkbox handling
     if (!isset($aParams['oxgbentries__oxactive'])) {
         $aParams['oxgbentries__oxactive'] = 0;
     }
     // shopid
     $aParams['oxgbentries__oxshopid'] = oxSession::getVar("actshop");
     $oLinks = oxNew("oxgbentry");
     if ($soxId != "-1") {
         $oLinks->load($soxId);
     } else {
         $aParams['oxgbentries__oxid'] = null;
         // author
         $aParams['oxgbentries__oxuserid'] = oxSession::getVar('auth');
     }
     $oLinks->assign($aParams);
     $oLinks->save();
     $this->setEditObjectId($oLinks->getId());
 }
 public function render()
 {
     parent::render();
     $this->_aViewData['edit'] = $oCategory = oxNew('oxcategory');
     // resetting
     oxSession::setVar('neworder_sess', null);
     $soxId = $this->getEditObjectId();
     if ($soxId != "-1" && isset($soxId)) {
         // load object
         $oCategory->load($soxId);
         $oArticleList = oxnew('oxarticlelist');
         $oArticleList->loadCategoryArticles($soxId, array());
         $this->_aViewData['oArticleList'] = $oArticleList;
         //Disable editing for derived items
         if ($oCategory->isDerived()) {
             $this->_aViewData['readonly'] = true;
         }
     }
     if (oxConfig::getParameter("aoc")) {
         return "marm_category_order_popup.tpl";
     }
     return "marm_category_order.tpl";
 }
 /**
  * Loads article category ordering info, passes it to Smarty
  * engine and returns name of template file "category_order.tpl".
  *
  * @return string
  */
 public function render()
 {
     parent::render();
     $this->_aViewData['edit'] = $oCategory = oxNew('oxcategory');
     // resetting
     oxSession::setVar('neworder_sess', null);
     $soxId = $this->getEditObjectId();
     if ($soxId != "-1" && isset($soxId)) {
         // load object
         $oCategory->load($soxId);
         //Disable editing for derived items
         if ($oCategory->isDerived()) {
             $this->_aViewData['readonly'] = true;
         }
     }
     if (oxConfig::getParameter("aoc")) {
         $aColumns = array();
         include_once 'inc/' . strtolower(__CLASS__) . '.inc.php';
         $this->_aViewData['oxajax'] = $aColumns;
         return "popups/category_order.tpl";
     }
     return "category_order.tpl";
 }
 /**
  * Method applies validation to entry and saves it to DB.
  * On error/success returns name of action to perform
  * (on error: "guestbookentry?error=x"", on success: "guestbook").
  *
  * @return string
  */
 public function saveEntry()
 {
     $sReviewText = trim((string) oxConfig::getParameter('rvw_txt', true));
     $sShopId = $this->getConfig()->getShopId();
     $sUserId = oxSession::getVar('usr');
     // guest book`s entry is validated
     if (!$sUserId) {
         oxUtilsView::getInstance()->addErrorToDisplay('EXCEPTION_GUESTBOOKENTRY_ERRLOGGINTOWRITEENTRY');
         //return to same page
         return;
     }
     if (!$sShopId) {
         oxUtilsView::getInstance()->addErrorToDisplay('EXCEPTION_GUESTBOOKENTRY_ERRUNDEFINEDSHOP');
         return 'guestbookentry';
     }
     // empty entries validation
     if ('' == $sReviewText) {
         oxUtilsView::getInstance()->addErrorToDisplay('EXCEPTION_GUESTBOOKENTRY_ERRREVIEWCONTAINSNOTEXT');
         return 'guestbookentry';
     }
     // flood protection
     $oEntrie = oxNew('oxgbentry');
     if ($oEntrie->floodProtection($sShopId, $sUserId)) {
         oxUtilsView::getInstance()->addErrorToDisplay('EXCEPTION_GUESTBOOKENTRY_ERRMAXIMUMNOMBEREXCEEDED');
         return 'guestbookentry';
     }
     // double click protection
     if ($this->canAcceptFormData()) {
         // here the guest book entry is saved
         $oEntry = oxNew('oxgbentry');
         $oEntry->oxgbentries__oxshopid = new oxField($sShopId);
         $oEntry->oxgbentries__oxuserid = new oxField($sUserId);
         $oEntry->oxgbentries__oxcontent = new oxField($sReviewText);
         $oEntry->save();
     }
     return 'guestbook';
 }
 /**
  * Adds selected report(s) to generating list.
  *
  * @return null
  */
 public function addreporttolist()
 {
     $aReports = oxSession::getVar("allstat_reports");
     $soxId = oxConfig::getParameter('synchoxid');
     // assigning all items
     if (oxConfig::getParameter('all')) {
         $aStats = array();
         foreach ($aReports as $oRep) {
             $aStats[] = $oRep->filename;
         }
     } else {
         $aStats = $this->_getActionIds('oxstat.oxid');
     }
     $oStat = oxNew('oxstatistic');
     if ($oStat->load($soxId)) {
         $aStatData = (array) $oStat->getReports();
         // additional check
         foreach ($aReports as $oRep) {
             if (in_array($oRep->filename, $aStats) && !in_array($oRep->filename, $aStatData)) {
                 $aStatData[] = $oRep->filename;
             }
         }
         $oStat->setReports($aStatData);
         $oStat->save();
     }
 }
 /**
  * Saves deliveryset data to different language (eg. english).
  *
  * @return null
  */
 public function saveinnlang()
 {
     $soxId = $this->getEditObjectId();
     $aParams = oxConfig::getParameter("editval");
     // checkbox handling
     if (!isset($aParams['oxdeliveryset__oxactive'])) {
         $aParams['oxdeliveryset__oxactive'] = 0;
     }
     // shopid
     $sShopID = oxSession::getVar("actshop");
     $aParams['oxdeliveryset__oxshopid'] = $sShopID;
     $oDelSet = oxNew("oxdeliveryset");
     if ($soxId != "-1") {
         $oDelSet->loadInLang($this->_iEditLang, $soxId);
     } else {
         $aParams['oxdeliveryset__oxid'] = null;
     }
     //$aParams = $oDelSet->ConvertNameArray2Idx( $aParams);
     $oDelSet->setLanguage(0);
     $oDelSet->assign($aParams);
     // apply new language
     $oDelSet->setLanguage(oxConfig::getParameter("new_lang"));
     $oDelSet->save();
     // set oxid if inserted
     $this->setEditObjectId($oDelSet->getId());
 }
 /**
  * Place the order
  *
  * @return bool
  */
 protected function _processOrder()
 {
     if (!$this->_auth()) {
         return false;
     }
     if (!$this->_validateQuote()) {
         return false;
     }
     try {
         // TODO: To avoid duplicates look for order with the same Rakuten order no
         /** @var $oUser oxUser */
         $oUser = oxNew('oxuser');
         $oUser->loadActiveUser();
         /** @var $oOrder oxOrder */
         $oOrder = oxNew('oxorder');
         /** @var $oCountry oxCountry */
         $oCountry = oxNew('oxcountry');
         // $oUser = $this->getSession()->getBasket->getUser();
         $address = $this->_request->client;
         // Billing Address
         $oUser->oxuser__oxcompany = new oxField((string) $address->company);
         $oUser->oxuser__oxusername = new oxField((string) $address->email);
         $oUser->oxuser__oxfname = new oxField((string) $address->first_name);
         $oUser->oxuser__oxlname = new oxField((string) $address->last_name);
         $oUser->oxuser__oxstreet = new oxField((string) $address->street);
         $oUser->oxuser__oxstreetnr = new oxField((string) $address->street_no);
         $oUser->oxuser__oxaddinfo = new oxField((string) $address->address_add);
         $oUser->oxuser__oxustid = new oxField('');
         $oUser->oxuser__oxcity = new oxField((string) $address->city);
         $sCountryId = $oUser->getUserCountryId((string) $address->country);
         $oUser->oxuser__oxcountryid = new oxField($sCountryId ? $sCountryId : (string) $address->country);
         // $oUser->oxuser__oxcountry   = new oxField($oUser->getUserCountry($sCountryId));
         $oUser->oxuser__oxstateid = new oxField('');
         $oUser->oxuser__oxzip = new oxField((string) $address->zip_code);
         $oUser->oxuser__oxfon = new oxField((string) $address->phone);
         $oUser->oxuser__oxfax = new oxField('');
         switch ((string) $address->gender) {
             case 'Herr':
                 $sGender = 'MR';
                 break;
             case 'Frau':
                 $sGender = 'MRS';
                 break;
             default:
                 $sGender = '';
         }
         $oUser->oxuser__oxsal = new oxField($sGender);
         // $oDelAdress = oxNew( 'oxaddress' );
         $address = $this->_request->delivery_address;
         // Shipping Address
         $oOrder->oxorder__oxdelcompany = new oxField((string) $address->company);
         $oOrder->oxorder__oxdelfname = new oxField((string) $address->first_name);
         $oOrder->oxorder__oxdellname = new oxField((string) $address->last_name);
         $oOrder->oxorder__oxdelstreet = new oxField((string) $address->street);
         $oOrder->oxorder__oxdelstreetnr = new oxField((string) $address->street_no);
         $oOrder->oxorder__oxdeladdinfo = new oxField((string) $address->address_add);
         $oOrder->oxorder__oxdelcity = new oxField((string) $address->city);
         $sCountryId = $oUser->getUserCountryId((string) $address->country);
         $oOrder->oxorder__oxdelcountryid = new oxField($sCountryId ? $sCountryId : (string) $address->country);
         // $oOrder->oxorder__oxdelcountry   = new oxField($oUser->getUserCountry($sCountryId));
         $oOrder->oxorder__oxdelstateid = new oxField('');
         $oOrder->oxorder__oxdelzip = new oxField((string) $address->zip_code);
         $oOrder->oxorder__oxdelfon = new oxField((string) $address->phone);
         $oOrder->oxorder__oxdelfax = new oxField('');
         switch ((string) $address->gender) {
             case 'Herr':
                 $sGender = 'MR';
                 break;
             case 'Frau':
                 $sGender = 'MRS';
                 break;
             default:
                 $sGender = '';
         }
         $oOrder->oxorder__oxdelsal = new oxField($sGender);
         // get delivery country name from delivery country id
         // if ( $oDelAdress->oxaddress__oxcountryid->value && $oDelAdress->oxaddress__oxcountryid->value != -1 ) {
         //     $oCountry = oxNew( 'oxcountry' );
         //     $oCountry->load( $oDelAdress->oxaddress__oxcountryid->value );
         //     $oDelAdress->oxaddress__oxcountry = clone $oCountry->oxcountry__oxtitle;
         // }
         $sGetChallenge = oxSession::getVar('sess_challenge');
         $oOrder->setId($sGetChallenge);
         $oOrder->oxorder__oxfolder = new oxField(key($this->getConfig()->getShopConfVar('aOrderfolder', $this->getConfig()->getShopId())), oxField::T_RAW);
         $message = '';
         if (trim((string) $this->_request->comment_client) != '') {
             $message .= sprintf('Customer\'s Comment: %s', trim((string) $this->_request->comment_client) . " // \n");
         }
         $message .= sprintf('Rakuten Order No: %s', (string) $this->_request->order_no . " // \n") . sprintf('Rakuten Client ID: %s', (string) $this->_request->client->client_id);
         $oOrder->oxorder__oxremark = new oxField($message, oxField::T_RAW);
         $res = $oOrder->finalizeOrder($this->getSession()->getBasket(), $oUser, true);
         if ($res == 1) {
             // OK
             $oOrder->oxorder__oxpaymenttype = new oxField('rakuten');
             $oOrder->oxorder__oxpaymentid = new oxField();
             $oOrder->oxorder__oxtransid = new oxField((string) $this->_request->order_no);
             $oOrder->oxorder__oxtransstatus = new oxField('New');
             $oOrder->oxorder__oxartvatprice1 = new oxField((double) $this->_request->total_tax_amount, oxField::T_RAW);
             $oOrder->oxorder__oxartvatprice2 = new oxField(0, oxField::T_RAW);
             $oOrder->oxorder__oxdelcost = new oxField((double) $this->_request->shipping, oxField::T_RAW);
             $oOrder->oxorder__oxpaycost = new oxField(0, oxField::T_RAW);
             $oOrder->oxorder__oxwrapcost = new oxField(0, oxField::T_RAW);
             // TODO: support gift wrapping somehow
             $oOrder->oxorder__oxdiscount = new oxField(0, oxField::T_RAW);
             $subtotal = (double) $this->_request->total - (double) $this->_request->total_tax_amount - (double) $this->_request->shipping;
             $oOrder->oxorder__oxtotalnetsum = new oxField($subtotal, oxField::T_RAW);
             $oOrder->oxorder__oxtotalbrutsum = new oxField($subtotal + (double) $this->_request->total_tax_amount, oxField::T_RAW);
             $oOrder->oxorder__oxtotalordersum = new oxField((double) $this->_request->total, oxField::T_RAW);
             $oOrder->save();
             $this->getSession()->getBasket()->deleteBasket();
         } else {
             // Error
             return false;
         }
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
 /**
  * Returns session Remote Access token. Later you can pass the token over rtoken URL param
  * when you want to access the shop, for example, from different client.
  *
  * @return string
  */
 public function getRemoteAccessToken()
 {
     $sRaToken = oxSession::getInstance()->getRemoteAccessToken();
     return $sRaToken;
 }
示例#29
0
 /**
  * Sets the actual currency
  *
  * @param int $iCur 0 = EUR, 1 = GBP, 2 = CHF
  *
  * @return null
  */
 public function setActShopCurrency($iCur)
 {
     $aCurrencies = $this->getCurrencyArray();
     if (isset($aCurrencies[$iCur])) {
         oxSession::setVar('currency', $iCur);
         $this->_oActCurrencyObject = null;
     }
 }
 /**
  * get category attributes by category Id
  *
  * @param string  $sCategoryId category Id
  * @param integer $iLang       language No
  *
  * @return object;
  */
 public function getCategoryAttributes($sCategoryId, $iLang)
 {
     $aSessionFilter = oxSession::getVar('session_attrfilter');
     $oArtList = oxNew("oxarticlelist");
     $oArtList->loadCategoryIDs($sCategoryId, $aSessionFilter);
     // Only if we have articles
     if (count($oArtList) > 0) {
         $oDb = oxDb::getDb();
         $sArtIds = '';
         foreach (array_keys($oArtList->getArray()) as $sId) {
             if ($sArtIds) {
                 $sArtIds .= ',';
             }
             $sArtIds .= $oDb->quote($sId);
         }
         $sActCatQuoted = $oDb->quote($sCategoryId);
         $sAttTbl = getViewName('oxattribute', $iLang);
         $sO2ATbl = getViewName('oxobject2attribute', $iLang);
         $sC2ATbl = getViewName('oxcategory2attribute', $iLang);
         $sSelect = "SELECT DISTINCT att.oxid, att.oxtitle, o2a.oxvalue " . "FROM {$sAttTbl} as att, {$sO2ATbl} as o2a ,{$sC2ATbl} as c2a " . "WHERE att.oxid = o2a.oxattrid AND c2a.oxobjectid = {$sActCatQuoted} AND c2a.oxattrid = att.oxid AND o2a.oxvalue !='' AND o2a.oxobjectid IN ({$sArtIds}) " . "ORDER BY c2a.oxsort , att.oxpos, att.oxtitle, o2a.oxvalue";
         $rs = $oDb->execute($sSelect);
         if ($rs != false && $rs->recordCount() > 0) {
             while (!$rs->EOF && (list($sAttId, $sAttTitle, $sAttValue) = $rs->fields)) {
                 if (!$this->offsetExists($sAttId)) {
                     $oAttribute = oxNew("oxattribute");
                     $oAttribute->setTitle($sAttTitle);
                     $this->offsetSet($sAttId, $oAttribute);
                     $iLang = oxLang::getInstance()->getBaseLanguage();
                     if (isset($aSessionFilter[$sCategoryId][$iLang][$sAttId])) {
                         $oAttribute->setActiveValue($aSessionFilter[$sCategoryId][$iLang][$sAttId]);
                     }
                 } else {
                     $oAttribute = $this->offsetGet($sAttId);
                 }
                 $oAttribute->addValue($sAttValue);
                 $rs->moveNext();
             }
         }
     }
     return $this;
 }