/** * After validate event * @return object */ public function afterValidate() { if (count($this->ids)) { $save = array(); // The values we would like to check if they were changed // key = value from this model // value = value from the tickets model $valuesChanged = array('status' => 'ticketstatus', 'type' => 'tickettype', 'category' => 'ticketcategory', 'priority' => 'priority', 'version' => 'ticketversion', 'fixedin' => 'fixedin', 'assignedtoid' => 'assignedtoid'); // Loop the values foreach ($valuesChanged as $key => $value) { if ($this->{$key}) { $save[$value] = $this->{$key}; } } // Only update if we have any if (count($save)) { // Update all the ticket ids Tickets::model()->updateByPk($this->ids, $save); // Load one ticket model $model = Tickets::model()->findByPk(reset($this->ids)); $this->activity['projectid'] = $model->projectid; $this->activity['type'] = Activity::TYPE_TICKET; $this->activity['title'] = 'Used multi-Moderation to update <strong>{n}</strong> {title}.'; // Append project params $this->activity['params'] = array_merge($this->activity['params'], array('{n}' => count($this->ids), '{title}' => CHtml::link(Yii::t('tickets', 'Tickets'), array('/tickets')))); // Activity: New Project Activity::log($this->activity); } } return parent::afterValidate(); }
public function run() { $model = BaseFormModel::newModel('LoginForm'); Yii::app()->user->setReturnUrl(Yii::app()->request->url); if (Yii::app()->user->hasFlash('user_login_error')) { $this->widget('AlertWidget', array('title' => 'Авторизация не удалась', 'type' => 'error', 'message' => Yii::app()->user->getFlash('user_login_error'))); } $this->render($this->view, array('model' => $model)); }
public function actionRecover() { $model = BaseFormModel::newModel('RecoverForm'); $modelClass = get_class($model); $this->performAjaxValidation($model, 'recover-form'); if (isset($_POST[$modelClass])) { $model->attributes = $_POST[$modelClass]; if ($model->validate()) { $model->onRecover = array($this, 'sendRecoverMessage'); $model->recover(); Yii::app()->user->setFlash('recoverSuccess', 'Новый пароль от вашего аккаунта отправлен вам на e-mail.'); $this->refresh(); } } $this->render('/recover', array('model' => $model)); }
public function run() { $model = BaseFormModel::newModel('LoginForm'); $modelClass = get_class($model); $ajaxId = isset($_POST['login-widget-form']) ? 'login-widget-form' : 'login-form'; if (isset($_POST['ajax']) && $_POST['ajax'] === $ajaxId) { echo CActiveForm::validate($model); Yii::app()->end(); } if (isset($_POST[$modelClass])) { $model->attributes = $_POST[$modelClass]; if ($model->validate() && $model->login()) { Yii::log('Успешная авторизация под логином ' . $model->username, CLogger::LEVEL_INFO, 'application.login.success'); unset(Yii::app()->request->cookies['login_attempt']); $this->controller->redirect(Yii::app()->user->returnUrl); } else { Yii::log('Ошибка авторизации (логин=' . $model->username . ')', CLogger::LEVEL_INFO, 'application.login.error'); Yii::app()->user->setFlash('user_login_error', CHtml::errorSummary($model, ' ')); if (isset(Yii::app()->request->cookies['login_attempt'])) { $cookie = Yii::app()->request->cookies['login_attempt']; $cookie->value += 1; } else { $cookie = new CHttpCookie('login_attempt', 1); $cookie->expire = time() * 60; } Yii::app()->request->cookies['login_attempt'] = $cookie; } } $view = '/login'; if (Yii::app()->isBackend) { $view = 'backend.views.auth'; } if ($view != null) { $this->controller->render($view, array('model' => $model)); } else { $this->controller->redirect(Yii::app()->user->returnUrl); } }