/** * Tests OxReg::get() and OxReg::set() */ public function testSetGetInstance() { $oTest = new stdClass(); $oTest->testPublic = "testPublicVal"; Registry::set("testCase", $oTest); $oTest2 = Registry::get("testCase"); $this->assertEquals("testPublicVal", $oTest2->testPublic); }
/** * Returns path to edition directory. If no additional editions are found, returns base path. * * @return string */ public function getDirectoryPath() { if (Registry::instanceExists('oxConfigFile')) { $configFile = Registry::get('oxConfigFile'); } else { $configFile = new ConfigFile(getShopBasePath() . '/config.inc.php'); Registry::set('oxConfigFile', $configFile); } $editionsPath = $configFile->getVar('vendorDirectory') . '/' . static::EDITIONS_DIRECTORY; $path = getShopBasePath(); if ($this->getEditionSelector()->isEnterprise()) { $path = $editionsPath . '/' . static::ENTERPRISE_DIRECTORY; } elseif ($this->getEditionSelector()->isProfessional()) { $path = $editionsPath . '/' . static::PROFESSIONAL_DIRECTORY; } return realpath($path) . DIRECTORY_SEPARATOR; }
/** * make rss data array from given oxlist * * @param oxList $oList recommlist object * * @deprecated since v5.3 (2016-06-17); Listmania will be moved to an own module. * * @return array */ protected function _getRecommListItems($oList) { $myUtilsUrl = Registry::get("oxUtilsUrl"); $aItems = array(); foreach ($oList as $oRecommList) { $oItem = new stdClass(); $oItem->title = $oRecommList->oxrecommlists__oxtitle->value; $oItem->guid = $oItem->link = $myUtilsUrl->prepareUrlForNoSession($oRecommList->getLink()); $oItem->isGuidPermalink = true; $oItem->description = $oRecommList->oxrecommlists__oxdesc->value; $aItems[] = $oItem; } return $aItems; }
/** * Deletes record and other information related to this article such as images from DB, * also removes variants. Returns true if entry was deleted. * * @param string $sOXID Article id * * @throws \Exception * * @return bool */ public function delete($sOXID = null) { if (!$sOXID) { $sOXID = $this->getId(); } if (!$sOXID) { return false; } $database = oxDb::getDb(); $database->startTransaction(); try { // #2339 delete first variants before deleting parent product $this->_deleteVariantRecords($sOXID); $this->load($sOXID); $this->_deletePics(); $this->_onChangeResetCounts($sOXID, $this->oxarticles__oxvendorid->value, $this->oxarticles__oxmanufacturerid->value); // delete self $deleted = parent::delete($sOXID); $this->_deleteRecords($sOXID); Registry::get("oxSeoEncoderArticle")->onDeleteArticle($this); $this->onChange(ACTION_DELETE, $sOXID, $this->oxarticles__oxparentid->value); $database->commitTransaction(); } catch (Exception $exception) { $database->rollbackTransaction(); throw $exception; } return $deleted; }
/** * @return string */ private function getVendorDir() { /** @var ConfigFile $shopConfig */ $shopConfig = Registry::get("oxConfigFile"); $vendorDir = $shopConfig->getVar('vendorDirectory'); return $vendorDir; }
/** * Returns default category sorting for selected category * * @return array */ public function getUserSelectedSorting() { $sortDirections = array('desc', 'asc'); $request = Registry::get(Request::class); $sortBy = $request->getRequestParameter($this->getSortOrderByParameterName()); $sortOrder = $request->getRequestParameter($this->getSortOrderParameterName()); if ($sortBy && $sortOrder && Registry::getUtils()->isValidAlpha($sortOrder) && in_array(Str::getStr()->strtolower($sortOrder), $sortDirections) && in_array($sortBy, oxNew('oxArticle')->getFieldNames())) { return array('sortby' => $sortBy, 'sortdir' => $sortOrder); } }
/** * Check for forced edition in config file. If edition is not specified, * determine it by ClassMap existence. * * @return string */ protected function findEdition() { if (!class_exists('OxidEsales\\Eshop\\Core\\Registry') || !Registry::instanceExists('oxConfigFile')) { $configFile = new ConfigFile(getShopBasePath() . "config.inc.php"); } $configFile = isset($configFile) ? $configFile : Registry::get('oxConfigFile'); $edition = $configFile->getVar('edition') ?: $this->findEditionByClassMap(); $configFile->setVar('edition', $edition); return strtoupper($edition); }
/** * First test if all required fields were filled, then performed * additional checking oxcmp_user::CheckValues(). If no errors * occured - trying to create new user (oxuser::CreateUser()), * logging him to shop (oxuser::Login() if user has entered password). * If oxuser::CreateUser() returns false - this means user is * already created - we only logging him to shop (oxcmp_user::Login()). * If there is any error with missing data - function will return * false and set error code (oxcmp_user::iError). If user was * created successfully - will return "payment" to redirect to * payment interface. * * Template variables: * <b>usr_err</b> * * Session variables: * <b>usr_err</b>, <b>usr</b> * * @return mixed redirection string or true if successful, false otherwise */ public function createUser() { $blActiveLogin = $this->getParent()->isEnabledPrivateSales(); $oConfig = $this->getConfig(); if ($blActiveLogin && !$oConfig->getRequestParameter('ord_agb') && $oConfig->getConfigParam('blConfirmAGB')) { oxRegistry::get("oxUtilsView")->addErrorToDisplay('READ_AND_CONFIRM_TERMS', false, true); return false; } // collecting values to check $sUser = $oConfig->getRequestParameter('lgn_usr'); // first pass $sPassword = $oConfig->getRequestParameter('lgn_pwd', true); // second pass $sPassword2 = $oConfig->getRequestParameter('lgn_pwd2', true); $aInvAdress = $oConfig->getRequestParameter('invadr', true); $aInvAdress = $this->cleanBillingAddress($aInvAdress); $aDelAdress = $this->_getDelAddressData(); $aDelAdress = $this->cleanDeliveryAddress($aDelAdress); $database = oxDb::getDb(); $database->startTransaction(); try { /** @var oxUser $oUser */ $oUser = oxNew('oxuser'); $oUser->checkValues($sUser, $sPassword, $sPassword2, $aInvAdress, $aDelAdress); $iActState = $blActiveLogin ? 0 : 1; // setting values $oUser->oxuser__oxusername = new oxField($sUser, oxField::T_RAW); $oUser->setPassword($sPassword); $oUser->oxuser__oxactive = new oxField($iActState, oxField::T_RAW); // used for checking if user email currently subscribed $iSubscriptionStatus = $oUser->getNewsSubscription()->getOptInStatus(); $oUser->createUser(); $oUser = $this->configureUserBeforeCreation($oUser); $oUser->load($oUser->getId()); $oUser->changeUserData($oUser->oxuser__oxusername->value, $sPassword, $sPassword, $aInvAdress, $aDelAdress); if ($blActiveLogin) { // accepting terms.. $oUser->acceptTerms(); } $sUserId = oxRegistry::getSession()->getVariable("su"); $sRecEmail = oxRegistry::getSession()->getVariable("re"); if ($this->getConfig()->getConfigParam('blInvitationsEnabled') && $sUserId && $sRecEmail) { // setting registration credit points.. $oUser->setCreditPointsForRegistrant($sUserId, $sRecEmail); } // assigning to newsletter $blOptin = oxRegistry::getConfig()->getRequestParameter('blnewssubscribed'); if ($blOptin && $iSubscriptionStatus == 1) { // if user was assigned to newsletter // and is creating account with newsletter checked, // don't require confirm $oUser->getNewsSubscription()->setOptInStatus(1); $oUser->addToGroup('oxidnewsletter'); $this->_blNewsSubscriptionStatus = 1; } else { $blOrderOptInEmailParam = $this->getConfig()->getConfigParam('blOrderOptInEmail'); $this->_blNewsSubscriptionStatus = $oUser->setNewsSubscription($blOptin, $blOrderOptInEmailParam); } $oUser->addToGroup('oxidnotyetordered'); $oUser->logout(); $database->commitTransaction(); } catch (\OxidEsales\EshopCommunity\Core\Exception\UserException $exception) { Registry::get("oxUtilsView")->addErrorToDisplay($exception, false, true); $database->rollbackTransaction(); return false; } catch (\OxidEsales\EshopCommunity\Core\Exception\InputException $exception) { Registry::get("oxUtilsView")->addErrorToDisplay($exception, false, true); $database->rollbackTransaction(); return false; } catch (\OxidEsales\EshopCommunity\Core\Exception\DatabaseConnectionException $exception) { Registry::get("oxUtilsView")->addErrorToDisplay($exception, false, true); $database->rollbackTransaction(); return false; } catch (\OxidEsales\EshopCommunity\Core\Exception\ConnectionException $exception) { Registry::get("oxUtilsView")->addErrorToDisplay($exception, false, true); $database->rollbackTransaction(); return false; } catch (Exception $exception) { $database->rollbackTransaction(); throw $exception; } if (!$blActiveLogin) { oxRegistry::getSession()->setVariable('usr', $oUser->getId()); $this->_afterLogin($oUser); // order remark //V #427: order remark for new users $sOrderRemark = oxRegistry::getConfig()->getRequestParameter('order_remark', true); if ($sOrderRemark) { oxRegistry::getSession()->setVariable('ordrem', $sOrderRemark); } } // send register eMail //TODO: move into user if ((int) oxRegistry::getConfig()->getRequestParameter('option') == 3) { $oxEMail = oxNew('oxemail'); if ($blActiveLogin) { $oxEMail->sendRegisterConfirmEmail($oUser); } else { $oxEMail->sendRegisterEmail($oUser); } } // new registered $this->_blIsNewUser = true; $sAction = 'payment?new_user=1&success=1'; if ($this->_blNewsSubscriptionStatus !== null && !$this->_blNewsSubscriptionStatus) { $sAction = 'payment?new_user=1&success=1&newslettererror=4'; } return $sAction; }
/** * Get search table name. * Needed in case of searching for data in table oxartextends or its views. * * @param string $table * @param string $field Chose table depending on field. * * @return string */ protected function getSearchTableName($table, $field) { $searchTable = $table; if ($field == 'oxlongdesc') { $searchTable = Registry::get('oxTableViewNameGenerator')->getViewName('oxartextends'); } return $searchTable; }