shop_main.php

Go to the documentation of this file.
00001 <?php
00002 
00003 
00009 class Shop_Main extends oxAdminDetails
00010 {
00018     public function render()
00019     {
00020         $myConfig = $this->getConfig();
00021 
00022         parent::render();
00023 
00024         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00025 
00026 
00027         if ( $soxId != "-1" && isset( $soxId)) {
00028             // load object
00029             $oShop = oxNew( "oxshop" );
00030             $isubjlang = oxConfig::getParameter("subjlang");
00031             if ( !isset($isubjlang))
00032                 $isubjlang = $this->_iEditLang;
00033 
00034             if ($isubjlang && $isubjlang > 0) {
00035                 $this->_aViewData["subjlang"] =  $isubjlang;
00036             }
00037 
00038             $oShop->loadInLang( $isubjlang, $soxId );
00039 
00040             $this->_aViewData["edit"] =  $oShop;
00041             //oxSession::setVar( "actshop", $soxId);//echo "<h2>$soxId</h2>";
00042             oxSession::setVar( "shp", $soxId);
00043         }
00044 
00045 
00046         $this->_aViewData['IsOXDemoShop'] = $myConfig->isDemoShop();
00047         if ( !isset( $this->_aViewData['updatenav'] ) ) {
00048             $this->_aViewData['updatenav']    = oxConfig::getParameter( 'updatenav' );
00049         }
00050 
00051         return "shop_main.tpl";
00052     }
00053 
00059     public function save()
00060     {
00061 
00062         $myConfig = $this->getConfig();
00063         $soxId = $this->getEditObjectId();
00064 
00065         $aParams  = oxConfig::getParameter( "editval");
00066 
00067 
00068         //  #918 S
00069         // checkbox handling
00070         $aParams['oxshops__oxactive'] = ( isset( $aParams['oxshops__oxactive'] ) && $aParams['oxshops__oxactive'] == true )? 1 : 0;
00071         $aParams['oxshops__oxproductive'] = ( isset( $aParams['oxshops__oxproductive']) && $aParams['oxshops__oxproductive'] == true) ? 1 : 0;
00072 
00073         $isubjlang = oxConfig::getParameter("subjlang");
00074         $iLang = ( $isubjlang && $isubjlang > 0 ) ? $isubjlang : 0;
00075 
00076         $oShop = oxNew( "oxshop" );
00077         if ( $soxId != "-1" ) {
00078             $oShop->loadInLang( $iLang, $soxId );
00079         } else {
00080                 $aParams['oxshops__oxid'] = null;
00081         }
00082 
00083         if ( $aParams['oxshops__oxsmtp'] ) {
00084             $aParams['oxshops__oxsmtp'] = trim($aParams['oxshops__oxsmtp']);
00085         }
00086 
00087         $oShop->setLanguage(0);
00088         $oShop->assign( $aParams );
00089         $oShop->setLanguage($iLang );
00090 
00091         if ( ( $sNewSMPTPass = oxConfig::getParameter( "oxsmtppwd" ) ) ) {
00092             $oShop->oxshops__oxsmtppwd->setValue( $sNewSMPTPass == '-' ? "" : $sNewSMPTPass );
00093         }
00094 
00095 
00096         $oShop->save();
00097 
00098         $this->_aViewData["updatelist"] =  "1";
00099 
00100 
00101         oxSession::setVar( "actshop", $soxId);
00102     }
00103 
00109     protected function _getNonCopyConfigVars()
00110     {
00111         $aNonCopyVars = array("aSerials", "IMS", "IMD", "IMA", "blBackTag");
00112         //adding non copable multishop field options
00113         $aMultiShopTables = $this->getConfig()->getConfigParam( 'aMultiShopTables' );
00114         foreach ( $aMultiShopTables as $sMultishopTable ) {
00115             $aNonCopyVars[] = 'blMallInherit_' . strtolower( $sMultishopTable );
00116         }
00117 
00118         return $aNonCopyVars;
00119     }
00120 
00128     protected function _copyConfigVars( $oShop )
00129     {
00130         $myConfig = $this->getConfig();
00131         $myUtilsObject = oxUtilsObject::getInstance();
00132         $oDB = oxDb::getDb();
00133 
00134         $aNonCopyVars = $this->_getNonCopyConfigVars();
00135 
00136         $sSelect = "select oxvarname, oxvartype, DECODE( oxvarvalue, ".$oDB->quote( $myConfig->getConfigParam( 'sConfigKey' ) ) .") as oxvarvalue, oxmodule from oxconfig where oxshopid = '1'";
00137         $rs = $oDB->execute( $sSelect );
00138         if ($rs != false && $rs->recordCount() > 0) {
00139                     while (!$rs->EOF) {
00140                         $sVarName = $rs->fields[0];
00141                         if (!in_array($sVarName, $aNonCopyVars)) {
00142                             $sID = $myUtilsObject->generateUID();
00143                             $sInsert = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue, oxmodule) values ( '$sID', ".$oDB->quote( $oShop->getId() )
00144                                             .", ".$oDB->quote( $rs->fields[0] )
00145                                             .", ".$oDB->quote( $rs->fields[1] )
00146                                             .",  ENCODE( ".$oDB->quote( $rs->fields[2] )
00147                                             .", '".$myConfig->getConfigParam( 'sConfigKey' )
00148                                             ."')"
00149                                             .", ".$oDB->quote( $rs->fields[3] ) . " )";
00150                                             $oDB->execute( $sInsert );
00151                         }
00152                         $rs->moveNext();
00153                     }
00154         }
00155 
00156         $sInheritAll = $oShop->oxshops__oxisinherited->value?"true":"false";
00157         $aMultiShopTables = $myConfig->getConfigParam( 'aMultiShopTables' );
00158         foreach ( $aMultiShopTables as $sMultishopTable ) {
00159             $myConfig->saveShopConfVar("bool", 'blMallInherit_' . strtolower($sMultishopTable), $sInheritAll, $oShop->oxshops__oxid->value);
00160         }
00161     }
00162 
00163 
00169     protected function _getShopIds()
00170     {
00171         //loading shop ids
00172         $aShopIds = array();
00173         $sRs = oxDb::getDb()->execute( "select oxid, oxname from oxshops" );
00174         if ($sRs != false && $sRs->recordCount() > 0) {
00175             while ( !$sRs->EOF ) {
00176                 $aShopIds[$sRs->fields[0]] = new oxStdClass();
00177                 $aShopIds[$sRs->fields[0]]->oxid   = $sRs->fields[0];
00178                 $aShopIds[$sRs->fields[0]]->oxname = $sRs->fields[1];
00179                 $sRs->moveNext();
00180             }
00181         }
00182 
00183         return $aShopIds;
00184     }
00185 
00186 }