/** * Get an applicants pdfs * @param \Jazzee\Entity\Applicant $applicant */ public function getAttachments(\Jazzee\Entity\Applicant $applicant) { $attachments = array('attachments' => array(), 'allowAttach' => $this->checkIsAllowed($this->controllerName, 'attachApplicantPdf'), 'allowDelete' => $this->checkIsAllowed($this->controllerName, 'deleteApplicantPdf')); foreach ($applicant->getAttachments() as $attachment) { $base = $applicant->getFullName() . '_attachment_' . $attachment->getId(); //remove slashes in path to fix an apache issues with encoding slashes in redirects $base = str_replace(array('/', '\\'), 'slash', $base); $pdfName = $base . '.pdf'; $pngName = $base . 'preview.png'; \Jazzee\Globals::getFileStore()->createSessionFile($pdfName, $attachment->getAttachmentHash()); if ($attachment->getThumbnailHash() != null) { \Jazzee\Globals::getFileStore()->createSessionFile($pngName, $attachment->getThumbnailHash()); $thumbnailPath = \Jazzee\Globals::path('file/' . \urlencode($pngName)); } else { $thumbnailPath = \Jazzee\Globals::path('resource/foundation/media/default_pdf_logo.png'); } $attachments['attachments'][] = array('id' => $attachment->getId(), 'filePath' => $this->path('file/' . \urlencode($pdfName)), 'previewPath' => $this->path('file/' . $thumbnailPath)); } return $attachments; }