login.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class Login extends oxAdminView
00008 {
00012     public function __construct()
00013     {
00014         $this->getConfig()->setConfigParam( 'blAdmin', true );
00015         $this->_sThisAction  = "login";
00016     }
00017 
00024     public function render()
00025     {   $myConfig = $this->getConfig();
00026 
00027         //resets user once on this screen.
00028         $oUser = oxNew( "oxuser" );
00029         $oUser->logout();
00030 
00031         oxView::render();
00032 
00033         //if( $myConfig->blDemoMode)
00034         $oBaseShop = oxNew( "oxshop" );
00035 
00036         $oBaseShop->load( $myConfig->getBaseShopId());
00037             $sVersion = $oBaseShop->oxshops__oxversion->value;
00038 
00039         $this->getViewConfig()->setViewConfigParam( 'sShopVersion', $sVersion );
00040 
00041         if ( $myConfig->detectVersion() == 1) {   // demo
00042             $this->addTplParam( "user", "admin");
00043             $this->addTplParam( "pwd", "admin");
00044         }
00045         //#533 user profile
00046         $this->addTplParam( "profiles", oxUtils::getInstance()->loadAdminProfile($myConfig->getConfigParam( 'aInterfaceProfiles' )));
00047 
00048         // #656 add admin languages
00049         $aLanguages = array();
00050         $sSourceDir = $myConfig->getConfigParam('sShopDir') . $myConfig->getTemplateBase( true );
00051 
00052         $iDefLangCache = (int) oxUtilsServer::getInstance()->getOxCookie('oxidadminlanguage');
00053 
00054         // setting template language ..
00055         $aLangParams = $myConfig->getConfigParam('aLanguageParams');
00056 
00057         $aLangArr = oxLang::getInstance()->getLanguageArray();
00058 
00059         $handle = opendir( $sSourceDir);
00060         while ( false !== ( $file = readdir( $handle ) ) ) {
00061             $sLangName = "";
00062             $iLangNr = 0;
00063 
00064             if ( is_dir("$sSourceDir/$file") && file_exists("$sSourceDir/$file/lang.php") ) {
00065                     include "$sSourceDir/$file/lang.php";
00066                     $oLang = new stdClass();
00067                     $oLang->sValue      = $sLangName;
00068                     $oLang->blSelected  = ($iLangNr == $iDefLangCache);
00069                     if ( isset($aLangParams[$file]['baseId']) ) {
00070                         $iLangNr = $aLangParams[$file]['baseId'];
00071                     }
00072                     $aLanguages[$iLangNr] = $oLang;
00073             }
00074         }
00075         $this->addTplParam( "aLanguages", $aLanguages);
00076 
00077         return "login.tpl";
00078     }
00079 
00085     public function checklogin()
00086     {
00087         $myUtilsServer = oxUtilsServer::getInstance();
00088 
00089         $user    = oxConfig::getParameter(  'user' );
00090         $pwd     = oxConfig::getParameter(  'pwd' );
00091         $profile = oxConfig::getParameter(  'profile' );
00092 
00093         try { // trying to login
00094             $oUser = oxNew( "oxuser" );
00095             $oUser->login( $user, $pwd);
00096         } catch ( oxUserException $oEx ) {
00097             oxUtilsView::getInstance()->addErrorToDisplay('LOGIN_ERROR');
00098             $this->addTplParam( 'user', $user );
00099             $this->addTplParam( 'pwd', $pwd );
00100             $this->addTplParam( 'profile', $profile );
00101             return;
00102         } catch (oxCookieException $oEx) {
00103             oxUtilsView::getInstance()->addErrorToDisplay('LOGIN_NO_COOKIE_SUPPORT');
00104             $this->addTplParam( 'user', $user );
00105             $this->addTplParam( 'pwd', $pwd );
00106             $this->addTplParam( 'profile', $profile );
00107             return;
00108         } catch (oxConnectionException $oEx) {
00109             oxUtilsView::getInstance()->addErrorToDisplay($oEx);
00110         }
00111 
00112         // success
00113         oxUtils::getInstance()->logger( "login successful" );
00114         // #533
00115         if ( isset( $profile ) ) {
00116             $aProfiles = oxSession::getVar( "aAdminProfiles" );
00117             if ( $aProfiles && isset($aProfiles[$profile])) {
00118                 // setting cookie to store last locally used profile
00119                 $myUtilsServer->setOxCookie ("oxidadminprofile", $profile."@".implode( "@", $aProfiles[$profile]), time()+31536000, "/" );
00120                 oxSession::setVar( "profile", $aProfiles[$profile] );
00121             }
00122         } else //deleting cookie info, as setting profile to default
00123             $myUtilsServer->setOxCookie ("oxidadminprofile", "", time()-3600, "/" );
00124 
00125         // languages
00126         $iLang = oxConfig::getParameter(  "chlanguage" );
00127         $myUtilsServer->setOxCookie ("oxidadminlanguage", $iLang, time()+31536000, "/" );
00128         //P
00129         //oxSession::setVar( "blAdminTemplateLanguage", $iLang );
00130         oxLang::getInstance()->setTplLanguage( $iLang );
00131 
00132         return "admin_start";
00133     }
00134 
00140     protected function _authorize()
00141     {
00142         // users are always authorized to use login page
00143         return true;
00144     }
00145 
00151     public function getViewId()
00152     {
00153         return strtolower( get_class( $this ) );
00154     }
00155 }

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5