Ejemplo n.º 1
0
 /**
  * Output a single file
  * @param string $name
  */
 public function actionGet($name)
 {
     if ($file = \Jazzee\Globals::getFileStore()->getSessionFile($name)) {
         $file->output();
     }
     //send a 404
     $request = new Lvc_Request();
     $request->setControllerName('error');
     $request->setActionName('index');
     $request->setActionParams(array('error' => '404', 'message' => 'File Not Found'));
     // Get a new front controller without any routers, and have it process our handmade request.
     $frontController = new Lvc_FrontController();
     $frontController->processRequest($request);
     exit(0);
 }
Ejemplo n.º 2
0
 /**
  * Render a single answer in the PDF
  * @param \Jazzee\ApplicantPDF $pdf
  * @param \Jazzee\Entity\Page $page
  * @param \Jazzee\Entity\Answer $answer
  */
 protected function renderPdfAnswerFromArray(\Jazzee\Entity\Page $page, \Jazzee\ApplicantPDF $pdf, array $answerData)
 {
     foreach ($page->getElements() as $element) {
         $element->getJazzeeElement()->setController($this->_controller);
         $value = $element->getJazzeeElement()->pdfValueFromArray($answerData, $pdf);
         if (!empty($value)) {
             $pdf->addText("{$element->getTitle()}: ", 'b');
             $pdf->addText("{$value}\n", 'p');
         }
     }
     if ($attachment = $answerData['attachment']) {
         $pdf->addPdf(\Jazzee\Globals::getFileStore()->getFileContents($attachment["attachmentHash"]));
     }
 }
Ejemplo n.º 3
0
 /**
  * PDF a full single applicant using the display array
  * @param \Jazzee\Entity\Application $application
  * @param array $applicant
  * @return string the PDF buffer suitable for display
  */
 public function pdfFromApplicantArray(\Jazzee\Entity\Application $application, array $applicant)
 {
     $this->pdf->set_info("Title", $this->pdf->convert_to_unicode('utf8', $applicant["fullName"], '') . ' Application');
     $this->addText($applicant["fullName"] . "\n", 'h1');
     $this->addText('Email Address: ' . $applicant["email"] . "\n", 'p');
     if ($applicant["isLocked"]) {
         switch ($applicant["decision"]["status"]) {
             case 'finalDeny':
                 $status = 'Denied';
                 break;
             case 'finalAdmit':
                 $status = 'Admited';
                 break;
             case 'acceptOffer':
                 $status = 'Accepted';
                 break;
             case 'declineOffer':
                 $status = 'Declined';
                 break;
             default:
                 $status = 'No Decision';
         }
     } else {
         $status = 'Not Locked';
     }
     $this->addText("Admission Status: {$status}\n", 'p');
     $this->write();
     $pages = array();
     foreach ($applicant['pages'] as $pageArray) {
         $pages[$pageArray['id']] = $pageArray['answers'];
     }
     foreach ($application->getApplicationPages(\Jazzee\Entity\ApplicationPage::APPLICATION) as $applicationPath) {
         if ($applicationPath->getJazzeePage() instanceof \Jazzee\Interfaces\PdfPage) {
             $applicationPath->getJazzeePage()->setController($this->_controller);
             $pageData = array_key_exists($applicationPath->getPage()->getId(), $pages) ? $pages[$applicationPath->getPage()->getId()] : array();
             $applicationPath->getJazzeePage()->renderPdfSectionFromArray($pageData, $this);
         }
     }
     $this->write();
     $this->pdf->end_page_ext("");
     foreach ($applicant["attachments"] as $attachment) {
         $blob = \Jazzee\Globals::getFileStore()->getFileContents($attachment["attachmentHash"]);
         $this->addPdf($blob);
         $blob = null;
     }
     $this->attachPdfs();
     $this->pdf->end_document("");
     return $this->pdf->get_buffer();
 }
Ejemplo n.º 4
0
 /**
  * When removing an element answer remove its file association as well
  * @param \Jazzee\Entity\ElementAnswer $elementAnswer
  */
 public function removeElementAnswer(\Jazzee\Entity\ElementAnswer $elementAnswer)
 {
     if ($elementAnswer->getEShortString()) {
         \Jazzee\Globals::getFileStore()->removeFile($elementAnswer->getEShortString());
     }
 }
Ejemplo n.º 5
0
 /**
  * Get the temporary path to the PDF file
  * @return string
  */
 public function getTmpFilePath()
 {
     return \Jazzee\Globals::getFileStore()->getFilePath($this->fileHash);
 }
Ejemplo n.º 6
0
 /**
  * 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;
 }
Ejemplo n.º 7
0
 /**
  * Remove any attachmetn file pointers
  * @PreRemove
  */
 public function preRemove()
 {
     if ($this->thumbnailHash) {
         \Jazzee\Globals::getFileStore()->removeFile($this->thumbnailHash);
     }
     \Jazzee\Globals::getFileStore()->removeFile($this->attachmentHash);
 }
