public function render() { /** @var $oRakuten rakuten_checkout */ $oRakuten = oxNew('rakuten_checkout'); // Check which method will be used: Standard or Inline if ($this->getConfig()->getShopConfVar('sRakutenIntegrationMethod', -1) == 'STANDARD') { // Redirect to Rakuten Checkout if ($redirectUrl = $oRakuten->getRedirectUrl()) { // Received redirect URL oxUtils::getInstance()->redirect($redirectUrl, false, 302); } else { // Error returned, redirecting to the shopping cart oxUtils::getInstance()->redirect($this->_getBasketUrl(), false, 302); } } elseif ($this->getConfig()->getShopConfVar('sRakutenIntegrationMethod', -1) == 'INLINE') { // Inline integration (iFrame) if ($inlineCode = $oRakuten->getRedirectUrl(true)) { // Loading iFrame $this->_aViewData['oxidBlock_content'][] = $inlineCode; return parent::render(); } else { // Error returned, redirecting to the shopping cart oxUtils::getInstance()->redirect($this->_getBasketUrl(), false, 302); } } else { // Unknown integration method oxUtilsView::getInstance()->addErrorToDisplay('Unknown integration method.'); oxUtils::getInstance()->redirect($this->_getBasketUrl(), false, 302); } return false; }
/** * Executes parent method parent::render(), creates deliveryset category tree, * passes data to Smarty engine and returns name of template file "deliveryset_main.tpl". * * @return string */ public function render() { $myConfig = $this->getConfig(); $sTheme = $this->_sTheme = $this->getEditObjectId(); $sShopId = $myConfig->getShopId(); if (!isset($sTheme)) { $sTheme = $this->_sTheme = $this->getConfig()->getConfigParam('sTheme'); } $oTheme = oxNew('oxTheme'); if ($oTheme->load($sTheme)) { $this->_aViewData["oTheme"] = $oTheme; try { $aDbVariables = $this->_loadConfVars($sShopId, $this->_getModuleForConfigVars()); $this->_aViewData["var_constraints"] = $aDbVariables['constraints']; $this->_aViewData["var_grouping"] = $aDbVariables['grouping']; foreach ($this->_aConfParams as $sType => $sParam) { $this->_aViewData[$sParam] = $aDbVariables['vars'][$sType]; } } catch (oxException $oEx) { oxUtilsView::getInstance()->addErrorToDisplay($oEx); $oEx->debugOut(); } } else { oxUtilsView::getInstance()->addErrorToDisplay(oxNew("oxException", 'EXCEPTION_THEME_NOT_LOADED')); } return 'theme_config.tpl'; }
/** * Checks user login data, on success returns "admin_start". * * @return mixed */ public function checklogin() { $myUtilsServer = oxUtilsServer::getInstance(); $myUtilsView = oxUtilsView::getInstance(); $sUser = oxConfig::getParameter('user', true); $sPass = oxConfig::getParameter('pwd', true); $sProfile = oxConfig::getParameter('profile'); try { // trying to login $oUser = oxNew("oxuser"); $oUser->login($sUser, $sPass); $iSubshop = (int) $oUser->oxuser__oxrights->value; if ($iSubshop) { oxSession::setVar("shp", $iSubshop); oxSession::setVar('currentadminshop', $iSubshop); oxConfig::getInstance()->setShopId($iSubshop); } } catch (oxUserException $oEx) { $myUtilsView->addErrorToDisplay('LOGIN_ERROR'); $oStr = getStr(); $this->addTplParam('user', $oStr->htmlspecialchars($sUser)); $this->addTplParam('pwd', $oStr->htmlspecialchars($sPass)); $this->addTplParam('profile', $oStr->htmlspecialchars($sProfile)); return; } catch (oxCookieException $oEx) { $myUtilsView->addErrorToDisplay('LOGIN_NO_COOKIE_SUPPORT'); $oStr = getStr(); $this->addTplParam('user', $oStr->htmlspecialchars($sUser)); $this->addTplParam('pwd', $oStr->htmlspecialchars($sPass)); $this->addTplParam('profile', $oStr->htmlspecialchars($sProfile)); return; } catch (oxConnectionException $oEx) { $myUtilsView->addErrorToDisplay($oEx); } // success oxUtils::getInstance()->logger("login successful"); // #533 if (isset($sProfile)) { $aProfiles = oxSession::getVar("aAdminProfiles"); if ($aProfiles && isset($aProfiles[$sProfile])) { // setting cookie to store last locally used profile $myUtilsServer->setOxCookie("oxidadminprofile", $sProfile . "@" . implode("@", $aProfiles[$sProfile]), time() + 31536000, "/"); oxSession::setVar("profile", $aProfiles[$sProfile]); } } else { //deleting cookie info, as setting profile to default $myUtilsServer->setOxCookie("oxidadminprofile", "", time() - 3600, "/"); } // languages $iLang = oxConfig::getParameter("chlanguage"); $aLanguages = oxLang::getInstance()->getAdminTplLanguageArray(); if (!isset($aLanguages[$iLang])) { $iLang = key($aLanguages); } $myUtilsServer->setOxCookie("oxidadminlanguage", $aLanguages[$iLang]->abbr, time() + 31536000, "/"); //P //oxSession::setVar( "blAdminTemplateLanguage", $iLang ); oxLang::getInstance()->setTplLanguage($iLang); return "admin_start"; }
/** * returns existing or creates smarty object * Returns smarty object. If object not yet initiated - creates it. Sets such * default parameters, like cache lifetime, cache/templates directory, etc. * * @param bool $blReload set true to force smarty reload * * @return smarty */ public function getSmarty($blReload = false) { if (!self::$_oSmarty || $blReload) { self::$_oSmarty = new Smarty(); $this->_fillCommonSmartyProperties(self::$_oSmarty); $this->_smartyCompileCheck(self::$_oSmarty); } return self::$_oSmarty; }
/** * Sets exception errros to template * * @return null */ public function displayExceptionError() { $aViewData = $this->getViewData(); //add all exceptions to display $aErrors = $this->_getErrors(); if (is_array($aErrors) && count($aErrors)) { oxUtilsView::getInstance()->passAllErrorsToView($aViewData, $aErrors); } $oSmarty = oxUtilsView::getInstance()->getSmarty(); $oSmarty->assign_by_ref("Errors", $aViewData["Errors"]); // resetting errors from session oxSession::setVar('Errors', array()); }
/** * Downloads connector, displays message on success, error on failure. * * @return null */ public function getConnector() { $oConfig = $this->getConfig(); $sEtUsername = $this->getConfig()->getParameter("etUsername"); $sEtPassword = $this->getConfig()->getParameter("etPassword"); $sShopVersion = $this->getConfig()->getEdition() . " " . $this->getConfig()->getVersion(); $blSaveCredentials = $this->getConfig()->getParameter('blSaveCredentials'); try { $oConnector = oxNew("oxefidownloader"); $oConnector->downloadConnector($sEtUsername, $sEtPassword, $sShopVersion, $blSaveCredentials); $this->_aViewData['message'] = oxLang::getInstance()->translateString('EFIRE_DOWNLOADER_SUCCESS'); } catch (Exception $e) { oxUtilsView::getInstance()->addErrorToDisplay(sprintf(oxLang::getInstance()->translateString('EFIRE_DOWNLOADER_ERROR'), $e->getMessage())); } }
/** * Smarty plugin * ------------------------------------------------------------- * File: block.oxid_content.php * Type: string, html * Name: block_oxifcontent * Purpose: Output content snippet if content exists * add [{oxifcontent ident="..." }][{/oxifcontent}] where you want to display content * ------------------------------------------------------------- * * @param array $params params * @param string $content rendered content * @param Smarty &$smarty clever simulation of a method * @param bool &$repeat repeat * * @return string */ function smarty_block_oxifcontent($params, $content, &$smarty, &$repeat) { $myConfig = oxConfig::getInstance(); $sIdent = isset($params['ident']) ? $params['ident'] : null; $sOxid = isset($params['oxid']) ? $params['oxid'] : null; $sAssign = isset($params['assign']) ? $params['assign'] : null; $sObject = isset($params['object']) ? $params['object'] : 'oCont'; if ($repeat) { if ($sIdent || $sOxid) { static $aContentCache = array(); if ($sIdent && isset($aContentCache[$sIdent]) || $sOxid && isset($aContentCache[$sOxid])) { $oContent = $sOxid ? $aContentCache[$sOxid] : $aContentCache[$sIdent]; } else { $oContent = oxNew("oxcontent"); $blLoaded = $sOxid ? $oContent->load($sOxid) : $oContent->loadbyIdent($sIdent); if ($blLoaded) { $aContentCache[$oContent->getId()] = $aContentCache[$oContent->oxcontents__oxloadid->value] = $oContent; } else { $oContent = false; if ($sOxid) { $aContentCache[$sOxid] = $oContent; } else { $aContentCache[$sIdent] = $oContent; } } } $blLoaded = false; if ($oContent && $oContent->oxcontents__oxactive->value) { $smarty->assign($sObject, $oContent); $blLoaded = true; } } else { $blLoaded = false; } $repeat = $blLoaded; } else { $oStr = getStr(); $blHasSmarty = $oStr->strstr($content, '[{'); if ($blHasSmarty) { $content = oxUtilsView::getInstance()->parseThroughSmarty($content, $sIdent . md5($content), $myConfig->getActiveView()); } if ($sAssign) { $smarty->assign($sAssign, $content); } else { return $content; } } }
/** * Set theme * * @return null */ public function setTheme() { $sTheme = $this->getEditObjectId(); $oTheme = oxNew('oxtheme'); if (!$oTheme->load($sTheme)) { oxUtilsView::getInstance()->addErrorToDisplay(oxNew("oxException", 'EXCEPTION_THEME_NOT_LOADED')); return; } try { $oTheme->activate(); $this->resetContentCache(); } catch (oxException $oEx) { oxUtilsView::getInstance()->addErrorToDisplay($oEx); $oEx->debugOut(); } }
/** * @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; }
/** * Renders requested RSS feed * * Template variables: * <b>rss</b> * * @return string $this->_sThisTemplate current template file name */ public function render() { parent::render(); $oSmarty = oxUtilsView::getInstance()->getSmarty(); // #2873: In demoshop for RSS we set php_handling to SMARTY_PHP_PASSTHRU // as SMARTY_PHP_REMOVE removes not only php tags, but also xml if ($this->getConfig()->isDemoShop()) { $oSmarty->php_handling = SMARTY_PHP_PASSTHRU; } foreach (array_keys($this->_aViewData) as $sViewName) { $oSmarty->assign_by_ref($sViewName, $this->_aViewData[$sViewName]); } // variables are set as deprecated, use getters // $oSmarty->assign('xmldef', $this->getXmlDef()); // return rss xml, no further processing oxUtils::getInstance()->setHeader("Content-Type: text/xml; charset=" . oxLang::getInstance()->translateString("charset")); oxUtils::getInstance()->showMessageAndExit($this->_processOutput($oSmarty->fetch($this->_sThisTemplate, $this->getViewId()))); }
/** * Does Export line by line on position iCnt * * @param integer $iCnt export position * * @return bool */ public function nextTick($iCnt) { $myConfig = oxConfig::getInstance(); $iExportedItems = $iCnt; if ($oArticle = $this->getOneArticle($iCnt, $blContinue)) { $smarty = oxUtilsView::getInstance()->getSmarty(); $smarty->assign_by_ref("linenr", $iCnt); $smarty->assign_by_ref("article", $oArticle); $smarty->assign("spr", $myConfig->getConfigParam('sCSVSign')); $smarty->assign("encl", $myConfig->getConfigParam('sGiCsvFieldEncloser')); $smarty->assign("sManufacturer", $this->_getManufactorTitle($oArticle->oxarticles__oxmanufacturerid->value)); $smarty->assign("sPictureUrl", $this->_checkPictureUrl($oArticle)); $smarty->assign("sCategory", $oArticle->getCategory()->oxcategories__oxtitle->value); $this->write($smarty->fetch("googlebase_genexport.tpl", $this->getViewID())); return ++$iExportedItems; } return $blContinue; }
/** * Saves payment parameters changes. * * @return mixed */ public function save() { $oDb = oxDb::getDb(); $aParams = oxConfig::getParameter("confbools"); // Deleting old blocks for Tradoria Checkout ver.1.0.2 and updating payment type for old Tradoria Checkout orders $oDb->execute("DELETE `oxtplblocks` WHERE `OXID` IN ('tradoria_btn_top', 'tradoria_btn_bottom', 'tradoria_btn_minicart');"); $oDb->execute("UPDATE `oxorder` SET `OXPAYMENTTYPE` = 'rakuten' WHERE `OXPAYMENTTYPE`='tradoria';"); if ($aParams['blRakutenActive'] == 'true') { $oDb->execute("INSERT INTO `oxtplblocks` (`OXID`, `OXACTIVE`, `OXSHOPID`, `OXTEMPLATE`, `OXBLOCKNAME`, `OXPOS`, `OXFILE`, `OXMODULE`) VALUES ('rakuten_btn_top', '1', 'oxbaseshop', 'page/checkout/basket.tpl', 'basket_btn_next_top', '0', 'button', 'rakuten') ON DUPLICATE KEY UPDATE `OXACTIVE` = 1;"); $oDb->execute("INSERT INTO `oxtplblocks` (`OXID`, `OXACTIVE`, `OXSHOPID`, `OXTEMPLATE`, `OXBLOCKNAME`, `OXPOS`, `OXFILE`, `OXMODULE`) VALUES ('rakuten_btn_bottom', '1', 'oxbaseshop', 'page/checkout/basket.tpl', 'basket_btn_next_bottom', '0', 'button', 'rakuten') ON DUPLICATE KEY UPDATE `OXACTIVE` = 1;"); $oDb->execute("INSERT INTO `oxtplblocks` (`OXID`, `OXACTIVE`, `OXSHOPID`, `OXTEMPLATE`, `OXBLOCKNAME`, `OXPOS`, `OXFILE`, `OXMODULE`) VALUES ('rakuten_btn_minicart', '1', 'oxbaseshop', 'widget/minibasket/minibasket.tpl', 'widget_minibasket_total', '0', 'button', 'rakuten') ON DUPLICATE KEY UPDATE `OXACTIVE` = 1;"); } else { $oDb->execute("UPDATE `oxtplblocks` SET `OXACTIVE` = 0 WHERE `OXID` IN ('rakuten_btn_top', 'rakuten_btn_bottom', 'rakuten_btn_minicart');"); } parent::save(); // Refresh Smarty cache to hide/show Rakuten Checkout button on the front-end // oxUtils::getInstance()->rebuildCache(); // TODO: Discover "right" way to refresh Smarty cache. Line above doesn't work! (Oxid bug?) $smarty = oxUtilsView::getInstance()->getSmarty(); $smarty->clear_all_cache(); }
/** * Does Export line by line on position iCnt * * @param integer $iCnt export position * * @return bool */ public function nextTick($iCnt) { $myConfig = oxConfig::getInstance(); $iExportedItems = $iCnt; if ($oArticle = $this->getOneArticle($iCnt, $blContinue)) { $smarty = oxUtilsView::getInstance()->getSmarty(); $smarty->assign_by_ref("linenr", $iCnt); $smarty->assign_by_ref("article", $oArticle); #TODO: find out why its not working from config #$smarty->assign( "spr", $myConfig->getConfigParam( 'sCSVSign' ) ); #$smarty->assign( "encl", $myConfig->getConfigParam( 'sGiCsvFieldEncloser' ) ); $smarty->assign("spr", ";"); $smarty->assign("encl", '"'); $smarty->assign("sManufacturer", $this->_getManufactorTitle($oArticle->oxarticles__oxmanufacturerid->value)); $smarty->assign("sPictureUrl", $this->_checkPictureUrl($oArticle)); $smarty->assign("sCategory", $oArticle->getCategory()->oxcategories__oxtitle->value); $smarty->assign("sPriceBrut", $oArticle->getPrice(1)->getBruttoPrice()); $smarty->assign("sPriceNet", $oArticle->getPrice(1)->getNettoPrice()); $this->write($smarty->fetch("superclix_genexport.tpl", $this->getViewID())); return ++$iExportedItems; } return $blContinue; }
/** * 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'; }
/** * Executes parent method parent::render(), prints shop and * PHP configuration information. * * @return null */ public function render() { $myConfig = $this->getConfig(); parent::render(); $oAuthUser = oxNew('oxuser'); $oAuthUser->loadAdminUser(); $blisMallAdmin = $oAuthUser->oxuser__oxrights->value == "malladmin"; if ($blisMallAdmin && !$myConfig->isDemoShop()) { $aClassVars = get_object_vars($myConfig); $aSystemInfo = array(); $oSmarty = oxUtilsView::getInstance()->getSmarty(); while (list($name, $value) = each($aClassVars)) { if (gettype($value) == "object") { continue; } // security fix - we do not output dbname and dbpwd cause of demoshops if ($name == "oDB" || $name == "dbUser" || $name == "dbPwd" || $name == "oSerial" || $name == "aSerials" || $name == "sSerialNr") { continue; } $value = var_export($value, true); $value = str_replace("\n", "<br>", $value); $aSystemInfo[$name] = $value; //echo( "$name = $value <br>"); } $oSmarty->assign("oViewConf", $this->_aViewData["oViewConf"]); $oSmarty->assign("shop", $this->_aViewData["shop"]); $oSmarty->assign("isdemo", $myConfig->isDemoShop()); $oSmarty->assign("aSystemInfo", $aSystemInfo); echo $oSmarty->fetch("systeminfo.tpl"); echo "<br><br>"; phpinfo(); oxUtils::getInstance()->showMessageAndExit(""); } else { return oxUtils::getInstance()->showMessageAndExit("Access denied !"); } }
/** * Send request to Rakuten Checkout * * @param string $xml * @return array|bool|string * @throws Exception */ public function sendRequest($xml) { try { $rockinUrl = $this->getRockinUrl(); // TODO: add debugging // $this->_debugData['request_url'] = $this->_config->getRockinUrl(); // $this->_debugData['request'] = $xml; //setting the curl parameters. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $rockinUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); //setting the request curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //getting response from server $response = curl_exec($ch); if (curl_errno($ch)) { // TODO: log error, redirect to ERROR_URL // moving to display page to display curl errors // $_SESSION['curl_error_no'] = curl_errno($ch); // $_SESSION['curl_error_msg'] = curl_error($ch); throw new Exception(curl_error($ch), curl_errno($ch)); // return $this->errorUrl; } else { //closing the curl curl_close($ch); } } catch (Exception $e) { // TODO: log error, redirect to ERROR_URL // $this->_debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); // $this->_debug($this->_debugData); // throw $e; oxUtilsView::getInstance()->addErrorToDisplay(sprintf('CURL Error #%s: %s', $e->getCode(), $e->getMessage())); return false; } // TODO: log response... // $this->_debugData['response'] = $response; // $this->_debug($this->_debugData); return $response; }
/** * Sets mailer additional settings and sends "InviteMail" mail to user. * Returns true on success. * * @param object $oParams Mailing parameters object * * @return bool */ public function sendInviteMail($oParams) { $myConfig = $this->getConfig(); //sets language of shop $iCurrLang = $myConfig->getActiveShop()->getLanguage(); // shop info $oShop = $this->_getShop($iCurrLang); // mailer stuff $this->setFrom($oParams->send_email, $oParams->send_name); $this->setSMTP(); // create messages $oSmarty = oxUtilsView::getInstance()->getSmarty(); $this->setUser($oParams); $sHomeUrl = $this->getViewConfig()->getHomeLink(); //setting recommended user id if ($myConfig->getActiveView()->isActive('Invitations') && ($oActiveUser = $oShop->getUser())) { $sHomeUrl = oxUtilsUrl::getInstance()->appendParamSeparator($sHomeUrl); $sHomeUrl .= "su=" . $oActiveUser->getId(); } if (is_array($oParams->rec_email) && count($oParams->rec_email) > 0) { foreach ($oParams->rec_email as $sEmail) { if (!empty($sEmail)) { $sRegisterUrl = oxUtilsUrl::getInstance()->appendParamSeparator($sHomeUrl); //setting recipient user email $sRegisterUrl .= "re=" . md5($sEmail); $this->setViewData("sHomeUrl", $sRegisterUrl); // Process view data array through oxoutput processor $this->_processViewArray(); $this->setBody($oSmarty->fetch($this->_sInviteTemplate)); $this->setAltBody($oSmarty->fetch($this->_sInviteTemplatePlain)); $this->setSubject($oParams->send_subject); $this->setRecipient($sEmail); $this->setReplyTo($oParams->send_email, $oParams->send_name); $this->send(); $this->clearAllRecipients(); } } return true; } return false; }
/** * Send request to Rakuten Checkout * * @param string $xml * @return array|bool|string * @throws Exception */ public function sendRequest($xml) { try { $rockinUrl = $this->getRockinUrl(); /** * Setting the curl parameters. */ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $rockinUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); /** * Setting the request */ curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); /** * Getting response from server */ $response = curl_exec($ch); if (curl_errno($ch)) { throw new Exception(curl_error($ch), curl_errno($ch)); } else { curl_close($ch); } } catch (Exception $e) { oxUtilsView::getInstance()->addErrorToDisplay(sprintf('CURL Error #%s: %s', $e->getCode(), $e->getMessage())); return false; } return $response; }
/** * Sending email to selected customer * * @return null */ public function send() { $blError = true; // error if ($sOxid = $this->getEditObjectId()) { $oPricealarm = oxNew("oxpricealarm"); $oPricealarm->load($sOxid); $aParams = oxConfig::getParameter("editval"); $sMailBody = isset($aParams['oxpricealarm__oxlongdesc']) ? stripslashes($aParams['oxpricealarm__oxlongdesc']) : ''; if ($sMailBody) { $sMailBody = oxUtilsView::getInstance()->parseThroughSmarty($sMailBody, $oPricealarm->getId()); } $sRecipient = $oPricealarm->oxpricealarm__oxemail->value; $oEmail = oxNew('oxemail'); $blSuccess = (int) $oEmail->sendPricealarmToCustomer($sRecipient, $oPricealarm, $sMailBody); // setting result message if ($blSuccess) { $oPricealarm->oxpricealarm__oxsended->setValue(date("Y-m-d H:i:s")); $oPricealarm->save(); $blError = false; } } if (!$blError) { $this->_aViewData["mail_succ"] = 1; } else { $this->_aViewData["mail_err"] = 1; } }
/** * Starts session manager * * @return null */ public function init() { include getShopBasePath() . 'config.inc.php'; include getShopBasePath() . 'core/oxconfk.php'; //adding trailing slashes $oFileUtils = oxUtilsFile::getInstance(); $this->sShopDir = $oFileUtils->normalizeDir($this->sShopDir); $this->sCompileDir = $oFileUtils->normalizeDir($this->sCompileDir); $this->sShopURL = $oFileUtils->normalizeDir($this->sShopURL); $this->sSSLShopURL = $oFileUtils->normalizeDir($this->sSSLShopURL); $this->sAdminSSLURL = $oFileUtils->normalizeDir($this->sAdminSSLURL); // some important defaults if (!$this->getConfigParam('sDefaultLang')) { $this->setConfigParam('sDefaultLang', 0); } $this->setConfigParam('sTheme', 'basic'); $blLogChangesInAdmin = $this->getConfigParam('blLogChangesInAdmin'); if (!isset($blLogChangesInAdmin)) { $this->setConfigParam('blLogChangesInAdmin', false); } $blCheckTemplates = $this->getConfigParam('blCheckTemplates'); if (!isset($blCheckTemplates)) { $this->setConfigParam('blCheckTemplates', false); } $blAllowArticlesubclass = $this->getConfigParam('blAllowArticlesubclass'); if (!isset($blAllowArticlesubclass)) { $this->setConfigParam('blAllowArticlesubclass', false); } $iAdminListSize = $this->getConfigParam('iAdminListSize'); if (!isset($iAdminListSize)) { $this->setConfigParam('iAdminListSize', 9); } // #1173M for EE - not all pic are deleted $iPicCount = $this->getConfigParam('iPicCount'); if (!isset($iPicCount)) { $this->setConfigParam('iPicCount', 7); } $iZoomPicCount = $this->getConfigParam('iZoomPicCount'); if (!isset($iZoomPicCount)) { $this->setConfigParam('iZoomPicCount', 4); } //max shop id default value $iMaxShopId = $this->getConfigParam('iMaxShopId'); if (!isset($iMaxShopId)) { $this->setConfigParam('iMaxShopId', 64); } // disabling caching according to DODGER #655 : disable Caching as it doesnt work good enought $this->setConfigParam('blTemplateCaching', false); //setting ADODB timeout global $ADODB_SESS_LIFE; $ADODB_SESS_LIFE = 1; // ADODB cachelifetime $iDBCacheLifeTime = $this->getConfigParam('iDBCacheLifeTime'); if (!isset($iDBCacheLifeTime)) { $this->setConfigParam('iDBCacheLifeTime', 3600); } // 1 hour $sCoreDir = $this->getConfigParam('sShopDir'); $this->setConfigParam('sCoreDir', $sCoreDir . '/core/'); try { $sShopID = $this->getShopId(); $blConfigLoaded = $this->_loadVarsFromDb($sShopID); // load now if (empty($sShopID) || !$blConfigLoaded) { // if no config values where loaded (some problmems with DB), throwing an exception $oEx = oxNew("oxConnectionException"); $oEx->setMessage("Unable to load shop config values from database"); throw $oEx; } // loading theme config options $this->_loadVarsFromDb($sShopID, null, oxConfig::OXMODULE_THEME_PREFIX . $this->getConfigParam('sTheme')); // checking if custom theme (which has defined parent theme) config options should be loaded over parent theme (#3362) if ($this->getConfigParam('sCustomTheme')) { $this->_loadVarsFromDb($sShopID, null, oxConfig::OXMODULE_THEME_PREFIX . $this->getConfigParam('sCustomTheme')); } $this->_processSeoCall(); //starting up the session $this->getSession()->start(); } catch (oxConnectionException $oEx) { $oEx->debugOut(); if (defined('OXID_PHP_UNIT')) { return false; } elseif (0 != $this->iDebug) { oxUtils::getInstance()->showMessageAndExit($oEx->getString()); } else { header("HTTP/1.1 500 Internal Server Error"); header("Location: offline.html"); header("Connection: close"); } } catch (oxCookieException $oEx) { $this->_processSeoCall(); //starting up the session $this->getSession()->start(); // redirect to start page and display the error oxUtilsView::getInstance()->addErrorToDisplay($oEx); oxUtils::getInstance()->redirect($this->getShopHomeURL() . 'cl=start', true, 302); } //application initialization $this->_oStart = new oxStart(); $this->_oStart->appInit(); }
/** * get long description, parsed through smarty * * @return string */ public function getLongDesc() { return oxUtilsView::getInstance()->parseThroughSmarty($this->oxactions__oxlongdesc->getRawValue(), $this->getId() . $this->getLanguage()); }
/** * Check if this template is registered for block extends. If yes, then collect * the extended blocks and replace them into the compile result of this template. * Else, replace block tags to smarty comments. * * @param string $sSource source content * @param object &$oSmartyCompiler smarty compiler instance * * @return string */ function smarty_prefilter_oxblock($sSource, &$oSmartyCompiler) { $blUseSmarty3 = false; if (strpos($oSmartyCompiler->_version, 'Smarty3') === 0) { $blUseSmarty3 = true; } $blDebugTemplateBlocks = (bool) oxConfig::getInstance()->getConfigParam('blDebugTemplateBlocks'); $aBlocks = oxUtilsView::getInstance()->getTemplateBlocks($oSmartyCompiler->_current_file); $iLimit = 500; while (--$iLimit && preg_match('/\\[\\{\\s*block\\s+name\\s*=\\s*([\'"])([a-z0-9_]+)\\1\\s*\\}\\](.*?)\\[\\{\\s*\\/block\\s*\\}\\]/is', $sSource, $m)) { $sBlock = $m[0]; $sBlockName = $m[2]; $sBlockContent = $m[3]; if (preg_match('/^.+(\\[\\{\\s*block\\s+name\\s*=\\s*([\'"])([a-z0-9_]+)\\2\\s*\\}\\](.*?)\\[\\{\\s*\\/block\\s*\\}\\])$/is', $sBlock, $m)) { // shift to (deepest) nested tag opening $sBlock = $m[1]; $sBlockName = $m[3]; $sBlockContent = $m[4]; } $sPrepend = ''; $sAppend = ''; if ($blUseSmarty3) { $sPrepend = '[{__smartyblock__ name="' . $sBlockName . '"}]' . $sPrepend; $sAppend .= '[{/__smartyblock__}]'; } if ($blDebugTemplateBlocks) { $sTplDir = trim(oxConfig::getInstance()->getConfigParam('_sTemplateDir'), '/\\'); $sFile = str_replace(array('\\', '//'), '/', $oSmartyCompiler->_current_file); if (preg_match('@/' . preg_quote($sTplDir, '@') . '/(.*)$@', $sFile, $m)) { $sFile = $m[1]; } $sDbgName = $sFile . '->' . $sBlockName; $sPrepend = '[{capture name="_dbg_blocks"}]' . $sPrepend; $sDbgId = 'block_' . sprintf("%u", crc32($sDbgName)) . '_[{$_dbg_block_idr1}][{$_dbg_block_idr2}]'; $sAppend .= '[{/capture}][{math equation="rand()" assign="_dbg_block_idr1"}][{math equation="rand()" assign="_dbg_block_idr2"}]' . '<hr style="visibility:hidden;height:0;margin:0;padding:0;border:0;line-height:0;font-size:0;" class="debugBlocksStart" id="' . $sDbgId . '" title="' . $sDbgName . '">' . '[{$smarty.capture._dbg_blocks}]' . '<hr style="visibility:hidden;height:0;margin:0;padding:0;border:0;line-height:0;font-size:0;" class="debugBlocksEnd" title="' . $sDbgId . '">'; } if (!isset($aBlocks[$sBlockName]) || !is_array($aBlocks[$sBlockName])) { // block is unused, just use its content $sSource = str_replace($sBlock, $sPrepend . $sBlockContent . $sAppend, $sSource); } else { // go through the replacement array and fill in parent values // specified by [{$smarty.block.parent}] tag $sCurrBlock = $sBlockContent; foreach ($aBlocks[$sBlockName] as $sOverBlock) { $sCurrBlock = preg_replace('/\\[\\{\\s*\\$smarty\\.block\\.parent\\s*\\}\\]/i', $sCurrBlock, $sOverBlock); } $sSource = str_replace($sBlock, $sPrepend . $sCurrBlock . $sAppend, $sSource); } } if (!$iLimit) { if ($blUseSmarty3) { $oSmartyCompiler->trigger_error("block tags mismatch (or there are more than 500 blocks in one file).", E_USER_ERROR); } else { $oSmartyCompiler->_syntax_error("block tags mismatch (or there are more than 500 blocks in one file).", E_USER_ERROR, __FILE__, __LINE__); } } if ($blUseSmarty3) { $sSource = str_replace('__smartyblock__', 'block', $sSource); } return $sSource; }
/** * Check language input errors * * @return bool */ protected function _validateInput() { $blResult = true; $sOxId = $this->getEditObjectId(); $aParams = oxConfig::getParameter("editval"); // if creating new language, checking if language already exists with // entered language abbervation if ($sOxId == -1) { if ($this->_checkLangExists($aParams['abbr'])) { $oEx = oxNew('oxExceptionToDisplay'); $oEx->setMessage('LANGUAGE_ALREADYEXISTS_ERROR'); oxUtilsView::getInstance()->addErrorToDisplay($oEx); $blResult = false; } } // checking if language name is not empty if (empty($aParams['desc'])) { $oEx = oxNew('oxExceptionToDisplay'); $oEx->setMessage('LANGUAGE_EMPTYLANGUAGENAME_ERROR'); oxUtilsView::getInstance()->addErrorToDisplay($oEx); $blResult = false; } return $blResult; }
/** * Checks if password is fine and updates old one with new * password. On success user is redirected to success page * * @return string */ public function updatePassword() { $sNewPass = oxConfig::getParameter('password_new', true); $sConfPass = oxConfig::getParameter('password_new_confirm', true); $oUser = oxNew('oxuser'); if ($oExcp = $oUser->checkPassword($sNewPass, $sConfPass, true)) { switch ($oExcp->getMessage()) { case 'EXCEPTION_INPUT_EMPTYPASS': case 'EXCEPTION_INPUT_PASSTOOSHORT': return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWORDTOSHORT', false, true); default: return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRPASSWDONOTMATCH', false, true); } } // passwords are fine - updating and loggin user in if ($oUser->loadUserByUpdateId($this->getUpdateId())) { // setting new pass .. $oUser->setPassword($sNewPass); // resetting update pass params $oUser->setUpdateKey(true); // saving .. $oUser->save(); // forcing user login oxSession::setVar('usr', $oUser->getId()); return 'forgotpwd?success=1'; } else { // expired reminder return oxUtilsView::getInstance()->addErrorToDisplay('FORGOTPWD_ERRLINKEXPIRED', false, true); } }
/** * Checks for order rules confirmation ("ord_agb", "ord_custinfo" form values)(if no * rules agreed - returns to order view), loads basket contents (plus applied * price/amount discount if available - checks for stock, checks user data (if no * data is set - returns to user login page). Stores order info to database * (oxorder::finalizeOrder()). According to sum for items automatically assigns user to * special user group ( oxuser::onOrderExecute(); if this option is not disabled in * admin). Finally you will be redirected to next page (order::_getNextStep()). * * @return string */ public function execute() { if (!$this->getSession()->checkSessionChallenge()) { return; } $myConfig = $this->getConfig(); if (!oxConfig::getParameter('ord_agb') && $myConfig->getConfigParam('blConfirmAGB')) { $this->_blConfirmAGBError = 1; return; } // for compatibility reasons for a while. will be removed in future if (oxConfig::getParameter('ord_custinfo') !== null && !oxConfig::getParameter('ord_custinfo') && $this->isConfirmCustInfoActive()) { $this->_blConfirmCustInfoError = 1; return; } // additional check if we really really have a user now if (!($oUser = $this->getUser())) { return 'user'; } // get basket contents $oBasket = $this->getSession()->getBasket(); if ($oBasket->getProductsCount()) { try { $oOrder = oxNew('oxorder'); // finalizing ordering process (validating, storing order into DB, executing payment, setting status ...) $iSuccess = $oOrder->finalizeOrder($oBasket, $oUser); // performing special actions after user finishes order (assignment to special user groups) $oUser->onOrderExecute($oBasket, $iSuccess); // proceeding to next view return $this->_getNextStep($iSuccess); } catch (oxOutOfStockException $oEx) { oxUtilsView::getInstance()->addErrorToDisplay($oEx, false, true, 'basket'); } catch (oxNoArticleException $oEx) { oxUtilsView::getInstance()->addErrorToDisplay($oEx); } catch (oxArticleInputException $oEx) { oxUtilsView::getInstance()->addErrorToDisplay($oEx); } } }
/** * changes current user password * * @return null */ public function changePassword() { $oUser = $this->getUser(); if (!$oUser) { return; } $sOldPass = oxConfig::getParameter('password_old', true); $sNewPass = oxConfig::getParameter('password_new', true); $sConfPass = oxConfig::getParameter('password_new_confirm', true); if ($oExcp = $oUser->checkPassword($sNewPass, $sConfPass, true)) { switch ($oExcp->getMessage()) { case 'EXCEPTION_INPUT_EMPTYPASS': case 'EXCEPTION_INPUT_PASSTOOSHORT': return oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWORDTOSHORT', false, true); default: return oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRPASSWDONOTMATCH', false, true); } } if (!$sOldPass || !$oUser->isSamePassword($sOldPass)) { return oxUtilsView::getInstance()->addErrorToDisplay('ACCOUNT_PASSWORD_ERRINCORRECTCURRENTPASSW', false, true, 'user'); } // testing passed - changing password $oUser->setPassword($sNewPass); if ($oUser->save()) { $this->_blPasswordChanged = true; } }
/** * Returns array of basket oxarticle objects * * @return array */ public function getBasketArticles() { $aBasketArticles = array(); foreach ($this->_aBasketContents as $sItemKey => $oBasketItem) { try { $oProduct = $oBasketItem->getArticle(); if ($this->getConfig()->getConfigParam('bl_perfLoadSelectLists')) { // marking chosen select list $aSelList = $oBasketItem->getSelList(); if (is_array($aSelList) && ($aSelectlist = $oProduct->getSelectLists($sItemKey))) { reset($aSelList); while (list($conkey, $iSel) = each($aSelList)) { $aSelectlist[$conkey][$iSel] = $aSelectlist[$conkey][$iSel]; $aSelectlist[$conkey][$iSel]->selected = 1; } $oProduct->setSelectlist($aSelectlist); } } } catch (oxNoArticleException $oEx) { oxUtilsView::getInstance()->addErrorToDisplay($oEx); $this->removeItem($sItemKey); $this->calculateBasket(true); continue; } catch (oxArticleInputException $oEx) { oxUtilsView::getInstance()->addErrorToDisplay($oEx); $this->removeItem($sItemKey); $this->calculateBasket(true); continue; } $aBasketArticles[$sItemKey] = $oProduct; } return $aBasketArticles; }
/** * Saves modified extended article parameters. * * @return mixed */ public function save() { parent::save(); $soxId = $this->getEditObjectId(); $aParams = oxConfig::getParameter("editval"); // checkbox handling if (!isset($aParams['oxarticles__oxissearch'])) { $aParams['oxarticles__oxissearch'] = 0; } if (!isset($aParams['oxarticles__oxblfixedprice'])) { $aParams['oxarticles__oxblfixedprice'] = 0; } // new way of handling bundled articles //#1517C - remove posibility to add Bundled Product //$this->setBundleId($aParams, $soxId); // default values $aParams = $this->addDefaultValues($aParams); $oArticle = oxNew("oxarticle"); $oArticle->loadInLang($this->_iEditLang, $soxId); if ($aParams['oxarticles__oxtprice'] != $oArticle->oxarticles__oxtprice->value && $aParams['oxarticles__oxtprice'] && $aParams['oxarticles__oxtprice'] <= $oArticle->oxarticles__oxprice->value) { //$aParams['oxarticles__oxtprice'] = $oArticle->oxarticles__oxtprice->value; $this->_aViewData["errorsavingtprice"] = 1; } //$aParams = $oArticle->ConvertNameArray2Idx( $aParams); $oArticle->setLanguage(0); $oArticle->assign($aParams); $oArticle->setLanguage($this->_iEditLang); $oArticle = oxUtilsFile::getInstance()->processFiles($oArticle); $oArticle->save(); //saving media file $sMediaUrl = oxConfig::getParameter("mediaUrl"); $sMediaDesc = oxConfig::getParameter("mediaDesc"); $aMediaFile = $this->getConfig()->getUploadedFile("mediaFile"); if ($sMediaUrl && $sMediaUrl != 'http://' || $aMediaFile['name'] || $sMediaDesc) { if (!$sMediaDesc) { return oxUtilsView::getInstance()->addErrorToDisplay('EXCEPTION_NODESCRIPTIONADDED'); } if ((!$sMediaUrl || $sMediaUrl == 'http://') && !$aMediaFile['name']) { return oxUtilsView::getInstance()->addErrorToDisplay('EXCEPTION_NOMEDIAADDED'); } $oMediaUrl = oxNew("oxMediaUrl"); $oMediaUrl->setLanguage($this->_iEditLang); $oMediaUrl->oxmediaurls__oxisuploaded = new oxField(0, oxField::T_RAW); //handle uploaded file if ($aMediaFile['name']) { try { $sMediaUrl = oxUtilsFile::getInstance()->processFile('mediaFile', 'out/media/'); $oMediaUrl->oxmediaurls__oxisuploaded = new oxField(1, oxField::T_RAW); } catch (Exception $e) { return oxUtilsView::getInstance()->addErrorToDisplay($e->getMessage()); } } //save media url $oMediaUrl->oxmediaurls__oxobjectid = new oxField($soxId, oxField::T_RAW); $oMediaUrl->oxmediaurls__oxurl = new oxField($sMediaUrl, oxField::T_RAW); $oMediaUrl->oxmediaurls__oxdesc = new oxField($sMediaDesc, oxField::T_RAW); $oMediaUrl->save(); } }
/** * Checks if any error occured during import and displays them * * @param object $oErpImport Import object * * @return null */ protected function _checkImportErrors($oErpImport) { foreach ($oErpImport->getStatistics() as $aValue) { if (!$aValue['r']) { $oEx = oxNew("oxExceptionToDisplay"); $oEx->setMessage($aValue['m']); oxUtilsView::getInstance()->addErrorToDisplay($oEx, false, true, 'genimport'); } } }