login.php

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

Generated on Thu Feb 19 15:02:21 2009 for OXID eShop CE by  doxygen 1.5.5