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