Commit 393e1adc4a83afc2d650701d38a6bee5503d9189
1 parent
3c21f570
-Comments fixed
Showing
2 changed files
with
9 additions
and
6 deletions
Show diff stats
controllers/ManageController.php
@@ -90,6 +90,8 @@ | @@ -90,6 +90,8 @@ | ||
90 | $model = $this->findModel($id); | 90 | $model = $this->findModel($id); |
91 | 91 | ||
92 | $answer = new CommentModel(); | 92 | $answer = new CommentModel(); |
93 | + | ||
94 | + $answer->detachBehavior('blameable'); | ||
93 | 95 | ||
94 | if ($answer->load(Yii::$app->request->post()) && $answer->save()) { | 96 | if ($answer->load(Yii::$app->request->post()) && $answer->save()) { |
95 | Yii::$app->session->setFlash( | 97 | Yii::$app->session->setFlash( |
models/CommentModel.php
@@ -109,6 +109,7 @@ | @@ -109,6 +109,7 @@ | ||
109 | ], | 109 | ], |
110 | [ | 110 | [ |
111 | [ | 111 | [ |
112 | + 'user_id', | ||
112 | 'entity_id', | 113 | 'entity_id', |
113 | 'artbox_comment_pid', | 114 | 'artbox_comment_pid', |
114 | ], | 115 | ], |
@@ -134,7 +135,7 @@ | @@ -134,7 +135,7 @@ | ||
134 | [ | 135 | [ |
135 | 'class' => TimestampBehavior::className(), | 136 | 'class' => TimestampBehavior::className(), |
136 | ], | 137 | ], |
137 | - [ | 138 | + 'blameable' => [ |
138 | 'class' => BlameableBehavior::className(), | 139 | 'class' => BlameableBehavior::className(), |
139 | 'createdByAttribute' => 'user_id', | 140 | 'createdByAttribute' => 'user_id', |
140 | 'updatedByAttribute' => false, | 141 | 'updatedByAttribute' => false, |
@@ -144,7 +145,7 @@ | @@ -144,7 +145,7 @@ | ||
144 | 'attributes' => [ | 145 | 'attributes' => [ |
145 | ActiveRecord::EVENT_BEFORE_INSERT => 'ip', | 146 | ActiveRecord::EVENT_BEFORE_INSERT => 'ip', |
146 | ], | 147 | ], |
147 | - 'value' => function($event) { | 148 | + 'value' => function ($event) { |
148 | return \Yii::$app->request->userIP; | 149 | return \Yii::$app->request->userIP; |
149 | }, | 150 | }, |
150 | ], | 151 | ], |
@@ -202,7 +203,7 @@ | @@ -202,7 +203,7 @@ | ||
202 | 'entity' => $entity, | 203 | 'entity' => $entity, |
203 | 'entity_id' => $entityId, | 204 | 'entity_id' => $entityId, |
204 | 'status' => 1, | 205 | 'status' => 1, |
205 | - 'artbox_comment_pid' => NULL, | 206 | + 'artbox_comment_pid' => null, |
206 | ] | 207 | ] |
207 | ), | 208 | ), |
208 | 'pagination' => [ | 209 | 'pagination' => [ |
@@ -219,7 +220,7 @@ | @@ -219,7 +220,7 @@ | ||
219 | 220 | ||
220 | public function deleteComment(): bool | 221 | public function deleteComment(): bool |
221 | { | 222 | { |
222 | - if (\Yii::$app->user->id != NULL && \Yii::$app->user->id == $this->user_id) { | 223 | + if (\Yii::$app->user->id != null && \Yii::$app->user->id == $this->user_id) { |
223 | if ($this->delete()) { | 224 | if ($this->delete()) { |
224 | return true; | 225 | return true; |
225 | } | 226 | } |
@@ -262,7 +263,7 @@ | @@ -262,7 +263,7 @@ | ||
262 | ->andWhere( | 263 | ->andWhere( |
263 | [ | 264 | [ |
264 | 'or', | 265 | 'or', |
265 | - [ 'artbox_comment_rating.model' => NULL ], | 266 | + [ 'artbox_comment_rating.model' => null ], |
266 | [ 'artbox_comment_rating.model' => self::className() ], | 267 | [ 'artbox_comment_rating.model' => self::className() ], |
267 | ] | 268 | ] |
268 | ); | 269 | ); |
@@ -297,7 +298,7 @@ | @@ -297,7 +298,7 @@ | ||
297 | ] | 298 | ] |
298 | ), | 299 | ), |
299 | [ | 300 | [ |
300 | - 'target' => '_blank', | 301 | + 'target' => '_blank', |
301 | 'data-pjax' => '0', | 302 | 'data-pjax' => '0', |
302 | ] | 303 | ] |
303 | ); | 304 | ); |