Show
Ignore:
Timestamp:
12/14/2007 12:52:49 PM (13 months ago)
Author:
Shadowhand
Message:

Updates to Auth/ORM:

  • User_Model no longer assumes that digit strings are usernames (fix to where_key)
  • Implemented many<>many deletion in ORM::delete()
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/auth/models/user.php

    r1431 r1534  
    7676 
    7777        /** 
    78          * Removes all roles for this user when the object is deleted. 
     78         * Allows a model to be loaded by username or email address. 
    7979         */ 
    80         public function delete() 
    81         { 
    82                 $where = array($this->class.'_id' => $this->object->id); 
    83                 $table = $this->related_table('roles'); 
    84  
    85                 if ($return = parent::delete()) 
    86                 { 
    87                         // Remove users<>roles relationships 
    88                         self::$db 
    89                                 ->where($where) 
    90                                 ->delete($table); 
    91                 } 
    92  
    93                 return $return; 
    94         } 
    95  
    9680        protected function where_key($id = NULL) 
    9781        { 
    98                 if (is_string($id) AND ! is_numeric($id)) 
     82                if ( ! empty($id) AND is_string($id) AND ! ctype_digit($id)) 
    9983                { 
    10084                        return valid::email($id) ? 'email' : 'username';