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
00029 parent::render();
00030
00031 $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00032
00033
00034 if ( $soxId != "-1" && isset( $soxId)) {
00035
00036 $oShop = oxNew( "oxshop" );
00037 $isubjlang = oxConfig::getParameter("subjlang");
00038 if ( !isset($isubjlang))
00039 $isubjlang = $this->_iEditLang;
00040
00041 if ($isubjlang && $isubjlang > 0) {
00042 $this->_aViewData["subjlang"] = $isubjlang;
00043 }
00044
00045 $oShop->loadInLang( $isubjlang, $soxId );
00046
00047 $this->_aViewData["edit"] = $oShop;
00048
00049 oxSession::setVar( "shp", $soxId);
00050 }
00051
00052
00053 $this->_aViewData['IsOXDemoShop'] = $myConfig->isDemoShop();
00054 if ( !isset( $this->_aViewData['updatenav'] ) ) {
00055 $this->_aViewData['updatenav'] = oxConfig::getParameter( 'updatenav' );
00056 }
00057
00058 return "shop_main.tpl";
00059 }
00060
00066 public function save()
00067 {
00068 parent::save();
00069
00070 $myConfig = $this->getConfig();
00071 $soxId = $this->getEditObjectId();
00072
00073 $aParams = oxConfig::getParameter( "editval");
00074
00075
00076
00077
00078 $aParams['oxshops__oxactive'] = ( isset( $aParams['oxshops__oxactive'] ) && $aParams['oxshops__oxactive'] == true )? 1 : 0;
00079 $aParams['oxshops__oxproductive'] = ( isset( $aParams['oxshops__oxproductive']) && $aParams['oxshops__oxproductive'] == true) ? 1 : 0;
00080
00081 $isubjlang = oxConfig::getParameter("subjlang");
00082 $iLang = ( $isubjlang && $isubjlang > 0 ) ? $isubjlang : 0;
00083
00084 $oShop = oxNew( "oxshop" );
00085 if ( $soxId != "-1" ) {
00086 $oShop->loadInLang( $iLang, $soxId );
00087 } else {
00088 $aParams['oxshops__oxid'] = null;
00089 }
00090
00091 if ( $aParams['oxshops__oxsmtp'] ) {
00092 $aParams['oxshops__oxsmtp'] = trim($aParams['oxshops__oxsmtp']);
00093 }
00094
00095 $oShop->setLanguage(0);
00096 $oShop->assign( $aParams );
00097 $oShop->setLanguage($iLang );
00098
00099 if ( ( $sNewSMPTPass = oxConfig::getParameter( "oxsmtppwd" ) ) ) {
00100 $oShop->oxshops__oxsmtppwd->setValue( $sNewSMPTPass == '-' ? "" : $sNewSMPTPass );
00101 }
00102
00103
00104 try {
00105 $oShop->save();
00106 } catch ( oxExeption $e ) {
00107 return;
00108 }
00109
00110 $this->_aViewData["updatelist"] = "1";
00111
00112
00113 oxSession::setVar( "actshop", $soxId);
00114 }
00115
00121 protected function _getNonCopyConfigVars()
00122 {
00123 $aNonCopyVars = array("aSerials", "IMS", "IMD", "IMA", "blBackTag", "sUtilModule", "aModulePaths", "aModuleFiles", "aModuleTemplates", "aModules", "aDisabledModules");
00124
00125 $aMultiShopTables = $this->getConfig()->getConfigParam( 'aMultiShopTables' );
00126 foreach ( $aMultiShopTables as $sMultishopTable ) {
00127 $aNonCopyVars[] = 'blMallInherit_' . strtolower( $sMultishopTable );
00128 }
00129
00130 return $aNonCopyVars;
00131 }
00132
00140 protected function _copyConfigVars( $oShop )
00141 {
00142 $myConfig = $this->getConfig();
00143 $myUtilsObject = oxUtilsObject::getInstance();
00144 $oDB = oxDb::getDb();
00145
00146 $aNonCopyVars = $this->_getNonCopyConfigVars();
00147
00148 $sSelect = "select oxvarname, oxvartype, DECODE( oxvarvalue, ".$oDB->quote( $myConfig->getConfigParam( 'sConfigKey' ) ) .") as oxvarvalue, oxmodule from oxconfig where oxshopid = '1'";
00149 $rs = $oDB->execute( $sSelect );
00150 if ($rs != false && $rs->recordCount() > 0) {
00151 while (!$rs->EOF) {
00152 $sVarName = $rs->fields[0];
00153 if (!in_array($sVarName, $aNonCopyVars)) {
00154 $sID = $myUtilsObject->generateUID();
00155 $sInsert = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue, oxmodule) values ( '$sID', ".$oDB->quote( $oShop->getId() )
00156 .", ".$oDB->quote( $rs->fields[0] )
00157 .", ".$oDB->quote( $rs->fields[1] )
00158 .", ENCODE( ".$oDB->quote( $rs->fields[2] )
00159 .", '".$myConfig->getConfigParam( 'sConfigKey' )
00160 ."')"
00161 .", ".$oDB->quote( $rs->fields[3] ) . " )";
00162 $oDB->execute( $sInsert );
00163 }
00164 $rs->moveNext();
00165 }
00166 }
00167
00168 $sInheritAll = $oShop->oxshops__oxisinherited->value?"true":"false";
00169 $aMultiShopTables = $myConfig->getConfigParam( 'aMultiShopTables' );
00170 foreach ( $aMultiShopTables as $sMultishopTable ) {
00171 $myConfig->saveShopConfVar("bool", 'blMallInherit_' . strtolower($sMultishopTable), $sInheritAll, $oShop->oxshops__oxid->value);
00172 }
00173 }
00174
00175
00183 protected function _getShopIds()
00184 {
00185
00186 $aShopIds = array();
00187 $sRs = oxDb::getDb()->execute( "select oxid, oxname from oxshops" );
00188 if ($sRs != false && $sRs->recordCount() > 0) {
00189 while ( !$sRs->EOF ) {
00190 $aShopIds[$sRs->fields[0]] = new oxStdClass();
00191 $aShopIds[$sRs->fields[0]]->oxid = $sRs->fields[0];
00192 $aShopIds[$sRs->fields[0]]->oxname = $sRs->fields[1];
00193 $sRs->moveNext();
00194 }
00195 }
00196
00197 return $aShopIds;
00198 }
00199
00200 }