2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
2012-12-10 21:48:30 +00:00
|
|
|
* @package OSB
|
2010-11-29 22:41:08 +00:00
|
|
|
* @subpackage Auth
|
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2010 Deon George
|
|
|
|
* @license http://dev.leenooks.net/license.html
|
|
|
|
*/
|
|
|
|
class Model_Auth_UserDefault extends Model_Auth_User {
|
|
|
|
// Validation rules
|
2011-05-14 07:35:33 +00:00
|
|
|
public function rules() {
|
|
|
|
return array(
|
|
|
|
'username' => array(
|
|
|
|
array('not_empty'),
|
|
|
|
array('min_length', array(':value', 4)),
|
|
|
|
array('max_length', array(':value', 32)),
|
|
|
|
),
|
|
|
|
'password' => array(
|
|
|
|
array('not_empty'),
|
|
|
|
array('min_length', array(':value', 5)),
|
|
|
|
array('max_length', array(':value', 32)),
|
|
|
|
),
|
|
|
|
'email' => array(
|
|
|
|
array('not_empty'),
|
|
|
|
array('min_length', array(':value', 4)),
|
|
|
|
array('max_length', array(':value', 127)),
|
|
|
|
array('email'),
|
|
|
|
),
|
|
|
|
// @todo To test
|
|
|
|
'password_confirm' => array(
|
|
|
|
array('matches_ifset', array(':validation', 'password', 'password_confirm')),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
|
|
|
|
// Validation callbacks
|
2011-05-14 07:35:33 +00:00
|
|
|
// @todo _callbacks no longer used
|
2010-11-29 22:41:08 +00:00
|
|
|
protected $_callbacks = array(
|
|
|
|
'username' => array('username_available'),
|
|
|
|
'email' => array('email_available'),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Columns to ignore
|
|
|
|
protected $_ignored_columns = array('password_confirm');
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Complete our login
|
|
|
|
*
|
|
|
|
* For some database logins, we may not want to record the user last login
|
|
|
|
* details in the repository, so we just override that parent function
|
|
|
|
* here.
|
|
|
|
*
|
|
|
|
* We can also do some other post-login actions here.
|
2011-05-14 07:35:33 +00:00
|
|
|
* @todo Maybe we can do our session update here.
|
2010-11-29 22:41:08 +00:00
|
|
|
*/
|
2011-09-27 11:22:13 +00:00
|
|
|
public function complete_login() {
|
|
|
|
return $this->log('Logged In');
|
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test to see if a record has been changed
|
|
|
|
*/
|
|
|
|
public function changed() {
|
2011-10-12 22:20:08 +00:00
|
|
|
return (count($this->_changed));
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Debug function to see that has() finds
|
|
|
|
* @todo This function could be removed
|
|
|
|
*/
|
|
|
|
public function has_list($alias, $model) {
|
|
|
|
// Return list of matches
|
|
|
|
return DB::select()
|
|
|
|
->from($this->_has_many[$alias]['through'])
|
|
|
|
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
|
|
|
|
->where($this->_has_many[$alias]['far_key'], '=', $model->pk())
|
|
|
|
->execute($this->_db)
|
|
|
|
->as_array();
|
|
|
|
}
|
|
|
|
}
|
2011-08-16 02:27:19 +00:00
|
|
|
?>
|