public function actionActivation($key) { $record = Activations::model()->findByAttributes(array('key' => $key)); if ($record === null) { throw new CHttpException(412, Yii::t('page', 'Wrong activation key')); } if (Yii::app()->user->id != $record->user_id && $record->type != 'password_recovery') { $this->render('wrong_user'); return; } if ($record->type === 'registration') { Users::model()->updateByPk($record->user_id, array('status' => 'active')); $record->delete(); $this->redirect(array('login', 'login_type' => 'activation')); } elseif ($record->type === 'change_email') { Users::model()->updateByPk($record->user_id, array('email' => $record->add_data)); $record->delete(); $this->redirect(array('email_changed')); } elseif ($record->type == 'password_recovery') { $user = Users::model()->findByPk($record->user_id); $model = new LostForm(); $model->email = $user->email; if ($model->validate() && $model->sendPassword()) { $this->layout = '//layouts/login'; $this->render('pass_success_send'); } } elseif ($record->type == 'manager_registration') { $password = substr(preg_replace('/[oO0Il1]/i', '', md5(rand() . rand() . rand() . time())), 0, 8); Users::model()->updateByPk($record->user_id, array('status' => 'active', 'password' => md5($password))); $user_inf = Users::model()->findByPk($record->user_id); $email = Yii::app()->email; $email->AddAddress($user_inf->email); $email->Subject = 'Регистрация'; $email->Body = 'Поздравляем, ' . $user_inf->first_name . '! <br/> Доступ на сайт - ' . 'http://' . $_SERVER['HTTP_HOST'] . '/page/login' . ' <br/> Ваш логин - ' . $user_inf->email . ' <br/> Ваш пароль - ' . $password . ' <br/> С уважением, Администрация INCLIENT.RU<br/> <br/> Если у вас возникнут вопросы напишите в поддержку <br/> support@inclient.ru'; $email->send(); $record->delete(); $this->redirect(array('login', 'login_type' => 'activation')); } }