public function checkexists($attribute, $params) { if (!$this->hasErrors()) { $value = (string) $this->login_or_email; if (strpos($this->login_or_email, "@")) { // $user = User::model()->findByAttributes(array('email' => $this->login_or_email)); $user = User::model()->find(array('condition' => 'LOWER(email)=:email', 'params' => array(':email' => MHelper::String()->toLower($value)))); if ($user) { $this->user_id = $user->id; } } else { // $user = User::model()->findByAttributes(array('username' => $this->login_or_email)); $user = User::model()->find(array('condition' => 'LOWER(username)=:username', 'params' => array(':username' => MHelper::String()->toLower($value)))); if ($user) { $this->user_id = $user->id; } } if ($user === null) { if (strpos($value, "@")) { $this->addError("login_or_email", UsersModule::t("Email is incorrect.")); } else { $this->addError("login_or_email", UsersModule::t("Username is incorrect.")); } } } }
/** * Registration user */ public function actionRegistration() { $this->layout = '//layouts/login'; $model = new RegistrationForm(); // ajax validator if (isset($_POST['ajax']) && $_POST['ajax'] === 'signup-form_id') { /* echo UActiveForm::validate($model); Yii::app()->end(); */ $errors = CActiveForm::validate($model); echo $errors; Yii::app()->end(); } if (Yii::app()->user->id) { $this->redirect('/'); } else { $this->redirect('/login'); if (isset($_POST['RegistrationForm'])) { $model->attributes = $_POST['RegistrationForm']; $model->verifyPassword = $model->password; if ($model->validate()) { $soucePassword = $model->password; $model->activkey = UsersModule::encrypting(microtime() . $model->password); $model->password = UsersModule::encrypting($model->password); $model->verifyPassword = UsersModule::encrypting($model->verifyPassword); $model->status = Yii::app()->getModule('users')->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE; if ($model->save()) { Yii::app()->queue->subscribe($model->id, null, "User.{$model->id}"); if (Yii::app()->getModule('users')->sendActivationMail) { $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email)); UsersModule::sendMail($model->email, UsersModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UsersModule::t("Please activate you account go to {activation_url}", array('{activation_url}' => $activation_url))); } // wellcome email $subject = Yii::t('email', 'Welcome'); $message = Yii::t('email', 'Welcome to <a href="{url}">{catalog}</a>.', array('{url}' => $this->createAbsoluteUrl('/'), '{catalog}' => Yii::app()->name)); SendMail::send($model->email, $subject, $message, true); if ((Yii::app()->getModule('users')->loginNotActiv || Yii::app()->getModule('users')->activeAfterRegister && Yii::app()->getModule('users')->sendActivationMail == false) && Yii::app()->getModule('users')->autoLogin) { $identity = new UserIdentity($model->username, $soucePassword); $identity->authenticate(); Yii::app()->user->login($identity, 0); $this->redirect(Yii::app()->getModule('users')->returnUrl); } else { if (!Yii::app()->getModule('users')->activeAfterRegister && !Yii::app()->getModule('users')->sendActivationMail) { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Contact Admin to activate your account.")); } elseif (Yii::app()->getModule('users')->activeAfterRegister && Yii::app()->getModule('users')->sendActivationMail == false) { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UsersModule::t('Login'), Yii::app()->getModule('users')->loginUrl)))); } elseif (Yii::app()->getModule('users')->loginNotActiv) { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please check your email or login.")); } else { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please check your email.")); } $this->refresh(); } } } else { // var_dump($model->errors);die(); } } $this->render('/user/registration', array('model' => $model)); } }
/** * Authenticates the password. * This is the 'authenticate' validator as declared in rules(). */ public function authenticate($attribute, $params) { if (!$this->hasErrors()) { $identity = new UserIdentity($this->username, $this->password); $identity->authenticate(); switch ($identity->errorCode) { case UserIdentity::ERROR_NONE: $duration = $this->rememberMe ? Yii::app()->getModule('users')->rememberMeTime : 0; Yii::app()->user->login($identity, $duration); break; case UserIdentity::ERROR_EMAIL_INVALID: $this->addError("username", UsersModule::t("Email is incorrect.")); break; case UserIdentity::ERROR_USERNAME_INVALID: $this->addError("username", UsersModule::t("Username is incorrect.")); break; case UserIdentity::ERROR_STATUS_NOTACTIV: $this->addError("status", UsersModule::t("Your account is not activated.")); break; case UserIdentity::ERROR_PASSWORD_INVALID: $this->addError("password", UsersModule::t("Password is incorrect.")); break; } } }
/** * @param $value * @return string */ public function editAttribute($model, $field, $params = array()) { if (!isset($params['options'])) { $params['options'] = array(); } $options = $params['options']; unset($params['options']); return CHtml::activeFileField($model, $field->varname, $params) . ($model->getAttribute($field->varname) ? '<br/>' . CHtml::activeCheckBox($model, '[uwfdel]' . $field->varname, $params) . ' ' . CHtml::activeLabelEx($model, '[uwfdel]' . $field->varname, array('label' => UsersModule::t('Delete file'), 'style' => 'display:inline;')) : ''); }
/** * Activation user account */ public function actionActivation() { $email = $_GET['email']; $activkey = $_GET['activkey']; if ($email && $activkey) { $find = User::model()->notsafe()->findByAttributes(array('email' => $email)); if (isset($find) && $find->status) { $this->render('/user/message', array('title' => UsersModule::t("User activation"), 'content' => UsersModule::t("Your account is active."))); } elseif (isset($find->activkey) && $find->activkey == $activkey) { $find->activkey = UsersModule::encrypting(microtime()); $find->status = 1; $find->save(); $this->render('/user/message', array('title' => UsersModule::t("User activation"), 'content' => UsersModule::t("Your account is activated."))); } else { $this->render('/user/message', array('title' => UsersModule::t("User activation"), 'content' => UsersModule::t("Incorrect activation URL."))); } } else { $this->render('/user/message', array('title' => UsersModule::t("User activation"), 'content' => UsersModule::t("Incorrect activation URL."))); } }
<?php /** @var BootActiveForm $form */ $form2 = $this->beginWidget('CActiveForm', array('id' => 'recovery-form')); ?> <?php echo $form2->errorSummary($form); ?> <?php echo $form2->textField($form, 'login_or_email', array('hint' => UsersModule::t("Please enter your login or email addres."))); ?> <div class="control-group"> <div class="controls"> <?php echo CHtml::submitButton(UsersModule::t("Restore"), array('class' => 'btn')); ?> </div> </div> <?php $this->endWidget(); ?> </div><!-- form --> <?php } ?>
/** * Widget initialization * @return array */ public function init() { return array('name' => __CLASS__, 'label' => UsersModule::t('jQueryUI autocomplete', array(), __CLASS__), 'fieldType' => array('INTEGER'), 'params' => $this->params, 'paramsLabels' => array('modelName' => UsersModule::t('Model Name', array(), __CLASS__), 'optionName' => UsersModule::t('Lable field name', array(), __CLASS__), 'emptyFieldLabel' => UsersModule::t('Empty item name', array(), __CLASS__), 'emptyFieldValue' => UsersModule::t('Empty item value', array(), __CLASS__), 'relationName' => UsersModule::t('Profile model relation name', array(), __CLASS__), 'minLength' => UsersModule::t('minimal start research length', array(), __CLASS__))); }
/** * Widget initialization * @return array */ public function init() { return array('name' => __CLASS__, 'label' => UsersModule::t('Relation Belongs To', array(), __CLASS__), 'fieldType' => array('INTEGER'), 'params' => $this->params, 'paramsLabels' => array('modelName' => UsersModule::t('Model Name', array(), __CLASS__), 'optionName' => UsersModule::t('Lable field name', array(), __CLASS__), 'emptyField' => UsersModule::t('Empty item name', array(), __CLASS__), 'relationName' => UsersModule::t('Profile model relation name', array(), __CLASS__))); }
public static function activeDateField($model, $attribute, $htmlOptions = array()) { // SET UP ARRAYS OF OPTIONS FOR DAY, MONTH, YEAR $x = 1; $dayOptions = array('00' => ' - '); while ($x < 31) { $dayOptions[($x < 10 ? '0' : '') . $x] = $x; $x++; } $monthOptions = array('00' => ' - ', '01' => UsersModule::t('January'), '02' => UsersModule::t('February'), '03' => UsersModule::t('March'), '04' => UsersModule::t('April'), '05' => UsersModule::t('May'), '06' => UsersModule::t('June'), '07' => UsersModule::t('July'), '08' => UsersModule::t('August'), '09' => UsersModule::t('September'), '10' => UsersModule::t('October'), '11' => UsersModule::t('November'), '12' => UsersModule::t('December')); $yearOptions = array('0000' => ' - '); $x = 1901; while ($x < 2030) { $yearOptions[$x] = $x; $x++; } parent::resolveNameID($model, $attribute, $htmlOptions); if ($model->{$attribute} != '0000-00-00' && isset($model->{$attribute})) { if (is_array($model->{$attribute})) { $new = $model->{$attribute}; $day = $new['day']; $month = $new['month']; $year = $new['year']; } else { $new = explode('-', $model->{$attribute}); // intval removes leading zero $day = $new[2]; $month = $new[1]; $year = $new[0]; } } else { // DEFAULT TO 0 IF THERE IS NO DATE SET $day = '00'; $month = '00'; $year = '0000'; } //echo "<pre>"; print_r(array($day,$month,$year)); die(); $return = parent::dropDownList($htmlOptions['name'] . '[day]', $day, $dayOptions); $return .= parent::dropDownList($htmlOptions['name'] . '[month]', $month, $monthOptions); $return .= parent::dropDownList($htmlOptions['name'] . '[year]', $year, $yearOptions); return $return; }
public static function itemAlias($type, $code = NULL) { $_items = array('UserStatus' => array(self::STATUS_NOACTIVE => UsersModule::t('Not active'), self::STATUS_ACTIVE => UsersModule::t('Active'), self::STATUS_BANNED => UsersModule::t('Banned')), 'AdminStatus' => array('0' => UsersModule::t('No'), '1' => UsersModule::t('Yes'))); if (isset($code)) { return isset($_items[$type][$code]) ? $_items[$type][$code] : false; } else { return isset($_items[$type]) ? $_items[$type] : false; } }
/** * Verify Old Password */ public function verifyOldPassword($attribute, $params) { if (User::model()->notsafe()->findByPk(Yii::app()->user->id)->password != Yii::app()->getModule('users')->encrypting($this->$attribute)) $this->addError($attribute, UsersModule::t("Old Password is incorrect.")); }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $modelLogin = new UserLogin(); $modelRegister = new RegistrationForm(); $modelRecovery = new UserRecoveryForm(); // collect user input data if (isset($_POST['ajax']) && $_POST['ajax'] === 'form-login') { $errors = CActiveForm::validate($modelLogin); echo $errors; /* if(Yii::app()->request->urlReferrer && Yii::app()->request->urlReferrer == 'http://'.Yii::app()->request->serverName.'/mkreview'){ // Сохраняем в сессию единицу, чтобы сохранить данные в localStorage при создании отзыва Yii::app()->session['redirectReview'] = 1; }*/ Yii::app()->end(); } if (isset($_POST['ajax']) && $_POST['ajax'] === 'form-register') { if (isset($_POST['RegistrationForm']['username'])) { $modelRegister->fullname = $_POST['RegistrationForm']['username']; } $errors = CActiveForm::validate($modelRegister); if ($errors != '[]') { echo $errors; Yii::app()->end(); } } if (isset($_POST['UsersLogin'])) { $modelLogin->attributes = $_POST['UsersLogin']; // validate user input and redirect to previous page if valid if ($modelLogin->validate()) { $this->lastViset(); /* if(Yii::app()->request->urlReferrer && Yii::app()->request->urlReferrer == 'http://'.Yii::app()->request->serverName.'/mkreview'){ // Сохраняем в сессию единицу, чтобы сохранить данные в localStorage при создании отзыва Yii::app()->session['redirectReview'] = 1; }*/ if (Yii::app()->user->returnUrl == '/index.php' || Yii::app()->user->returnUrl == '/') { $this->redirect(Yii::app()->getModule('users')->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } else { VarDumper::dump($modelLogin->errors); die; // Ctrl + X Delete line } } if (isset($_POST['RegistrationForm'])) { $modelRegister->attributes = $_POST['RegistrationForm']; $modelRegister->fullname = $modelRegister->username; $modelRegister->verifyPassword = $modelRegister->password; if ($modelRegister->validate()) { $soucePassword = $modelRegister->password; $modelRegister->activkey = UsersModule::encrypting(microtime() . $modelRegister->password); $modelRegister->password = UsersModule::encrypting($modelRegister->password); $modelRegister->verifyPassword = UsersModule::encrypting($modelRegister->verifyPassword); $modelRegister->superuser = 0; $modelRegister->status = Yii::app()->getModule('users')->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE; if ($modelRegister->save()) { if (Yii::app()->getModule('users')->sendActivationMail) { $activation_url = $this->createAbsoluteUrl('/users/activation/activation', array("activkey" => $modelRegister->activkey, "email" => $modelRegister->email)); UsersModule::sendMail($modelRegister->email, UsersModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UsersModule::t("Please activate you account go to {activation_url}", array('{activation_url}' => $activation_url))); } // wellcome email // $subject = Yii::t('email','Welcome'); // $message = Yii::t('email', 'Welcome to <a href="{url}">{catalog}</a>.', array('{url}'=>$this->createAbsoluteUrl('/'), '{catalog}'=>Yii::app()->name)); // SendMail::send($modelRegister->email,$subject,$message,true); if ((Yii::app()->getModule('users')->loginNotActiv || Yii::app()->getModule('users')->activeAfterRegister && Yii::app()->getModule('users')->sendActivationMail == false) && Yii::app()->getModule('users')->autoLogin) { $identity = new UserIdentity($modelRegister->username, $soucePassword); $identity->authenticate(); Yii::app()->user->login($identity, 0); $this->lastViset(); if (Yii::app()->request->isAjaxRequest) { echo '[]'; Yii::app()->end(); } else { /*if(Yii::app()->request->urlReferrer && Yii::app()->request->urlReferrer == 'http://'.Yii::app()->request->serverName.'/mkreview'){ // Сохраняем в сессию единицу, чтобы сохранить данные в localStorage при создании отзыва Yii::app()->session['redirectReview'] = 1; }*/ if (Yii::app()->request->urlReferrer && Yii::app()->request->urlReferrer != 'http://' . Yii::app()->request->serverName . '/login') { $url = Yii::app()->request->urlReferrer; $this->redirect($url); } else { $this->redirect('/'); } } } else { if (!Yii::app()->getModule('users')->activeAfterRegister && !Yii::app()->getModule('users')->sendActivationMail) { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Contact Admin to activate your account.")); } elseif (Yii::app()->getModule('users')->activeAfterRegister && Yii::app()->getModule('users')->sendActivationMail == false) { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->getModule('users')->loginUrl)))); } elseif (Yii::app()->getModule('users')->loginNotActiv) { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please check your email or login.")); } else { Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please check your email.")); } if (Yii::app()->request->isAjaxRequest) { echo '[]'; Yii::app()->end(); } else { /*if(Yii::app()->request->urlReferrer && Yii::app()->request->urlReferrer == 'http://'.Yii::app()->request->serverName.'/mkreview'){ // Сохраняем в сессию единицу, чтобы сохранить данные в localStorage при создании отзыва Yii::app()->session['redirectReview'] = 1; }*/ if (Yii::app()->request->urlReferrer && Yii::app()->request->urlReferrer != 'http://' . Yii::app()->request->serverName . '/login') { $url = Yii::app()->request->urlReferrer; $this->redirect($url); } else { $this->redirect('/'); } } } } } else { var_dump($modelRegister->errors); die; } } // display the login form $this->render('application.modules.users.views.user.login', array('modelLogin' => $modelLogin, 'modelRecovery' => $modelRecovery, 'modelRegister' => $modelRegister)); } else { if (Yii::app()->request->urlReferrer && Yii::app()->request->urlReferrer != 'http://' . Yii::app()->request->serverName . '/login') { $url = Yii::app()->request->urlReferrer; $this->redirect($url); } else { $this->redirect('/'); } } }
/** * Initialization * @return array */ public function init() { return array('name' => __CLASS__, 'label' => UsersModule::t('jQueryUI datepicker'), 'fieldType' => array('DATE', 'VARCHAR'), 'params' => $this->params, 'paramsLabels' => array('dateFormat' => UsersModule::t('Date format'))); }
?> <?php echo CHtml::activePasswordField($form, 'password'); ?> <p class="hint"> <?php echo UsersModule::t("Minimal password length 5 symbols."); ?> </p> </div> <div class="row"> <?php echo CHtml::activeLabelEx($form, 'verifyPassword'); ?> <?php echo CHtml::activePasswordField($form, 'verifyPassword'); ?> </div> <div class="row submit"> <?php echo CHtml::submitButton(UsersModule::t("Save")); ?> </div> <?php echo CHtml::endForm(); ?> </div><!-- form -->
<?php $this->pageTitle = Yii::app()->name . ' - ' . UsersModule::t("Profile"); $this->breadcrumbs = array(UsersModule::t("Profile")); $this->menu = array(UsersModule::isAdmin() ? array('label' => UsersModule::t('Manage Users'), 'url' => array('/user/admin')) : array(), array('label' => UsersModule::t('Edit'), 'url' => array('edit')), array('label' => UsersModule::t('Change password'), 'url' => array('changepassword')), array('label' => UsersModule::t('Logout'), 'url' => array('/user/logout'))); ?> <h1><?php echo UsersModule::t('Your profile'); ?> </h1> <?php if (Yii::app()->user->hasFlash('profileMessage')) { ?> <div class="success"> <?php echo Yii::app()->user->getFlash('profileMessage'); ?> </div> <?php } ?> <table class="dataGrid"> <tr> <th class="label"><?php echo CHtml::encode($model->getAttributeLabel('username')); ?> </th> <td><?php echo CHtml::encode($model->username); ?>
echo $form->textField($model, 'username', array('size' => 20, 'maxlength' => 20)); ?> <?php echo $form->error($model, 'username'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'email'); ?> <?php echo $form->textField($model, 'email', array('size' => 60, 'maxlength' => 128)); ?> <?php echo $form->error($model, 'email'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? UsersModule::t('Create') : UsersModule::t('Save')); ?> </div> <?php $this->endWidget(); ?> </div><!-- form -->
<?php $this->pageTitle = Yii::app()->name . ' - ' . UsersModule::t("Login"); ?> <h1><?php echo $title; ?> </h1> <div class="form"> <?php echo $content; ?> </div><!-- yiiForm -->
/** * Returns an array of initial characters from the source. * Source can be a CActiveRecord, or an array of data or data objects. * By default, characters are returned in uppercase; set preserveCase true to * return characters in their original case. * Used in ApPagination * @param mixed string: table name; array: the data or data objects * @param string Attribute name. The attribute can be a relative attribute if * source is a, or an array of, CActiveRecord; e.g. relation.attribute. * If empty, source must be an array; the values of which are used. */ public function activeChars($source, $attribute = '', $preserveCase = false) { if (is_array($source)) { $chars = array(); if ($attribute) { if ($preserveCase) { foreach ($source as $datum) { $chars[] = substr(CHtml::value($datum, $attribute), 0, 1); } } else { foreach ($source as $datum) { $chars[] = strtoupper(substr(CHtml::value($datum, $attribute), 0, 1)); } } } else { if ($preserveCase) { foreach ($source as $datum) { $chars[] = substr($datum, 0, 1); } } else { foreach ($source as $datum) { $chars[] = strtoupper(substr($datum, 0, 1)); } } } return array_unique($chars); } elseif ($source instanceof CActiveRecord) { if (empty($attribute)) { throw new CException(UsersModule::t('core', 'Attribute cannot be empty when using a model')); } $connection = $source->getDbConnection(); if (($pos = strpos($attribute, '.')) !== false) { $name = substr($attribute, 0, $pos); $md = $source->getMetaData(); if (!isset($md->relations[$name])) { throw new CDbException(Yii::t('yii', '{class} does not have relation "{name}".', array('{class}' => get_class($this), '{name}' => $name))); } $source = CActiveRecord::model($md->relations[$name]->className); $attribute = substr($attribute, $pos + 1); } $sql = $preserveCase ? 'SELECT DISTINCT(SUBSTR(' . $connection->quoteColumnName($attribute) . ',1,1)) AS ' . $connection->quoteColumnName('c') . ' FROM ' . $connection->quoteTableName($source->tableName()) : 'SELECT DISTINCT(UPPER(SUBSTR(' . $connection->quoteColumnName($attribute) . ',1,1))) AS ' . $connection->quoteColumnName('c') . ' FROM ' . $connection->quoteTableName($source->tableName()); return Yii::app()->db->createCommand($sql)->queryColumn(); } }
/** * Change password */ public function actionChangepassword() { $model = new UserChangePassword(); if (Yii::app()->user->id) { // ajax validator if (isset($_POST['ajax']) && $_POST['ajax'] === 'changepassword-form') { echo UActiveForm::validate($model); Yii::app()->end(); } if (isset($_POST['UserChangePassword'])) { $model->attributes = $_POST['UserChangePassword']; if ($model->validate()) { $new_password = User::model()->notsafe()->findbyPk(Yii::app()->user->id); $new_password->password = UsersModule::encrypting($model->password); $new_password->activkey = UsersModule::encrypting(microtime() . $model->password); $new_password->save(); Yii::app()->user->setFlash('profileMessage', UsersModule::t("New password is saved.")); $this->redirect(array("profile")); } } $this->render('changepassword', array('model' => $model)); } }
/** * Recovery password */ public function actionRecovery() { // $this->layout = '//layouts/login'; $model = new UserLogin(); $modelRecovery = new UserRecoveryForm(); $this->performAjaxValidation($modelRecovery, 'form-reminder'); if (Yii::app()->user->id) { $this->redirect('/'); } else { $email = Yii::app()->request->getParam('email'); $activkey = Yii::app()->request->getParam('activkey'); $email = !empty($email) ? $email : ''; $activkey = !empty($activkey) ? $activkey : ''; if ($email && $activkey) { $form2 = new UserChangePassword(); $this->performAjaxValidation($form2, 'change_password'); $find = User::model()->notsafe()->findByAttributes(array('email' => $email)); if (isset($find) && $find->activkey == $activkey) { if (isset($_POST['UserChangePassword'])) { $form2->attributes = $_POST['UserChangePassword']; if ($form2->validate()) { $find->password = Yii::app()->getModule('users')->encrypting($form2->password); $find->activkey = Yii::app()->getModule('users')->encrypting(microtime() . $form2->password); if ($find->status == 0) { $find->status = 1; } $find->save(); $message = Yii::t('site', 'New password is saved.'); if (Yii::app()->request->isAjaxRequest) { echo CJSON::encode(array('flag' => true, 'message' => $message)); Yii::app()->end(); } else { Yii::app()->user->setFlash('recoveryMessage', $message); $this->redirect(Yii::app()->getModule('users')->recoveryUrl); } } } $this->render('changepasswordnew', array('model' => $form2)); } else { Yii::app()->user->setFlash('recoveryMessage', UsersModule::t("Incorrect recovery link.")); // $this->redirect(Yii::app()->getModule('users')->recoveryUrl); $this->redirect('/'); } } else { if (isset($_POST['UserRecoveryForm'])) { $modelRecovery->attributes = $_POST['UserRecoveryForm']; if ($modelRecovery->validate()) { $user = User::model()->notsafe()->findbyPk($modelRecovery->user_id); $activation_url = $this->createAbsoluteUrl(implode(Yii::app()->getModule('users')->recoveryUrl) . '?activkey=' . $user->activkey . '&email=' . $user->email); $subject = UsersModule::t("Request for password recovery in {site_name}", array('{site_name}' => Yii::app()->name)); $message = UsersModule::t("You have requested the password recovery for access to {site_name}.<br> To get the password and to set the new one follow the link: {activation_url}", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url)); // UsersModule::sendMail($user->email, $subject, $message); SendMail::send($user->email, $subject, $message, true); $message = Yii::t('site', "Please check your e-mail.<br> Instruction was sent to your e-mail address."); if (Yii::app()->request->isAjaxRequest) { echo CJSON::encode(array('flag' => true, 'message' => $message)); Yii::app()->end(); } else { Yii::app()->user->setFlash('recoveryMessage', $message); $this->refresh(); } } } $this->render('recovery', array('model' => $model, 'modelRecovery' => $modelRecovery)); } } }
/** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array('id' => UsersModule::t("Id"), 'fullname' => UsersModule::t("Name and surname"), 'username' => UsersModule::t("Username"), 'password' => UsersModule::t("Password"), 'verifyPassword' => UsersModule::t("Retype Password"), 'email' => UsersModule::t("E-mail"), 'verifyCode' => UsersModule::t("Verification Code"), 'activkey' => UsersModule::t("activation key"), 'create_at' => UsersModule::t("Registration date"), 'lastvisit_at' => UsersModule::t("Last visit"), 'status' => UsersModule::t("Status")); }