/**
  * Copy task in the modal view
  * @param string $id
  */
 public function actionModalCopyFromRelation($id)
 {
     $copyToTask = $this->processTaskCopy($id);
     //Log event for project audit
     if ($copyToTask->project->id > 0) {
         ProjectsUtil::logAddTaskEvent($copyToTask);
         ProjectsNotificationUtil::submitProjectNotificationMessage($copyToTask->project, ProjectAuditEvent::TASK_ADDED, $copyToTask, Yii::app()->user->userModel);
     }
     $this->actionModalDetails($copyToTask->id);
 }
Exemplo n.º 2
0
 /**
  * Handle audit of projects after save
  */
 protected function afterSave()
 {
     if ($this->getIsNewModel()) {
         ProjectAuditEvent::logAuditEvent(ProjectAuditEvent::PROJECT_CREATED, $this, $this->name);
         ProjectsNotificationUtil::submitProjectNotificationMessage($this, ProjectAuditEvent::PROJECT_CREATED);
     } elseif ($this->status == Project::STATUS_ARCHIVED && isset($this->originalAttributeValues['status'])) {
         ProjectAuditEvent::logAuditEvent(ProjectAuditEvent::PROJECT_ARCHIVED, $this, $this->name);
         ProjectsNotificationUtil::submitProjectNotificationMessage($this, ProjectAuditEvent::PROJECT_ARCHIVED);
     }
     parent::afterSave();
 }
 public function testNewNotificationWhenProjectIsArchived()
 {
     $project = new Project();
     $project->name = 'project-' . __FUNCTION__;
     $project->owner = self::$steve;
     $project->status = Project::STATUS_ARCHIVED;
     $this->assertEquals(0, EmailMessage::getCount());
     $this->assertEquals(0, Notification::getCount());
     ProjectsNotificationUtil::submitProjectNotificationMessage($project, ProjectAuditEvent::PROJECT_ARCHIVED);
     $emailMessages = EmailMessage::getAll();
     $notifications = Notification::getAll();
     $this->assertCount(1, $emailMessages);
     $this->assertCount(1, $notifications);
     $this->assertEquals('PROJECT: project-' . __FUNCTION__, $emailMessages[0]->subject);
     $this->assertContains("The project, 'project-" . __FUNCTION__ . "', is now archived.", $emailMessages[0]->content->textContent);
     $this->assertContains("The project, 'project-" . __FUNCTION__ . "', is now archived.", $emailMessages[0]->content->htmlContent);
     $this->assertContains("The project, 'project-" . __FUNCTION__ . "', is now archived.", $notifications[0]->notificationMessage->textContent);
     $this->assertContains("The project, 'project-" . __FUNCTION__ . "', is now archived.", $notifications[0]->notificationMessage->htmlContent);
 }