示例#1
0
 /**
  * @covers Applications\Entity\Application::getJob
  * @covers Applications\Entity\Application::setJob
  */
 public function testSetGetJob()
 {
     $user = new User();
     $user->setId(123);
     $job = new Job();
     $job->setUser($user);
     $this->target->setJob($job);
     $this->assertEquals($job, $this->target->getJob());
 }
示例#2
0
 public function init()
 {
     $this->isInitialized = true;
     if (!$this->application) {
         return;
     }
     $this->setEncoding('UTF-8');
     $subject = 'Fwd: Application to "%s" dated %s';
     if ($this->isTranslatorEnabled()) {
         $subject = $this->getTranslator()->translate($subject);
     }
     $this->setSubject(sprintf($subject, $this->application->getJob()->getTitle(), strftime('%x', $this->application->getDateCreated()->getTimestamp())));
     $this->generateBody();
 }
示例#3
0
 /**
  * @param Application $application
  * @param UserInterface $user
  * @return CvEntity
  * @since 0.26
  */
 public function createFromApplication(Application $application, UserInterface $user)
 {
     $cv = $this->create();
     $cv->setContact($application->getContact());
     $assignedUser = $application->getJob()->getUser();
     $cv->setUser($assignedUser);
     $perms = $cv->getPermissions();
     $perms->inherit($application->getPermissions());
     // grant view permission to the user that issued this creation.
     $perms->grant($user, PermissionsInterface::PERMISSION_VIEW);
     // revoke change permission to the original applicant
     $perms->revoke($application->getUser(), PermissionsInterface::PERMISSION_CHANGE);
     $applicationAttachments = $application->getAttachments();
     if (count($applicationAttachments) > 0) {
         $cvAttachments = [];
         /* @var $applicationAttachment \Applications\Entity\Attachment */
         foreach ($applicationAttachments as $applicationAttachment) {
             $file = new \Doctrine\MongoDB\GridFSFile();
             $file->setBytes($applicationAttachment->getContent());
             $cvAttachment = new \Cv\Entity\Attachment();
             $cvAttachment->setName($applicationAttachment->getName());
             $cvAttachment->setType($applicationAttachment->getType());
             $cvAttachment->setUser($assignedUser);
             $cvAttachment->setFile($file);
             $cvAttachment->setDateUploaded($applicationAttachment->getDateUploaded());
             $cvAttachments[] = $cvAttachment;
         }
         $cv->setAttachments(new \Doctrine\Common\Collections\ArrayCollection($cvAttachments));
     }
     return $cv;
 }
 protected function sendRecruiterMails()
 {
     /* @var Settings $adminSettings */
     $job = $this->application->getJob();
     $org = $job->getOrganization()->getParent(true);
     $workflow = $org->getWorkflowSettings();
     $admin = $org->getUser();
     $adminSettings = $admin->getSettings('Applications');
     $mailBcc = $adminSettings->getMailBCC();
     if ($workflow->getAcceptApplicationByDepartmentManager()) {
         /* Send mail to department manager, if there is at least one. */
         $managers = $org->getEmployeesByRole(EmployeeInterface::ROLE_DEPARTMENT_MANAGER);
         if (count($managers)) {
             foreach ($managers as $employee) {
                 /* @var EmployeeInterface $employee */
                 $this->mailService->send('Applications/NewApplication', ['job' => $job, 'user' => $employee->getUser(), 'bcc' => $adminSettings->getMailBCC() ? [$admin] : null]);
             }
             return;
         }
     }
     $recruiter = $job->getUser();
     /* @var \Applications\Entity\Settings $settings */
     $settings = $recruiter->getSettings('Applications');
     if ($settings->getMailAccess()) {
         $this->mailService->send('Applications/NewApplication', ['job' => $this->application->getJob(), 'user' => $recruiter, 'bcc' => $adminSettings->getMailBCC() ? [$admin] : null]);
     }
     if ($settings->getAutoConfirmMail()) {
         $ackBody = $settings->getMailConfirmationText();
         if (empty($ackBody)) {
             $ackBody = $settings->getMailConfirmationText();
         }
         if (!empty($ackBody)) {
             /* confirmation mail to the applicant */
             $ackMail = $this->mailService->get('Applications/Confirmation', ['application' => $this->application, 'body' => $ackBody, 'bcc' => $adminSettings->getMailBCC() ? [$admin] : null]);
             // Must be called after initializers in creation
             $ackMail->setSubject('Application confirmation');
             $ackMail->setFrom($recruiter->getInfo()->getEmail(), $recruiter->getInfo()->getDisplayName(false));
             $this->mailService->send($ackMail);
             $this->application->changeStatus(StatusInterface::CONFIRMED, sprintf('Mail was sent to %s', $this->application->getContact()->getEmail()));
         }
     }
 }
示例#5
0
 /**
  * @param Application $application
  * @param             $status
  *
  * @return AddressList
  */
 protected function getRecipient(Application $application, $status)
 {
     $recipient = Status::ACCEPTED == $status ? $application->getJob()->getUser()->getInfo() : $application->getContact();
     $email = $recipient->getEmail();
     $name = $recipient->getDisplayName(false);
     return $name ? [$email => $name] : [$email];
 }