Commit 393e1adc4a83afc2d650701d38a6bee5503d9189

Authored by Alexey Boroda
1 parent 3c21f570

-Comments fixed

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