Changeset 53

Show
Ignore:
Timestamp:
05/25/08 15:30:16 (2 years ago)
Author:
nperriault
Message:
  • Ported signin form and action to 1.1 forms framework
  • lib folder layout changed
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/apps/main/modules/sfGuardAuth/actions/actions.class.php

    r50 r53  
    1010{ 
    1111 
    12   public function executeActivate(
     12  public function executeActivate(sfWebRequest $request
    1313  { 
    1414    /* 
     
    3131    catch (Exception $e) 
    3232    { 
    33       $this->getRequest()->setError('errors', $this->__('Unable to activate your account')); 
     33      $request->setError('errors', $this->__('Unable to activate your account')); 
    3434      sfContext::getInstance()->getLogger()->err('Blocking error at account activation time: '.$e->getMessage()); 
    3535      return sfView::SUCCESS; 
     
    3737  } 
    3838   
    39   public function executeChangePassword(
    40   { 
    41     if ($this->getRequest()->getMethod() == sfRequest::POST
     39  public function executeChangePassword(sfWebRequest $request
     40  { 
     41    if ($request->isMethod('post')
    4242    { 
    4343      $user = $this->getUser()->getGuardUser(); 
    44       $password = $this->getRequestParameter('new_password'); 
     44      $password = $request->getParameter('new_password'); 
    4545      $user->setPassword($password); 
    4646      $user->save(); 
     
    5050  } 
    5151   
    52   public function executeDeleteAvatar(
     52  public function executeDeleteAvatar(sfWebRequest $request
    5353  { 
    5454    $user = $this->getUser()->getGuardUser(); 
     
    7272  } 
    7373   
    74   public function executeForgotPassword(
    75   { 
    76     if ($this->getRequest()->getMethod() == sfRequest::POST
     74  public function executeForgotPassword(sfWebRequest $request
     75  { 
     76    if ($request->isMethod('post')
    7777    { 
    7878      $password = substr(md5(rand(100000, 999999)), 0, 8); 
    79       $email = $this->getRequestParameter('email'); 
     79      $email = $request->getParameter('email'); 
    8080      $user = sfGuardUserPeer::retrieveByEmail($email); 
    8181      $this->forward404Unless($user, sprintf('User not with email "%s" found', $email)); 
     
    8383      $user->save(); 
    8484       
    85       $this->getRequest()->setAttribute('user', $user); 
    86       $this->getRequest()->setAttribute('password', $password); 
     85      $request->setAttribute('user', $user); 
     86      $request->setAttribute('password', $password); 
    8787      $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'forgotPassword', 
    8888                                                $user->getEmail(), 
     
    9090      if (!$mailSent) 
    9191      { 
    92         $this->getRequest()->setError('errors', $this->__('We were not able to send you an email. Please try again later.')); 
     92        $request->setError('errors', $this->__('We were not able to send you an email. Please try again later.')); 
    9393        return sfView::SUCCESS; 
    9494      } 
     
    9999  } 
    100100 
    101   public function executeProfile(
     101  public function executeProfile(sfWebRequest $request
    102102  { 
    103103    $this->embedGoogleJavascriptApi(); 
     
    105105    $this->user = $this->getUser()->getGuardUser(); 
    106106 
    107     if ($this->getRequest()->getMethod() != sfRequest::POST) 
     107    if ($request->getMethod() != sfRequest::POST) 
    108108    { 
    109109      return sfView::SUCCESS; 
    110110    } 
    111111     
    112     $profile = $this->getRequestParameter('profile', array()); 
     112    $profile = $request->getParameter('profile', array()); 
    113113     
    114114    # 1. Boolean values 
     
    177177    catch (Exception $e) 
    178178    { 
    179       $this->getRequest()->setError('errors', $this->__('Unable to save your profile')); 
     179      $request->setError('errors', $this->__('Unable to save your profile')); 
    180180      sfContext::getInstance()->getLogger()->err('Blocking error at profile save time: '.$e->getMessage()); 
    181181      return sfView::SUCCESS; 
     
    183183  } 
    184184 
    185   public function executeSkills(
     185  public function executeSkills(sfWebRequest $request
    186186  { 
    187187    $this->user = $this->getUser()->getGuardUser(); 
     
    189189    $this->skill_tags = sfConfig::get('app_people_skill_tags', array()); 
    190190    asort($this->skill_tags); 
    191     if ($this->getRequest()->getMethod() == sfRequest::POST
    192     { 
    193       $user_skills = $this->getRequestParameter('skills', array()); 
     191    if ($request->isMethod('post')
     192    { 
     193      $user_skills = $request->getParameter('skills', array()); 
    194194      $this->user->removeAllTags(); 
    195195      $this->user->save(); 
     
    231231    $this->form = new RegisterForm(); 
    232232     
    233     if (!$request->isMethod('post') or !$this->form->bindAndSave($request->getParameter('user'))) 
     233    // Recaptcha parameters 
     234    $captcha = array( 
     235      'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 
     236      'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'), 
     237    ); 
     238    $params = array_merge($request->getParameter('user', array()), array('captcha' => $captcha)); 
     239     
     240    if (!$request->isMethod('post') or !$this->form->bindAndSave($params)) 
    234241    { 
    235242      return sfView::SUCCESS; // redisplay form with errors 
     
    246253     
    247254    // Send user an activation email 
    248     $this->getRequest()->setAttribute('user', $user); 
    249     $this->getRequest()->setAttribute('activation', $activation); 
     255    $request->setAttribute('user', $user); 
     256    $request->setAttribute('activation', $activation); 
    250257    $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'register', 
    251258                                              $user->getEmail(), 
     
    255262    if (!$mailSent) 
    256263    { 
    257       $this->getRequest()->setError('errors', $this->__('We were unable to send you an activation email. Registration process failed.')); 
     264      $request->setError('errors', $this->__('We were unable to send you an activation email. Registration process failed.')); 
    258265      $activation->delete(); 
    259266      $user->delete(); 
     
    265272  } 
    266273   
    267   public function executeRegisterDone(
    268   { 
    269     $this->user = $this->getRequest()->getAttribute('user'); 
    270     return sfView::SUCCESS; 
    271   } 
    272    
    273   public function executeResendActivation(
    274   { 
    275     if ($this->getRequest()->getMethod() == sfRequest::POST
    276     { 
    277       $email = $this->getRequestParameter('email'); 
     274  public function executeRegisterDone(sfWebRequest $request
     275  { 
     276    $this->user = $request->getAttribute('user'); 
     277    return sfView::SUCCESS; 
     278  } 
     279   
     280  public function executeResendActivation(sfWebRequest $request
     281  { 
     282    if ($request->isMethod('post')
     283    { 
     284      $email = $request->getParameter('email'); 
    278285      $user = sfGuardUserPeer::retrieveByEmail($email); 
    279286       
     
    281288      $c->add(ActivationPeer::USER_ID, $user->getId()); 
    282289      $activation = ActivationPeer::doSelectOne($c); 
    283       $this->getRequest()->setAttribute('activation', $activation); 
     290      $request->setAttribute('activation', $activation); 
    284291       
    285292      $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'resendActivation', 
     
    288295      if (!$mailSent) 
    289296      { 
    290         $this->getRequest()->setError('errors', $this->__('We were unable to send you an email. We are digging the problem, stay tuned.')); 
     297        $request->setError('errors', $this->__('We were unable to send you an email. We are digging the problem, stay tuned.')); 
    291298        return sfView::SUCCESS; 
    292299      } 
     
    321328    if (!$this->activation) 
    322329    { 
    323       $this->getRequest()->setError('errors', $this->__('Unable to find this activation key: '.$key)); 
     330      $request->setError('errors', $this->__('Unable to find this activation key: '.$key)); 
    324331      return false; 
    325332    } 
     
    343350  public function validateChangePassword() 
    344351  { 
    345     if ($this->getRequest()->getMethod() == sfRequest::POST
     352    if ($this->getRequest()->isMethod('post')
    346353    { 
    347354      $user = $this->getUser()->getGuardUser(); 
    348355      if (!$user->checkPassword($this->getRequestParameter('current_password'))) 
    349356      { 
    350         $this->getRequest()->setError('errors', $this->__('You did not provide your current password correctly!')); 
     357        $request->setError('errors', $this->__('You did not provide your current password correctly!')); 
    351358        return false; 
    352359      } 
     
    357364  public function validateForgotPassword() 
    358365  { 
    359     if ($this->getRequest()->getMethod() == sfRequest::POST
     366    if ($this->getRequest()->isMethod('post')
    360367    { 
    361368      $user = sfGuardUserPeer::retrieveByEmail(trim($this->getRequestParameter('email'))); 
     
    376383  public function validateResendActivation() 
    377384  { 
    378     if ($this->getRequest()->getMethod() == sfRequest::POST
     385    if ($this->getRequest()->isMethod('post')
    379386    { 
    380387      $user = sfGuardUserPeer::retrieveByEmail(trim($this->getRequestParameter('email'))); 
  • trunk/apps/main/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php

    r48 r53  
    11<?php 
    2  
    3 /* 
    4  * This file is part of the symfony package. 
    5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  * 
    7  * For the full copyright and license information, please view the LICENSE 
    8  * file that was distributed with this source code. 
    9  */ 
    10  
    112/** 
    12  * 
     3 * Base sfGuardAuth actions 
     4 *  
    135 * @package    symfony 
    146 * @subpackage plugin 
    15  * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
    16  * @version    SVN: $Id: BasesfGuardAuthActions.class.php 6352 2007-12-07 09:16:20Z fabien $ 
    177 */ 
    188class BasesfGuardAuthActions extends myActions 
    199{ 
    20   public function executeSignin(
     10  public function executeSignin(sfWebRequest $request
    2111  { 
    2212    $user = $this->getUser(); 
    23     if ($this->getRequest()->getMethod() == sfRequest::POST
     13    if ($user->isAuthenticated()
    2414    { 
    25       $redirect = $user->getAttribute('redirect_after_login'); 
    26       $user->getAttributeHolder()->remove('redirect_after_login'); 
     15      return $this->redirect('@homepage'); 
     16    } 
     17 
     18    $this->form = new SigninForm(); 
     19 
     20    if ($request->isMethod('post')) 
     21    { 
     22      $this->form->bind($request->getParameter('signin')); 
    2723       
    28       if (!$redirect) // Trying referer 
     24      if ($this->form->isValid()) 
    2925      { 
    30         $redirect = $user->getAttribute('referer', $this->getRequest()->getReferer()); 
    31         $user->getAttributeHolder()->remove('referer'); 
     26        $values = $this->form->getValues(); 
     27        $this->getUser()->signin($values['user'], 'on' === $values['remember']); 
     28 
     29        $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $user->getReferer($request->getReferer())); 
     30 
     31        return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage'); 
    3232      } 
    33        
    34       if (!$redirect) // Getting default redirect route 
    35       { 
    36         $redirect = sfConfig::get('app_sf_guard_plugin_success_signin_url', '@homepage'); 
    37       } 
    38        
    39       $this->logMessage('Redirecting to '.$redirect); 
    40       $this->redirect($redirect); 
    41     } 
    42     elseif ($user->isAuthenticated()) 
    43     { 
    44       $redirect = $user->getAttribute('redirect', '@homepage'); 
    45       $user->getAttributeHolder()->remove('redirect'); 
    46       $this->redirect($redirect); 
    4733    } 
    4834    else 
    4935    { 
    50       if ($this->getRequest()->isXmlHttpRequest()) 
     36      if ($request->isXmlHttpRequest()) 
    5137      { 
    5238        $this->getResponse()->setHeaderOnly(true); 
     
    5642      } 
    5743 
    58       if (!$user->hasAttribute('referer')) 
    59       { 
    60         $user->setAttribute('referer', $this->getRequest()->getReferer()); 
    61       } 
     44      $user->setReferer($request->getReferer()); 
    6245 
    63       if ($this->getModuleName() != ($module = sfConfig::get('sf_login_module'))) 
     46      $module = sfConfig::get('sf_login_module'); 
     47      if ($this->getModuleName() != $module) 
    6448      { 
    6549        return $this->redirect($module.'/'.sfConfig::get('sf_login_action')); 
    6650      } 
    67        
    68       $routing = sfContext::getInstance()->getRouting(); 
    69       try 
    70       { 
    71         $controller = sfContext::getInstance()->getController(); 
    72         $uri = sfContext::getInstance()->getRouting()->getCurrentInternalUri(true); 
    73         $redirect = $controller->genUrl($uri, true); 
    74         $user->setAttribute('redirect_after_login', $redirect); 
    75         $this->logMessage(sprintf('Redirect url set to %s', $redirect)); 
    76       } 
    77       catch (Exception $e)  
    78       { 
    79         $this->logMessage('Unable to generate url for current route: '.$e->getMessage(),  
    80                           'warning'); 
    81       } 
    82        
     51 
    8352      $this->getResponse()->setStatusCode(401); 
    8453    } 
    8554  } 
    8655 
    87   public function executeSignout(
     56  public function executeSignout(sfWebRequest $request
    8857  { 
    8958    $this->getUser()->signOut(); 
    90     $signout_url = sfConfig::get('app_sf_guard_plugin_success_signout_url', '@homepage'); 
    91     $this->redirect($signout_url); 
     59 
     60    $signout_url = sfConfig::get('app_sf_guard_plugin_success_signout_url', $request->getReferer()); 
     61 
     62    $this->redirect('' != $signout_url ? $signout_url : '@homepage'); 
    9263  } 
    9364 
    9465  public function executeSecure() 
    9566  { 
    96     $this->getUser()->setAttribute('redirect_after_login',  
    97                                    sfContext::getInstance()->getRouting()->getCurrentInternalUri(true)); 
    9867    $this->getResponse()->setStatusCode(403); 
    9968  } 
     
    10372    throw new sfException('This method is not yet implemented.'); 
    10473  } 
    105  
    106   public function handleErrorSignin() 
    107   { 
    108     $user = $this->getUser(); 
    109     if (!$user->hasAttribute('referer')) 
    110     { 
    111       $user->setAttribute('referer', $this->getRequest()->getReferer()); 
    112     } 
    113  
    114     $module = sfConfig::get('sf_login_module'); 
    115     if ($this->getModuleName() != $module) 
    116     { 
    117       $this->forward(sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action')); 
    118     } 
    119  
    120     return sfView::SUCCESS; 
    121   } 
    12274} 
  • trunk/apps/main/modules/sfGuardAuth/templates/registerSuccess.php

    r50 r53  
    3131    <fieldset> 
    3232      <legend><?php echo __('Account informations') ?></legend> 
    33       <?php echo $form ?> 
    34       <?php /* 
    35       <div class="form-row required"> 
    36         <label for="username"><?php echo __('Username') ?></label> 
    37         <?php echo input_tag('username', $sf_params->get('username')) ?> 
    38         <div class="form_help"><?php echo __('Only alphanumeric, dash, underscore and dot characters allowed.') ?></div> 
    39         <?php echo form_error('username') ?> 
    40       </div> 
    41       <div class="form-row required"> 
    42         <label for="email"><?php echo __('Email') ?></label> 
    43         <?php echo input_tag('email', $sf_params->get('email')) ?> 
    44         <div class="form_help"><?php echo __('A valid mail address is required. An activation message will be sent.') ?></div> 
    45         <?php echo form_error('email') ?> 
    46       </div> 
    47       <div class="form-row required"> 
    48         <label for="password"><?php echo __('Password') ?></label> 
    49         <?php echo input_password_tag('password') ?> 
    50         <div class="form_help"><?php echo __('Six characters minimum.') ?></div> 
    51         <?php echo form_error('password') ?> 
    52       </div> 
    53       <div class="form-row required"> 
    54         <label for="password2"><?php echo __('Confirm password') ?></label> 
    55         <?php echo input_password_tag('password2') ?> 
    56         <?php echo form_error('password2') ?> 
    57       </div> 
    58       */?> 
     33      <?php echo $form->renderGlobalErrors() ?> 
     34      <?php echo $form['username']->renderRow() ?> 
     35      <?php echo $form['email']->renderRow() ?> 
     36      <?php echo $form['password']->renderRow() ?> 
     37      <?php echo $form['password2']->renderRow() ?> 
    5938    </fieldset> 
    6039  </div> 
     
    6241    <fieldset> 
    6342      <legend><?php echo __('Security') ?></legend> 
    64       <div class="form-row required"> 
    65         <?php /* 
    66         <?php echo label_for('captcha', __('Security code')) ?> 
    67         <?php echo input_tag('captcha', null, 'id=captcha style=width:100px'); ?> 
    68         <?php echo cryptographp_picture() ?> 
    69         <?php echo cryptographp_reload() ?> 
    70         <?php echo form_error('captcha') ?> 
    71         <p class="form-help"> 
    72           <?php echo __('This codes aims at detecting if you are a bot or a human person.') ?> 
    73         </p> 
    74         */ ?> 
    75       </div> 
     43      <?php echo $form['captcha']->renderRow() ?> 
    7644    </fieldset> 
    7745    <p class="tip"> 
     
    7947    </p> 
    8048    <p style="text-align:center"> 
     49      <?php echo $form['_csrf_token'] ?> 
    8150      <input type="submit" value="<?php echo __('Click here to register your account') ?>" /> 
    8251    </p> 
  • trunk/apps/main/modules/sfGuardAuth/templates/resendActivationSuccess.php

    r2 r53  
    1818</p> 
    1919 
    20 <?php echo form_tag('@user_resend_activation') ?
     20<form action="<?php echo url_for('@user_resend_activation') ?>" method="post"
    2121  <div class="fiftypercent"> 
    2222    <fieldset> 
    2323      <legend><?php echo __('Account informations') ?></legend> 
     24      <?php echo $form->renderGlobalErrors() ?> 
     25      <?php echo $form['email']->renderRow() ?> 
     26      <?php /* 
    2427      <div class="form-row required"> 
    2528        <label for="email"><?php echo __('Email address you provided at registration time') ?></label> 
     
    3740        </p> 
    3841      </div> 
     42      */ ?> 
    3943      <p> 
    40         <?php echo submit_tag(__('Send me my activation mail')) ?> 
     44        <?php echo $form['_csrf_token'] ?> 
     45        <input type="submit" value="<?php echo __('Send me my activation mail') ?>" /> 
    4146      </p> 
    4247    </fieldset> 
  • trunk/apps/main/modules/sfGuardAuth/templates/signinSuccess.php

    r2 r53  
    1111 
    1212<div id="sf_guard_auth_form"> 
    13 <?php echo form_tag('@sf_guard_signin') ?> 
    14   <div class="fiftypercent"> 
    15     <fieldset> 
    16       <legend><?php echo __('Please sign in') ?></legend> 
    17       <div class="form-row"> 
    18         <?php 
    19         echo form_error('username'),  
    20         label_for('username', __('Username')), 
    21         input_tag('username', $sf_data->get('sf_params')->get('username')); 
    22         ?> 
    23       </div> 
    24       <div class="form-row"> 
    25         <?php 
    26         echo form_error('password'),  
    27           label_for('password', __('Password')), 
    28           input_password_tag('password'); 
    29         ?> 
    30       </div> 
    31       <div class="form-row"> 
    32         <?php echo checkbox_tag('remember') ?> 
    33         <?php echo label_for('remember', __('Remember me?'), 'class=inline') ?> 
    34       </div> 
    35       <div class="form-row"> 
    36         <?php echo submit_tag(__('sign in')) ?> 
    37         | 
    38         <?php echo link_to(__('Forgot your password?'),  
    39                            '@user_forgot_password',  
    40                            array('id' => 'forgot_password')) ?> 
    41       </div> 
    42     </fieldset> 
    43   </div> 
    44   <div class="fiftypercent"> 
    45     <fieldset> 
    46       <legend><?php echo __('You don\'t have an account yet ?') ?></legend> 
    47       <div class="form-row"> 
    48         <?php echo big_button_to(__('Sign up!'), '@user_register', 'id=bt_signup') ?> 
    49       </div> 
    50       <p style="text-align:center"> 
    51         <?php echo link_to(__('Never received activation mail?'),  
    52                            '@user_resend_activation',  
    53                            array('id' => 'resend_activation')) ?> 
    54       </p> 
    55     </fieldset> 
    56   </div> 
    57 <?php echo end_form() ?> 
     13  <form action="<?php echo url_for('@sf_guard_signin') ?>" method="post"> 
     14    <div class="fiftypercent"> 
     15      <fieldset> 
     16        <legend><?php echo __('Please sign in') ?></legend> 
     17        <?php echo $form->renderGlobalErrors() ?> 
     18        <?php echo $form['username']->renderRow() ?> 
     19        <?php echo $form['password']->renderRow() ?> 
     20        <p> 
     21          <?php echo $form['remember'] ?> 
     22          <?php echo $form['remember']->renderLabel(__('Remember me'), array('class' => 'inline')) ?> 
     23        </p> 
     24        <div class="form-row"> 
     25          <?php echo $form['_csrf_token'] ?> 
     26          <input type="submit" value="<?php echo __('sign in') ?>" /> 
     27          | 
     28          <?php echo link_to(__('Forgot your password?'),  
     29                             '@user_forgot_password',  
     30                             array('id' => 'forgot_password')) ?> 
     31        </div> 
     32      </fieldset> 
     33    </div> 
     34    <div class="fiftypercent"> 
     35      <fieldset> 
     36        <legend><?php echo __('You don\'t have an account yet ?') ?></legend> 
     37        <div class="form-row"> 
     38          <?php echo big_button_to(__('Sign up!'), '@user_register', 'id=bt_signup') ?> 
     39        </div> 
     40        <p style="text-align:center"> 
     41          <?php echo link_to(__('Never received activation mail?'),  
     42                             '@user_resend_activation',  
     43                             array('id' => 'resend_activation')) ?> 
     44        </p> 
     45      </fieldset> 
     46    </div> 
     47  </form> 
    5848</div> 
  • trunk/lib/form/user/RegisterForm.class.php

    r52 r53  
    88{ 
    99 
    10   static protected $forbidden_names = array('admin', 'niko', 'contact', 'info', 'infos', 'commercial', 'tech', 'support', 'sales', 'partnership', 'webmaster', 'business', 'owner'); 
     10  static protected  
     11    $forbidden_names = array('admin', 'niko', 'contact', 'info', 'infos', 'commercial', 'tech', 'support', 'sales', 'partnership', 'webmaster', 'business', 'owner'); 
    1112   
    1213  public function configure() 
     
    1819      'password'  => new sfWidgetFormInputPassword(), 
    1920      'password2' => new sfWidgetFormInputPassword(), 
     21      'captcha'   => new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_public_key'))), 
    2022    )); 
    2123     
     
    2527      'email'     => 'Please enter a valid email address. An activation link will be sent to this adress.', 
    2628      'password'  => 'Your password must be 6 characters length minimum.', 
    27       'password2' => 'Please confirm your password for avoiding typos.' 
     29      'password2' => 'Please confirm your password for avoiding typos.', 
     30      'captcha'   => 'This codes aims at detecting if you are a bot or a human person.', 
    2831    )); 
    2932     
     
    4144      'password'  => new sfValidatorString(array('min_length' => 6, 'max_length' => 128)), 
    4245      'password2' => new sfValidatorString(array('min_length' => 6, 'max_length' => 128)), 
     46      'captcha'   => new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_private_key'))), 
    4347    )); 
    4448     
     
    4650    $this->validatorSchema->setPostValidator(new sfValidatorAnd(array( 
    4751      new sfValidatorSchemaCompare('password', 'equal', 'password2', array('throw_global_error' => true)), 
    48       new sfValidatorPropelUnique(array('model'  => 'sfGuardUser',  
    49                                         'column' => 'username')), 
     52      new sfValidatorPropelUnique(array('model'  => 'sfGuardUser', 'column' => 'username')), 
     53      new sfValidatorPropelUnique(array('model'  => 'sfGuardUser', 'column' => 'email')) 
    5054    ))); 
    5155     
  • trunk/lib/model/PluginsfGuardUser.php

    r49 r53  
    11<?php 
     2 
     3/* 
     4 * This file is part of the symfony package. 
     5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 * 
     7 * For the full copyright and license information, please view the LICENSE 
     8 * file that was distributed with this source code. 
     9 */ 
     10 
    211/** 
    3  * Local representation of sfGuardUser 
    412 * 
    513 * @package    symfony 
    614 * @subpackage plugin 
     15 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     16 * @version    SVN: $Id: PluginsfGuardUser.php 7995 2008-03-20 06:58:43Z fabien $ 
    717 */ 
    818class PluginsfGuardUser extends BasesfGuardUser 
     
    1222    $groups         = null, 
    1323    $permissions    = null, 
    14     $allPermissions = null, 
    15     $justKarma      = false; 
     24    $allPermissions = null; 
    1625 
    1726  /** 
     
    358367  { 
    359368  } 
     369   
     370  public function setPasswordHash($v) 
     371  { 
     372    if (!is_null($v) && !is_string($v)) 
     373    { 
     374      $v = (string) $v; 
     375    } 
     376 
     377    if ($this->password !== $v) 
     378    { 
     379      $this->password = $v; 
     380      $this->modifiedColumns[] = sfGuardUserPeer::PASSWORD; 
     381    } 
     382  } 
    360383 
    361384  /** 
     
    386409  { 
    387410    $algorithm = $this->getAlgorithm(); 
     411     
    388412    if (false !== $pos = strpos($algorithm, '::')) 
    389413    { 
    390414      $algorithm = array(substr($algorithm, 0, $pos), substr($algorithm, $pos + 2)); 
    391415    } 
     416     
    392417    if (!is_callable($algorithm)) 
    393418    { 
    394419      throw new sfException(sprintf('The algorithm callable "%s" is not callable.', $algorithm)); 
    395420    } 
    396  
     421     
    397422    return $this->getPassword() == call_user_func_array($algorithm, array($this->getSalt().$password)); 
    398423  } 
     
    652677    try 
    653678    { 
    654       $profile = $this->getProfile(); 
    655       if ($profile) 
    656       { 
    657         $profile->delete($con); 
     679      if ($profile = $this->getProfile()) 
     680      { 
     681        $profile->delete(); 
    658682      } 
    659683    }