Changeset 254

Show
Ignore:
Timestamp:
04/10/08 00:02:40 (9 months ago)
Author:
shupp
Message:

Login module CS cleanups

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Framework/Module/Login.php

    r238 r254  
    66 * Framework_Module_Login 
    77 * 
    8  * @author      Bill Shupp <hostmaster@shupp.org> 
    9  * @copyright   Bill Shupp <hostmaster@shupp.org> 
    10  * @package     ToasterAdmin 
    11  * @subpackage  Module 
    12  * @filesource 
     8 * PHP Version 5.1.0+ 
     9 * 
     10 * @category   Mail 
     11 * @package    ToasterAdmin 
     12 * @subpackage Module 
     13 * @author     Bill Shupp <hostmaster@shupp.org> 
     14 * @copyright  2007-2008 Bill Shupp <hostmaster@shupp.org> 
     15 * @license    GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
     16 * @link       http://trac.merchbox.com/trac/toasteradmin 
    1317 */ 
    1418 
     
    1620 * Framework_Module_Login 
    1721 * 
    18  * @author      Bill Shupp <hostmaster@shupp.org> 
    19  * @package     ToasterAdmin 
    20  * @subpackage  Module 
     22 * @category   Mail 
     23 * @package    ToasterAdmin 
     24 * @subpackage Module 
     25 * @author     Bill Shupp <hostmaster@shupp.org> 
     26 * @copyright  2007-2008 Bill Shupp <hostmaster@shupp.org> 
     27 * @license    GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
     28 * @link       http://trac.merchbox.com/trac/toasteradmin 
    2129 */ 
    2230class Framework_Module_Login extends Framework_Auth_No 
     
    2533     * __default 
    2634     * 
    27      * @access      public 
    28      * @return      mixed 
     35     * Just display the login form. 
     36     * 
     37     * @access public 
     38     * @return void 
    2939     */ 
    3040    public function __default() 
     
    3545    } 
    3646 
     47    /** 
     48     * loginNow  
     49     *  
     50     * Try and log the user in. 
     51     *  
     52     * @access public 
     53     * @return void 
     54     */ 
    3755    public function loginNow() 
    3856    { 
    3957        $this->tplFile = 'Login.tpl'; 
     58 
    4059        $form = $this->createLoginForm(); 
    4160        if ($form->validate()) { 
    42             if (!$result = $this->user->authenticate($_POST['email'], $_POST['password'])) { 
     61            $result = $this->user->authenticate($_POST['email'], $_POST['password']); 
     62            if (!$result) { 
    4363                $this->setData('loginError', _('Login failed')); 
    4464                $this->setData('QF_Form', $form->toHtml()); 
    45                 $this->session->email = null; 
     65                $this->session->email    = null; 
    4666                $this->session->password =  null; 
    4767                return; 
    4868            } 
     69 
    4970            $crypt = new Crypt_Blowfish((string)Framework::$site->config->mcryptKey); 
    50             $emailArray = explode('@', $_POST['email']); 
    51             $this->session->user = $emailArray[0]; 
    52             $this->session->domain = $emailArray[1]; 
    53             $this->session->email = $_POST['email']; 
    54             $this->session->password = $crypt->encrypt($_POST['password']); 
     71 
     72            $emailArray                    = explode('@', $_POST['email']); 
     73            $this->session->user           = $emailArray[0]; 
     74            $this->session->domain         = $emailArray[1]; 
     75            $this->session->email          = $_POST['email']; 
     76            $this->session->password       = $crypt->encrypt($_POST['password']); 
    5577            $this->session->lastActionTime = time(); 
    5678            header('Location: ./index.php?module=Home'); 
     
    6183    } 
    6284 
    63     private function createLoginForm() 
     85    /** 
     86     * createLoginForm  
     87     *  
     88     * Create HTML_QuickForm object for the login form 
     89     *  
     90     * @access protected 
     91     * @return object  HTML_QuickForm object 
     92     */ 
     93    protected function createLoginForm() 
    6494    { 
    65         $form = new HTML_QuickForm('formLogin', 'post', $_SERVER['REQUEST_URI'] . '&event=loginNow'); 
     95        $form = new HTML_QuickForm('formLogin', 'post', 
     96            $_SERVER['REQUEST_URI'] . '&event=loginNow'); 
    6697 
    6798        $form->addElement('header', 'MyHeader', _('Login')); 
     
    70101        $form->addElement('submit', 'submit', _('Login')); 
    71102 
    72         $form->addRule('email', _('Please enter your email address'), 'required', null, 'client'); 
    73         $form->addRule('email', _('Please enter a valid email address'), 'email', null, 'client'); 
    74         $form->addRule('password', _('Please enter your password'), 'required', null, 'client'); 
     103        $form->addRule('email', _('Please enter your email address'), 
     104            'required', null, 'client'); 
     105        $form->addRule('email', _('Please enter a valid email address'), 
     106            'email', null, 'client'); 
     107        $form->addRule('password', _('Please enter your password'), 
     108            'required', null, 'client'); 
    75109        $form->applyFilter('__ALL__', 'trim'); 
    76110 
     
    78112    } 
    79113 
    80     function logoutNow() { 
     114    /** 
     115     * logoutNow  
     116     *  
     117     * Log the user out. 
     118     *  
     119     * @access public 
     120     * @return void 
     121     */ 
     122    public function logoutNow() 
     123    { 
    81124        $this->session->destroy(); 
    82125        $this->setData('message', _('Logged out successfully')); 
     
    84127    } 
    85128 
    86     function logoutInactive() { 
     129    /** 
     130     * logoutInactive  
     131     *  
     132     * Log the user out for inactivity 
     133     *  
     134     * @access public 
     135     * @return void 
     136     */ 
     137    public function logoutInactive() 
     138    { 
    87139        $this->session->destroy(); 
    88         $this->setData('message', _('You have been logged out automatically for inactivity')); 
     140        $this->setData('message', 
     141            _('You have been logged out automatically for inactivity')); 
    89142        return $this->__default(); 
    90143    } 
    91  
    92144} 
    93145