Example #1
0
 /**
  * Generates the Mail Body
  */
 protected function generateBody()
 {
     $message = new Mime\Message();
     $text = $this->generateHtml();
     $textPart = new Mime\Part($text);
     $textPart->type = 'text/html';
     $textPart->charset = 'UTF-8';
     $textPart->disposition = Mime\Mime::DISPOSITION_INLINE;
     $message->addPart($textPart);
     if (isset($this->application->getContact()->image) && $this->application->getContact()->getImage()->id) {
         /* @var $image \Auth\Entity\UserImage */
         $image = $this->application->getContact()->getImage();
         $part = new Mime\Part($image->getResource());
         $part->type = $image->type;
         $part->encoding = Mime\Mime::ENCODING_BASE64;
         $part->filename = $image->name;
         $part->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
         $message->addPart($part);
     }
     foreach ($this->application->getAttachments() as $attachment) {
         /* @var $part \Applications\Entity\Attachment */
         $part = new Mime\Part($attachment->getResource());
         $part->type = $attachment->type;
         $part->encoding = Mime\Mime::ENCODING_BASE64;
         $part->filename = $attachment->name;
         $part->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
         $message->addPart($part);
     }
     $this->setBody($message);
 }
Example #2
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()));
         }
     }
 }
 /**
  * @param $application Application
  * @return $this
  */
 public function setApplication(Application $application)
 {
     /* Applications\Entity\Contact */
     $this->setTo($application->getContact()->getEmail());
     return parent::setApplication($application);
 }
Example #5
0
 public function testSetGetContactWithoutContact2()
 {
     $this->target->setContact(new Info());
     $this->assertEquals(new Contact(), $this->target->getContact());
 }
Example #6
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];
 }