Created
November 7, 2010 06:03
-
-
Save iammerrick/665979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
class Model_User extends Model_Auth_User { | |
protected $_has_many = array( | |
'user_tokens' => array('model' => 'user_token'), | |
'roles' => array('model' => 'role', 'through' => 'roles_users'), | |
); | |
protected $_rules = array( | |
'username' => array( | |
'not_empty' => NULL, | |
'min_length' => array(4), | |
'max_length' => array(32), | |
'regex' => array('/^[-\pL\pN_.]++$/uD'), | |
'alpha_dash' => array() | |
), | |
'password' => array( | |
'not_empty' => NULL, | |
'min_length' => array(5), | |
'max_length' => array(42), | |
), | |
'password_confirm' => array( | |
'matches' => array('password'), | |
), | |
'email' => array( | |
'not_empty' => NULL, | |
'min_length' => array(4), | |
'max_length' => array(127), | |
'email' => NULL, | |
), | |
'first_name' => array( | |
'not_empty' => NULL, | |
'max_length' => array(255) | |
), | |
'last_name' => array( | |
'not_empty' => NULL, | |
'max_length' => array(255) | |
), | |
'mobile' => array( | |
'not_empty' => NULL, | |
'phone' => array(10) | |
) | |
); | |
protected $_filters = array( | |
'mobile' => array('Model_User::remove_dashes' => array()), | |
); | |
protected $_callbacks = array( | |
'username' => array('username_available'), | |
'email' => array('email_available'), | |
); | |
protected $_labels = array( | |
'username' => 'username', | |
'email' => 'email address', | |
'password' => 'password', | |
'password_confirm' => 'password confirmation', | |
'first_name' => 'first name', | |
'last_name' => 'last name', | |
'mobile' => 'mobile phone number', | |
); | |
protected $_ignored_columns = array('password_confirm'); | |
public static function remove_dashes($value) | |
{ | |
$value = preg_replace('/\D+/', '', $value); | |
return $value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment