shop_main.php

Go to the documentation of this file.
00001 <?php
00002 
00003 
00009 class Shop_Main extends oxAdminDetails
00010 {
00016     const SHOP_FIELD_SET_SIZE = 64;
00017 
00025     public function render()
00026     {
00027         $myConfig = $this->getConfig();
00028         parent::render();
00029 
00030         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00031 
00032 
00033         if ( $soxId != "-1" && isset( $soxId)) {
00034             // load object
00035             $oShop = oxNew( "oxshop" );
00036             $isubjlang = oxConfig::getParameter("subjlang");
00037             if ( !isset($isubjlang))
00038                 $isubjlang = $this->_iEditLang;
00039 
00040             if ($isubjlang && $isubjlang > 0) {
00041                 $this->_aViewData["subjlang"] =  $isubjlang;
00042             }
00043 
00044             $oShop->loadInLang( $isubjlang, $soxId );
00045 
00046             $this->_aViewData["edit"] =  $oShop;
00047             //oxSession::setVar( "actshop", $soxId);//echo "<h2>$soxId</h2>";
00048             oxSession::setVar( "shp", $soxId);
00049         }
00050 
00051 
00052         $this->_aViewData['IsOXDemoShop'] = $myConfig->isDemoShop();
00053         if ( !isset( $this->_aViewData['updatenav'] ) ) {
00054             $this->_aViewData['updatenav']    = oxConfig::getParameter( 'updatenav' );
00055         }
00056 
00057         return "shop_main.tpl";
00058     }
00059 
00065     public function save()
00066     {
00067         parent::save();
00068 
00069         $myConfig = $this->getConfig();
00070         $soxId = $this->getEditObjectId();
00071 
00072         $aParams  = oxConfig::getParameter( "editval");
00073 
00074 
00075         //  #918 S
00076         // checkbox handling
00077         $aParams['oxshops__oxactive'] = ( isset( $aParams['oxshops__oxactive'] ) && $aParams['oxshops__oxactive'] == true )? 1 : 0;
00078         $aParams['oxshops__oxproductive'] = ( isset( $aParams['oxshops__oxproductive']) && $aParams['oxshops__oxproductive'] == true) ? 1 : 0;
00079 
00080         $isubjlang = oxConfig::getParameter("subjlang");
00081         $iLang = ( $isubjlang && $isubjlang > 0 ) ? $isubjlang : 0;
00082 
00083         $oShop = oxNew( "oxshop" );
00084         if ( $soxId != "-1" ) {
00085             $oShop->loadInLang( $iLang, $soxId );
00086         } else {
00087                 $aParams['oxshops__oxid'] = null;
00088         }
00089 
00090         if ( $aParams['oxshops__oxsmtp'] ) {
00091             $aParams['oxshops__oxsmtp'] = trim($aParams['oxshops__oxsmtp']);
00092         }
00093 
00094         $oShop->setLanguage(0);
00095         $oShop->assign( $aParams );
00096         $oShop->setLanguage($iLang );
00097 
00098         if ( ( $sNewSMPTPass = oxConfig::getParameter( "oxsmtppwd" ) ) ) {
00099             $oShop->oxshops__oxsmtppwd->setValue( $sNewSMPTPass == '-' ? "" : $sNewSMPTPass );
00100         }
00101 
00102 
00103         try {
00104             $oShop->save();
00105         } catch ( oxException $e ) {
00106             return;
00107         }
00108 
00109         $this->_aViewData["updatelist"] =  "1";
00110 
00111 
00112         oxSession::setVar( "actshop", $soxId);
00113     }
00114 
00120     protected function _getNonCopyConfigVars()
00121     {
00122         $aNonCopyVars = array("aSerials", "IMS", "IMD", "IMA", "sBackTag", "sUtilModule", "aModulePaths", "aModuleFiles", "aModuleEvents", "aModuleVersions", "aModuleTemplates", "aModules", "aDisabledModules");
00123         //adding non copable multishop field options
00124         $aMultiShopTables = $this->getConfig()->getConfigParam( 'aMultiShopTables' );
00125         foreach ( $aMultiShopTables as $sMultishopTable ) {
00126             $aNonCopyVars[] = 'blMallInherit_' . strtolower( $sMultishopTable );
00127         }
00128 
00129         return $aNonCopyVars;
00130     }
00131 
00139     protected function _copyConfigVars( $oShop )
00140     {
00141         $myConfig = $this->getConfig();
00142         $myUtilsObject = oxUtilsObject::getInstance();
00143         $oDB = oxDb::getDb();
00144 
00145         $aNonCopyVars = $this->_getNonCopyConfigVars();
00146 
00147         $sSelect = "select oxvarname, oxvartype, DECODE( oxvarvalue, ".$oDB->quote( $myConfig->getConfigParam( 'sConfigKey' ) ) .") as oxvarvalue, oxmodule from oxconfig where oxshopid = '1'";
00148         $rs = $oDB->execute( $sSelect );
00149         if ($rs != false && $rs->recordCount() > 0) {
00150                     while (!$rs->EOF) {
00151                         $sVarName = $rs->fields[0];
00152                         if (!in_array($sVarName, $aNonCopyVars)) {
00153                             $sID = $myUtilsObject->generateUID();
00154                             $sInsert = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue, oxmodule) values ( '$sID', ".$oDB->quote( $oShop->getId() )
00155                                             .", ".$oDB->quote( $rs->fields[0] )
00156                                             .", ".$oDB->quote( $rs->fields[1] )
00157                                             .",  ENCODE( ".$oDB->quote( $rs->fields[2] )
00158                                             .", '".$myConfig->getConfigParam( 'sConfigKey' )
00159                                             ."')"
00160                                             .", ".$oDB->quote( $rs->fields[3] ) . " )";
00161                                             $oDB->execute( $sInsert );
00162                         }
00163                         $rs->moveNext();
00164                     }
00165         }
00166 
00167         $sInheritAll = $oShop->oxshops__oxisinherited->value?"true":"false";
00168         $aMultiShopTables = $myConfig->getConfigParam( 'aMultiShopTables' );
00169         foreach ( $aMultiShopTables as $sMultishopTable ) {
00170             $myConfig->saveShopConfVar("bool", 'blMallInherit_' . strtolower($sMultishopTable), $sInheritAll, $oShop->oxshops__oxid->value);
00171         }
00172     }
00173 
00174 }