diff --git a/ground/controllers/CommentsController.php b/ground/controllers/CommentsController.php index 6f81da3..87a7fe8 100644 --- a/ground/controllers/CommentsController.php +++ b/ground/controllers/CommentsController.php @@ -41,6 +41,7 @@ class CommentsController extends Controller $ownerId = Point::model()->getByPK((int) $_POST['parentId'])->author; } + // Оповещение автору статьи или точки if ($ownerId != App::$user->id) { Notifications::model()->add(array( 'userId' => $ownerId, @@ -51,6 +52,19 @@ class CommentsController extends Controller )); } + // Оповещение тому, на чей комментарий отвечают + if (intval($_POST['answerTo']) > 0) { + $parentComment = Comment::model()->getByPK(intval($_POST['answerTo'])); + if ($parentComment->userId != App::$user->id) { + Notifications::model()->add(array( + 'userId' => $parentComment->userId, + 'fromUserId' => App::$user->id, + 'objectId' => $comment->id, + 'type' => Notifications::typeReply, + 'date' => time(), + )); + } + } App::redirect('/' . $_POST['parentType'] . '/' . $_POST['parentId'] . '#comment' . $comment->id); } diff --git a/ground/models/Comment.php b/ground/models/Comment.php index dd6476a..8346f6e 100644 --- a/ground/models/Comment.php +++ b/ground/models/Comment.php @@ -7,7 +7,7 @@ class Comment extends Model { $this->_tableName_ = 'comments'; parent::__construct($fromArray); - $this->setRelation('refUser', 'userId', 'User', 'id', self::TO_ONE); + $this->setRelation('RefUser', 'userId', 'User', 'id', self::TO_ONE); } static function model() diff --git a/ground/views/comments/all.php b/ground/views/comments/all.php index 218648d..5488f39 100644 --- a/ground/views/comments/all.php +++ b/ground/views/comments/all.php @@ -1,6 +1,7 @@