Пример #1
0
 /**
  * Construcutor takes the application we want to display
  * @param \Jazzee\Entity\Application $application
  */
 public function __construct(\Jazzee\Entity\Application $application)
 {
     $applicantElements = array('firstName' => 'First Name', 'lastName' => 'Last Name', 'email' => 'Email', 'createdAt' => 'Created At', 'updatedAt' => 'Updated At', 'lastLogin' => 'Last Login', 'percentComplete' => 'Progress', 'isLocked' => 'Locked', 'lockedAt' => 'Last Locked', 'hasPaid' => 'Paid', 'externalId' => 'External ID', 'attachments' => 'Attachments', 'status_declined' => 'Declined', 'status_admitted' => 'Admitted', 'status_denied' => 'Denied', 'status_accepted' => 'Accepted', 'status_nominate_admit' => 'Nominate Admit', 'status_nominate_deny' => 'Nominate Deny');
     foreach ($application->getApplicants() as $applicant) {
         foreach ($applicant->getTags() as $tag) {
             $applicantElements[$tag->getId()] = $tag->getTitle();
         }
     }
     $weight = 0;
     foreach ($applicantElements as $name => $title) {
         $this->_elements[] = new \Jazzee\Display\Element('applicant', $title, $weight++, $name, null);
     }
     $pages = array();
     foreach ($application->getApplicationPages() as $applicationPage) {
         if (is_subclass_of($applicationPage->getPage()->getType()->getClass(), 'Jazzee\\Interfaces\\DataPage')) {
             foreach ($applicationPage->getJazzeePage()->listDisplayElements() as $displayElement) {
                 $this->_elements[] = $displayElement;
                 if ($displayElement->getType() == 'page') {
                     $this->_pageIds[] = $displayElement->getPageId();
                 } else {
                     if ($displayElement->getType() == 'element') {
                         $this->_elementIds[] = $displayElement->getName();
                         $this->_pageIds[] = $application->getElementById($displayElement->getName())->getPage()->getId();
                     }
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  * Redirect from an appliy path
  * @param string $path
  * @return string
  */
 public function redirectApplyPath($path)
 {
     $this->redirectPath('apply/' . $this->_application->getProgram()->getShortName() . '/' . $this->_application->getCycle()->getName() . '/' . $path);
 }
Пример #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();
 }
Пример #4
0
 public static function isAllowed($controller, $action, \Jazzee\Entity\User $user = null, \Jazzee\Entity\Program $program = null, \Jazzee\Entity\Application $application = null)
 {
     if ($application and $application->isPublished()) {
         $action = 'liveIndex';
     } else {
         $action = 'index';
     }
     //all action authorizations are controlled by the index action
     return parent::isAllowed($controller, $action, $user, $program, $application);
 }
Пример #5
0
 /**
  * Use the index action to controll acccess
  * require a published application
  * @param type $controller
  * @param string $action
  * @param \Jazzee\Entity\User $user
  * @param \Jazzee\Entity\Program $program
  * @param \Jazzee\Entity\Application $application
  * @return type
  */
 public static function isAllowed($controller, $action, \Jazzee\Entity\User $user = null, \Jazzee\Entity\Program $program = null, \Jazzee\Entity\Application $application = null)
 {
     if (!$application || !$application->isPublished()) {
         return false;
     }
     //several views are controller by the index action
     if (in_array($action, array('bulk', 'sampleFile'))) {
         $action = 'index';
     }
     return parent::isAllowed($controller, $action, $user, $program, $application);
 }
Пример #6
0
 /**
  * Create a new display element from the Elements of another display
  * @param \Jazzee\Interfaces\DisplayElement $originalElement
  * @param \Jazzee\Entity\Application $application
  * 
  * @return \Jazzee\Interfaces\DisplayElement
  */
 public static function createFromDisplayElement(\Jazzee\Interfaces\DisplayElement $originalElement, \Jazzee\Entity\Application $application)
 {
     $displayElement = new \Jazzee\Entity\DisplayElement($originalElement->getType());
     switch ($originalElement->getType()) {
         case 'element':
             if (!($element = $application->getElementById($originalElement->getName()))) {
                 throw new \Jazzee\Exception("{$originalElement->getName()} is not a valid Jazzee Element ID, so it cannot be used in a 'element' display element.  Element: " . var_export($originalElement, true));
             }
             $displayElement->setElement($element);
             break;
         case 'page':
             if (!($applicationPage = $application->getApplicationPageByPageId($originalElement->getPageId())) and !($applicationPage = $application->getApplicationPageByChildPageId($originalElement->getPageId()))) {
                 throw new \Jazzee\Exception("{$originalElement->getPageId()} is not a valid Page ID, so it cannot be used in a 'page' display element.  Element: " . var_export($originalElement, true));
             }
             $displayElement->setPage($applicationPage->getPage());
         case 'applicant':
             $displayElement->setName($originalElement->getName());
             break;
     }
     $displayElement->setTitle($originalElement->getTitle());
     $displayElement->setWeight($originalElement->getWeight());
     return $displayElement;
 }
Пример #7
0
 public function getMaximumDisplayForApplication(\Jazzee\Entity\Application $application)
 {
     $display = new \Jazzee\Display\Union();
     $hasProgramRole = false;
     foreach ($this->roles as $role) {
         if (!$role->isGlobal() and $role->getProgram()->getId() == $application->getProgram()->getId()) {
             $hasProgramRole = true;
             if ($roleDisplay = $role->getDisplayForApplication($application)) {
                 $display->addDisplay($roleDisplay);
             } else {
                 $display->addDisplay(new \Jazzee\Display\FullApplication($application));
                 break;
                 //we interupt the loop here because once we have included a full display there is no reason to continue
             }
         }
     }
     //Temporary solution global users dont generally have program roles, but get access to all the elementns
     //for any action they can see
     if (!$hasProgramRole) {
         $display->addDisplay(new \Jazzee\Display\FullApplication($application));
     }
     return $display;
 }