Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ResendActivationForm extends CFormModel {
- public $username;
- /**
- * Declares the validation rules.
- * The rules state that username and password are required,
- * and password needs to be authenticated.
- */
- public function rules() {
- return array(
- // username and password are required
- array('username', 'required'),
- array('username', 'length', 'min' => 6, 'max' => 32),
- //user alpha numeric
- array('username', 'match', 'pattern' => '/^[a-z]+([a-z0-9])+$/'),
- //username must exist
- array('username', 'exist', 'className' => 'User', 'attributeName' => 'username'),
- array('username', 'checkActive'),
- );
- }
- public function checkActive($attribute, $params) {
- if (!$this->hasErrors()) {
- $user = User::model()->findByAttributes(array('username' => $this->username));
- if ($user->status == 1)
- $this->addError("username", "Your account is already active.");
- }
- }
- }
- ?>
- <?php
- class ForgotPasswordForm extends CFormModel {
- public $username;
- /**
- * Declares the validation rules.
- * The rules state that username and password are required,
- * and password needs to be authenticated.
- */
- public function rules() {
- return array(
- // username and password are required
- array('username', 'required'),
- array('username', 'length', 'min' => 6, 'max' => 32),
- //user alpha numeric
- array('username', 'match', 'pattern' => '/^[a-z]+([a-z0-9])+$/'),
- //username must exist
- array('username', 'exist', 'className' => 'User', 'attributeName' => 'username'),
- array('username', 'checkActive'),
- );
- }
- public function checkActive($attribute, $params) {
- if (!$this->hasErrors()) {
- $user = User::model()->findByAttributes(array('username' => $this->username));
- if ($user->status !== 1)
- $this->addError("username", "Your account is not activate. Please activate first.");
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment