navigation.php

Go to the documentation of this file.
00001 <?php
00005 class Navigation extends oxAdminView
00006 {
00012     protected $_sAllowedHost = "http://admin.oxid-esales.com";
00013 
00020     public function render()
00021     {
00022         parent::render();
00023         $myUtilsServer = oxUtilsServer::getInstance();
00024 
00025         $sItem = oxConfig::getParameter("item");
00026         $sItem = $sItem ? basename( $sItem ) : false;
00027         if ( !$sItem ) {
00028             $sItem = "nav_frame.tpl";
00029             $aFavorites = oxConfig::getParameter( "favorites" );
00030             if ( is_array( $aFavorites ) ) {
00031                 $myUtilsServer->setOxCookie('oxidadminfavorites', implode( '|', $aFavorites ) );
00032             }
00033         } else {
00034             $oNavTree = $this->getNavigation();
00035 
00036             // set menu structure
00037             $this->_aViewData["menustructure"] = $oNavTree->getDomXml()->documentElement->childNodes;
00038 
00039             // version patch strin
00040             $sVersion = str_replace( array ("EE.", "PE."), "", $this->_sShopVersion);
00041             $this->_aViewData["sVersion"] = trim($sVersion);
00042 
00043             //checking requirements if this is not nav frame reload
00044             if ( !oxConfig::getParameter( "navReload" ) ) {
00045                 // #661 execute stuff we run each time when we start admin once
00046                 if ('home.tpl' == $sItem) {
00047                     $this->_aViewData['aMessage'] = $this->_doStartUpChecks();
00048                 }
00049             } else {
00050                 //removing reload param to force requirements checking next time
00051                 oxSession::deleteVar("navReload");
00052             }
00053 
00054             // favorite navigation
00055             $aFavorites = explode( '|', $myUtilsServer->getOxCookie( 'oxidadminfavorites' ) );
00056 
00057             if ( is_array( $aFavorites ) && count( $aFavorites ) ) {
00058                 $this->_aViewData["menufavorites"] = $oNavTree->getListNodes( $aFavorites );
00059                 $this->_aViewData["aFavorites"]    = $aFavorites;
00060             }
00061 
00062             // history navigation
00063             $aHistory = explode( '|', $myUtilsServer->getOxCookie( 'oxidadminhistory' ) );
00064             if ( is_array( $aHistory ) && count( $aHistory ) ) {
00065                 $this->_aViewData["menuhistory"] = $oNavTree->getListNodes( $aHistory );
00066             }
00067 
00068             // open history node ?
00069             $this->_aViewData["blOpenHistory"] = oxConfig::getParameter( 'openHistory' );
00070         }
00071 
00072         $oShoplist = oxNew( 'oxshoplist' );
00073         $oBaseShop = $oShoplist->getBaseObject();
00074 
00075         $sWhere = '';
00076         $blisMallAdmin = oxSession::getVar( 'malladmin' );
00077         if (!$blisMallAdmin) {
00078             // we only allow to see our shop
00079             $sShopID = oxSession::getVar("actshop");
00080             $sWhere = "where ".$oBaseShop->getViewName().".oxid = '$sShopID'";
00081         }
00082 
00083         $oShoplist->selectString("select ".$oBaseShop->getSelectFields()." from ".$oBaseShop->getViewName()." $sWhere");
00084         $this->_aViewData['shoplist'] = $oShoplist;
00085 
00086         return $sItem;
00087     }
00088 
00094     public function chshp()
00095     {
00096         parent::chshp();
00097 
00098         // informing about basefrm parameters
00099         $this->_aViewData['loadbasefrm'] = true;
00100         $sListView = oxConfig::getParameter( 'listview' );
00101         $sEditView = oxConfig::getParameter( 'editview' );
00102         $iActEdit  = oxConfig::getParameter( 'actedit' );
00103 
00104 
00105         $this->_aViewData['listview'] = $sListView;
00106         $this->_aViewData['editview'] = $sEditView;
00107         $this->_aViewData['actedit']  = $iActEdit;
00108     }
00109 
00115     public function logout()
00116     {
00117         $mySession = $this->getSession();
00118         $myConfig = $this->getConfig();
00119 
00120         $oUser = oxNew("oxuser");
00121         $oUser->logout();
00122 
00123         // kill session
00124         $mySession->destroy();
00125 
00126         // delete also, this is usually not needed but for security reasons we execute still
00127         if ( $myConfig->getConfigParam('blAdodbSessionHandler' ) ) {
00128             $oDb = oxDb::getDb();
00129             $oDb->execute("delete from oxsessions where SessionID = ".$oDb->quote($mySession->getId()));
00130         }
00131 
00132         //reseting content cache if needed
00133         if ( $myConfig->getConfigParam('blClearCacheOnLogout' ) ) {
00134             $this->resetContentCache();
00135         }
00136 
00137         oxUtils::getInstance()->redirect( 'index.php', true, 302 );
00138     }
00139 
00145     public function exturl()
00146     {
00147         $myUtils = oxUtils::getInstance();
00148         if ( $sUrl = oxConfig::getParameter( "url" ) ) {
00149 
00150             // Limit external url's only allowed host
00151             $myConfig = $this->getConfig();
00152             if ( $myConfig->getConfigParam('blLoadDynContents') && strpos( $sUrl, $this->_sAllowedHost ) === 0 ) {
00153 
00154                 $sPath = $myConfig->getConfigParam('sCompileDir') . "/" . md5( $sUrl ) . '.html';
00155                 if ( $myUtils->getRemoteCachePath( $sUrl, $sPath ) ) {
00156 
00157                     $oStr = getStr();
00158                     $sVersion = $myConfig->getVersion();
00159                     $sEdition = $myConfig->getFullEdition();
00160                     $sCurYear = date( "Y" );
00161 
00162                     // Get ceontent
00163                     $sOutput = file_get_contents( $sPath );
00164 
00165                     // Fix base path
00166                     $sOutput = $oStr->preg_replace( "/<\/head>/i", "<base href=\"".dirname( $sUrl ).'/'."\"></head>\n  <!-- OXID eShop {$sEdition}, Version {$sVersion}, Shopping Cart System (c) OXID eSales AG 2003 - {$sCurYear} - http://www.oxid-esales.com -->", $sOutput );
00167 
00168                     // Fix self url's
00169                     $myUtils->showMessageAndExit( $oStr->preg_replace( "/href=\"#\"/i", 'href="javascript::void();"', $sOutput ) );
00170                 }
00171             } else {
00172                 // Caching not allowed, redirecting
00173                 $myUtils->redirect( $sUrl, true, 302 );
00174             }
00175         }
00176 
00177         $myUtils->showMessageAndExit( "" );
00178     }
00179 
00186     protected function _doStartUpChecks()
00187     {   // #661
00188         $aMessage = array ();
00189 
00190         // check if system reguirements are ok
00191         $oSysReq = new oxSysRequirements();
00192         if ( !$oSysReq->getSysReqStatus() ) {
00193             $aMessage['warning']  = oxLang::getInstance()->translateString('NAVIGATION_SYSREQ_MESSAGE');
00194             $aMessage['warning'] .= '<a href="?cl=sysreq&amp;stoken='.$this->getSession()->getSessionChallengeToken().'" target="basefrm">';
00195             $aMessage['warning'] .= oxLang::getInstance()->translateString('NAVIGATION_SYSREQ_MESSAGE2').'</a>';
00196         }
00197 
00198         // version check
00199         if ( $this->getConfig()->getConfigParam('blCheckForUpdates' ) ) {
00200             if ( $sVersionNotice = $this->_checkVersion() ) {
00201                 $aMessage['message'] .= $sVersionNotice;
00202             }
00203         }
00204 
00205 
00206         // check if setup dir is deleted
00207         if ( file_exists( $this->getConfig()->getConfigParam('sShopDir').'/setup/index.php' ) ) {
00208             $aMessage['warning'] .= ((! empty($aMessage['warning']))?"<br>":'').oxLang::getInstance()->translateString('SETUP_DIRNOTDELETED_WARNING');
00209         }
00210 
00211         // check if updateApp dir is deleted or empty
00212         $sUpdateDir = $this->getConfig()->getConfigParam( 'sShopDir' ) . '/updateApp/';
00213         if ( file_exists( $sUpdateDir ) && !(count(glob("$sUpdateDir/*")) === 0) ) {
00214             $aMessage['warning'] .= ((! empty($aMessage['warning']))?"<br>":'').oxLang::getInstance()->translateString('UPDATEAPP_DIRNOTDELETED_WARNING');
00215         }
00216 
00217         // check if config file is writable
00218         $sConfPath = $this->getConfig()->getConfigParam( 'sShopDir' ) . "/config.inc.php";
00219         if ( !is_readable( $sConfPath ) || is_writable( $sConfPath ) ) {
00220             $aMessage['warning'] .= ( ( ! empty($aMessage['warning'] ) )?"<br>":'' ).oxLang::getInstance()->translateString('SETUP_CONFIGPERMISSIONS_WARNING' );
00221         }
00222 
00223         return $aMessage;
00224     }
00225 
00231     protected function _checkVersion()
00232     {
00233             $sVersion = 'CE';
00234 
00235         $sQuery = 'http://admin.oxid-esales.com/'.$sVersion.'/onlinecheck.php?getlatestversion';
00236         if ($sVersion = oxUtilsFile::getInstance()->readRemoteFileAsString($sQuery)) {
00237             // current version is older ..
00238             if (version_compare($this->getConfig()->getVersion(), $sVersion) == '-1') {
00239                 return sprintf(oxLang::getInstance()->translateString('NAVIGATION_NEWVERSIONAVAILABLE'), $sVersion);
00240             }
00241         }
00242     }
00243 }