Ejemplo n.º 8
0
 /**
  * Setup Doctrine ORM
  */
 protected function setupDoctrine()
 {
     //setup doctrine
     $doctrineConfig = new \Doctrine\ORM\Configuration();
     //We use different caching and proxy settings in Development status
     if ($this->_config->getStatus() == 'DEVELOPMENT') {
         $doctrineConfig->setAutoGenerateProxyClasses(true);
         $doctrineConfig->setProxyDir($this->_config->getVarPath() . '/tmp');
     } else {
         $doctrineConfig->setAutoGenerateProxyClasses(false);
         $doctrineConfig->setProxyDir(__DIR__ . '/Entity/Proxy');
         if (!extension_loaded('apc')) {
             throw new Exception('APC cache is required, but was not available.');
         }
     }
     $driver = $doctrineConfig->newDefaultAnnotationDriver(array(__DIR__ . "/Entity"));
     $doctrineConfig->setMetadataDriverImpl($driver);
     $doctrineConfig->setProxyNamespace('Jazzee\\Entity\\Proxy');
     $doctrineConfig->setMetadataCacheImpl(self::getCache());
     $doctrineConfig->setQueryCacheImpl(self::getCache());
     $doctrineConfig->setResultCacheImpl(self::getCache());
     $connectionParams = array('dbname' => $this->_config->getDbName(), 'user' => $this->_config->getDbUser(), 'password' => $this->_config->getDbPassword(), 'host' => $this->_config->getDbHost(), 'port' => $this->_config->getDbPort(), 'driver' => $this->_config->getDbDriver());
     $previewStore = $this->_session->getStore('preview', 3600);
     if ($previewStore->check('previewdbpath')) {
         $this->_previewMode = true;
         $connectionParams['driver'] = 'pdo_sqlite';
         $connectionParams['path'] = $previewStore->get('previewdbpath');
         $exitLink = $this->path('preview/end');
         $this->addMessage('info', "You are in preview mode, the changes you make will not be saved.  You can exit preview mode by visiting <a href='{$exitLink}'>{$exitLink}</a>");
     }
     $eventManager = new \Doctrine\Common\EventManager();
     $eventManager->addEventListener(array(\Doctrine\ORM\Events::onFlush), new \Jazzee\Entity\ApplicantEventListener());
     $eventManager->addEventListener(array(\Doctrine\ORM\Events::onFlush, \Doctrine\ORM\Events::preRemove), new \Jazzee\Entity\AnswerEventListener());
     $eventManager->addEventListener(array(\Doctrine\ORM\Events::onFlush), new \Jazzee\Entity\ApplicationEventListener());
     $this->_em = \Doctrine\ORM\EntityManager::create($connectionParams, $doctrineConfig, $eventManager);
     $this->_em->getConfiguration()->addCustomHydrationMode('ApplicantArrayHydrator', 'Jazzee\\Entity\\ApplicantArrayHydrator');
     $this->_em->getConfiguration()->addCustomHydrationMode('ApplicantDisplayHydrator', 'Jazzee\\Entity\\ApplicantDisplayHydrator');
     $this->_em->getConfiguration()->addCustomHydrationMode('ApplicantPDFTemplateHydrator', 'Jazzee\\Entity\\ApplicantPDFTemplateHydrator');
     \Jazzee\Globals::setEntityManager($this->_em);
 }
Ejemplo n.º 9
0
 public static function getFileStore()
 {
     return \Jazzee\Globals::getInstance()->getThisFileStore();
 }
Ejemplo n.º 10
0
 /**
  * Format applicant Array removing non-display values so the resulting array 
  * is smaller
  *
  * @param array $applicant
  * 
  * @return array
  */
 public function formatApplicantDisplayArray(array $applicant)
 {
     $applicant = $this->formatApplicantArray($applicant);
     $fileStore = \Jazzee\Globals::getFileStore();
     $attachments = array();
     foreach ($applicant['attachments'] as $attachment) {
         $base = $applicant['fullName'] . '_attachment_' . '_' . $attachment['id'];
         //remove slashes in path to fix an apache issues with encoding slashes in redirects
         $base = str_replace(array('/', '\\'), 'slash', $base);
         $name = $base . '.pdf';
         $fileStore->createSessionFile($name, $attachment['attachmentHash']);
         $attachment['filePath'] = \Jazzee\Globals::path('file/' . \urlencode($name));
         if ($attachment['thumbnailHash'] != null) {
             $name = $base . '.png';
             $fileStore->createSessionFile($name, $attachment['thumbnailHash']);
             $attachment['thumbnailPath'] = \Jazzee\Globals::path('file/' . \urlencode($name));
         } else {
             $attachment['thumbnailPath'] = \Jazzee\Globals::path('resource/foundation/media/default_pdf_logo.png');
         }
         $attachment['displayValue'] = "<a href='{$attachment['filePath']}'><img src='{$attachment['thumbnailPath']}' /></a>";
         $attachments[] = $attachment;
     }
     $applicant['attachments'] = $attachments;
     return $applicant;
 }
