Esempio n. 1
0
 static function add($role, $action, $result = false, $note = '')
 {
     $log = new Log();
     $log->role = $role . (Yii::$app->user->identity ? ' -' . Yii::$app->user->identity->username : '');
     $log->action = $action;
     $log->result = $result ? $result : '成功';
     $log->note = $note ? $note : '';
     $log->save();
 }
Esempio n. 2
0
 /**
  * Creates a new Log model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Log();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 3
0
 public function emailSend($user, $description = null)
 {
     if (($id = yii::$app->UserComponent->idFromUsername($user)) === false) {
         throw new \yii\web\HttpException(500, sprintf('User not found %s', $user));
     }
     $logModel = new Log();
     $logModel->user_id = $id;
     $logModel->sys_event_id = Types::$systemEvent['email_send']['id'];
     $logModel->description = $description;
     $logModel->save();
 }