diff --git a/ground/controllers/CommentsController.php b/ground/controllers/CommentsController.php
index 7ee30c6..6f81da3 100644
--- a/ground/controllers/CommentsController.php
+++ b/ground/controllers/CommentsController.php
@@ -34,6 +34,24 @@ class CommentsController extends Controller
'html' => $html,
));
$comment->save();
+
+ if ($_POST['parentType'] == 'article') {
+ $ownerId = Article::model()->getByPK((int) $_POST['parentId'])->author;
+ } else {
+ $ownerId = Point::model()->getByPK((int) $_POST['parentId'])->author;
+ }
+
+ if ($ownerId != App::$user->id) {
+ Notifications::model()->add(array(
+ 'userId' => $ownerId,
+ 'fromUserId' => App::$user->id,
+ 'objectId' => $comment->id,
+ 'type' => ($_POST['parentType'] == 'article') ? Notifications::typeNewCommentArticle : Notifications::typeNewCommentPoint,
+ 'date' => time(),
+ ));
+ }
+
+
App::redirect('/' . $_POST['parentType'] . '/' . $_POST['parentId'] . '#comment' . $comment->id);
}
diff --git a/ground/models/Notifications.php b/ground/models/Notifications.php
index b35c108..8ede5e9 100644
--- a/ground/models/Notifications.php
+++ b/ground/models/Notifications.php
@@ -16,6 +16,7 @@ class Notifications extends Model
$this->setRelation('RefUser', 'userId', 'User', 'id', self::TO_ONE);
$this->setRelation('RefFromUser', 'fromUserId', 'User', 'id', self::TO_ONE);
$this->setRelation('RefPoint', 'objectId', 'Point', 'id', self::TO_ONE);
+ $this->setRelation('RefComment', 'objectId', 'Comment', 'id', self::TO_ONE);
}
static function model()
diff --git a/ground/views/user/notification.php b/ground/views/user/notification.php
index 77d5cd9..d661d5b 100644
--- a/ground/views/user/notification.php
+++ b/ground/views/user/notification.php
@@ -6,8 +6,9 @@ switch ($notification->type) {
print strftime('%d %b %H:%M', $notification->date).' — Ваша точка "'.$notification->RefPoint->name.'" прошла модерацию.';
break;
case Notifications::typeNewCommentPoint:
-
-
+ $comment = $notification->RefComment;
+ $point = Point::model()->getByPK($comment->parentId);
+ print strftime('%d %b %H:%M', $notification->date).' — Новый комментарий к точке "'.$point->name.'".';
break;
default:
break;