From 393e1adc4a83afc2d650701d38a6bee5503d9189 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 7 Nov 2017 15:07:30 +0200 Subject: [PATCH] -Comments fixed --- controllers/ManageController.php | 2 ++ models/CommentModel.php | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/controllers/ManageController.php b/controllers/ManageController.php index 5001066..1ec5aa3 100755 --- a/controllers/ManageController.php +++ b/controllers/ManageController.php @@ -90,6 +90,8 @@ $model = $this->findModel($id); $answer = new CommentModel(); + + $answer->detachBehavior('blameable'); if ($answer->load(Yii::$app->request->post()) && $answer->save()) { Yii::$app->session->setFlash( diff --git a/models/CommentModel.php b/models/CommentModel.php index 0fc5182..c61e9b7 100755 --- a/models/CommentModel.php +++ b/models/CommentModel.php @@ -109,6 +109,7 @@ ], [ [ + 'user_id', 'entity_id', 'artbox_comment_pid', ], @@ -134,7 +135,7 @@ [ 'class' => TimestampBehavior::className(), ], - [ + 'blameable' => [ 'class' => BlameableBehavior::className(), 'createdByAttribute' => 'user_id', 'updatedByAttribute' => false, @@ -144,7 +145,7 @@ 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => 'ip', ], - 'value' => function($event) { + 'value' => function ($event) { return \Yii::$app->request->userIP; }, ], @@ -202,7 +203,7 @@ 'entity' => $entity, 'entity_id' => $entityId, 'status' => 1, - 'artbox_comment_pid' => NULL, + 'artbox_comment_pid' => null, ] ), 'pagination' => [ @@ -219,7 +220,7 @@ public function deleteComment(): bool { - if (\Yii::$app->user->id != NULL && \Yii::$app->user->id == $this->user_id) { + if (\Yii::$app->user->id != null && \Yii::$app->user->id == $this->user_id) { if ($this->delete()) { return true; } @@ -262,7 +263,7 @@ ->andWhere( [ 'or', - [ 'artbox_comment_rating.model' => NULL ], + [ 'artbox_comment_rating.model' => null ], [ 'artbox_comment_rating.model' => self::className() ], ] ); @@ -297,7 +298,7 @@ ] ), [ - 'target' => '_blank', + 'target' => '_blank', 'data-pjax' => '0', ] ); -- libgit2 0.21.4