Commit 179a0e00fef5ef2ad34da6d191dd61babc2077c7

Authored by Anastasia
1 parent d59bf484

bug fix artbox-comment

views/artbox_comment_item.php
@@ -56,7 +56,7 @@ @@ -56,7 +56,7 @@
56 </div> 56 </div>
57 <div class="artbox_item_tools comment-panel"> 57 <div class="artbox_item_tools comment-panel">
58 <?php 58 <?php
59 - if (!\Yii::$app->user->isGuest) { 59 + if (!\Yii::$app->user->isGuest && $reply) {
60 ?> 60 ?>
61 <a href="" class="btn-comm-answer" data-action="reply"><?php echo \Yii::t( 61 <a href="" class="btn-comm-answer" data-action="reply"><?php echo \Yii::t(
62 'artbox-comment', 62 'artbox-comment',
@@ -64,7 +64,7 @@ @@ -64,7 +64,7 @@
64 ); ?></a> 64 ); ?></a>
65 <?php 65 <?php
66 } 66 }
67 - if (!\Yii::$app->user->isGuest && \Yii::$app->user->id == $model->customer_id) { 67 + if (!\Yii::$app->user->isGuest && \Yii::$app->user->id == $model->customer_id && $delete) {
68 ?> 68 ?>
69 <a href="" class="btn-comm-delete" data-action="delete" data-url="<?php echo Url::to( 69 <a href="" class="btn-comm-delete" data-action="delete" data-url="<?php echo Url::to(
70 [ 70 [
@@ -125,7 +125,7 @@ @@ -125,7 +125,7 @@
125 </div> 125 </div>
126 <div class="artbox_child_tools comment-panel"> 126 <div class="artbox_child_tools comment-panel">
127 <?php 127 <?php
128 - if (!\Yii::$app->user->isGuest) { 128 + if (!\Yii::$app->user->isGuest && $reply) {
129 ?> 129 ?>
130 <a href="" class="btn-comm-answer" data-action="reply"><?php echo \Yii::t( 130 <a href="" class="btn-comm-answer" data-action="reply"><?php echo \Yii::t(
131 'artbox-comment', 131 'artbox-comment',
@@ -133,7 +133,7 @@ @@ -133,7 +133,7 @@
133 ); ?></a> 133 ); ?></a>
134 <?php 134 <?php
135 } 135 }
136 - if (!\Yii::$app->user->isGuest && \Yii::$app->user->id == $child->customer_id) { 136 + if (!\Yii::$app->user->isGuest && \Yii::$app->user->id == $child->customer_id && $delete) {
137 ?> 137 ?>
138 <a href="" class="btn-comm-delete" data-action="delete" data-url="<?php echo Url::to( 138 <a href="" class="btn-comm-delete" data-action="delete" data-url="<?php echo Url::to(
139 [ 139 [
views/artbox_comment_list.php
@@ -15,7 +15,9 @@ @@ -15,7 +15,9 @@
15 * @var Model $model 15 * @var Model $model
16 * @var ActiveDataProvider $comments 16 * @var ActiveDataProvider $comments
17 * @var View $this 17 * @var View $this
18 - * @var srring $display_name 18 + * @var string $display_name
  19 + * @var boolean $reply ,
  20 + * @var boolean $delete
19 */ 21 */
20 Pjax::begin(); 22 Pjax::begin();
21 if(( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != NULL) { 23 if(( $success = \Yii::$app->session->getFlash('artbox_comment_success') ) != NULL) {
@@ -28,7 +30,9 @@ @@ -28,7 +30,9 @@
28 'emptyText' => false, 30 'emptyText' => false,
29 'summary' => '', 31 'summary' => '',
30 'viewParams' => [ 32 'viewParams' => [
31 - 'display_name' => $display_name 33 + 'display_name' => $display_name,
  34 + 'reply' => $reply,
  35 + 'delete' => $delete
32 ] 36 ]
33 37
34 ]); 38 ]);
widgets/CommentWidget.php
@@ -24,9 +24,17 @@ @@ -24,9 +24,17 @@
24 */ 24 */
25 class CommentWidget extends Widget 25 class CommentWidget extends Widget
26 { 26 {
  27 +
  28 + /**
  29 + * @var bool display reply and delete links
  30 + */
  31 + public $reply = true;
  32 + public $delete = true;
27 /** 33 /**
28 * @var string what field is displayed in the user name 34 * @var string what field is displayed in the user name
29 */ 35 */
  36 +
  37 +
30 public $display_name = 'username'; 38 public $display_name = 'username';
31 39
32 /** 40 /**
@@ -370,12 +378,13 @@ @@ -370,12 +378,13 @@
370 'model' => $this->getModel(), 378 'model' => $this->getModel(),
371 'formId' => $this->formId, 379 'formId' => $this->formId,
372 'rating_model' => $ratingModel, 380 'rating_model' => $ratingModel,
  381 +
373 ] 382 ]
374 ), 383 ),
375 $form_options 384 $form_options
376 ); 385 );
377 386
378 - if (!\Yii::$app->user->isGuest) { 387 + if (!\Yii::$app->user->isGuest && $this->reply) {
379 $reply_options = $this->replyOptions; 388 $reply_options = $this->replyOptions;
380 $this->parts[ 'reply_form' ] = Html::tag( 389 $this->parts[ 'reply_form' ] = Html::tag(
381 ArrayHelper::remove($reply_options, 'tag', 'div'), 390 ArrayHelper::remove($reply_options, 'tag', 'div'),
@@ -405,6 +414,8 @@ @@ -405,6 +414,8 @@
405 'item_options' => $this->itemOptions, 414 'item_options' => $this->itemOptions,
406 'item_view' => $this->itemView, 415 'item_view' => $this->itemView,
407 'display_name' => $this->display_name, 416 'display_name' => $this->display_name,
  417 + 'reply' => $this->reply,
  418 + 'delete' => $this->delete
408 419
409 ] 420 ]
410 ), 421 ),