コード例 #1
0
ファイル: Task.php プロジェクト: maruthisivaprasad/zurmo
 /**
  *  Process notifications on modal details screen
  */
 private function processNotificationsToBeSent()
 {
     if (array_key_exists('status', $this->originalAttributeValues)) {
         if ($this->status == Task::STATUS_AWAITING_ACCEPTANCE && $this->requestedByUser->id != Yii::app()->user->userModel->id) {
             TasksNotificationUtil::submitTaskNotificationMessage($this, TasksNotificationUtil::TASK_STATUS_BECOMES_AWAITING_ACCEPTANCE, Yii::app()->user->userModel);
         } elseif ($this->status == Task::STATUS_REJECTED && $this->owner->id != Yii::app()->user->userModel->id) {
             TasksNotificationUtil::submitTaskNotificationMessage($this, TasksNotificationUtil::TASK_STATUS_BECOMES_REJECTED, Yii::app()->user->userModel);
         } elseif ($this->status == Task::STATUS_COMPLETED) {
             TasksNotificationUtil::submitTaskNotificationMessage($this, TasksNotificationUtil::TASK_STATUS_BECOMES_COMPLETED, Yii::app()->user->userModel);
         }
     }
     if ($this->isNewModel) {
         if ($this->owner->id != $this->requestedByUser->id && $this->owner->id != Yii::app()->user->userModel->id) {
             TasksNotificationUtil::submitTaskNotificationMessage($this, TasksNotificationUtil::TASK_NEW);
         }
     } elseif (array_key_exists('owner', $this->originalAttributeValues) && $this->owner->id != Yii::app()->user->userModel->id) {
         TasksNotificationUtil::submitTaskNotificationMessage($this, TasksNotificationUtil::TASK_OWNER_CHANGE);
     }
 }
コード例 #2
0
 public function testTaskAddCommentWithExtraSubscribers()
 {
     $task = new Task();
     $task->name = 'Her Task';
     $task->owner = self::$sally;
     $task->requestedByUser = self::$katie;
     $notificationSubscriber = new NotificationSubscriber();
     $notificationSubscriber->person = self::$steve;
     $notificationSubscriber->hasReadLatest = false;
     $task->notificationSubscribers->add($notificationSubscriber);
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Notification::getCount());
     $this->assertTrue($task->save());
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(1, Notification::getCount());
     EmailMessage::deleteAll();
     Notification::deleteAll();
     $taskId = $task->id;
     $task->forget();
     $task = Task::getById($taskId);
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Notification::getCount());
     //Now add comment
     $comment = new Comment();
     $comment->description = 'some comment';
     $task->comments->add($comment);
     $this->assertTrue($task->save());
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Notification::getCount());
     TasksNotificationUtil::submitTaskNotificationMessage($task, TasksNotificationUtil::TASK_NEW_COMMENT, self::$super, $comment);
     $this->assertEquals(3, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(3, Notification::getCount());
     $emailMessages = EmailMessage::getAllByFolderType(EmailFolder::TYPE_OUTBOX);
     $this->assertCount(3, $emailMessages);
     $this->assertTrue('*****@*****.**' == $emailMessages[0]->recipients[0]->toAddress || '*****@*****.**' == $emailMessages[1]->recipients[0]->toAddress || '*****@*****.**' == $emailMessages[2]->recipients[0]->toAddress);
     $this->assertTrue('*****@*****.**' == $emailMessages[0]->recipients[0]->toAddress || '*****@*****.**' == $emailMessages[1]->recipients[0]->toAddress || '*****@*****.**' == $emailMessages[2]->recipients[0]->toAddress);
     $this->assertTrue('*****@*****.**' == $emailMessages[0]->recipients[0]->toAddress || '*****@*****.**' == $emailMessages[1]->recipients[0]->toAddress || '*****@*****.**' == $emailMessages[2]->recipients[0]->toAddress);
 }
 /**
  * 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);
         }
     }
 }
コード例 #4
0
 /**
  * Close task
  * @param $id
  * @throws NotSupportedException
  */
 public function actionCloseTask($id)
 {
     $task = Task::getById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($task);
     $task->status = Task::STATUS_COMPLETED;
     $saved = $task->save();
     if (!$saved) {
         throw new NotSupportedException();
     }
     TasksNotificationUtil::submitTaskNotificationMessage($task, TasksNotificationUtil::TASK_STATUS_BECOMES_COMPLETED, Yii::app()->user->userModel);
 }
コード例 #5
0
 /**
  * Process Task Edit
  * @param Task $task
  */
 protected function processTaskEdit(Task $task)
 {
     $isNewModel = $task->isNewModel;
     if (RightsUtil::canUserAccessModule('TasksModule', Yii::app()->user->userModel)) {
         if (isset($_POST['ajax']) && $_POST['ajax'] == 'task-modal-edit-form') {
             $controllerUtil = static::getZurmoControllerUtil();
             $controllerUtil->validateAjaxFromPost($task, 'Task');
             if ($isNewModel) {
                 TasksNotificationUtil::makeAndSubmitNewTaskNotificationMessage($task);
             }
             Yii::app()->getClientScript()->setToAjaxMode();
             Yii::app()->end(0, false);
         } else {
             echo ModalEditAndDetailsControllerUtil::setAjaxModeAndRenderModalEditView($this, 'TaskModalEditView', $task);
         }
     }
 }