idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
37,800
protected function _copyFile ( $ sSource , $ sTarget ) { if ( ! is_dir ( dirname ( $ sTarget ) ) ) { mkdir ( dirname ( $ sTarget ) , 0744 , true ) ; } $ blDone = true ; if ( $ sSource !== $ sTarget ) { $ blDone = copy ( $ sSource , $ sTarget ) ; } if ( $ blDone ) { $ blDone = @ chmod ( $ sTarget , 0644 ) ; } return $ blDone ; }
Copy file from source to target location
37,801
protected function _moveImage ( $ sSource , $ sTarget ) { if ( ! is_dir ( dirname ( $ sTarget ) ) ) { mkdir ( dirname ( $ sTarget ) , 0744 , true ) ; } $ blDone = true ; if ( $ sSource !== $ sTarget ) { $ blDone = move_uploaded_file ( $ sSource , $ sTarget ) ; } if ( $ blDone ) { $ blDone = @ chmod ( $ sTarget , 0644 ) ; } return $ blDone ; }
Moves image from source to target location
37,802
public function checkFile ( $ sFile ) { $ aCheckCache = \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> getVariable ( "checkcache" ) ; if ( isset ( $ aCheckCache [ $ sFile ] ) ) { return $ aCheckCache [ $ sFile ] ; } $ blRet = true ; if ( ! is_readable ( $ sFile ) ) { $ blRet = $ this -> urlValidate ( $ sFile ) ; } $ aCheckCache [ $ sFile ] = $ blRet ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( "checkcache" , $ aCheckCache ) ; return $ blRet ; }
Checks if passed file exists and may be opened for reading . Returns true on success .
37,803
public function processFile ( $ sFileName , $ sUploadPath ) { $ aFileInfo = $ _FILES [ $ sFileName ] ; $ sBasePath = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'sShopDir' ) ; if ( ! isset ( $ aFileInfo [ 'name' ] ) || ! isset ( $ aFileInfo [ 'tmp_name' ] ) ) { throw oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ StandardException :: class , 'EXCEPTION_NOFILE' ) ; } if ( ! getStr ( ) -> preg_match ( '/^[\-_a-z0-9\.]+$/i' , $ aFileInfo [ 'name' ] ) ) { throw oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ StandardException :: class , 'EXCEPTION_FILENAMEINVALIDCHARS' ) ; } if ( isset ( $ aFileInfo [ 'error' ] ) && $ aFileInfo [ 'error' ] ) { throw oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ StandardException :: class , 'EXCEPTION_FILEUPLOADERROR_' . ( ( int ) $ aFileInfo [ 'error' ] ) ) ; } $ aPathInfo = pathinfo ( $ aFileInfo [ 'name' ] ) ; $ sExt = $ aPathInfo [ 'extension' ] ; $ sFileName = $ aPathInfo [ 'filename' ] ; $ aAllowedUploadTypes = ( array ) \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'aAllowedUploadTypes' ) ; $ aAllowedUploadTypes = array_map ( "strtolower" , $ aAllowedUploadTypes ) ; if ( ! in_array ( strtolower ( $ sExt ) , $ aAllowedUploadTypes ) ) { throw oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ StandardException :: class , 'EXCEPTION_NOTALLOWEDTYPE' ) ; } $ sFileName = $ this -> _getUniqueFileName ( $ sBasePath . $ sUploadPath , $ sFileName , $ sExt ) ; if ( $ this -> _moveImage ( $ aFileInfo [ 'tmp_name' ] , $ sBasePath . $ sUploadPath . "/" . $ sFileName ) ) { return $ sFileName ; } return false ; }
Process uploaded files . Returns unique file name on fail false
37,804
protected function _getUniqueFileName ( $ sFilePath , $ sFileName , $ sFileExt , $ sSufix = "" , $ blUnique = true ) { $ sFilePath = $ this -> normalizeDir ( $ sFilePath ) ; $ iFileCounter = 0 ; $ sTempFileName = $ sFileName ; $ oStr = getStr ( ) ; while ( $ blUnique && file_exists ( $ sFilePath . "/" . $ sFileName . $ sSufix . "." . $ sFileExt ) ) { $ iFileCounter ++ ; $ sTempFileName = $ oStr -> preg_replace ( "/\(" . $ iFileCounter . "\)/" , "" , $ sTempFileName ) ; $ sFileName = $ sTempFileName . "($iFileCounter)" ; } return $ sFileName . $ sSufix . "." . $ sFileExt ; }
Checks if file with same name does not exist if exists - addes number prefix to file name Returns unique file name .
37,805
public function translateError ( $ iError ) { $ message = '' ; if ( $ iError > 0 && $ iError < 9 && 5 !== $ iError ) { $ message = 'EXCEPTION_FILEUPLOADERROR_' . ( ( int ) $ iError ) ; } return $ message ; }
Translate php file upload errors to user readable format .
37,806
protected function _getCategoryList ( ) { if ( $ this -> _oCatList == null ) { $ this -> _oCatList = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ CategoryList :: class ) ; $ this -> _oCatList -> updateCategoryTree ( false ) ; } return $ this -> _oCatList ; }
Returns category list object
37,807
public function save ( ) { parent :: save ( ) ; if ( $ this -> _allowAdminEdit ( $ this -> getEditObjectId ( ) ) ) { $ aParams = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "editval" ) ; $ oAdress = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Address :: class ) ; if ( isset ( $ aParams [ 'oxaddress__oxid' ] ) && $ aParams [ 'oxaddress__oxid' ] == "-1" ) { $ aParams [ 'oxaddress__oxid' ] = null ; } else { $ oAdress -> load ( $ aParams [ 'oxaddress__oxid' ] ) ; } $ oAdress -> assign ( $ aParams ) ; $ oAdress -> save ( ) ; $ this -> sSavedOxid = $ oAdress -> getId ( ) ; } }
Saves user addressing information .
37,808
public function delAddress ( ) { $ this -> _blDelete = false ; if ( $ this -> _allowAdminEdit ( $ this -> getEditObjectId ( ) ) ) { $ aParams = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "editval" ) ; if ( isset ( $ aParams [ 'oxaddress__oxid' ] ) && $ aParams [ 'oxaddress__oxid' ] != "-1" ) { $ oAdress = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Address :: class ) ; $ this -> _blDelete = $ oAdress -> delete ( $ aParams [ 'oxaddress__oxid' ] ) ; } } }
Deletes user addressing information .
37,809
public function moveLeft ( ) { $ sArticleId = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'aid' ) ; if ( $ sArticleId && ( $ aItems = $ this -> getCompareItems ( ) ) ) { $ sPrevArticleId = null ; $ blFound = false ; foreach ( $ aItems as $ sOxid => $ sVal ) { if ( $ sOxid == $ sArticleId ) { $ blFound = true ; } if ( ! $ blFound ) { $ sPrevArticleId = $ sOxid ; } } if ( $ sPrevArticleId ) { $ aNewItems = [ ] ; foreach ( $ aItems as $ sOxid => $ sVal ) { if ( $ sOxid == $ sPrevArticleId ) { $ aNewItems [ $ sArticleId ] = true ; } elseif ( $ sOxid == $ sArticleId ) { $ aNewItems [ $ sPrevArticleId ] = true ; } else { $ aNewItems [ $ sOxid ] = true ; } } $ this -> setCompareItems ( $ aNewItems ) ; } } }
moves current article to the left in compare items array
37,810
public function moveRight ( ) { $ sArticleId = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'aid' ) ; if ( $ sArticleId && ( $ aItems = $ this -> getCompareItems ( ) ) ) { $ sNextArticleId = 0 ; $ blFound = false ; foreach ( $ aItems as $ sOxid => $ sVal ) { if ( $ blFound ) { $ sNextArticleId = $ sOxid ; $ blFound = false ; } if ( $ sOxid == $ sArticleId ) { $ blFound = true ; } } if ( $ sNextArticleId ) { $ aNewItems = [ ] ; foreach ( $ aItems as $ sOxid => $ sVal ) { if ( $ sOxid == $ sArticleId ) { $ aNewItems [ $ sNextArticleId ] = true ; } elseif ( $ sOxid == $ sNextArticleId ) { $ aNewItems [ $ sArticleId ] = true ; } else { $ aNewItems [ $ sOxid ] = true ; } } $ this -> setCompareItems ( $ aNewItems ) ; } } }
moves current article to the right in compare items array
37,811
public function getCompArtList ( ) { if ( $ this -> _oArtList === null ) { if ( ( $ aItems = $ this -> getCompareItems ( ) ) ) { $ oList = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ ArticleList :: class ) ; $ oList -> loadIds ( array_keys ( $ aItems ) ) ; if ( $ this -> _iArticlesPerPage > 0 ) { $ this -> _iCntPages = ceil ( $ oList -> count ( ) / $ this -> _iArticlesPerPage ) ; $ aItems = $ this -> _removeArticlesFromPage ( $ aItems , $ oList ) ; } $ this -> _oArtList = $ this -> _changeArtListOrder ( $ aItems , $ oList ) ; } } return $ this -> _oArtList ; }
Template variable getter . Returns comparison s article list in order per page
37,812
public function getAttributeList ( ) { if ( $ this -> _oAttributeList === null ) { $ this -> _oAttributeList = false ; if ( $ oArtList = $ this -> getCompArtList ( ) ) { $ aProductIds = array_keys ( $ oArtList ) ; foreach ( $ oArtList as $ oArticle ) { if ( $ oArticle -> getParentId ( ) ) { $ aProductIds [ ] = $ oArticle -> getParentId ( ) ; } } $ oAttributeList = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ AttributeList :: class ) ; $ this -> _oAttributeList = $ oAttributeList -> loadAttributesByIds ( $ aProductIds ) ; } } return $ this -> _oAttributeList ; }
Template variable getter . Returns attribute list
37,813
protected function _removeArticlesFromPage ( $ aItems , $ oList ) { $ aListKeys = $ oList -> arrayKeys ( ) ; $ aItemKeys = array_keys ( $ aItems ) ; $ aKeys = array_intersect ( $ aItemKeys , $ aListKeys ) ; $ aNewItems = [ ] ; $ iActPage = $ this -> getActPage ( ) ; for ( $ i = $ this -> _iArticlesPerPage * $ iActPage ; $ i < $ this -> _iArticlesPerPage * $ iActPage + $ this -> _iArticlesPerPage ; $ i ++ ) { if ( ! isset ( $ aKeys [ $ i ] ) ) { break ; } $ aNewItems [ $ aKeys [ $ i ] ] = & $ aItems [ $ aKeys [ $ i ] ] ; } return $ aNewItems ; }
Cuts page articles
37,814
protected function _changeArtListOrder ( $ aItems , $ oList ) { $ oNewList = [ ] ; $ iCnt = 0 ; $ iActPage = $ this -> getActPage ( ) ; foreach ( $ aItems as $ sOxid => $ sVal ) { if ( ! isset ( $ oList [ $ sOxid ] ) ) { continue ; } $ iCnt ++ ; $ oNewList [ $ sOxid ] = $ oList [ $ sOxid ] ; $ oNewList [ $ sOxid ] -> hidePrev = false ; if ( $ iActPage == 0 && $ iCnt == 1 ) { $ oNewList [ $ sOxid ] -> hidePrev = true ; } $ oNewList [ $ sOxid ] -> hideNext = false ; if ( ( $ iActPage + 1 ) == $ this -> _iCntPages && $ iCnt == count ( $ aItems ) ) { $ oNewList [ $ sOxid ] -> hideNext = true ; } } return $ oNewList ; }
Changes order of list elements
37,815
public static function autoload ( $ class ) { if ( false !== strpos ( $ class , 'OxidEsales\Eshop\\' ) ) { return false ; } $ instance = static :: getInstance ( ) ; $ class = strtolower ( basename ( $ class ) ) ; if ( $ classPath = $ instance -> getFilePath ( $ class ) ) { include $ classPath ; } else { $ class = preg_replace ( '/_parent$/i' , '' , $ class ) ; if ( ! in_array ( $ class , $ instance -> triedClasses ) ) { $ instance -> triedClasses [ ] = $ class ; $ instance -> createExtensionClassChain ( $ class ) ; } } }
Tries to autoload given class . If class was not found in module files array checks module extensions .
37,816
protected function getFilePath ( $ class ) { $ filePath = '' ; $ moduleFiles = Registry :: getUtilsObject ( ) -> getModuleVar ( 'aModuleFiles' ) ; if ( is_array ( $ moduleFiles ) ) { $ basePath = getShopBasePath ( ) ; foreach ( $ moduleFiles as $ moduleId => $ classPaths ) { if ( array_key_exists ( $ class , $ classPaths ) ) { $ moduleFilePath = $ basePath . 'modules/' . $ classPaths [ $ class ] ; if ( file_exists ( $ moduleFilePath ) ) { $ filePath = $ moduleFilePath ; } } } } return $ filePath ; }
Tries to find file path for given class . Returns empty string on path not found .
37,817
public function getProduct ( ) { if ( $ this -> _oArticle === null ) { $ this -> _oArticle = false ; $ aParams = $ this -> _getParams ( ) ; $ oArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; $ oArticle -> load ( $ aParams [ 'aid' ] ) ; $ this -> _oArticle = $ oArticle ; } return $ this -> _oArticle ; }
Template variable getter . Returns active article
37,818
public function showSuggest ( ) { if ( $ this -> _blShowSuggest === null ) { $ this -> _blShowSuggest = ( bool ) \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'blshowsuggest' ) ; } return $ this -> _blShowSuggest ; }
check if the wishlist is allowed
37,819
public function getWishList ( ) { if ( $ this -> _oWishList === null ) { $ this -> _oWishList = false ; if ( $ oUser = $ this -> getUser ( ) ) { $ this -> _oWishList = $ oUser -> getBasket ( 'wishlist' ) ; if ( $ this -> _oWishList -> isEmpty ( ) ) { $ this -> _oWishList = false ; } } } return $ this -> _oWishList ; }
Show the Wishlist
37,820
public function getWishProductList ( ) { if ( $ this -> _aWishProductList === null ) { $ this -> _aWishProductList = false ; if ( $ oWishList = $ this -> getWishList ( ) ) { $ this -> _aWishProductList = $ oWishList -> getArticles ( ) ; } } return $ this -> _aWishProductList ; }
Returns array of producst assigned to user wish list
37,821
public function sendWishList ( ) { if ( ! \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> checkSessionChallenge ( ) ) { return false ; } $ aParams = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'editval' , true ) ; if ( is_array ( $ aParams ) ) { $ oUtilsView = \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) ; $ oParams = ( object ) $ aParams ; $ this -> setEnteredData ( ( object ) \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'editval' ) ) ; if ( ! isset ( $ aParams [ 'rec_name' ] ) || ! isset ( $ aParams [ 'rec_email' ] ) || ! $ aParams [ 'rec_name' ] || ! $ aParams [ 'rec_email' ] ) { return $ oUtilsView -> addErrorToDisplay ( 'ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY' , false , true ) ; } else { if ( $ oUser = $ this -> getUser ( ) ) { $ sFirstName = 'oxuser__oxfname' ; $ sLastName = 'oxuser__oxlname' ; $ sSendEmail = 'send_email' ; $ sUserNameField = 'oxuser__oxusername' ; $ sSendName = 'send_name' ; $ sSendId = 'send_id' ; $ oParams -> $ sSendEmail = $ oUser -> $ sUserNameField -> value ; $ oParams -> $ sSendName = $ oUser -> $ sFirstName -> getRawValue ( ) . ' ' . $ oUser -> $ sLastName -> getRawValue ( ) ; $ oParams -> $ sSendId = $ oUser -> getId ( ) ; $ this -> _blEmailSent = oxNew ( \ OxidEsales \ Eshop \ Core \ Email :: class ) -> sendWishlistMail ( $ oParams ) ; if ( ! $ this -> _blEmailSent ) { return $ oUtilsView -> addErrorToDisplay ( 'ERROR_MESSAGE_CHECK_EMAIL' , false , true ) ; } } } } }
Sends wishlist mail to recipient . On errors returns false .
37,822
public function logout ( ) { $ mySession = $ this -> getSession ( ) ; $ myConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ oUser = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ User :: class ) ; $ oUser -> logout ( ) ; $ mySession -> destroy ( ) ; if ( $ myConfig -> getConfigParam ( 'blClearCacheOnLogout' ) ) { $ this -> resetContentCache ( true ) ; } \ OxidEsales \ Eshop \ Core \ Registry :: getUtils ( ) -> redirect ( 'index.php' , true , 302 ) ; }
Destroy session redirects to admin login and clears cache
37,823
protected function _doStartUpChecks ( ) { $ aMessage = [ ] ; if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blCheckSysReq' ) !== false ) { $ oSysReq = oxNew ( \ OxidEsales \ Eshop \ Core \ SystemRequirements :: class ) ; if ( ! $ oSysReq -> getSysReqStatus ( ) ) { $ aMessage [ 'warning' ] = \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( 'NAVIGATION_SYSREQ_MESSAGE' ) ; $ aMessage [ 'warning' ] .= '<a href="?cl=sysreq&amp;stoken=' . $ this -> getSession ( ) -> getSessionChallengeToken ( ) . '" target="basefrm">' ; $ aMessage [ 'warning' ] .= \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( 'NAVIGATION_SYSREQ_MESSAGE2' ) . '</a>' ; } } else { $ aMessage [ 'message' ] = \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( 'NAVIGATION_SYSREQ_MESSAGE_INACTIVE' ) ; $ aMessage [ 'message' ] .= '<a href="?cl=sysreq&amp;stoken=' . $ this -> getSession ( ) -> getSessionChallengeToken ( ) . '" target="basefrm">' ; $ aMessage [ 'message' ] .= \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( 'NAVIGATION_SYSREQ_MESSAGE2' ) . '</a>' ; } if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blCheckForUpdates' ) ) { if ( $ sVersionNotice = $ this -> _checkVersion ( ) ) { $ aMessage [ 'message' ] .= $ sVersionNotice ; } } if ( file_exists ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'sShopDir' ) . '/Setup/index.php' ) ) { $ aMessage [ 'warning' ] .= ( ( ! empty ( $ aMessage [ 'warning' ] ) ) ? "<br>" : '' ) . \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( 'SETUP_DIRNOTDELETED_WARNING' ) ; } $ sUpdateDir = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'sShopDir' ) . '/updateApp/' ; if ( file_exists ( $ sUpdateDir ) && ! ( count ( glob ( "$sUpdateDir/*" ) ) === 0 ) ) { $ aMessage [ 'warning' ] .= ( ( ! empty ( $ aMessage [ 'warning' ] ) ) ? "<br>" : '' ) . \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( 'UPDATEAPP_DIRNOTDELETED_WARNING' ) ; } $ sConfPath = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'sShopDir' ) . "/config.inc.php" ; if ( ! is_readable ( $ sConfPath ) || is_writable ( $ sConfPath ) ) { $ aMessage [ 'warning' ] .= ( ( ! empty ( $ aMessage [ 'warning' ] ) ) ? "<br>" : '' ) . \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( 'SETUP_CONFIGPERMISSIONS_WARNING' ) ; } return $ aMessage ; }
Every Time Admin starts we perform these checks returns some messages if there is something to display
37,824
protected function _checkVersion ( ) { $ edition = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getEdition ( ) ; $ query = 'http://admin.oxid-esales.com/' . $ edition . '/onlinecheck.php?getlatestversion' ; if ( $ version = \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsFile ( ) -> readRemoteFileAsString ( $ query ) ) { if ( version_compare ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getVersion ( ) , $ version ) == '-1' ) { return sprintf ( \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( 'NAVIGATION_NEWVERSIONAVAILABLE' ) , $ version ) ; } } }
Checks if newer shop version available . If true - returns message
37,825
public function save ( ) { parent :: save ( ) ; $ oOrder = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Order :: class ) ; if ( $ oOrder -> load ( $ this -> getEditObjectId ( ) ) ) { $ oRemark = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Remark :: class ) ; $ oRemark -> load ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "rem_oxid" ) ) ; $ oRemark -> oxremark__oxtext = new \ OxidEsales \ Eshop \ Core \ Field ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "remarktext" ) ) ; $ oRemark -> oxremark__oxheader = new \ OxidEsales \ Eshop \ Core \ Field ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "remarkheader" ) ) ; $ oRemark -> oxremark__oxtype = new \ OxidEsales \ Eshop \ Core \ Field ( "r" ) ; $ oRemark -> oxremark__oxparentid = new \ OxidEsales \ Eshop \ Core \ Field ( $ oOrder -> oxorder__oxuserid -> value ) ; $ oRemark -> save ( ) ; } }
Saves order history item text changes .
37,826
public function validate ( string $ metaDataFilePath , string $ metaDataVersion , array $ metaData ) { $ this -> currentValidationMetaDataVersion = $ metaDataVersion ; $ this -> metaDataFilePath = $ metaDataFilePath ; $ supportedMetaDataKeys = $ this -> metaDataSchemataProvider -> getFlippedMetaDataSchemaForVersion ( $ this -> currentValidationMetaDataVersion ) ; foreach ( $ metaData as $ metaDataKey => $ value ) { if ( is_scalar ( $ value ) ) { $ this -> validateMetaDataKey ( $ supportedMetaDataKeys , ( string ) $ metaDataKey ) ; } elseif ( true === \ is_array ( $ value ) ) { $ this -> validateMetaDataSection ( $ supportedMetaDataKeys , $ metaDataKey , $ value ) ; } else { throw new UnsupportedMetaDataValueTypeException ( 'The value type "' . \ gettype ( $ value ) . '" is not supported in metadata version ' . $ this -> currentValidationMetaDataVersion ) ; } } }
Validate that a given metadata meets the specifications of a given metadata version
37,827
private function validateMetaDataSectionItems ( array $ supportedMetaDataKeys , string $ sectionName , array $ sectionData ) { foreach ( $ sectionData as $ sectionItem ) { if ( \ is_array ( $ sectionItem ) ) { $ metaDataKeys = array_keys ( $ sectionItem ) ; foreach ( $ metaDataKeys as $ metaDataKey ) { $ this -> validateMetaDataKey ( $ supportedMetaDataKeys [ $ sectionName ] , $ metaDataKey ) ; } } } }
Validate well defined section items
37,828
public function removeDiscGroup ( ) { $ config = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ groupIds = $ this -> _getActionIds ( 'oxobject2discount.oxid' ) ; if ( $ config -> getRequestParameter ( 'all' ) ) { $ query = $ this -> _addFilter ( "delete oxobject2discount.* " . $ this -> _getQuery ( ) ) ; \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) -> Execute ( $ query ) ; } elseif ( $ groupIds && is_array ( $ groupIds ) ) { $ groupIdsQuoted = implode ( ", " , \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) -> quoteArray ( $ groupIds ) ) ; $ query = "delete from oxobject2discount where oxobject2discount.oxid in (" . $ groupIdsQuoted . ") " ; \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) -> Execute ( $ query ) ; } }
Removes user group from discount config
37,829
public function addDiscGroup ( ) { $ config = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ groupIds = $ this -> _getActionIds ( 'oxgroups.oxid' ) ; $ discountId = $ config -> getRequestParameter ( 'synchoxid' ) ; if ( $ config -> getRequestParameter ( 'all' ) ) { $ groupTable = $ this -> _getViewName ( 'oxgroups' ) ; $ groupIds = $ this -> _getAll ( $ this -> _addFilter ( "select $groupTable.oxid " . $ this -> _getQuery ( ) ) ) ; } if ( $ discountId && $ discountId != self :: NEW_DISCOUNT_ID && is_array ( $ groupIds ) ) { foreach ( $ groupIds as $ groupId ) { $ object2Discount = oxNew ( \ OxidEsales \ Eshop \ Core \ Model \ BaseModel :: class ) ; $ object2Discount -> init ( 'oxobject2discount' ) ; $ object2Discount -> oxobject2discount__oxdiscountid = new \ OxidEsales \ Eshop \ Core \ Field ( $ discountId ) ; $ object2Discount -> oxobject2discount__oxobjectid = new \ OxidEsales \ Eshop \ Core \ Field ( $ groupId ) ; $ object2Discount -> oxobject2discount__oxtype = new \ OxidEsales \ Eshop \ Core \ Field ( "oxgroups" ) ; $ object2Discount -> save ( ) ; } } }
Adds user group to discount config
37,830
protected function _getArtStock ( $ dAddAmount = 0 , $ blAllowNegativeStock = false ) { $ masterDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getMaster ( ) ; $ sQ = 'select oxstock from oxarticles where oxid = ' . $ masterDb -> quote ( $ this -> oxorderarticles__oxartid -> value ) ; $ iStockCount = ( float ) $ masterDb -> getOne ( $ sQ ) ; $ iStockCount += $ dAddAmount ; if ( ! $ blAllowNegativeStock && $ iStockCount < 0 ) { $ iStockCount = 0 ; } return $ iStockCount ; }
Adds or substracts defined amount passed by param from arcticle stock
37,831
public function getPersParams ( ) { if ( $ this -> _aPersParam != null ) { return $ this -> _aPersParam ; } if ( $ this -> oxorderarticles__oxpersparam -> value ) { $ this -> _aPersParam = unserialize ( $ this -> oxorderarticles__oxpersparam -> value ) ; } return $ this -> _aPersParam ; }
Order persistent data getter
37,832
public function setPersParams ( $ aParams ) { $ this -> _aPersParam = $ aParams ; $ this -> oxorderarticles__oxpersparam = new \ OxidEsales \ Eshop \ Core \ Field ( serialize ( $ aParams ) , \ OxidEsales \ Eshop \ Core \ Field :: T_RAW ) ; }
Order persistent params setter
37,833
public function getParentId ( ) { if ( isset ( $ this -> oxorderarticles__oxartparentid ) && $ this -> oxorderarticles__oxartparentid -> value !== false ) { return $ this -> oxorderarticles__oxartparentid -> value ; } $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ oArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; $ sQ = "select oxparentid from " . $ oArticle -> getViewName ( ) . " where oxid=" . $ oDb -> quote ( $ this -> getProductId ( ) ) ; $ this -> oxarticles__oxparentid = new \ OxidEsales \ Eshop \ Core \ Field ( $ oDb -> getOne ( $ sQ ) ) ; return $ this -> oxarticles__oxparentid -> value ; }
Returns product parent id
37,834
protected function _setArticleParams ( ) { $ this -> oxarticles__oxstock = $ this -> oxorderarticles__oxamount ; $ this -> oxarticles__oxtitle = $ this -> oxorderarticles__oxtitle ; $ this -> oxarticles__oxwidth = $ this -> oxorderarticles__oxwidth ; $ this -> oxarticles__oxlength = $ this -> oxorderarticles__oxlength ; $ this -> oxarticles__oxheight = $ this -> oxorderarticles__oxheight ; $ this -> oxarticles__oxweight = $ this -> oxorderarticles__oxweight ; $ this -> oxarticles__oxsubclass = $ this -> oxorderarticles__oxsubclass ; $ this -> oxarticles__oxartnum = $ this -> oxorderarticles__oxartnum ; $ this -> oxarticles__oxshortdesc = $ this -> oxorderarticles__oxshortdesc ; $ this -> oxarticles__oxvat = $ this -> oxorderarticles__oxvat ; $ this -> oxarticles__oxprice = $ this -> oxorderarticles__oxprice ; $ this -> oxarticles__oxbprice = $ this -> oxorderarticles__oxbprice ; $ this -> oxarticles__oxthumb = $ this -> oxorderarticles__oxthumb ; $ this -> oxarticles__oxpic1 = $ this -> oxorderarticles__oxpic1 ; $ this -> oxarticles__oxpic2 = $ this -> oxorderarticles__oxpic2 ; $ this -> oxarticles__oxpic3 = $ this -> oxorderarticles__oxpic3 ; $ this -> oxarticles__oxpic4 = $ this -> oxorderarticles__oxpic4 ; $ this -> oxarticles__oxpic5 = $ this -> oxorderarticles__oxpic5 ; $ this -> oxarticles__oxfile = $ this -> oxorderarticles__oxfile ; $ this -> oxarticles__oxdelivery = $ this -> oxorderarticles__oxdelivery ; $ this -> oxarticles__oxissearch = $ this -> oxorderarticles__oxissearch ; $ this -> oxarticles__oxfolder = $ this -> oxorderarticles__oxfolder ; $ this -> oxarticles__oxtemplate = $ this -> oxorderarticles__oxtemplate ; $ this -> oxarticles__oxexturl = $ this -> oxorderarticles__oxexturl ; $ this -> oxarticles__oxurlimg = $ this -> oxorderarticles__oxurlimg ; $ this -> oxarticles__oxurldesc = $ this -> oxorderarticles__oxurldesc ; $ this -> oxarticles__oxshopid = $ this -> oxorderarticles__oxordershopid ; $ this -> oxarticles__oxquestionemail = $ this -> oxorderarticles__oxquestionemail ; $ this -> oxarticles__oxsearchkeys = $ this -> oxorderarticles__oxsearchkeys ; }
Sets article parameters to current object so this object can be used for basket calculation
37,835
public function getSelectLists ( $ sKeyPrefix = null ) { $ aSelLists = [ ] ; if ( $ oArticle = $ this -> _getOrderArticle ( ) ) { $ aSelLists = $ oArticle -> getSelectLists ( ) ; } return $ aSelLists ; }
Returns article select lists implements iBaseArticle interface method
37,836
public function getOrderArticleSelectList ( $ sArtId = null , $ sOrderArtSelList = null ) { if ( $ this -> _aOrderArticleSelList === null ) { $ sOrderArtSelList = $ sOrderArtSelList ? $ sOrderArtSelList : $ this -> oxorderarticles__oxselvariant -> value ; $ sOrderArtSelList = explode ( ' || ' , $ sOrderArtSelList ) [ 0 ] ; $ aRet = [ ] ; if ( $ oArticle = $ this -> _getOrderArticle ( $ sArtId ) ) { $ aList = explode ( ", " , $ sOrderArtSelList ) ; $ oStr = getStr ( ) ; $ aArticleSelList = $ oArticle -> getSelectLists ( ) ; if ( count ( $ aArticleSelList ) > 0 ) { foreach ( $ aList as $ sList ) { if ( $ sList ) { $ aVal = explode ( ":" , $ sList ) ; if ( isset ( $ aVal [ 0 ] ) && isset ( $ aVal [ 1 ] ) ) { $ sOrderArtListTitle = $ oStr -> strtolower ( trim ( $ aVal [ 0 ] ) ) ; $ sOrderArtSelValue = $ oStr -> strtolower ( trim ( $ aVal [ 1 ] ) ) ; $ iSelListNum = 0 ; foreach ( $ aArticleSelList as $ aSelect ) { if ( $ oStr -> strtolower ( $ aSelect [ 'name' ] ) == $ sOrderArtListTitle ) { $ iSelValueNum = 0 ; foreach ( $ aSelect as $ oSel ) { if ( $ oStr -> strtolower ( $ oSel -> name ) == $ sOrderArtSelValue ) { $ aRet [ $ iSelListNum ] = $ iSelValueNum ; break ; } $ iSelValueNum ++ ; } } $ iSelListNum ++ ; } } } } } } $ this -> _aOrderArticleSelList = $ aRet ; } return $ this -> _aOrderArticleSelList ; }
Returns order article selection list array
37,837
public function getBasketPrice ( $ dAmount , $ aSelList , $ oBasket ) { $ oArticle = $ this -> _getOrderArticle ( ) ; if ( $ oArticle ) { return $ oArticle -> getBasketPrice ( $ dAmount , $ aSelList , $ oBasket ) ; } else { return $ this -> getPrice ( ) ; } }
Returns basket order article price
37,838
public function getCategoryIds ( $ blActCats = false , $ blSkipCache = false ) { $ aCatIds = [ ] ; if ( $ oOrderArticle = $ this -> _getOrderArticle ( ) ) { $ aCatIds = $ oOrderArticle -> getCategoryIds ( $ blActCats , $ blSkipCache ) ; } return $ aCatIds ; }
Returns empty array implements iBaseArticle interface getter method
37,839
public function getPrice ( ) { $ oBasePrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ oBasePrice -> setBruttoPriceMode ( ) ; $ oBasePrice -> setVat ( $ this -> oxorderarticles__oxvat -> value ) ; $ oBasePrice -> setPrice ( $ this -> oxorderarticles__oxbprice -> value ) ; return $ oBasePrice ; }
Returns order article unit price
37,840
public function setNewAmount ( $ iNewAmount ) { if ( $ iNewAmount >= 0 ) { $ oArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; if ( $ oArticle -> load ( $ this -> oxorderarticles__oxartid -> value ) ) { $ iStockChange = $ iNewAmount - $ this -> oxorderarticles__oxamount -> value ; if ( $ iStockChange > 0 && ( $ iOnStock = $ oArticle -> checkForStock ( $ iStockChange ) ) !== false ) { if ( $ iOnStock !== true ) { $ iStockChange = $ iOnStock ; $ iNewAmount = $ this -> oxorderarticles__oxamount -> value + $ iStockChange ; } } $ this -> updateArticleStock ( $ iStockChange * - 1 , \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blAllowNegativeStock' ) ) ; $ this -> oxorderarticles__oxamount = new \ OxidEsales \ Eshop \ Core \ Field ( $ iNewAmount , \ OxidEsales \ Eshop \ Core \ Field :: T_RAW ) ; $ this -> save ( ) ; } } }
Ordered article stock setter . Before setting new stock value additionally checks for original article stock value . Is stock values < = preferred adjusts order stock according to it
37,841
public function cancelOrderArticle ( ) { if ( $ this -> oxorderarticles__oxstorno -> value == 0 ) { $ myConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ this -> oxorderarticles__oxstorno = new \ OxidEsales \ Eshop \ Core \ Field ( 1 ) ; if ( $ this -> save ( ) ) { $ this -> updateArticleStock ( $ this -> oxorderarticles__oxamount -> value , $ myConfig -> getConfigParam ( 'blAllowNegativeStock' ) ) ; } } }
Sets order article storno value to 1 and if stock control is on - restores previous oxarticle stock state
37,842
public function delete ( $ sOXID = null ) { if ( $ blDelete = parent :: delete ( $ sOXID ) ) { $ myConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; if ( $ this -> oxorderarticles__oxstorno -> value != 1 ) { $ this -> updateArticleStock ( $ this -> oxorderarticles__oxamount -> value , $ myConfig -> getConfigParam ( 'blAllowNegativeStock' ) ) ; } } return $ blDelete ; }
Deletes order article object . If deletion succeded - updates article stock information . Returns deletion status
37,843
public function getWrapping ( ) { if ( $ this -> oxorderarticles__oxwrapid -> value ) { $ oWrapping = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Wrapping :: class ) ; if ( $ oWrapping -> load ( $ this -> oxorderarticles__oxwrapid -> value ) ) { return $ oWrapping ; } } return null ; }
get used wrapping
37,844
public function getBrutPriceFormated ( ) { $ oLang = \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) ; $ oOrder = $ this -> getOrder ( ) ; $ oCurrency = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getCurrencyObject ( $ oOrder -> oxorder__oxcurrency -> value ) ; return $ oLang -> formatCurrency ( $ this -> oxorderarticles__oxbprice -> value , $ oCurrency ) ; }
Get brut price formated
37,845
public function getNetPriceFormated ( ) { $ oLang = \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) ; $ oOrder = $ this -> getOrder ( ) ; $ oCurrency = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getCurrencyObject ( $ oOrder -> oxorder__oxcurrency -> value ) ; return $ oLang -> formatCurrency ( $ this -> oxorderarticles__oxnprice -> value , $ oCurrency ) ; }
Get Net price formated
37,846
public function getOrder ( ) { if ( $ this -> oxorderarticles__oxorderid -> value ) { if ( isset ( $ this -> _aOrderCache [ $ this -> oxorderarticles__oxorderid -> value ] ) ) { return $ this -> _aOrderCache [ $ this -> oxorderarticles__oxorderid -> value ] ; } $ oOrder = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Order :: class ) ; if ( $ oOrder -> load ( $ this -> oxorderarticles__oxorderid -> value ) ) { return $ this -> _aOrderCache [ $ this -> oxorderarticles__oxorderid -> value ] = $ oOrder ; } } return null ; }
Returns oxOrder object that the article belongs to
37,847
public function _setOrderFiles ( ) { $ oArticle = $ this -> getArticle ( ) ; if ( $ oArticle -> oxarticles__oxisdownloadable -> value ) { $ oConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ sOrderId = $ this -> oxorderarticles__oxorderid -> value ; $ sOrderArticleId = $ this -> getId ( ) ; $ sShopId = $ oConfig -> getShopId ( ) ; $ oUser = $ oConfig -> getUser ( ) ; $ oFiles = $ oArticle -> getArticleFiles ( true ) ; if ( $ oFiles ) { foreach ( $ oFiles as $ oFile ) { $ oOrderFile = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ OrderFile :: class ) ; $ oOrderFile -> setOrderId ( $ sOrderId ) ; $ oOrderFile -> setOrderArticleId ( $ sOrderArticleId ) ; $ oOrderFile -> setShopId ( $ sShopId ) ; $ iMaxDownloadCount = ( ! empty ( $ oUser ) && ! $ oUser -> hasAccount ( ) ) ? $ oFile -> getMaxUnregisteredDownloadsCount ( ) : $ oFile -> getMaxDownloadsCount ( ) ; $ oOrderFile -> setFile ( $ oFile -> oxfiles__oxfilename -> value , $ oFile -> getId ( ) , $ iMaxDownloadCount * $ this -> oxorderarticles__oxamount -> value , $ oFile -> getLinkExpirationTime ( ) , $ oFile -> getDownloadExpirationTime ( ) ) ; $ oOrderFile -> save ( ) ; } } } }
Set order files
37,848
public function readResultFile ( $ sOutputKey = null ) { $ sCurrentKey = ( empty ( $ sOutputKey ) ) ? $ this -> _sOutputKey : $ sOutputKey ; return $ this -> _oUtils -> fromFileCache ( $ sCurrentKey ) ; }
Reads exported result file contents
37,849
public function downloadResultFile ( $ sOutputKey = null ) { $ sCurrentKey = ( empty ( $ sOutputKey ) ) ? $ this -> _sOutputKey : $ sOutputKey ; $ this -> _oUtils = \ OxidEsales \ Eshop \ Core \ Registry :: getUtils ( ) ; $ iFileSize = filesize ( $ this -> _oUtils -> getCacheFilePath ( $ sCurrentKey ) ) ; $ this -> _oUtils -> setHeader ( "Pragma: public" ) ; $ this -> _oUtils -> setHeader ( "Expires: 0" ) ; $ this -> _oUtils -> setHeader ( "Cache-Control: must-revalidate, post-check=0, pre-check=0, private" ) ; $ this -> _oUtils -> setHeader ( 'Content-Disposition: attachment;filename=' . $ this -> _sOutputFileName ) ; $ this -> _oUtils -> setHeader ( "Content-Type:text/html;charset=utf-8" ) ; if ( $ iFileSize ) { $ this -> _oUtils -> setHeader ( "Content-Length: " . $ iFileSize ) ; } echo $ this -> _oUtils -> fromFileCache ( $ sCurrentKey ) ; }
Sends generated file for download
37,850
public function getVoucherByNr ( $ sVoucherNr , $ aVouchers = [ ] , $ blCheckavalability = false ) { $ oRet = null ; if ( ! empty ( $ sVoucherNr ) ) { $ sViewName = $ this -> getViewName ( ) ; $ sSeriesViewName = getViewName ( 'oxvoucherseries' ) ; $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sQ = "select {$sViewName}.* from {$sViewName}, {$sSeriesViewName} where {$sSeriesViewName}.oxid = {$sViewName}.oxvoucherserieid and {$sViewName}.oxvouchernr = " . $ oDb -> quote ( $ sVoucherNr ) . " and " ; if ( is_array ( $ aVouchers ) ) { foreach ( $ aVouchers as $ sVoucherId => $ sSkipVoucherNr ) { $ sQ .= "{$sViewName}.oxid != " . $ oDb -> quote ( $ sVoucherId ) . " and " ; } } $ sQ .= "( {$sViewName}.oxorderid is NULL || {$sViewName}.oxorderid = '' ) " ; $ sQ .= " and ( {$sViewName}.oxdateused is NULL || {$sViewName}.oxdateused = 0 ) " ; if ( $ blCheckavalability ) { $ iTime = time ( ) - $ this -> _getVoucherTimeout ( ) ; $ sQ .= " and {$sViewName}.oxreserved < '{$iTime}' " ; } $ sQ .= " limit 1" ; if ( ! ( $ oRet = $ this -> assignRecord ( $ sQ ) ) ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_NOVOUCHER' ) ; $ oEx -> setVoucherNr ( $ sVoucherNr ) ; throw $ oEx ; } } return $ oRet ; }
Gets voucher from db by given number .
37,851
public function markAsUsed ( $ sOrderId , $ sUserId , $ dDiscount ) { if ( $ this -> oxvouchers__oxid -> value ) { $ this -> oxvouchers__oxorderid -> setValue ( $ sOrderId ) ; $ this -> oxvouchers__oxuserid -> setValue ( $ sUserId ) ; $ this -> oxvouchers__oxdiscount -> setValue ( $ dDiscount ) ; $ this -> oxvouchers__oxdateused -> setValue ( date ( "Y-m-d" , \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsDate ( ) -> getTime ( ) ) ) ; $ this -> save ( ) ; } }
marks voucher as used
37,852
public function markAsReserved ( ) { $ sVoucherID = $ this -> oxvouchers__oxid -> value ; if ( $ sVoucherID ) { $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sQ = "update oxvouchers set oxreserved = " . time ( ) . " where oxid = " . $ oDb -> quote ( $ sVoucherID ) ; $ oDb -> Execute ( $ sQ ) ; } }
mark voucher as reserved
37,853
public function checkVoucherAvailability ( $ aVouchers , $ dPrice ) { $ this -> _isAvailableWithSameSeries ( $ aVouchers ) ; $ this -> _isAvailableWithOtherSeries ( $ aVouchers ) ; $ this -> _isValidDate ( ) ; $ this -> _isAvailablePrice ( $ dPrice ) ; $ this -> _isNotReserved ( ) ; return true ; }
Checks availability without user logged in . Returns array with errors .
37,854
protected function _isAvailablePrice ( $ dPrice ) { $ oSeries = $ this -> getSerie ( ) ; $ oCur = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getActShopCurrencyObject ( ) ; if ( $ oSeries -> oxvoucherseries__oxminimumvalue -> value && $ dPrice < ( $ oSeries -> oxvoucherseries__oxminimumvalue -> value * $ oCur -> rate ) ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_INCORRECTPRICE' ) ; $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; } return true ; }
Checks availability about price . Returns error array .
37,855
protected function _isAvailableWithSameSeries ( $ aVouchers ) { if ( is_array ( $ aVouchers ) ) { $ sId = $ this -> getId ( ) ; if ( isset ( $ aVouchers [ $ sId ] ) ) { unset ( $ aVouchers [ $ sId ] ) ; } $ oSeries = $ this -> getSerie ( ) ; if ( ! $ oSeries -> oxvoucherseries__oxallowsameseries -> value ) { foreach ( $ aVouchers as $ voucherId => $ voucherNr ) { $ oVoucher = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Voucher :: class ) ; $ oVoucher -> load ( $ voucherId ) ; if ( $ this -> oxvouchers__oxvoucherserieid -> value == $ oVoucher -> oxvouchers__oxvoucherserieid -> value ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_NOTALLOWEDSAMESERIES' ) ; $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; } } } } return true ; }
Checks if calculation with vouchers of the same series possible . Returns true on success .
37,856
protected function _isAvailableWithOtherSeries ( $ aVouchers ) { if ( is_array ( $ aVouchers ) && count ( $ aVouchers ) ) { $ oSeries = $ this -> getSerie ( ) ; $ sIds = implode ( ',' , \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) -> quoteArray ( array_keys ( $ aVouchers ) ) ) ; $ blAvailable = true ; $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; if ( ! $ oSeries -> oxvoucherseries__oxallowotherseries -> value ) { $ sSql = "select 1 from oxvouchers where oxvouchers.oxid in ($sIds) and " ; $ sSql .= "oxvouchers.oxvoucherserieid != " . $ oDb -> quote ( $ this -> oxvouchers__oxvoucherserieid -> value ) ; $ blAvailable &= ! $ oDb -> getOne ( $ sSql ) ; } else { $ sSql = "select 1 from oxvouchers left join oxvoucherseries on oxvouchers.oxvoucherserieid=oxvoucherseries.oxid " ; $ sSql .= "where oxvouchers.oxid in ($sIds) and oxvouchers.oxvoucherserieid != " . $ oDb -> quote ( $ this -> oxvouchers__oxvoucherserieid -> value ) ; $ sSql .= "and not oxvoucherseries.oxallowotherseries" ; $ blAvailable &= ! $ oDb -> getOne ( $ sSql ) ; } if ( ! $ blAvailable ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_NOTALLOWEDOTHERSERIES' ) ; $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; } } return true ; }
Checks if calculation with vouchers from the other series possible . Returns true on success .
37,857
protected function _isValidDate ( ) { $ oSeries = $ this -> getSerie ( ) ; $ iTime = time ( ) ; $ iTomorrow = mktime ( 0 , 0 , 0 , date ( "m" ) , date ( "d" ) + 1 , date ( "Y" ) ) ; $ iYesterday = mktime ( 0 , 0 , 0 , date ( "m" ) , date ( "d" ) - 1 , date ( "Y" ) ) ; $ iFrom = ( ( int ) $ oSeries -> oxvoucherseries__oxbegindate -> value ) ? strtotime ( $ oSeries -> oxvoucherseries__oxbegindate -> value ) : $ iYesterday ; $ iTo = ( ( int ) $ oSeries -> oxvoucherseries__oxenddate -> value ) ? strtotime ( $ oSeries -> oxvoucherseries__oxenddate -> value ) : $ iTomorrow ; if ( $ iFrom < $ iTime && $ iTo > $ iTime ) { return true ; } $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'MESSAGE_COUPON_EXPIRED' ) ; if ( $ iFrom > $ iTime && $ iTo > $ iTime ) { $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_NOVOUCHER' ) ; } $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; }
Checks if voucher is in valid time period . Returns true on success .
37,858
protected function _isNotReserved ( ) { if ( $ this -> oxvouchers__oxreserved -> value < time ( ) - $ this -> _getVoucherTimeout ( ) ) { return true ; } $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'EXCEPTION_VOUCHER_ISRESERVED' ) ; $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; }
Checks if voucher is not yet reserved before .
37,859
protected function _isAvailableInOtherOrder ( $ oUser ) { $ oSeries = $ this -> getSerie ( ) ; if ( ! $ oSeries -> oxvoucherseries__oxallowuseanother -> value ) { $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sSelect = 'select count(*) from ' . $ this -> getViewName ( ) . ' where oxuserid = ' . $ oDb -> quote ( $ oUser -> oxuser__oxid -> value ) . ' and ' ; $ sSelect .= 'oxvoucherserieid = ' . $ oDb -> quote ( $ this -> oxvouchers__oxvoucherserieid -> value ) . ' and ' ; $ sSelect .= '((oxorderid is not NULL and oxorderid != "") or (oxdateused is not NULL and oxdateused != 0)) ' ; if ( $ oDb -> getOne ( $ sSelect ) ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_NOTALLOWEDSAMESERIES' ) ; $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; } } return true ; }
Checks if user already used vouchers from this series and can he use it again .
37,860
protected function _isValidUserGroup ( $ oUser ) { $ oVoucherSeries = $ this -> getSerie ( ) ; $ oUserGroups = $ oVoucherSeries -> setUserGroups ( ) ; if ( ! $ oUserGroups -> count ( ) ) { return true ; } if ( $ oUser ) { foreach ( $ oUserGroups as $ oGroup ) { if ( $ oUser -> inGroup ( $ oGroup -> getId ( ) ) ) { return true ; } } } $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_NOTVALIDUSERGROUP' ) ; $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; }
Checks if user belongs to the same group as the voucher . Returns true on sucess .
37,861
public function getSimpleVoucher ( ) { $ oVoucher = new stdClass ( ) ; $ oVoucher -> sVoucherId = $ this -> getId ( ) ; $ oVoucher -> sVoucherNr = null ; if ( $ this -> oxvouchers__oxvouchernr ) { $ oVoucher -> sVoucherNr = $ this -> oxvouchers__oxvouchernr -> value ; } return $ oVoucher ; }
Returns compact voucher object which is used in oxBasket
37,862
public function getSerie ( ) { if ( $ this -> _oSerie !== null ) { return $ this -> _oSerie ; } $ oSerie = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ VoucherSerie :: class ) ; if ( ! $ oSerie -> load ( $ this -> oxvouchers__oxvoucherserieid -> value ) ) { throw oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ ObjectException :: class ) ; } $ this -> _oSerie = $ oSerie ; return $ oSerie ; }
create oxVoucherSerie object of this voucher
37,863
protected function _isProductVoucher ( ) { $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ oSeries = $ this -> getSerie ( ) ; $ sSelect = "select 1 from oxobject2discount where oxdiscountid = " . $ oDb -> quote ( $ oSeries -> getId ( ) ) . " and oxtype = 'oxarticles'" ; $ blOk = ( bool ) $ oDb -> getOne ( $ sSelect ) ; return $ blOk ; }
Returns true if voucher is product specific otherwise false
37,864
protected function _getSerieDiscount ( ) { $ oSeries = $ this -> getSerie ( ) ; $ oDiscount = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Discount :: class ) ; $ oDiscount -> setId ( $ oSeries -> getId ( ) ) ; $ oDiscount -> oxdiscount__oxshopid = new \ OxidEsales \ Eshop \ Core \ Field ( $ oSeries -> oxvoucherseries__oxshopid -> value ) ; $ oDiscount -> oxdiscount__oxactive = new \ OxidEsales \ Eshop \ Core \ Field ( true ) ; $ oDiscount -> oxdiscount__oxactivefrom = new \ OxidEsales \ Eshop \ Core \ Field ( $ oSeries -> oxvoucherseries__oxbegindate -> value ) ; $ oDiscount -> oxdiscount__oxactiveto = new \ OxidEsales \ Eshop \ Core \ Field ( $ oSeries -> oxvoucherseries__oxenddate -> value ) ; $ oDiscount -> oxdiscount__oxtitle = new \ OxidEsales \ Eshop \ Core \ Field ( $ oSeries -> oxvoucherseries__oxserienr -> value ) ; $ oDiscount -> oxdiscount__oxamount = new \ OxidEsales \ Eshop \ Core \ Field ( 1 ) ; $ oDiscount -> oxdiscount__oxamountto = new \ OxidEsales \ Eshop \ Core \ Field ( MAX_64BIT_INTEGER ) ; $ oDiscount -> oxdiscount__oxprice = new \ OxidEsales \ Eshop \ Core \ Field ( 0 ) ; $ oDiscount -> oxdiscount__oxpriceto = new \ OxidEsales \ Eshop \ Core \ Field ( MAX_64BIT_INTEGER ) ; $ oDiscount -> oxdiscount__oxaddsumtype = new \ OxidEsales \ Eshop \ Core \ Field ( $ oSeries -> oxvoucherseries__oxdiscounttype -> value == 'percent' ? '%' : 'abs' ) ; $ oDiscount -> oxdiscount__oxaddsum = new \ OxidEsales \ Eshop \ Core \ Field ( $ oSeries -> oxvoucherseries__oxdiscount -> value ) ; $ oDiscount -> oxdiscount__oxitmartid = new \ OxidEsales \ Eshop \ Core \ Field ( ) ; $ oDiscount -> oxdiscount__oxitmamount = new \ OxidEsales \ Eshop \ Core \ Field ( ) ; $ oDiscount -> oxdiscount__oxitmmultiple = new \ OxidEsales \ Eshop \ Core \ Field ( ) ; return $ oDiscount ; }
Returns the discount object created from voucher serie data
37,865
protected function _getBasketItems ( $ oDiscount = null ) { if ( $ this -> oxvouchers__oxorderid -> value ) { return $ this -> _getOrderBasketItems ( $ oDiscount ) ; } elseif ( $ this -> getSession ( ) -> getBasket ( ) ) { return $ this -> _getSessionBasketItems ( $ oDiscount ) ; } else { return [ ] ; } }
Returns basket item information array from session or order .
37,866
protected function _getProductDiscountValue ( $ dPrice ) { $ oDiscount = $ this -> _getSerieDiscount ( ) ; $ aBasketItems = $ this -> _getBasketItems ( $ oDiscount ) ; if ( ! count ( $ aBasketItems ) && ! $ this -> isAdmin ( ) ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_NOVOUCHER' ) ; $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; } $ oSeries = $ this -> getSerie ( ) ; $ oVoucherPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ oDiscountPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ oProductPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ oProductTotal = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ blDiscountApplied = false ; foreach ( $ aBasketItems as $ aBasketItem ) { if ( $ blDiscountApplied and ! empty ( $ oSeries -> oxvoucherseries__oxcalculateonce -> value ) ) { break ; } $ oDiscountPrice -> setPrice ( $ aBasketItem [ 'discount' ] ) ; $ oProductPrice -> setPrice ( $ aBasketItem [ 'price' ] ) ; if ( ! $ oSeries -> oxvoucherseries__oxcalculateonce -> value ) { $ oDiscountPrice -> multiply ( $ aBasketItem [ 'amount' ] ) ; $ oProductPrice -> multiply ( $ aBasketItem [ 'amount' ] ) ; } $ oVoucherPrice -> add ( $ oDiscountPrice -> getBruttoPrice ( ) ) ; $ oProductTotal -> add ( $ oProductPrice -> getBruttoPrice ( ) ) ; if ( ! empty ( $ aBasketItem [ 'discount' ] ) ) { $ blDiscountApplied = true ; } } $ dVoucher = $ oVoucherPrice -> getBruttoPrice ( ) ; $ dProduct = $ oProductTotal -> getBruttoPrice ( ) ; if ( $ dVoucher > $ dProduct ) { return $ dProduct ; } return $ dVoucher ; }
Returns the discount value used if voucher is aplied only for specific products .
37,867
protected function _getCategoryDiscountValue ( $ dPrice ) { $ oDiscount = $ this -> _getSerieDiscount ( ) ; $ aBasketItems = $ this -> _getBasketItems ( $ oDiscount ) ; if ( ! count ( $ aBasketItems ) && ! $ this -> isAdmin ( ) ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_NOVOUCHER' ) ; $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; } $ oProductPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ oProductTotal = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; foreach ( $ aBasketItems as $ aBasketItem ) { $ oProductPrice -> setPrice ( $ aBasketItem [ 'price' ] ) ; $ oProductPrice -> multiply ( $ aBasketItem [ 'amount' ] ) ; $ oProductTotal -> add ( $ oProductPrice -> getBruttoPrice ( ) ) ; } $ dProduct = $ oProductTotal -> getBruttoPrice ( ) ; $ dVoucher = $ oDiscount -> getAbsValue ( $ dProduct ) ; return ( $ dVoucher > $ dProduct ) ? $ dProduct : $ dVoucher ; }
Returns the discount value used if voucher is applied only for specific categories .
37,868
protected function _getVoucherTimeout ( ) { $ iVoucherTimeout = ( int ) \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'iVoucherTimeout' ) ? : 3 * 3600 ; return $ iVoucherTimeout ; }
Returns a configured value for voucher timeouts or a default of 3 hours if not configured
37,869
public function render ( ) { parent :: render ( ) ; $ aClassVars = get_object_vars ( $ this ) ; foreach ( $ aClassVars as $ name => $ value ) { $ this -> _aViewData [ $ name ] = $ value ; } $ this -> _aViewData [ 'sOutputFile' ] = $ this -> _sFilePath ; $ this -> _aViewData [ 'sDownloadFile' ] = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'sShopURL' ) . $ this -> sExportPath . $ this -> sExportFileName . "." . $ this -> sExportFileType ; return $ this -> _sThisTemplate ; }
Calls parent rendering methods sends implementation class names to template and returns default template name
37,870
public function createMainExportView ( ) { $ this -> _aViewData [ "cattree" ] = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ CategoryList :: class ) ; $ this -> _aViewData [ "cattree" ] -> loadList ( ) ; $ oLangObj = oxNew ( \ OxidEsales \ Eshop \ Core \ Language :: class ) ; $ aLangs = $ oLangObj -> getLanguageArray ( ) ; foreach ( $ aLangs as $ id => $ language ) { $ language -> selected = ( $ id == $ this -> _iEditLang ) ; $ this -> _aViewData [ "aLangs" ] [ $ id ] = clone $ language ; } }
Prepares and fill all data which all the dyn exports needs
37,871
public function write ( $ sLine ) { $ sLine = $ this -> removeSID ( $ sLine ) ; $ sLine = str_replace ( [ "\r\n" , "\n" ] , "" , $ sLine ) ; fwrite ( $ this -> fpFile , $ sLine . "\r\n" ) ; }
writes one line into open export file
37,872
public function getExportPerTick ( ) { if ( $ this -> _iExportPerTick === null ) { $ this -> _iExportPerTick = ( int ) \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( "iExportNrofLines" ) ; if ( ! $ this -> _iExportPerTick ) { $ this -> _iExportPerTick = $ this -> iExportPerTick ; } } return $ this -> _iExportPerTick ; }
Returns how many articles should be exported per tick
37,873
public function getDefaultCategoryString ( $ oArticle ) { $ sLang = \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> getBaseLanguage ( ) ; $ oDB = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sCatView = getViewName ( 'oxcategories' , $ sLang ) ; $ sO2CView = getViewName ( 'oxobject2category' , $ sLang ) ; $ sQ = "select $sCatView.oxtitle from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid " ; $ sQ .= "where oxobject2category.oxobjectid=" . $ oDB -> quote ( $ oArticle -> getId ( ) ) . " and $sCatView.oxactive = 1 order by oxobject2category.oxtime " ; return $ oDB -> getOne ( $ sQ ) ; }
Loads article default category
37,874
public function prepareCSV ( $ sInput ) { $ sInput = \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsString ( ) -> prepareCSVField ( $ sInput ) ; return str_replace ( [ "&nbsp;" , "&euro;" , "|" ] , [ " " , "" , "" ] , $ sInput ) ; }
Converts field for CSV
37,875
public function prepareXML ( $ sInput ) { $ sOutput = str_replace ( "&" , "&amp;" , $ sInput ) ; $ sOutput = str_replace ( "\"" , "&quot;" , $ sOutput ) ; $ sOutput = str_replace ( ">" , "&gt;" , $ sOutput ) ; $ sOutput = str_replace ( "<" , "&lt;" , $ sOutput ) ; $ sOutput = str_replace ( "'" , "&apos;" , $ sOutput ) ; return $ sOutput ; }
Changes special chars to be XML compatible
37,876
public function prepareExport ( ) { $ oDB = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sHeapTable = $ this -> _getHeapTableName ( ) ; $ oRs = $ oDB -> select ( "SHOW VARIABLES LIKE 'version'" ) ; $ sTableCharset = $ this -> _generateTableCharSet ( $ oRs -> fields [ 1 ] ) ; if ( ! ( $ this -> _createHeapTable ( $ sHeapTable , $ sTableCharset ) ) ) { \ OxidEsales \ Eshop \ Core \ Registry :: getUtils ( ) -> showMessageAndExit ( "Could not create HEAP Table {$sHeapTable}\n<br>" ) ; } $ sCatAdd = $ this -> _getCatAdd ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "acat" ) ) ; if ( ! $ this -> _insertArticles ( $ sHeapTable , $ sCatAdd ) ) { \ OxidEsales \ Eshop \ Core \ Registry :: getUtils ( ) -> showMessageAndExit ( "Could not insert Articles in Table {$sHeapTable}\n<br>" ) ; } $ this -> _removeParentArticles ( $ sHeapTable ) ; $ this -> _setSessionParams ( ) ; return $ oDB -> getOne ( "select count(*) from {$sHeapTable}" ) ; }
create export resultset
37,877
public function getOneArticle ( $ iCnt , & $ blContinue ) { $ myConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ myConfig -> setConfigParam ( 'blExport' , true ) ; $ blContinue = false ; if ( ( $ oArticle = $ this -> _initArticle ( $ this -> _getHeapTableName ( ) , $ iCnt , $ blContinue ) ) ) { $ blContinue = true ; $ oArticle = $ this -> _setCampaignDetailLink ( $ oArticle ) ; } $ myConfig -> setConfigParam ( 'blExport' , false ) ; return $ oArticle ; }
get s one oxid for exporting
37,878
public function assureContent ( $ sInput , $ sReplace = null ) { $ oStr = getStr ( ) ; if ( ! $ oStr -> strlen ( $ sInput ) ) { if ( ! isset ( $ sReplace ) || ! $ oStr -> strlen ( $ sReplace ) ) { $ sReplace = "-" ; } $ sInput = $ sReplace ; } return $ sInput ; }
Make sure that string is never empty .
37,879
protected function _generateTableCharSet ( $ sMysqlVersion ) { $ sTableCharset = "" ; if ( version_compare ( $ sMysqlVersion , '4.1.0' , '>=' ) > 0 ) { $ oDB = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: FETCH_MODE_ASSOC ) ; $ oRs = $ oDB -> select ( "SHOW FULL COLUMNS FROM `oxarticles` WHERE field like 'OXID'" ) ; if ( isset ( $ oRs -> fields [ 'Collation' ] ) && ( $ sMysqlCollation = $ oRs -> fields [ 'Collation' ] ) ) { $ oRs = $ oDB -> select ( "SHOW COLLATION LIKE '{$sMysqlCollation}'" ) ; if ( isset ( $ oRs -> fields [ 'Charset' ] ) && ( $ sMysqlCharacterSet = $ oRs -> fields [ 'Charset' ] ) ) { $ sTableCharset = "DEFAULT CHARACTER SET {$sMysqlCharacterSet} COLLATE {$sMysqlCollation}" ; } } } return $ sTableCharset ; }
generates table charset
37,880
protected function _getCatAdd ( $ aChosenCat ) { $ sCatAdd = null ; if ( is_array ( $ aChosenCat ) && count ( $ aChosenCat ) ) { $ oDB = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sCatAdd = " and ( " ; $ blSep = false ; foreach ( $ aChosenCat as $ sCat ) { if ( $ blSep ) { $ sCatAdd .= " or " ; } $ sCatAdd .= "oxobject2category.oxcatnid = " . $ oDB -> quote ( $ sCat ) ; $ blSep = true ; } $ sCatAdd .= ")" ; } return $ sCatAdd ; }
creates additional cat string
37,881
protected function _insertArticles ( $ sHeapTable , $ sCatAdd ) { $ oDB = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ iExpLang = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "iExportLanguage" ) ; if ( ! isset ( $ iExpLang ) ) { $ iExpLang = \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> getVariable ( "iExportLanguage" ) ; } $ oArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; $ oArticle -> setLanguage ( $ iExpLang ) ; $ sO2CView = getViewName ( 'oxobject2category' , $ iExpLang ) ; $ sArticleTable = getViewName ( "oxarticles" , $ iExpLang ) ; $ insertQuery = "insert into {$sHeapTable} select {$sArticleTable}.oxid from {$sArticleTable}, {$sO2CView} as oxobject2category where " ; $ insertQuery .= $ oArticle -> getSqlActiveSnippet ( ) ; if ( ! \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "blExportVars" ) ) { $ insertQuery .= " and {$sArticleTable}.oxid = oxobject2category.oxobjectid and {$sArticleTable}.oxparentid = '' " ; } else { $ insertQuery .= " and ( {$sArticleTable}.oxid = oxobject2category.oxobjectid or {$sArticleTable}.oxparentid = oxobject2category.oxobjectid ) " ; } $ sSearchString = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "search" ) ; if ( isset ( $ sSearchString ) ) { $ insertQuery .= "and ( {$sArticleTable}.OXTITLE like " . $ oDB -> quote ( "%{$sSearchString}%" ) ; $ insertQuery .= " or {$sArticleTable}.OXSHORTDESC like " . $ oDB -> quote ( "%$sSearchString%" ) ; $ insertQuery .= " or {$sArticleTable}.oxsearchkeys like " . $ oDB -> quote ( "%$sSearchString%" ) . " ) " ; } if ( $ sCatAdd ) { $ insertQuery .= $ sCatAdd ; } if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blUseStock' ) && ( $ dMinStock = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "sExportMinStock" ) ) ) { $ dMinStock = str_replace ( [ ";" , " " , "/" , "'" ] , "" , $ dMinStock ) ; $ insertQuery .= " and {$sArticleTable}.oxstock >= " . $ oDB -> quote ( $ dMinStock ) ; } $ insertQuery .= " group by {$sArticleTable}.oxid" ; return $ oDB -> execute ( $ insertQuery ) ? true : false ; }
inserts articles into heaptable
37,882
protected function _removeParentArticles ( $ sHeapTable ) { if ( ! ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "blExportMainVars" ) ) ) { $ oDB = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sArticleTable = getViewName ( 'oxarticles' ) ; $ sQ = "select $sHeapTable.oxid from $sHeapTable, $sArticleTable where $sHeapTable.oxid = $sArticleTable.oxparentid group by $sHeapTable.oxid" ; $ oRs = $ oDB -> select ( $ sQ ) ; $ sDel = "delete from $sHeapTable where oxid in ( " ; $ blSep = false ; if ( $ oRs != false && $ oRs -> count ( ) > 0 ) { while ( ! $ oRs -> EOF ) { if ( $ blSep ) { $ sDel .= "," ; } $ sDel .= $ oDB -> quote ( $ oRs -> fields [ 0 ] ) ; $ blSep = true ; $ oRs -> fetchRow ( ) ; } } $ sDel .= " )" ; $ oDB -> execute ( $ sDel ) ; } }
removes parent articles so that we only have variants itself
37,883
protected function _setSessionParams ( ) { \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> deleteVariable ( "sExportDelCost" ) ; $ dDelCost = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "sExportDelCost" ) ; if ( isset ( $ dDelCost ) ) { $ dDelCost = str_replace ( [ ";" , " " , "/" , "'" ] , "" , $ dDelCost ) ; $ dDelCost = str_replace ( "," , "." , $ dDelCost ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( "sExportDelCost" , $ dDelCost ) ; } \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> deleteVariable ( "sExportMinPrice" ) ; $ dMinPrice = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "sExportMinPrice" ) ; if ( isset ( $ dMinPrice ) ) { $ dMinPrice = str_replace ( [ ";" , " " , "/" , "'" ] , "" , $ dMinPrice ) ; $ dMinPrice = str_replace ( "," , "." , $ dMinPrice ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( "sExportMinPrice" , $ dMinPrice ) ; } \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> deleteVariable ( "sExportCampaign" ) ; $ sCampaign = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "sExportCampaign" ) ; if ( isset ( $ sCampaign ) ) { $ sCampaign = str_replace ( [ ";" , " " , "/" , "'" ] , "" , $ sCampaign ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( "sExportCampaign" , $ sCampaign ) ; } \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> deleteVariable ( "blAppendCatToCampaign" ) ; $ blAppendCatToCampaign = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "blAppendCatToCampaign" ) ; if ( $ blAppendCatToCampaign ) { \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( "blAppendCatToCampaign" , $ blAppendCatToCampaign ) ; } \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> deleteVariable ( "iExportLanguage" ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( "iExportLanguage" , \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "iExportLanguage" ) ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( "sExportCustomHeader" , \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "sExportCustomHeader" ) ) ; }
stores some info in session
37,884
protected function _loadRootCats ( ) { if ( $ this -> _aCatLvlCache === null ) { $ this -> _aCatLvlCache = [ ] ; $ sCatView = getViewName ( 'oxcategories' ) ; $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sSQL = "select oxid from $sCatView where oxparentid = 'oxrootid'" ; $ oRs = $ oDb -> select ( $ sSQL ) ; if ( $ oRs != false && $ oRs -> count ( ) > 0 ) { while ( ! $ oRs -> EOF ) { $ sSQL = "SELECT s.oxid, s.oxtitle, s.oxparentid, count( * ) AS LEVEL FROM $sCatView v, $sCatView s WHERE s.oxrootid = '" . $ oRs -> fields [ 0 ] . "' and v.oxrootid='" . $ oRs -> fields [ 0 ] . "' and s.oxleft BETWEEN v.oxleft AND v.oxright AND s.oxhidden = '0' GROUP BY s.oxleft order by level" ; $ oRs2 = $ oDb -> select ( $ sSQL ) ; if ( $ oRs2 != false && $ oRs2 -> count ( ) > 0 ) { while ( ! $ oRs2 -> EOF ) { $ oCat = new stdClass ( ) ; $ oCat -> _sOXID = $ oRs2 -> fields [ 0 ] ; $ oCat -> oxtitle = $ oRs2 -> fields [ 1 ] ; $ oCat -> oxparentid = $ oRs2 -> fields [ 2 ] ; $ oCat -> ilevel = $ oRs2 -> fields [ 3 ] ; $ this -> _aCatLvlCache [ $ oCat -> _sOXID ] = $ oCat ; $ oRs2 -> fetchRow ( ) ; } } $ oRs -> fetchRow ( ) ; } } } return $ this -> _aCatLvlCache ; }
Load all root cat s == all trees
37,885
protected function _findDeepestCatPath ( $ oArticle ) { $ sRet = "" ; $ aIds = $ oArticle -> getCategoryIds ( ) ; if ( is_array ( $ aIds ) && count ( $ aIds ) ) { if ( $ aCatLvlCache = $ this -> _loadRootCats ( ) ) { $ sIdMax = null ; $ dMaxLvl = 0 ; foreach ( $ aIds as $ sCatId ) { if ( $ dMaxLvl < $ aCatLvlCache [ $ sCatId ] -> ilevel ) { $ dMaxLvl = $ aCatLvlCache [ $ sCatId ] -> ilevel ; $ sIdMax = $ sCatId ; $ sRet = $ aCatLvlCache [ $ sCatId ] -> oxtitle ; } } while ( true ) { if ( ! isset ( $ aCatLvlCache [ $ sIdMax ] -> oxparentid ) || $ aCatLvlCache [ $ sIdMax ] -> oxparentid == "oxrootid" ) { break ; } $ sIdMax = $ aCatLvlCache [ $ sIdMax ] -> oxparentid ; $ sRet = $ aCatLvlCache [ $ sIdMax ] -> oxtitle . "/" . $ sRet ; } } } return $ sRet ; }
finds deepest category path
37,886
protected function _setCampaignDetailLink ( $ oArticle ) { if ( $ sCampaign = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "sExportCampaign" ) ) { $ oArticle -> appendLink ( "campaign={$sCampaign}" ) ; if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "blAppendCatToCampaign" ) && ( $ sCat = $ this -> getCategoryString ( $ oArticle ) ) ) { $ oArticle -> appendLink ( "/$sCat" ) ; } } return $ oArticle ; }
sets detail link for campaigns
37,887
public function getArticleRecommUri ( $ oArticle , $ iLang ) { $ sSeoUri = null ; if ( $ oRecomm = $ this -> _getRecomm ( $ oArticle , $ iLang ) ) { if ( ! ( $ sSeoUri = $ this -> _loadFromDb ( 'oxarticle' , $ oArticle -> getId ( ) , $ iLang , null , $ oRecomm -> getId ( ) , true ) ) ) { $ oArticle = $ this -> _getProductForLang ( $ oArticle , $ iLang ) ; $ sTitle = $ this -> _prepareArticleTitle ( $ oArticle ) ; $ sSeoUri = \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ SeoEncoderRecomm :: class ) -> getRecommUri ( $ oRecomm , $ iLang ) ; $ sSeoUri = $ this -> _processSeoUrl ( $ sSeoUri . $ sTitle , $ oArticle -> getId ( ) , $ iLang ) ; $ aStdParams = [ 'recommid' => $ oRecomm -> getId ( ) , 'listtype' => $ this -> _getListType ( ) ] ; $ this -> _saveToDb ( 'oxarticle' , $ oArticle -> getId ( ) , \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsUrl ( ) -> appendUrl ( $ oArticle -> getBaseStdLink ( $ iLang ) , $ aStdParams ) , $ sSeoUri , $ iLang , null , 0 , $ oRecomm -> getId ( ) ) ; } } return $ sSeoUri ; }
Returns SEO uri for passed article and active tag
37,888
protected function _getRecomm ( $ oArticle , $ iLang ) { $ oList = null ; $ oView = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getActiveView ( ) ; if ( $ oView instanceof \ OxidEsales \ Eshop \ Application \ Controller \ FrontendController ) { $ oList = $ oView -> getActiveRecommList ( ) ; } return $ oList ; }
Returns active recommendation list object if available
37,889
protected function _createArticleCategoryUri ( $ oArticle , $ oCategory , $ iLang ) { startProfile ( __FUNCTION__ ) ; $ oArticle = $ this -> _getProductForLang ( $ oArticle , $ iLang ) ; $ sTitle = $ this -> _prepareArticleTitle ( $ oArticle ) ; $ sSeoUri = $ this -> _processSeoUrl ( \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ SeoEncoderCategory :: class ) -> getCategoryUri ( $ oCategory , $ iLang ) . $ sTitle , $ oArticle -> getId ( ) , $ iLang ) ; $ sCatId = $ oCategory -> getId ( ) ; $ this -> _saveToDb ( 'oxarticle' , $ oArticle -> getId ( ) , \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsUrl ( ) -> appendUrl ( $ oArticle -> getBaseStdLink ( $ iLang ) , [ 'cnid' => $ sCatId ] ) , $ sSeoUri , $ iLang , null , 0 , $ sCatId ) ; stopProfile ( __FUNCTION__ ) ; return $ sSeoUri ; }
create article uri for given category and save it
37,890
protected function _getCategory ( $ oArticle , $ iLang ) { $ oCat = null ; $ oView = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getActiveView ( ) ; if ( $ oView instanceof \ OxidEsales \ Eshop \ Application \ Controller \ FrontendController ) { $ oCat = $ oView -> getActiveCategory ( ) ; } elseif ( $ oView instanceof \ OxidEsales \ Eshop \ Core \ Controller \ BaseController ) { $ oCat = $ oView -> getActCategory ( ) ; } return $ oCat ; }
Returns active category if available
37,891
protected function _getMainCategory ( $ oArticle ) { $ oMainCat = null ; $ sArtId = $ oArticle -> getId ( ) ; if ( isset ( $ oArticle -> oxarticles__oxparentid -> value ) && $ oArticle -> oxarticles__oxparentid -> value ) { $ sArtId = $ oArticle -> oxarticles__oxparentid -> value ; } $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sQ = "select oxcatnid from " . getViewName ( "oxobject2category" ) . " where oxobjectid = " . $ oDb -> quote ( $ sArtId ) . " order by oxtime" ; $ sIdent = md5 ( $ sQ ) ; if ( ( $ sMainCatId = $ this -> _loadFromCache ( $ sIdent , "oxarticle" ) ) === false ) { $ sMainCatId = $ oDb -> getOne ( $ sQ ) ; $ this -> _saveInCache ( $ sIdent , $ sMainCatId , "oxarticle" ) ; } if ( $ sMainCatId ) { $ oMainCat = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Category :: class ) ; if ( ! $ oMainCat -> load ( $ sMainCatId ) ) { $ oMainCat = null ; } } return $ oMainCat ; }
Returns products main category id
37,892
public function getArticleVendorUri ( $ oArticle , $ iLang , $ blRegenerate = false ) { startProfile ( __FUNCTION__ ) ; $ sSeoUri = null ; if ( $ oVendor = $ this -> _getVendor ( $ oArticle , $ iLang ) ) { if ( $ blRegenerate || ! ( $ sSeoUri = $ this -> _loadFromDb ( 'oxarticle' , $ oArticle -> getId ( ) , $ iLang , null , $ oVendor -> getId ( ) , true ) ) ) { $ oArticle = $ this -> _getProductForLang ( $ oArticle , $ iLang ) ; $ sTitle = $ this -> _prepareArticleTitle ( $ oArticle ) ; $ sSeoUri = \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ SeoEncoderVendor :: class ) -> getVendorUri ( $ oVendor , $ iLang ) ; $ sSeoUri = $ this -> _processSeoUrl ( $ sSeoUri . $ sTitle , $ oArticle -> getId ( ) , $ iLang ) ; $ aStdParams = [ 'cnid' => "v_" . $ oVendor -> getId ( ) , 'listtype' => $ this -> _getListType ( ) ] ; $ this -> _saveToDb ( 'oxarticle' , $ oArticle -> getId ( ) , \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsUrl ( ) -> appendUrl ( $ oArticle -> getBaseStdLink ( $ iLang ) , $ aStdParams ) , $ sSeoUri , $ iLang , null , 0 , $ oVendor -> getId ( ) ) ; } stopProfile ( __FUNCTION__ ) ; } return $ sSeoUri ; }
Returns vendor seo uri for current article
37,893
protected function _getVendor ( $ oArticle , $ iLang ) { $ oView = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getActiveView ( ) ; $ oVendor = null ; if ( $ sActVendorId = $ oArticle -> oxarticles__oxvendorid -> value ) { if ( $ oView instanceof \ OxidEsales \ Eshop \ Application \ Controller \ FrontendController && ( $ oActVendor = $ oView -> getActVendor ( ) ) ) { $ oVendor = $ oActVendor ; } else { $ oVendor = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Vendor :: class ) ; } if ( $ oVendor -> getId ( ) !== $ sActVendorId ) { $ oVendor = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Vendor :: class ) ; if ( ! $ oVendor -> loadInLang ( $ iLang , $ sActVendorId ) ) { $ oVendor = null ; } } } return $ oVendor ; }
Returns active vendor if available
37,894
public function getArticleManufacturerUri ( $ oArticle , $ iLang , $ blRegenerate = false ) { $ sSeoUri = null ; startProfile ( __FUNCTION__ ) ; if ( $ oManufacturer = $ this -> _getManufacturer ( $ oArticle , $ iLang ) ) { if ( $ blRegenerate || ! ( $ sSeoUri = $ this -> _loadFromDb ( 'oxarticle' , $ oArticle -> getId ( ) , $ iLang , null , $ oManufacturer -> getId ( ) , true ) ) ) { $ oArticle = $ this -> _getProductForLang ( $ oArticle , $ iLang ) ; $ sTitle = $ this -> _prepareArticleTitle ( $ oArticle ) ; $ sSeoUri = \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ SeoEncoderManufacturer :: class ) -> getManufacturerUri ( $ oManufacturer , $ iLang ) ; $ sSeoUri = $ this -> _processSeoUrl ( $ sSeoUri . $ sTitle , $ oArticle -> getId ( ) , $ iLang ) ; $ aStdParams = [ 'mnid' => $ oManufacturer -> getId ( ) , 'listtype' => $ this -> _getListType ( ) ] ; $ this -> _saveToDb ( 'oxarticle' , $ oArticle -> getId ( ) , \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsUrl ( ) -> appendUrl ( $ oArticle -> getBaseStdLink ( $ iLang ) , $ aStdParams ) , $ sSeoUri , $ iLang , null , 0 , $ oManufacturer -> getId ( ) ) ; } stopProfile ( __FUNCTION__ ) ; } return $ sSeoUri ; }
Returns manufacturer seo uri for current article
37,895
protected function _getManufacturer ( $ oArticle , $ iLang ) { $ oManufacturer = null ; if ( $ sActManufacturerId = $ oArticle -> oxarticles__oxmanufacturerid -> value ) { $ oView = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getActiveView ( ) ; if ( $ oView instanceof \ OxidEsales \ Eshop \ Application \ Controller \ FrontendController && ( $ oActManufacturer = $ oView -> getActManufacturer ( ) ) ) { $ oManufacturer = $ oActManufacturer ; } else { $ oManufacturer = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Manufacturer :: class ) ; } if ( $ oManufacturer -> getId ( ) !== $ sActManufacturerId || $ oManufacturer -> getLanguage ( ) != $ iLang ) { $ oManufacturer = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Manufacturer :: class ) ; if ( ! $ oManufacturer -> loadInLang ( $ iLang , $ sActManufacturerId ) ) { $ oManufacturer = null ; } } } return $ oManufacturer ; }
Returns active manufacturer if available
37,896
public function getArticleMainUrl ( $ oArticle , $ iLang = null ) { if ( ! isset ( $ iLang ) ) { $ iLang = $ oArticle -> getLanguage ( ) ; } return $ this -> _getFullUrl ( $ this -> getArticleMainUri ( $ oArticle , $ iLang ) , $ iLang ) ; }
return article main url with path of its default category
37,897
public function getArticleUrl ( $ oArticle , $ iLang = null , $ iType = 0 ) { if ( ! isset ( $ iLang ) ) { $ iLang = $ oArticle -> getLanguage ( ) ; } $ sUri = null ; switch ( $ iType ) { case OXARTICLE_LINKTYPE_VENDOR : $ sUri = $ this -> getArticleVendorUri ( $ oArticle , $ iLang ) ; break ; case OXARTICLE_LINKTYPE_MANUFACTURER : $ sUri = $ this -> getArticleManufacturerUri ( $ oArticle , $ iLang ) ; break ; case OXARTICLE_LINKTYPE_RECOMM : $ sUri = $ this -> getArticleRecommUri ( $ oArticle , $ iLang ) ; break ; case OXARTICLE_LINKTYPE_PRICECATEGORY : default : $ sUri = $ this -> getArticleUri ( $ oArticle , $ iLang ) ; break ; } if ( ! $ sUri ) { $ sUri = $ this -> getArticleMainUri ( $ oArticle , $ iLang ) ; } return $ this -> _getFullUrl ( $ sUri , $ iLang ) ; }
Encodes article URLs into SEO format
37,898
public function onDeleteArticle ( $ oArticle ) { $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sIdQuoted = $ oDb -> quote ( $ oArticle -> getId ( ) ) ; $ oDb -> execute ( "delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxarticle'" ) ; $ oDb -> execute ( "delete from oxobject2seodata where oxobjectid = $sIdQuoted" ) ; $ oDb -> execute ( "delete from oxseohistory where oxobjectid = $sIdQuoted" ) ; }
deletes article seo entries
37,899
public function removeActionArticle ( ) { $ sActionId = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'oxid' ) ; $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ oDb -> Execute ( 'delete from oxobject2action ' . 'where oxactionid=' . $ oDb -> quote ( $ sActionId ) . ' and oxclass = "oxarticle"' ) ; }
Removing article assignment