trunk
This commit is contained in:
1 parent
11cc1b9dd1
commit
7bc0e46305
162 files changed
+19744
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LoginForm class.
|
||||
* LoginForm is the data structure for keeping
|
||||
* user login form data. It is used by the 'login' action of 'SiteController'.
|
||||
*/
|
||||
class RegisterForm extends CFormModel
|
||||
{
|
||||
public $username;
|
||||
public $password;
|
||||
public $email;
|
||||
|
||||
/**
|
||||
* Declares the validation rules.
|
||||
* The rules state that username and password are required,
|
||||
* and password needs to be authenticated.
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('username, password, email', 'required'),
|
||||
array('email', 'email'),
|
||||
array('username', 'unique'),
|
||||
);
|
||||
}
|
||||
|
||||
public function unique($attribute,$params)
|
||||
{
|
||||
|
||||
if(!$this->hasErrors())
|
||||
{
|
||||
$count = user::model()->count('username=:username', array('username'=>$this->username));
|
||||
if ($count != 0)
|
||||
$this->addError('username','Username already exists');
|
||||
|
||||
$count = user::model()->count('email=:email', array('email'=>$this->email));
|
||||
if ($count != 0)
|
||||
$this->addError('email','Email already exists');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user