当前位置: 首页>>代码示例>>PHP>>正文


PHP Registration::model方法代码示例

本文整理汇总了PHP中Registration::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Registration::model方法的具体用法?PHP Registration::model怎么用?PHP Registration::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Registration的用法示例。


在下文中一共展示了Registration::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 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));
 }
开发者ID:RSol,项目名称:yupe,代码行数:58,代码来源:RecoveryPasswordAction.php

示例2: actionCompetitors

 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);
 }
开发者ID:sunshy360,项目名称:cubingchina,代码行数:9,代码来源:ToolsController.php

示例3: loadModel

 /**
  * 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;
 }
开发者ID:RSol,项目名称:yupe,代码行数:16,代码来源:RegistrationController.php

示例4: actionCreate

 /**
  * 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));
 }
开发者ID:RSol,项目名称:yupe,代码行数:17,代码来源:DefaultController.php

示例5: run

 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));
     }
 }
开发者ID:RSol,项目名称:yupe,代码行数:43,代码来源:ActivateAction.php

示例6: actionStatistics

 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));
 }
开发者ID:sunshy360,项目名称:cubingchina,代码行数:20,代码来源:UserController.php

示例7: actionCreate

 /**
  * 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));
 }
开发者ID:akilraj1255,项目名称:rajeshwari,代码行数:25,代码来源:VacateController.php

示例8: array

        <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>
开发者ID:TheTypoMaster,项目名称:myapps,代码行数:30,代码来源:select_general.php

示例9: uniqueEmail

 public function uniqueEmail($attribute, $params)
 {
     if ($user = Registration::model()->exists('email=:email', array('email' => $this->email))) {
         $this->addError($attribute, 'Email already exists!');
     }
 }
开发者ID:KaranSofat,项目名称:yii,代码行数:6,代码来源:Registration.php

示例10: loadModel

 /**
  * 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;
 }
开发者ID:TheTypoMaster,项目名称:myapps,代码行数:15,代码来源:RegistrationController.php

示例11: isRegistrationFull

 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;
 }
开发者ID:sunshy360,项目名称:cubingchina,代码行数:4,代码来源:Competition.php

示例12: actionCompanyIds

 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>";
 }
开发者ID:TheTypoMaster,项目名称:myapps,代码行数:13,代码来源:GeneralController.php

示例13: changePassword

 public function changePassword($password)
 {
     $this->password = Registration::model()->hashPassword($password, $this->salt);
     return $this->update(array('password'));
 }
开发者ID:RSol,项目名称:yupe,代码行数:5,代码来源:User.php

示例14: actionCreateOrg

 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));
 }
开发者ID:sharmarakesh,项目名称:edusec-college-management-system,代码行数:44,代码来源:SiteController.php

示例15: actionToggle

 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}));
 }
开发者ID:sunshy360,项目名称:cubingchina,代码行数:18,代码来源:RegistrationController.php


注:本文中的Registration::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。