OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
shop_main.php
Go to the documentation of this file.
1 <?php
2 
3 
9 class Shop_Main extends oxAdminDetails
10 {
11 
17  const SHOP_FIELD_SET_SIZE = 64;
18 
26  public function render()
27  {
28  $myConfig = $this->getConfig();
30 
31  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
32 
33 
34  if ($soxId != "-1" && isset($soxId)) {
35  // load object
36  $oShop = oxNew("oxshop");
37  $isubjlang = oxRegistry::getConfig()->getRequestParameter("subjlang");
38  if (!isset($isubjlang)) {
39  $isubjlang = $this->_iEditLang;
40  }
41 
42  if ($isubjlang && $isubjlang > 0) {
43  $this->_aViewData["subjlang"] = $isubjlang;
44  }
45 
46  $oShop->loadInLang($isubjlang, $soxId);
47 
48  $this->_aViewData["edit"] = $oShop;
49  //oxSession::setVar( "actshop", $soxId);//echo "<h2>$soxId</h2>";
50  oxRegistry::getSession()->setVariable("shp", $soxId);
51  }
52 
53 
54  $this->_aViewData['IsOXDemoShop'] = $myConfig->isDemoShop();
55  if (!isset($this->_aViewData['updatenav'])) {
56  $this->_aViewData['updatenav'] = oxRegistry::getConfig()->getRequestParameter('updatenav');
57  }
58 
59  return "shop_main.tpl";
60  }
61 
67  public function save()
68  {
69  parent::save();
70 
71  $myConfig = $this->getConfig();
72  $soxId = $this->getEditObjectId();
73 
74  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
75 
76 
77  // #918 S
78  // checkbox handling
79  $aParams['oxshops__oxactive'] = (isset($aParams['oxshops__oxactive']) && $aParams['oxshops__oxactive'] == true) ? 1 : 0;
80  $aParams['oxshops__oxproductive'] = (isset($aParams['oxshops__oxproductive']) && $aParams['oxshops__oxproductive'] == true) ? 1 : 0;
81 
82  $isubjlang = oxRegistry::getConfig()->getRequestParameter("subjlang");
83  $iLang = ($isubjlang && $isubjlang > 0) ? $isubjlang : 0;
84 
86  $oShop = oxNew("oxshop");
87  if ($soxId != "-1") {
88  $oShop->loadInLang($iLang, $soxId);
89  } else {
90  $aParams['oxshops__oxid'] = null;
91  }
92 
93  if ($aParams['oxshops__oxsmtp']) {
94  $aParams['oxshops__oxsmtp'] = trim($aParams['oxshops__oxsmtp']);
95  }
96 
97  $oShop->setLanguage(0);
98  $oShop->assign($aParams);
99  $oShop->setLanguage($iLang);
100 
101  if (($sNewSMPTPass = oxRegistry::getConfig()->getRequestParameter("oxsmtppwd"))) {
102  $oShop->oxshops__oxsmtppwd->setValue($sNewSMPTPass == '-' ? "" : $sNewSMPTPass);
103  }
104 
105 
106  try {
107  $oShop->save();
108  } catch (oxException $e) {
109 
110  return;
111  }
112 
113  $this->_aViewData["updatelist"] = "1";
114 
115 
116  oxRegistry::getSession()->setVariable("actshop", $soxId);
117  }
118 
124  protected function _getNonCopyConfigVars()
125  {
126  $aNonCopyVars = array("aSerials", "IMS", "IMD", "IMA", "sBackTag", "sUtilModule", "aModulePaths", "aModuleFiles", "aModuleEvents", "aModuleVersions", "aModuleTemplates", "aModules", "aDisabledModules");
127  //adding non copable multishop field options
128  $aMultiShopTables = $this->getConfig()->getConfigParam('aMultiShopTables');
129  foreach ($aMultiShopTables as $sMultishopTable) {
130  $aNonCopyVars[] = 'blMallInherit_' . strtolower($sMultishopTable);
131  }
132 
133  return $aNonCopyVars;
134  }
135 
141  protected function _copyConfigVars($oShop)
142  {
143  $myConfig = $this->getConfig();
144  $myUtilsObject = oxUtilsObject::getInstance();
145  $oDB = oxDb::getDb();
146 
147  $aNonCopyVars = $this->_getNonCopyConfigVars();
148 
149  $sSelect = "select oxvarname, oxvartype, DECODE( oxvarvalue, " . $oDB->quote($myConfig->getConfigParam('sConfigKey')) . ") as oxvarvalue, oxmodule from oxconfig where oxshopid = '1'";
150  $rs = $oDB->execute($sSelect);
151  if ($rs != false && $rs->recordCount() > 0) {
152  while (!$rs->EOF) {
153  $sVarName = $rs->fields[0];
154  if (!in_array($sVarName, $aNonCopyVars)) {
155  $sID = $myUtilsObject->generateUID();
156  $sInsert = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue, oxmodule) values ( '$sID', " . $oDB->quote($oShop->getId())
157  . ", " . $oDB->quote($rs->fields[0])
158  . ", " . $oDB->quote($rs->fields[1])
159  . ", ENCODE( " . $oDB->quote($rs->fields[2])
160  . ", '" . $myConfig->getConfigParam('sConfigKey')
161  . "')"
162  . ", " . $oDB->quote($rs->fields[3]) . " )";
163  $oDB->execute($sInsert);
164  }
165  $rs->moveNext();
166  }
167  }
168 
169  $sInheritAll = $oShop->oxshops__oxisinherited->value ? "true" : "false";
170  $aMultiShopTables = $myConfig->getConfigParam('aMultiShopTables');
171  foreach ($aMultiShopTables as $sMultishopTable) {
172  $myConfig->saveShopConfVar("bool", 'blMallInherit_' . strtolower($sMultishopTable), $sInheritAll, $oShop->oxshops__oxid->value);
173  }
174  }
175 }