Show
Ignore:
Timestamp:
05/13/08 00:50:52 (8 months ago)
Author:
aarkerio
Message:

Messages to all class

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/models/user.php

    r471 r480  
    5454 
    5555 public $validate = array( 
    56       'login'    => VALID_NOT_EMPTY, 
    57       'pwd' => VALID_NOT_EMPTY, 
    58       'username' => VALID_NOT_EMPTY, 
    59       'name' => VALID_NOT_EMPTY, 
    60       'email'    => VALID_EMAIL 
    61    ); 
    62   
     56              'login'    => VALID_NOT_EMPTY, 
     57              'pwd'      => VALID_NOT_EMPTY, 
     58              'username' => VALID_NOT_EMPTY, 
     59              'name'     => VALID_NOT_EMPTY, 
     60              'email'    => VALID_EMAIL 
     61               ); 
     62/*  
     63I will work on this later 
     64public $validate = array( 
     65            'username' => array('rule' => 'alphanumeric', 
     66                        'required' => true, 
     67                        'message' => 'Please enter a username'), 
     68            'pwd' => array('rule' => array('confirmPassword', 'password'), 
     69                        'message' => 'Passwords do not match'), 
     70            'pwd_confirm' => array('rule' => 'alphanumeric', 
     71                            'required' => true) 
     72            ); 
     73*/ 
     74 
     75public function confirmPassword($data)  
     76{ 
     77  $valid = false; 
     78         
     79  if ($data['password'] == Security::hash(Configure::read('Security.salt') . $this->data['User']['password_confirm']))  
     80  { 
     81      $valid = true; 
     82  }  
     83         
     84  return $valid; 
     85}  
     86 
    6387 /* 
    6488  * excepts : model you need 
     
    79103    return true; 
    80104  } 
     105 
     106 /* 
     107  * Remove pwd if too short 
     108  * 
     109  */ 
     110  public function beforeValidate() 
     111  { 
     112    
     113    if ( !empty($this->data['User']['pwd']) ): 
     114           die( debug($this->data['User']['pwd'])); 
     115          if ( strlen($this->data['User']['pwd']) < 6):   // only if pwd is big enough 
     116                 unset($this->data['User']['pwd']);       
     117      endif; 
     118 
     119    endif; 
     120 
     121 
     122    return true; 
     123  } 
    81124} 
    82125?>