public function run($code) { $recovery = RecoveryPassword::model()->with('user')->find('code = :code', array(':code' => $code)); if (!$recovery) { Yii::log(Yii::t('user', 'Код восстановления пароля {code} не найден!', array('{code}' => $code)), CLogger::LEVEL_ERROR, UserModule::$logCategory); Yii::app()->user->setFlash(YFlashMessages::ERROR_MESSAGE, Yii::t('user', 'Код восстановления пароля не найден! Попробуйте еще раз!')); $this->controller->redirect(array('/user/account/recovery')); } // автоматическое восстановление пароля if (Yii::app()->getModule('user')->autoRecoveryPassword) { $newPassword = Registration::model()->generateRandomPassword(); $recovery->user->password = Registration::model()->hashPassword($newPassword, $recovery->user->salt); $transaction = Yii::app()->db->beginTransaction(); try { if ($recovery->user->save() && RecoveryPassword::model()->deleteAll('user_id = :user_id', array(':user_id' => $recovery->user->id))) { $transaction->commit(); $emailBody = $this->controller->renderPartial('application.modules.user.views.email.passwordAutoRecoverySuccessEmail', array('model' => $recovery->user, 'password' => $newPassword), true); Yii::app()->mail->send(Yii::app()->getModule('user')->notifyEmailFrom, $recovery->user->email, Yii::t('user', 'Успешное восстановление пароля!'), $emailBody); Yii::app()->user->setFlash(YFlashMessages::NOTICE_MESSAGE, Yii::t('user', 'Новый пароль отправлен Вам на email!')); Yii::log(Yii::t('user', 'Успешное восстановление пароля!'), CLogger::LEVEL_ERROR, UserModule::$logCategory); $this->controller->redirect(array('/user/account/login')); } } catch (CDbException $e) { $transaction->rollback(); Yii::app()->user->setFlash(YFlashMessages::ERROR_MESSAGE, Yii::t('user', 'Ошибка при смене пароля!')); Yii::log(Yii::t('user', 'Ошибка при автоматической смене пароля {error}!', array('{error}' => $e->getMessage())), CLogger::LEVEL_ERROR, UserModule::$logCategory); $this->controller->redirect(array('/user/account/recovery')); } } // выбор своего пароля $changePasswordForm = new ChangePasswordForm(); // если отправили фому с новым паролем if (Yii::app()->request->isPostRequest && isset($_POST['ChangePasswordForm'])) { $changePasswordForm->setAttributes($_POST['ChangePasswordForm']); if ($changePasswordForm->validate()) { $transaction = Yii::app()->db->beginTransaction(); try { // смена пароля пользователя $recovery->user->password = Registration::model()->hashPassword($changePasswordForm->password, $recovery->user->salt); // удалить все запросы на восстановление для данного пользователя if ($recovery->user->save() && RecoveryPassword::model()->deleteAll('user_id = :user_id', array(':user_id' => $recovery->user->id))) { $transaction->commit(); Yii::app()->user->setFlash(YFlashMessages::NOTICE_MESSAGE, Yii::t('user', 'Пароль изменен!')); Yii::log(Yii::t('user', 'Успешная смена пароля для пользоателя {user}!', array('{user}' => $recovery->user->id)), CLogger::LEVEL_INFO, UserModule::$logCategory); $emailBody = $this->controller->renderPartial('application.modules.user.views.email.passwordRecoverySuccessEmail', array('model' => $recovery->user), true); Yii::app()->mail->send(Yii::app()->getModule('user')->notifyEmailFrom, $recovery->user->email, Yii::t('user', 'Успешное восстановление пароля!'), $emailBody); $this->controller->redirect(array('/user/account/login')); } } catch (CDbException $e) { $transaction->rollback(); Yii::app()->user->setFlash(YFlashMessages::ERROR_MESSAGE, Yii::t('user', 'Ошибка при смене пароля!')); Yii::log(Yii::t('Ошибка при смене пароля {error}!', array('{error}' => $e->getMessage())), CLogger::LEVEL_ERROR, UserModule::$logCategory); $this->controller->redirect(array('/user/account/recovery')); } } } $this->controller->render('changePassword', array('model' => $changePasswordForm)); }
public function actionCompetitors() { $registrations = Registration::model()->with('user')->findAllByAttributes(array('competition_id' => $this->iGet('id'), 'status' => Registration::STATUS_ACCEPTED), array('order' => 'date ASC')); $names = array(); foreach ($registrations as $registration) { $names[] = $registration->user->getAttributeValue('name', true); } $this->ajaxOK($names); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = Registration::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new User(); if (Yii::app()->request->isPostRequest && !empty($_POST['User'])) { $model->setAttributes($_POST['User']); $model->setAttributes(array('salt' => Registration::model()->generateSalt(), 'password' => Registration::model()->hashPassword($model->password, $model->salt), 'registration_ip' => Yii::app()->request->userHostAddress)); if ($model->save()) { Yii::app()->user->setFlash(YFlashMessages::NOTICE_MESSAGE, Yii::t('user', 'Новый пользователь добавлен!')); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function run($code) { $code = trim($code); // пытаемся сделать выборку из таблицы регистраций $registration = Registration::model()->find('code = :code', array(':code' => $code)); if (is_null($registration)) { Yii::app()->user->setFlash(YFlashMessages::ERROR_MESSAGE, Yii::t('user', 'Ошибка активации! Возможно данный аккаунт уже активирован! Попробуете зарегистрироваться вновь?')); $this->controller->redirect(array(Yii::app()->getModule('user')->accountActivationFailure)); } // процедура активации // проверить параметры пользователя по "черным спискам" if (!Yii::app()->getModule('user')->isAllowedIp(Yii::app()->request->userHostAddress)) { // перенаправить на экшн для фиксации невалидных ip адресов $this->controller->redirect(array(Yii::app()->getModule('user')->invalidIpAction)); } // проверить на email if (!Yii::app()->getModule('user')->isAllowedEmail($registration->email)) { // перенаправить на экшн для фиксации невалидных ip адресов $this->controller->redirect(array(Yii::app()->getModule('user')->invalidEmailAction)); } // все проверки прошли - активируем аккаунт $transaction = Yii::app()->db->beginTransaction(); try { // создать запись в таблице пользователей и удалить запись в таблице регистраций $user = new User(); $user->setAttributes($registration->getAttributes()); if ($registration->delete() && $user->save()) { $transaction->commit(); Yii::log(Yii::t('user', "Активирован аккаунт с code = {code}!", array('{code}' => $code)), CLogger::LEVEL_INFO, UserModule::$logCategory); Yii::app()->user->setFlash(YFlashMessages::NOTICE_MESSAGE, Yii::t('user', 'Вы успешно активировали аккаунт! Теперь Вы можете войти!')); // отправить сообщение о активации аккаунта $emailBody = $this->controller->renderPartial('application.modules.user.views.email.accountActivatedEmail', array('model' => $user), true); Yii::app()->mail->send(Yii::app()->getModule('user')->notifyEmailFrom, $user->email, Yii::t('user', 'Аккаунт активирован!'), $emailBody); $this->controller->redirect(array(Yii::app()->getModule('user')->accountActivationSuccess)); } throw new CDbException(Yii::t('user', 'При активации аккаунта произошла ошибка!')); } catch (CDbException $e) { $transaction->rollback(); Yii::app()->user->setFlash(YFlashMessages::ERROR_MESSAGE, Yii::t('user', 'При активации аккаунта произошла ошибка! Попробуйте позже!')); Yii::log(Yii::t('user', "При активации аккаунта c code => {code} произошла ошибка {error}!", array('{code}' => $code, '{error}' => $e->getMessage())), CLogger::LEVEL_ERROR, UserModule::$logCategory); $this->controller->redirect(array(Yii::app()->getModule('user')->accountActivationFailure)); } }
public function actionStatistics() { $totalUser = User::model()->countByAttributes(array('status' => User::STATUS_NORMAL)); $advancedUser = User::model()->countByAttributes(array('status' => User::STATUS_NORMAL, 'role' => array(User::ROLE_DELEGATE, User::ROLE_ORGANIZER, User::ROLE_ADMINISTRATOR))); $uncheckedUser = User::model()->countByAttributes(array('status' => User::STATUS_NORMAL, 'role' => array(User::ROLE_UNCHECKED))); $userPerDay = round($totalUser / ceil((time() - strtotime('2014-06-06')) / 86400), 2); $totalRegistration = Registration::model()->with('user')->count('user.status=' . User::STATUS_NORMAL); $acceptedRegistration = Registration::model()->with('user')->countByAttributes(array('status' => Registration::STATUS_ACCEPTED), 'user.status=' . User::STATUS_NORMAL); $dailyUser = User::getDailyUser(); $dailyRegistration = Registration::getDailyRegistration(); $dailyData = $this->mergeDailyData($dailyUser, $dailyRegistration); $hourlyUser = User::getHourlyUser(); $hourlyRegistration = Registration::getHourlyRegistration(); $hourlyData = $this->mergeHourlyData($hourlyUser, $hourlyRegistration); $userRegion = User::getUserRegion(); $userGender = User::getUserGender(); $userAge = User::getUserAge(); $userWca = User::getUserWca(); $this->render('statistics', array('totalUser' => $totalUser, 'advancedUser' => $advancedUser, 'uncheckedUser' => $uncheckedUser, 'userPerDay' => $userPerDay, 'totalRegistration' => $totalRegistration, 'acceptedRegistration' => $acceptedRegistration, 'dailyData' => $dailyData, 'hourlyData' => $hourlyData, 'userRegion' => $userRegion, 'userGender' => $userGender, 'userAge' => $userAge, 'userWca' => $userWca)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Vacate(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Vacate'])) { $allot = Allotment::model()->findByAttributes(array('room_no' => $_POST['Vacate']['room_no'], 'status' => 'S')); $reg = Registration::model()->DeleteAllByAttributes(array('student_id' => $allot->student_id)); $mess = MessFee::model()->DeleteAllByAttributes(array('student_id' => $allot->student_id)); $model->attributes = $_POST['Vacate']; $model->allot_id = $allot->id; $allot->status = 'C'; $allot->student_id = NULL; $allot->created = NULL; $allot->save(); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
<table border="0" width="980"> <?php echo $form->errorSummary($model); ?> <tr><td width="40%"> <?php echo $form->labelEx($model, 'company_name'); ?> </td> <td width="60%"> <?php echo $form->dropDownList($model, 'company_name', CHtml::listData(Registration::model()->findAll('1 ORDER BY company_name'), 'company_id', 'company_name'), array('prompt' => 'Please Choose', 'name' => 'General_company_name', 'id' => 'General_company_name')); ?> </td></tr> <tr><td> <?php echo $form->labelEx($model, 'year'); ?> </td> <td> <?php echo $form->dropDownList($model, 'year', CHtml::listData(Year::model()->findAll(), 'year', 'year'), array('name' => 'year', 'prompt' => 'Please Choose')); ?> <?php echo $form->error($model, 'year'); ?> </td>
public function uniqueEmail($attribute, $params) { if ($user = Registration::model()->exists('email=:email', array('email' => $this->email))) { $this->addError($attribute, 'Email already exists!'); } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Registration the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Registration::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function isRegistrationFull() { return $this->person_num > 0 && Registration::model()->with(array('user' => array('condition' => 'user.status=' . User::STATUS_NORMAL)))->countByAttributes(array('competition_id' => $this->id, 'status' => Registration::STATUS_ACCEPTED)) >= $this->person_num; }
public function actionCompanyIds() { if ($_POST['General']['company_name']) { $company_name = $_POST['General']['company_name']; } $data = Registration::model()->findByAttributes(array('company_name' => $company_name)); //print_r($data); echo "<td><b>Company ID</b></td>"; echo "<td>"; //echo CHtml::tag('input', array( 'type'=>'text' , 'value' => $data->company_id)); echo CHtml::textField("General[company_id]", $data->company_id, array('readonly' => 'readonly', 'id' => 'General_company_id')); echo "</td>"; }
public function changePassword($password) { $this->password = Registration::model()->hashPassword($password, $this->salt); return $this->update(array('password')); }
public function actionCreateOrg() { $reg_details = Registration::model()->count(); if ($reg_details == 0) { $this->redirect(array('registration/create')); } $this->layout = 'select_company_main'; $model = new Organization(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['Organization']['organization_name']) && !empty($_POST['Organization']['address_line1']) && !empty($_POST['Organization']['city']) && !empty($_POST['Organization']['state']) && !empty($_POST['Organization']['country']) && !empty($_POST['Organization']['pin']) && !empty($_POST['Organization']['phone']) && !empty($_POST['Organization']['no_of_semester']) && !empty($_POST['Organization']['email'])) { $country_model = new Country(); $country_model->name = $_POST['Organization']['country']; $country_model->save(); $state_model = new State(); $state_model->state_name = $_POST['Organization']['state']; $state_model->country_id = $country_model->id; $state_model->save(); $city_model = new City(); $city_model->city_name = $_POST['Organization']['city']; $city_model->country_id = $country_model->id; $city_model->state_id = $state_model->state_id; $city_model->save(); $model->attributes = $_POST['Organization']; $model->organization_created_by = 1; $model->organization_creation_date = new CDbExpression('NOW()'); if (!empty($_FILES['Organization']['tmp_name']['logo'])) { $file = CUploadedFile::getInstance($model, 'logo'); //$model->filename = $file->name; $model->file_type = $file->type; $fp = fopen($file->tempName, 'r'); $content = fread($fp, filesize($file->tempName)); fclose($fp); $model->logo = $content; } $model->city = $city_model->city_id; $model->state = $state_model->state_id; $model->country = $country_model->id; if ($model->save(false)) { $this->redirect(array('site/redirectLogin')); } } $this->render('create_org', array('model' => $model)); }
public function actionToggle() { $id = $this->iRequest('id'); $model = Registration::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'Not found'); } if ($this->user->isOrganizer() && $model->competition && !isset($model->competition->organizers[$this->user->id])) { throw new CHttpException(401, 'Unauthorized'); } $attribute = $this->sRequest('attribute'); $model->{$attribute} = 1 - $model->{$attribute}; if ($model->isAccepted()) { $model->total_fee = $model->getTotalFee(true); } $model->save(); $this->ajaxOk(array('value' => $model->{$attribute})); }
<td width="247" valign="top"> <?php $this->renderPartial('/settings/hostel_left'); ?> </td> <td valign="top"> <div class="cont_right"> <h1><?php echo Yii::t('hostel', 'Student Details'); ?> </h1> <?php $allot = Allotment::model()->findByAttributes(array('student_id' => $studentid, 'status' => 'S')); if ($allot != NULL) { $stud = Students::model()->findByAttributes(array('id' => $allot->student_id)); $register = Registration::model()->findByAttributes(array('student_id' => $allot->student_id)); $food = FoodInfo::model()->findByAttributes(array('id' => $register->food_preference)); $mess = MessFee::model()->findByAttributes(array('student_id' => $allot->student_id)); $floor = Floor::model()->findByAttributes(array('id' => $allot->floor)); $hostel = Hosteldetails::model()->findByAttributes(array('id' => $floor->hostel_id)); ?> <div class="pdtab_Con" style="padding:0px;"> <table width="100%" cellpadding="0" cellspacing="0" border="0" > <tr class="pdtab-h"> <td align="center"><?php echo Yii::t('hostel', 'Student Name'); ?> </td> <td align="center"><?php echo Yii::t('hostel', 'Hostel'); ?>
<div class="cont_right"> <div class="yellow_bx" style="background-image:none;width:90%;padding-bottom:45px;"> <div class="y_bx_head" style="width:90%"> <h1><?php echo Yii::t('hostel', 'Notifications'); ?> </h1> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <?php $request = Roomrequest::model()->findAll('status=:x order by created_at DESC limit 1', array(':x' => 'C')); if ($request != NULL) { $i = 1; foreach ($request as $request_1) { echo '<tr>'; $student = Students::model()->findByAttributes(array('id' => $request_1->student_id)); $reg = Registration::model()->findByAttributes(array('student_id' => $request_1->student_id)); if ($request_1->allot_id != NULL) { $allot = Allotment::model()->findByAttributes(array('id' => $request_1->allot_id)); if ($student != NULL) { echo '<td align="center">' . $i . '</td>'; echo '<td align="center"><strong>' . ucfirst($student->last_name . ' ' . $student->first_name) . '</td>'; echo '<td align="center">' . $i . '</td>'; echo '<td align="center">' . $i . '</td>'; echo $i . ' <strong>' . ucfirst($student->first_name . ' ' . $student->last_name) . ' has been requested for changing room to' . ' ' . $allot->room_no . ' ' . $allot->bed_no . ' ' . '</strong>[ ' . CHtml::link(Yii::t('hostel', 'Allot'), array('/hostel/allotment/create', 'studentid' => $request_1->student_id, 'allotid' => $request_1->allot_id)) . ' ]<br>'; $i++; } } else { if ($request_1->allot_id == NULL) { $i = 1; if ($student != NULL) { echo $i . ' <strong>' . ucfirst($student->first_name . ' ' . $student->last_name) . ' has been applied for hostel facility</strong> ' . CHtml::link(Yii::t('hostel', 'Register'), array('/hostel/registration/update', 'studentid' => $request_1->student_id, 'id' => $reg->id));
public function actionCreateuser() { $this->stepName = Yii::t('install', 'Шаг 4 из 6 : "Создание учетной записи администратора"'); $model = new CreateUserForm(); if (Yii::app()->request->isPostRequest && isset($_POST['CreateUserForm'])) { $model->setAttributes($_POST['CreateUserForm']); if ($model->validate()) { $user = new User(); $salt = Registration::model()->generateSalt(); $user->setAttributes(array('nick_name' => $model->userName, 'email' => $model->email, 'salt' => $salt, 'password' => Registration::model()->hashPassword($model->password, $salt), 'registration_date' => new CDbExpression('NOW()'), 'registration_ip' => Yii::app()->request->userHostAddress, 'access_level' => User::ACCESS_LEVEL_ADMIN)); if ($user->save()) { Yii::app()->user->setFlash(YFlashMessages::NOTICE_MESSAGE, Yii::t('install', 'Администратор успешно создан!')); if (!@touch($this->alreadyInstalledFlag)) { Yii::app()->user->setFlash(YFlashMessages::WARNING_MESSAGE, Yii::t('install', "Не удалось создать файл {file}, для избежания повторной установки, пожалуйста, создайте его самостоятельно или отключите модуль 'Install' сразу после установки!", array('{file}' => $this->alreadyInstalledFlag))); } $this->redirect(array('/install/default/sitesettings/')); } //@TODO добавить вывод сообщений об ошибке сохранения } } $this->render('createuser', array('model' => $model)); }
foreach ($roles as $role) { if (sizeof($roles) == 1 and $role->name == 'student') { ?> <div id="parent_Sect"> <?php $this->renderPartial('/settings/studentleft'); ?> <div id="parent_rightSect"> <div class="parentright_innercon"> <h1>Hostel Details</h1> <div class="profile_details" style="position:relative;"> <?php $student = Students::model()->findByAttributes(array('uid' => Yii::app()->user->id)); $register = Registration::model()->findByAttributes(array('student_id' => $student->id, 'status' => 'S')); if ($register != NULL) { $foodinfo = FoodInfo::model()->findByAttributes(array('id' => $register->food_preference)); $mess = MessFee::model()->findByAttributes(array('student_id' => $student->id)); ?> <div class="but_right_con" style=" position:absolute; top:13px; right:-70px;"><?php echo CHtml::link(Yii::t('hostel', 'Change Room'), array('/hostel/room/change', 'id' => $student->id), array('class' => 'com_but')); ?> </div> <div class="emp_tabwrapper"> <?php if (!isset($_REQUEST['id']) || $_REQUEST['id'] === '1') {
$this->renderPartial('/settings/hostel_left'); ?> </td> <td valign="top"> <div class="cont_right"> <h1><?php echo Yii::t('hostel', 'Mess Manage'); ?> </h1> <div class="formCon" > <div class="formConInner"> <?php $student_id = $_REQUEST['id']; $stud = Students::model()->findByAttributes(array('id' => $_REQUEST['id'])); $name = $stud->last_name . ' ' . $stud->first_name; $register = Registration::model()->findByAttributes(array('student_id' => $_REQUEST['id'])); $rid = $register->id; $food = $register->food_preference; $foodinfo = FoodInfo::model()->findByAttributes(array('id' => $food)); $food_preference = $foodinfo->food_preference; ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td ><?php echo '<td><strong>' . CHtml::label(Yii::t('hostel', 'Name')) . '</strong></td><td>'; ?> </td> <td> </td> <td width="82%" ><input type="text" name="name" value="<?php echo $name; ?>