shop_main.php

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