Commit 179a0e00fef5ef2ad34da6d191dd61babc2077c7

Authored by Anastasia
1 parent d59bf484

bug fix artbox-comment

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