Commit 8f36efb77f1ca9dc27ae2ce875990b30dc7a37ed
1 parent
2211268d
Added comments to prod.
Showing
5 changed files
with
143 additions
and
31 deletions
Show diff stats
backend/views/layouts/main-sidebar.php
| ... | ... | @@ -156,6 +156,12 @@ use yii\widgets\Menu; |
| 156 | 156 | 'options' => ['class'=>\Yii::$app->user->can('customer') ? '' :'hide'], |
| 157 | 157 | ], |
| 158 | 158 | [ |
| 159 | + 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-comment"></i> <span>{label}</span></a>', | |
| 160 | + 'label' => 'Комментарии', | |
| 161 | + 'url' => ['/artbox-comments'], | |
| 162 | + 'options' => ['class'=>\Yii::$app->user->can('artbox-comments') ? '' :'hide'], | |
| 163 | + ], | |
| 164 | + [ | |
| 159 | 165 | 'label' => 'Настройка ролей', |
| 160 | 166 | 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-cog"></i> <span>{label}</span></a>', |
| 161 | 167 | 'active' => preg_match('/^user.*$/', $this->context->id) | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + namespace common\behaviors; | |
| 4 | + | |
| 5 | + use common\models\Articles; | |
| 6 | + use common\modules\comment\models\CommentModel; | |
| 7 | + use common\modules\product\models\Product; | |
| 8 | + use common\widgets\Mailer; | |
| 9 | + use yii\base\Behavior; | |
| 10 | + use yii\base\Event; | |
| 11 | + use yii\db\ActiveRecord; | |
| 12 | + use yii\helpers\Url; | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * Class NotifyBehavior | |
| 16 | + * @property CommentModel $owner | |
| 17 | + * @package common\behaviors | |
| 18 | + */ | |
| 19 | + class NotifyBehavior extends Behavior | |
| 20 | + { | |
| 21 | + | |
| 22 | + public function events() | |
| 23 | + { | |
| 24 | + return [ | |
| 25 | + ActiveRecord::EVENT_AFTER_UPDATE => 'afterUpdate', | |
| 26 | + ]; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public function afterUpdate($event) | |
| 30 | + { | |
| 31 | + /** | |
| 32 | + * @var Event $event | |
| 33 | + * @var CommentModel $owner | |
| 34 | + */ | |
| 35 | + $owner = $this->owner; | |
| 36 | + if($owner->status == $owner::STATUS_ACTIVE) { | |
| 37 | + $entity = $owner->entity; | |
| 38 | + $model = $entity::findOne($owner->entity_id); | |
| 39 | + if($model != NULL) { | |
| 40 | + if(!empty( $owner->user )) { | |
| 41 | + $customer = $owner->user; | |
| 42 | + } | |
| 43 | + $url = ''; | |
| 44 | + if($model::className() == Product::className()) { | |
| 45 | + $url = Url::to([ | |
| 46 | + 'catalog/product', | |
| 47 | + 'product' => $model, | |
| 48 | + '#' => 'artbox-comment', | |
| 49 | + ], true); | |
| 50 | + } elseif($model::className() == Articles::className()) { | |
| 51 | + $url = Url::to([ | |
| 52 | + 'articles/show', | |
| 53 | + 'translit' => $model->translit, | |
| 54 | + 'id' => $model->id, | |
| 55 | + '#' => 'artbox-comment', | |
| 56 | + ], true); | |
| 57 | + } | |
| 58 | + $mailer = Mailer::widget([ | |
| 59 | + 'type' => 'comment_notify', | |
| 60 | + 'params' => [ | |
| 61 | + 'model' => $model, | |
| 62 | + 'url' => $url, | |
| 63 | + ], | |
| 64 | + 'subject' => 'Ваш комментарий опубликован', | |
| 65 | + 'email' => ( !empty( $customer ) ? $customer->email : $owner->email ), | |
| 66 | + ]); | |
| 67 | + return $mailer; | |
| 68 | + } | |
| 69 | + } | |
| 70 | + return false; | |
| 71 | + } | |
| 72 | + } | |
| 0 | 73 | \ No newline at end of file | ... | ... |
common/modules/comment/models/CommentModel.php
| 1 | 1 | <?php |
| 2 | 2 | namespace common\modules\comment\models; |
| 3 | 3 | |
| 4 | + use common\behaviors\NotifyBehavior; | |
| 4 | 5 | use common\behaviors\RatingBehavior; |
| 5 | 6 | use common\modules\comment\behaviors\ParentBehavior; |
| 6 | 7 | use common\modules\comment\models\interfaces\CommentInterface; |
| ... | ... | @@ -136,6 +137,9 @@ |
| 136 | 137 | [ |
| 137 | 138 | 'class' => RatingBehavior::className(), |
| 138 | 139 | ], |
| 140 | + [ | |
| 141 | + 'class' => NotifyBehavior::className(), | |
| 142 | + ], | |
| 139 | 143 | ]; |
| 140 | 144 | } |
| 141 | 145 | ... | ... |
| 1 | +<?php | |
| 2 | + /** | |
| 3 | + * @var array $params | |
| 4 | + */ | |
| 5 | + use yii\db\ActiveRecord; | |
| 6 | + | |
| 7 | +?> | |
| 8 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
| 9 | +<html lang="uk"> | |
| 10 | +<head> | |
| 11 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
| 12 | + <title>Rukzachok.com.ua</title> | |
| 13 | + <style type="text/css"> | |
| 14 | + body { | |
| 15 | + font-family: helvetica neue, arial, sans-serif; | |
| 16 | + line-height: 1.5; | |
| 17 | + padding: 0; | |
| 18 | + margin: 0; | |
| 19 | + } | |
| 20 | + </style> | |
| 21 | +</head> | |
| 22 | +<body style="margin: 0;"> | |
| 23 | +<div class="container" style=" | |
| 24 | + margin: 0 auto; | |
| 25 | + font-family: helvetica neue, arial, sans-serif; | |
| 26 | + font-size: 16px; | |
| 27 | + line-height: 1.5; | |
| 28 | + width: 100%; | |
| 29 | + max-width: 740px; | |
| 30 | + min-width: 360px; | |
| 31 | + "> | |
| 32 | + <h3>Ваш коммертарий успешно опубликован.</h3> | |
| 33 | + <p>Чтобы просмотреть комментарий перейдите по ссылке: <a href="<?= $params['url']; ?>"></a></p> | |
| 34 | +</div> | |
| 35 | +</body> | |
| 36 | +</html> | |
| 0 | 37 | \ No newline at end of file | ... | ... |
frontend/views/catalog/product.php
| ... | ... | @@ -175,23 +175,23 @@ |
| 175 | 175 | </ul> |
| 176 | 176 | </div> |
| 177 | 177 | <div class="artbox_comment_description"> |
| 178 | - <?php | |
| 179 | - if(!empty( $product->averageRating ) && $product->averageRating->value) { | |
| 180 | - ?> | |
| 181 | - <div class="rateit" data-rateit-value="<?php echo $product->averageRating->value; ?>" data-rateit-readonly="true" data-rateit-ispreset="true"></div> | |
| 182 | - <?php | |
| 183 | - } | |
| 184 | - ?> | |
| 185 | - <p><a href="#artbox-comment"> | |
| 186 | - <?php | |
| 187 | - $comment_count = count($product->comments); | |
| 188 | - if($comment_count) { | |
| 189 | - echo "Отзывов: " . $comment_count; | |
| 190 | - } else { | |
| 191 | - echo "Оставть отзыв"; | |
| 192 | - } | |
| 193 | - ?> | |
| 194 | - </a></p> | |
| 178 | + <?php | |
| 179 | + if(!empty( $product->averageRating ) && $product->averageRating->value) { | |
| 180 | + ?> | |
| 181 | + <div class="rateit" data-rateit-value="<?php echo $product->averageRating->value; ?>" data-rateit-readonly="true" data-rateit-ispreset="true"></div> | |
| 182 | + <?php | |
| 183 | + } | |
| 184 | + ?> | |
| 185 | + <p><a href="#artbox-comment"> | |
| 186 | + <?php | |
| 187 | + $comment_count = count($product->comments); | |
| 188 | + if($comment_count) { | |
| 189 | + echo "Отзывов: " . $comment_count; | |
| 190 | + } else { | |
| 191 | + echo "Оставть отзыв"; | |
| 192 | + } | |
| 193 | + ?> | |
| 194 | + </a></p> | |
| 195 | 195 | </div> |
| 196 | 196 | <br> |
| 197 | 197 | <?php |
| ... | ... | @@ -202,20 +202,14 @@ |
| 202 | 202 | */ |
| 203 | 203 | ?> |
| 204 | 204 | </div> |
| 205 | - <?php | |
| 206 | - if($product->category->category_id == 130) { | |
| 207 | - ?> | |
| 208 | - <div class="labels_block"> | |
| 209 | - <div class="labels_item"> | |
| 210 | - <img src="/img/icon_100_original_01.png" alt=""> | |
| 211 | - </div> | |
| 212 | - <div class="labels_item"> | |
| 213 | - <img src="/img/icon_100_quaranty_01.png" alt=""> | |
| 214 | - </div> | |
| 215 | - </div> | |
| 216 | - <?php | |
| 217 | - } | |
| 218 | - ?> | |
| 205 | + <div class="labels_block"> | |
| 206 | + <div class="labels_item"> | |
| 207 | + <img src="/img/icon_100_original_01.png" alt=""> | |
| 208 | + </div> | |
| 209 | + <div class="labels_item"> | |
| 210 | + <img src="/img/icon_100_quaranty_01.png" alt=""> | |
| 211 | + </div> | |
| 212 | + </div> | |
| 219 | 213 | <?php /* |
| 220 | 214 | <div class="product_service"> |
| 221 | 215 | <ul> | ... | ... |