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         parent::save();
00062 
00063         $myConfig = $this->getConfig();
00064         $soxId = $this->getEditObjectId();
00065 
00066         $aParams  = oxConfig::getParameter( "editval");
00067 
00068 
00069         //  #918 S
00070         // checkbox handling
00071         $aParams['oxshops__oxactive'] = ( isset( $aParams['oxshops__oxactive'] ) && $aParams['oxshops__oxactive'] == true )? 1 : 0;
00072         $aParams['oxshops__oxproductive'] = ( isset( $aParams['oxshops__oxproductive']) && $aParams['oxshops__oxproductive'] == true) ? 1 : 0;
00073 
00074         $isubjlang = oxConfig::getParameter("subjlang");
00075         $iLang = ( $isubjlang && $isubjlang > 0 ) ? $isubjlang : 0;
00076 
00077         $oShop = oxNew( "oxshop" );
00078         if ( $soxId != "-1" ) {
00079             $oShop->loadInLang( $iLang, $soxId );
00080         } else {
00081                 $aParams['oxshops__oxid'] = null;
00082         }
00083 
00084         if ( $aParams['oxshops__oxsmtp'] ) {
00085             $aParams['oxshops__oxsmtp'] = trim($aParams['oxshops__oxsmtp']);
00086         }
00087 
00088         $oShop->setLanguage(0);
00089         $oShop->assign( $aParams );
00090         $oShop->setLanguage($iLang );
00091 
00092         if ( ( $sNewSMPTPass = oxConfig::getParameter( "oxsmtppwd" ) ) ) {
00093             $oShop->oxshops__oxsmtppwd->setValue( $sNewSMPTPass == '-' ? "" : $sNewSMPTPass );
00094         }
00095 
00096 
00097         $oShop->save();
00098 
00099         $this->_aViewData["updatelist"] =  "1";
00100 
00101 
00102         oxSession::setVar( "actshop", $soxId);
00103     }
00104 
00110     protected function _getNonCopyConfigVars()
00111     {
00112         $aNonCopyVars = array("aSerials", "IMS", "IMD", "IMA", "blBackTag");
00113         //adding non copable multishop field options
00114         $aMultiShopTables = $this->getConfig()->getConfigParam( 'aMultiShopTables' );
00115         foreach ( $aMultiShopTables as $sMultishopTable ) {
00116             $aNonCopyVars[] = 'blMallInherit_' . strtolower( $sMultishopTable );
00117         }
00118 
00119         return $aNonCopyVars;
00120     }
00121 
00129     protected function _copyConfigVars( $oShop )
00130     {
00131         $myConfig = $this->getConfig();
00132         $myUtilsObject = oxUtilsObject::getInstance();
00133         $oDB = oxDb::getDb();
00134 
00135         $aNonCopyVars = $this->_getNonCopyConfigVars();
00136 
00137         $sSelect = "select oxvarname, oxvartype, DECODE( oxvarvalue, ".$oDB->quote( $myConfig->getConfigParam( 'sConfigKey' ) ) .") as oxvarvalue, oxmodule from oxconfig where oxshopid = '1'";
00138         $rs = $oDB->execute( $sSelect );
00139         if ($rs != false && $rs->recordCount() > 0) {
00140                     while (!$rs->EOF) {
00141                         $sVarName = $rs->fields[0];
00142                         if (!in_array($sVarName, $aNonCopyVars)) {
00143                             $sID = $myUtilsObject->generateUID();
00144                             $sInsert = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue, oxmodule) values ( '$sID', ".$oDB->quote( $oShop->getId() )
00145                                             .", ".$oDB->quote( $rs->fields[0] )
00146                                             .", ".$oDB->quote( $rs->fields[1] )
00147                                             .",  ENCODE( ".$oDB->quote( $rs->fields[2] )
00148                                             .", '".$myConfig->getConfigParam( 'sConfigKey' )
00149                                             ."')"
00150                                             .", ".$oDB->quote( $rs->fields[3] ) . " )";
00151                                             $oDB->execute( $sInsert );
00152                         }
00153                         $rs->moveNext();
00154                     }
00155         }
00156 
00157         $sInheritAll = $oShop->oxshops__oxisinherited->value?"true":"false";
00158         $aMultiShopTables = $myConfig->getConfigParam( 'aMultiShopTables' );
00159         foreach ( $aMultiShopTables as $sMultishopTable ) {
00160             $myConfig->saveShopConfVar("bool", 'blMallInherit_' . strtolower($sMultishopTable), $sInheritAll, $oShop->oxshops__oxid->value);
00161         }
00162     }
00163 
00164 
00170     protected function _getShopIds()
00171     {
00172         //loading shop ids
00173         $aShopIds = array();
00174         $sRs = oxDb::getDb()->execute( "select oxid, oxname from oxshops" );
00175         if ($sRs != false && $sRs->recordCount() > 0) {
00176             while ( !$sRs->EOF ) {
00177                 $aShopIds[$sRs->fields[0]] = new oxStdClass();
00178                 $aShopIds[$sRs->fields[0]]->oxid   = $sRs->fields[0];
00179                 $aShopIds[$sRs->fields[0]]->oxname = $sRs->fields[1];
00180                 $sRs->moveNext();
00181             }
00182         }
00183 
00184         return $aShopIds;
00185     }
00186 
00187 }