/**
  * Finds the ActionLog model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return ActionLog the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ActionLog::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function search($params)
 {
     $query = ActionLog::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['time' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'time', $this->time])->andFilterWhere(['like', 'user_remote', $this->user_remote])->andFilterWhere(['like', 'action', $this->action])->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'message', $this->status])->andFilterWhere(['like', 'message', $this->message]);
     return $dataProvider;
 }
 public function afterFind($event)
 {
     ActionLog::add(ActionLog::LOG_STATUS_INFO, $this->message !== null ? $this->message : __METHOD__);
 }
 /**
  * The register action
  */
 public function actionSignup()
 {
     $model = Yii::$app->getModule('accounts')->getModel('user', true, ['scenario' => 'signup']);
     if (Yii::$app->request->isAjax) {
         if ($model->load(Yii::$app->request->post())) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
         return false;
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->setSignupUserConfig() && $model->save()) {
             $logInfo = ['info' => $model->username . ' has successfully registered.', 'username' => $model->username, 'email' => $model->email, 'role' => $model->role, 'status' => $model->status];
             if (Yii::$app->getModule('accounts')->enableEmailSignupActivation) {
                 $email = Yii::$app->mail->compose(Yii::$app->getModule('accounts')->emailViewsPath . 'signupActivation', ['user' => $model])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])->setTo($model->email)->setSubject(Yii::t('accounts', 'Account activation for {appname}', ['appname' => Yii::$app->name]))->send();
                 $logInfo['email_activation'] = ['auth_key' => $model->auth_key, 'send_from' => Yii::$app->params['supportEmail'], 'send_to' => $model->email];
                 if ($email) {
                     $logInfo['email_activation']['send_status'] = 'success';
                     Yii::$app->session->setFlash('success-signup-email', Yii::t('accounts', 'Registration was successful. Please check your email inbox for further action to account activation.'));
                 } else {
                     $logInfo['email_activation']['send_status'] = 'error';
                     Yii::$app->session->setFlash('error-signup-email', Yii::t('accounts', 'Registration was successful, but the activation email could not be sent. Please contact us if you think this is a server error. Thank you.'));
                 }
                 $this->goLogin(['/site/index']);
             } else {
                 $logInfo['email_activation'] = 'disabled';
                 if (Yii::$app->getUser()->login($model)) {
                     $logInfo['auto_login'] = '******';
                     Yii::$app->session->setFlash('success-signup', Yii::t('accounts', 'Registration was successful.'));
                     return $this->redirect(['profile', 'u' => $model->username]);
                 } else {
                     $logInfo['auto_login'] = '******';
                     Yii::$app->session->setFlash('error-signup', Yii::t('accounts', 'Registration failed. Please contact us if you think this is a server error. Thank you.'));
                     return $this->goLogin(['/site/index']);
                 }
             }
             ActionLog::add(ActionLog::LOG_STATUS_INFO, $logInfo, $model->id);
         } else {
             ActionLog::add(ActionLog::LOG_STATUS_ERROR, ['username' => $this->username, 'email' => $this->email, 'errors' => $user->errors]);
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Example #5
0
 /**
  * @inheritdoc
  */
 protected function afterLogin($identity)
 {
     ActionLog::add(ActionLog::LOG_STATUS_INFO, null, $identity->id);
 }