/**
  * 列表页批量删除提交的地方
  */
 public function actionDelall()
 {
     if (Yii::$app->request->isAjax) {
         if (UserLog::deleteAll(['id' => array_filter($_GET['id'])])) {
             echo '1';
         } else {
             echo '0';
         }
     }
 }
Beispiel #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UserLog::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'object_pk' => $this->object_pk, 'created_at' => $this->created_at, 'is_success' => $this->is_success]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'action', $this->action])->andFilterWhere(['like', 'object_class', $this->object_class]);
     return $dataProvider;
 }
 /**
  * function ->delete ()
  */
 public function delete()
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     $model = $this;
     if ($log = new UserLog()) {
         $log->username = $username;
         $log->action = 'Delete';
         $log->object_class = 'ProductCategoryToProduct';
         $log->object_pk = $model->id;
         $log->created_at = $now;
         $log->is_success = 0;
         $log->save();
     }
     if (parent::delete()) {
         if ($log) {
             $log->is_success = 1;
             $log->save();
         }
         return true;
     }
     return false;
 }
Beispiel #4
0
 /**
  * function ->delete ()
  */
 public function delete()
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     $model = $this;
     if ($log = new UserLog()) {
         $log->username = $username;
         $log->action = 'Delete';
         $log->object_class = 'NoreplyEmail';
         $log->object_pk = $model->id;
         $log->created_at = $now;
         $log->is_success = 0;
         $log->save();
     }
     if (parent::delete()) {
         if ($log) {
             $log->is_success = 1;
             $log->save();
         }
         FileUtils::removeFolder(Yii::$app->params['images_folder'] . $model->image_path);
         return true;
     }
     return false;
 }
Beispiel #5
0
 /**
  * Deletes an existing FriendLink model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     if (!$this->is_access('links/delete')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     $model = $this->findModel($id);
     $model->delete();
     \backend\models\UserLog::addData('friend_link', $model->link_id, "删除友情链接[{$model->link_name}]", 'delete');
     return $this->redirect(['index']);
 }
Beispiel #6
0
 /**
  * Finds the UserLog model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UserLog the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UserLog::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #7
0
 /**
  * Deletes an existing Menu model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     if (!$this->is_access('menu/delete')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     $model = $this->findModel($id);
     $model->delete();
     \backend\models\UserLog::addData('menu', $id, "删除菜单[{$model->title}]", 'delete');
     return $this->redirect(['index']);
 }
Beispiel #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUserLogs()
 {
     return $this->hasMany(UserLog::className(), ['username' => 'username']);
 }