Ejemplo n.º 11
0
/**
 * render the attachment piece of a single answer
 * Displayes the png preview and the delete link
 */
if ($attachment = $answer->getAttachment()) {
    $base = $answer->getPage()->getTitle() . '_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');
    }
    ?>
  <a href="<?php 
    print $this->path('file/' . \urlencode($pdfName));
    ?>
"><img src="<?php 
    print $thumbnailPath;
    ?>
" /></a>
  <?php 
    if ($this->controller->checkIsAllowed('applicants_single', 'deleteAnswerPdf')) {
        ?>
    <br /><a href='<?php 
        print $this->path('applicants/single/' . $answer->getApplicant()->getId() . '/deleteAnswerPdf/' . $answer->getId());
        ?>
Ejemplo n.º 12
0
 /**
  * Setup configuration
  *
  * Load config.ini.php
  * translate to foundation config
  * create absolute path
  * set defautl timezone
  */
 protected function setupConfiguration()
 {
     $this->_config = new \Jazzee\Configuration();
     $this->_foundationConfig = new \Foundation\Configuration();
     if ($this->_config->getStatus() == 'DEVELOPMENT') {
         $this->_foundationConfig->setCacheType('array');
     } else {
         $this->_foundationConfig->setCacheType('apc');
     }
     $this->_foundationConfig->setMailSubjectPrefix($this->_config->getMailSubjectPrefix());
     $this->_foundationConfig->setMailDefaultFromAddress($this->_config->getMailDefaultFromAddress());
     $this->_foundationConfig->setMailDefaultFromName($this->_config->getMailDefaultFromName());
     $this->_foundationConfig->setMailOverrideToAddress($this->_config->getMailOverrideToAddress());
     $this->_foundationConfig->setMailServerType($this->_config->getMailServerType());
     $this->_foundationConfig->setMailServerHost($this->_config->getMailServeHost());
     $this->_foundationConfig->setMailServerPort($this->_config->getMailServerPort());
     $this->_foundationConfig->setMailServerUsername($this->_config->getMailServerUsername());
     $this->_foundationConfig->setMailServerPassword($this->_config->getMailServerPassword());
     \Foundation\VC\Config::setCache(self::getCache());
     if (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] == 'off') {
         $protocol = 'http';
     } else {
         $protocol = 'https';
     }
     if (in_array($_SERVER['SERVER_PORT'], array('80', '443'))) {
         $port = '';
     } else {
         $port = ':' . $_SERVER['SERVER_PORT'];
     }
     $this->_serverPath = $protocol . '://' . $_SERVER['SERVER_NAME'] . $port;
     \Jazzee\Globals::setConfig($this->_config);
 }
Ejemplo n.º 13
0
 /**
  * Render a single answer in the PDF
  * @param \Jazzee\ApplicantPDF $pdf
  * @param \Jazzee\Entity\Page $page
  * @param \Jazzee\Entity\Answer $answer
  */
 protected function renderPdfAnswerFromArray(\Jazzee\Entity\Page $page, \Jazzee\ApplicantPDF $pdf, array $answerData)
 {
     if (!empty($answerData['elements'])) {
         $pdf->addText("{$this->_applicationPage->getPage()->getVar('branchingElementLabel')}: ", 'b');
         $pdf->addText("{$answerData['elements'][0]['displayValue']}\n", 'p');
         foreach ($page->getChildren() as $childPage) {
             $jazzeePage = $childPage->getApplicationPageJazzeePage();
             $jazzeePage->setController($this->_controller);
             $jazzeePage->renderPdfAnswerFromArray($childPage, $pdf, $answerData);
         }
         if ($attachment = $answerData['attachment']) {
             $pdf->addPdf(\Jazzee\Globals::getFileStore()->getFileContents($attachment["attachmentHash"]));
         }
     } else {
         if (!empty($answerData['children'][0])) {
             $childAnswer = $answerData['children'][0];
             $childPage = $page->getChildById($childAnswer['page_id']);
             $pdf->addText("{$this->_applicationPage->getPage()->getVar('branchingElementLabel')}: ", 'b');
             $pdf->addText("{$childPage->getTitle()}\n", 'p');
             $jazzeePage = $childPage->getApplicationPageJazzeePage();
             $jazzeePage->setController($this->_controller);
             $jazzeePage->renderPdfAnswerFromArray($childPage, $pdf, $childAnswer);
         }
     }
 }