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 = oxUtilsServer::getInstance()->getOxCookie('oxidadminlanguage');
00054         if ( !isset( $iDefLangCache))
00055             $iDefLangCache= 0;
00056 
00057         $handle = opendir( $sSourceDir);
00058         while ( false !== ( $file = readdir( $handle ) ) ) {
00059             $sLangName = "";
00060             $iLangNr = 0;
00061             if ( is_dir("$sSourceDir/$file") && file_exists("$sSourceDir/$file/lang.php") ) {
00062                     include "$sSourceDir/$file/lang.php";
00063                     $oLang = new stdClass();
00064                     $oLang->sValue      = $sLangName;
00065                     $oLang->blSelected  = ($iLangNr == $iDefLangCache);
00066                     $aLanguages[$iLangNr] = $oLang;
00067                 }
00068         }
00069         $this->addTplParam( "aLanguages", $aLanguages);
00070 
00071         return "login.tpl";
00072     }
00073 
00079     public function checklogin()
00080     {
00081         $myUtilsServer = oxUtilsServer::getInstance();
00082 
00083         $user    = oxConfig::getParameter(  'user' );
00084         $pwd     = oxConfig::getParameter(  'pwd' );
00085         $profile = oxConfig::getParameter(  'profile' );
00086 
00087         try { // trying to login
00088             $oUser = oxNew( "oxuser" );
00089             $oUser->login( $user, $pwd);
00090         } catch ( oxUserException $oEx ) {
00091             oxUtilsView::getInstance()->addErrorToDisplay('LOGIN_ERROR');
00092             $this->addTplParam( 'user', $user );
00093             $this->addTplParam( 'pwd', $pwd );
00094             $this->addTplParam( 'profile', $profile );
00095             return;
00096         } catch (oxCookieException $oEx) {
00097             oxUtilsView::getInstance()->addErrorToDisplay('LOGIN_NO_COOKIE_SUPPORT');
00098             $this->addTplParam( 'user', $user );
00099             $this->addTplParam( 'pwd', $pwd );
00100             $this->addTplParam( 'profile', $profile );
00101             return;
00102         } catch (oxConnectionException $oEx) {
00103             oxUtilsView::getInstance()->addErrorToDisplay($oEx);
00104         }
00105 
00106         // success
00107         oxUtils::getInstance()->logger( "login successful" );
00108         // #533
00109         if ( isset( $profile ) ) {
00110             $aProfiles = oxSession::getVar( "aAdminProfiles" );
00111             if ( $aProfiles && isset($aProfiles[$profile])) {
00112                 // setting cookie to store last locally used profile
00113                 $myUtilsServer->setOxCookie ("oxidadminprofile", $profile."@".implode( "@", $aProfiles[$profile]), time()+31536000, "/" );
00114                 oxSession::setVar( "profile", $aProfiles[$profile] );
00115             }
00116         } else //deleting cookie info, as setting profile to default
00117             $myUtilsServer->setOxCookie ("oxidadminprofile", "", time()-3600, "/" );
00118 
00119         // languages
00120         $iLang = oxConfig::getParameter(  "chlanguage" );
00121         $myUtilsServer->setOxCookie ("oxidadminlanguage", $iLang, time()+31536000, "/" );
00122         //P
00123         //oxSession::setVar( "blAdminTemplateLanguage", $iLang );
00124         oxLang::getInstance()->setTplLanguage( $iLang );
00125 
00126         return "admin_start";
00127     }
00128 
00134     protected function _authorize()
00135     {
00136         // users are always authorized to use login page
00137         return true;
00138     }
00139 
00145     public function getViewId()
00146     {
00147         return strtolower( get_class( $this ) );
00148     }
00149 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5