/** * Override to handle sending email messages on new comment */ protected function afterSuccessfulSave($model) { assert('$model instanceof Item'); parent::afterSuccessfulSave($model); $user = Yii::app()->user->userModel; if ($this->relatedModel instanceof Conversation) { $participants = ConversationsUtil::resolvePeopleToSendNotificationToOnNewComment($this->relatedModel, $user); CommentsUtil::sendNotificationOnNewComment($this->relatedModel, $model, $user, $participants); } elseif ($this->relatedModel instanceof Mission) { $participants = MissionsUtil::resolvePeopleToSendNotificationToOnNewComment($this->relatedModel, $user); CommentsUtil::sendNotificationOnNewComment($this->relatedModel, $model, $user, $participants); } }
/** * Override to handle sending email messages on new comment */ protected function afterSuccessfulSave($model) { assert('$model instanceof Item'); parent::afterSuccessfulSave($model); $user = Yii::app()->user->userModel; if ($this->relatedModel instanceof Conversation) { $participants = ConversationsUtil::resolvePeopleToSendNotificationToOnNewComment($this->relatedModel, $user); CommentsUtil::sendNotificationOnNewComment($this->relatedModel, $model, $participants); } elseif ($this->relatedModel instanceof Mission) { $participants = MissionsUtil::resolvePeopleToSendNotificationToOnNewComment($this->relatedModel, $user); CommentsUtil::sendNotificationOnNewComment($this->relatedModel, $model, $participants); } elseif ($this->relatedModel instanceof Task) { TasksNotificationUtil::submitTaskNotificationMessage($this->relatedModel, TasksNotificationUtil::TASK_NEW_COMMENT, $model->createdByUser, $model); //Log the event if ($this->relatedModel->project->id > 0) { ProjectsUtil::logAddCommentEvent($this->relatedModel, $model->description); } } }
/** * @depends testResolvePeopleOnConversation */ public function testResolvePeopleToSendNotificationToOnNewComment() { $super = Yii::app()->user->userModel; $jack = User::getByUsername('jack'); $steven = User::getByUsername('steven'); $conversation = new Conversation(); $conversation->owner = Yii::app()->user->userModel; $conversation->subject = 'Test People To Send Notification'; $conversation->description = 'This is a test conversation'; $peopleToSendNotification = ConversationsUtil::resolvePeopleToSendNotificationToOnNewComment($conversation, $super); $this->assertEquals(0, count($peopleToSendNotification)); $conversationParticipant = new ConversationParticipant(); $conversationParticipant->person = $jack; $conversation->conversationParticipants->add($conversationParticipant); $peopleToSendNotification = ConversationsUtil::resolvePeopleToSendNotificationToOnNewComment($conversation, $super); $this->assertEquals(1, count($peopleToSendNotification)); $this->assertEquals($jack, $peopleToSendNotification[0]); }