Beispiel #1
0
 /**
  * Save data from editing a page
  * @param integer $pageId
  */
 public function actionSavePage($pageId)
 {
     $data = json_decode($this->post['data']);
     switch ($data->status) {
         case 'delete':
             if ($applicationPage = $this->_em->getRepository('\\Jazzee\\Entity\\ApplicationPage')->findOneBy(array('page' => $pageId, 'application' => $this->_application->getId()))) {
                 if ($this->_em->getRepository('\\Jazzee\\Entity\\Page')->hasApplicationAnswers($applicationPage->getPage(), $this->_application)) {
                     $this->setLayoutVar('status', 'error');
                     $this->addMessage('error', $applicationPage->getTitle() . ' could not be deleted becuase it has applicant information associated with it.');
                 } else {
                     if (!$applicationPage->getPage()->isGlobal()) {
                         $this->_em->remove($applicationPage->getPage());
                     }
                     $this->_em->remove($applicationPage);
                     $this->addMessage('success', $applicationPage->getTitle() . ' deleted');
                 }
             }
             break;
         case 'new-global':
             $applicationPage = new \Jazzee\Entity\ApplicationPage();
             $applicationPage->setPage($this->_em->getRepository('\\Jazzee\\Entity\\Page')->findOneBy(array('id' => $pageId, 'isGlobal' => true)));
             $applicationPage->setKind($data->kind);
             $applicationPage->setApplication($this->_application);
             $applicationPage->setWeight($data->weight);
             $applicationPage->setTitle($data->title);
             $applicationPage->setMin($data->min);
             $applicationPage->setMax($data->max);
             if ($data->isRequired) {
                 $applicationPage->required();
             } else {
                 $applicationPage->optional();
             }
             $applicationPage->setInstructions($data->instructions);
             $applicationPage->setLeadingText($data->leadingText);
             $applicationPage->setTrailingText($data->trailingText);
             $this->_em->persist($applicationPage);
             $this->addMessage('success', $data->title . ' created.');
             break;
         case 'new':
         case 'copy':
             $page = new \Jazzee\Entity\Page();
             $page->notGlobal();
             $page->setType($this->_em->getRepository('\\Jazzee\\Entity\\PageType')->find($data->typeId));
             $this->_em->persist($page);
             $applicationPage = new \Jazzee\Entity\ApplicationPage();
             $applicationPage->setPage($page);
             $applicationPage->setKind($data->kind);
             $applicationPage->setWeight($data->weight);
             $applicationPage->setApplication($this->_application);
             $applicationPage->getJazzeePage()->setController($this);
             //only do setup for new pages, copies lready ahve elements
             if ($data->status == 'new') {
                 $applicationPage->getJazzeePage()->setupNewPage();
             }
             $this->addMessage('success', $data->title . ' created.');
         default:
             if (!isset($applicationPage)) {
                 $applicationPage = $this->_em->getRepository('\\Jazzee\\Entity\\ApplicationPage')->findOneBy(array('page' => $pageId, 'application' => $this->_application->getId()));
             }
             $this->savePage($applicationPage, $data);
     }
 }
Beispiel #2
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
 {
     $jazzeeConfiguration = new \Jazzee\Configuration();
     if ($jazzeeConfiguration->getStatus() == 'PRODUCTION') {
         $output->write('<error>You cannot create a demo in production.</error>' . PHP_EOL);
         exit;
     }
     $programName = $input->getOption('programName') ? $input->getOption('programName') : 'Demo';
     $shortName = $input->getOption('shortName') ? $input->getOption('shortName') : 'demo';
     $entityManager = $this->getHelper('em')->getEntityManager();
     if ($entityManager->getRepository('\\Jazzee\\Entity\\Program')->findBy(array('name' => $programName))) {
         $output->write("<error>A program named '{$programName}' already exists.</error>" . PHP_EOL);
         exit;
     }
     if ($entityManager->getRepository('\\Jazzee\\Entity\\Program')->findBy(array('shortName' => $shortName))) {
         $output->write("<error>A program with the shortname '{$shortName}' already exists.</error>" . PHP_EOL);
         exit;
     }
     if (!($cycle = $entityManager->getRepository('\\Jazzee\\Entity\\Cycle')->findOneBy(array('name' => 'demo')))) {
         $cycle = new \Jazzee\Entity\Cycle();
         $cycle->setName('demo');
         $cycle->setStart('today');
         $cycle->setEnd('next year');
         $entityManager->persist($cycle);
     }
     $program = new \Jazzee\Entity\Program();
     $program->setName($programName);
     $program->setShortName($shortName);
     $entityManager->persist($program);
     $application = new \Jazzee\Entity\Application();
     $application->setProgram($program);
     $application->setCycle($cycle);
     $application->setWelcome('THIS IS A DEMO APP.');
     $application->visible();
     $application->setOpen('yesterday');
     $application->setClose('next year');
     $application->publish(true);
     $entityManager->persist($application);
     $StandardPageType = $entityManager->getRepository('\\Jazzee\\Entity\\PageType')->findOneBy(array('class' => '\\Jazzee\\Page\\Standard'));
     $page = new \Jazzee\Entity\Page();
     $page->setTitle('Optional Page');
     $page->optional();
     $page->setType($StandardPageType);
     $entityManager->persist($page);
     $count = 1;
     foreach ($entityManager->getRepository('\\Jazzee\\Entity\\ElementType')->findAll() as $type) {
         $element = $this->demoElement($type, $entityManager);
         $element->setTitle($type->getName());
         $element->optional();
         $element->setWeight($count);
         $page->addElement($element);
         $entityManager->persist($element);
         $count++;
     }
     $applicationPage = new \Jazzee\Entity\ApplicationPage();
     $applicationPage->setApplication($application);
     $applicationPage->setPage($page);
     $applicationPage->setKind(\Jazzee\Entity\ApplicationPage::APPLICATION);
     $applicationPage->setWeight(1);
     $entityManager->persist($applicationPage);
     $page = new \Jazzee\Entity\Page();
     $page->setTitle('Required Page');
     $page->setType($StandardPageType);
     $entityManager->persist($page);
     $count = 1;
     foreach ($entityManager->getRepository('\\Jazzee\\Entity\\ElementType')->findAll() as $type) {
         $element = $this->demoElement($type, $entityManager);
         $element->setTitle($type->getName());
         $element->required();
         $element->setWeight($count);
         $page->addElement($element);
         $entityManager->persist($element);
         $count++;
     }
     $applicationPage = new \Jazzee\Entity\ApplicationPage();
     $applicationPage->setApplication($application);
     $applicationPage->setPage($page);
     $applicationPage->setKind(\Jazzee\Entity\ApplicationPage::APPLICATION);
     $applicationPage->setWeight(2);
     $entityManager->persist($applicationPage);
     $entityManager->flush();
     $output->write("<info>Demo program {$programName} created successfully.</info>" . PHP_EOL);
 }
 /**
  * Create a preview application
  * @param \Doctrine\ORM\EntityManager $em
  * @param \Jazzee\Entity\Role $adminRole
  * @return \Jazzee\Entity\Application
  */
 protected function createPreviewApplication(\Doctrine\ORM\EntityManager $em, \Jazzee\Entity\Role $adminRole)
 {
     $newApplication = new \Jazzee\Entity\Application();
     $properties = array('contactName', 'contactEmail', 'welcome', 'statusIncompleteText', 'statusNoDecisionText', 'statusAdmitText', 'statusDenyText', 'statusAcceptText', 'statusDeclineText');
     foreach ($properties as $name) {
         $set = 'set' . ucfirst($name);
         $get = 'get' . ucfirst($name);
         $newApplication->{$set}($this->_application->{$get}());
     }
     $timeProperties = array('open', 'close', 'begin');
     foreach ($timeProperties as $name) {
         $set = 'set' . ucfirst($name);
         $get = 'get' . ucfirst($name);
         $newApplication->{$set}($this->_application->{$get}()->format('c'));
     }
     $newApplication->publish(true);
     $newApplication->visible();
     $program = new \Jazzee\Entity\Program();
     $program->setName($this->_program->getName());
     $program->setShortName($this->_program->getShortName());
     $em->persist($program);
     $newApplication->setProgram($program);
     $cycle = new \Jazzee\Entity\Cycle();
     $cycle->setName($this->_cycle->getName());
     $cycle->setStart('yesterday');
     $cycle->setEnd('next year');
     $em->persist($cycle);
     $newApplication->setCycle($cycle);
     foreach ($this->_application->getApplicationPages() as $applicationPage) {
         $newPage = $this->copyPage($em, $applicationPage->getPage());
         $newApplicationPage = new \Jazzee\Entity\ApplicationPage();
         $newApplicationPage->setApplication($newApplication);
         $newApplicationPage->setPage($newPage);
         $newApplicationPage->setWeight($applicationPage->getWeight());
         $newApplicationPage->setKind($applicationPage->getKind());
         $newApplicationPage->setTitle($applicationPage->getTitle());
         $newApplicationPage->setMin($applicationPage->getMin());
         $newApplicationPage->setMax($applicationPage->getMax());
         $newApplicationPage->setInstructions($applicationPage->getInstructions());
         $newApplicationPage->setLeadingText($applicationPage->getLeadingText());
         $newApplicationPage->setTrailingText($applicationPage->getTrailingText());
         if ($applicationPage->isRequired()) {
             $newApplicationPage->required();
         } else {
             $newApplicationPage->optional();
         }
         if ($applicationPage->showAnswerStatus()) {
             $newApplicationPage->showAnswerStatus();
         } else {
             $newApplicationPage->hideAnswerStatus();
         }
         $em->persist($newApplicationPage);
     }
     $em->persist($newApplication);
     $newRole = new \Jazzee\Entity\Role();
     $newRole->setName('Preview Access');
     $newRole->notGlobal();
     $newRole->setProgram($program);
     foreach ($adminRole->getActions() as $action) {
         $newAction = new \Jazzee\Entity\RoleAction();
         $newAction->setRole($newRole);
         $newAction->setAction($action->getAction());
         $newAction->setController($action->getController());
         $em->persist($newAction);
     }
     $em->persist($newRole);
     $user = new \Jazzee\Entity\User();
     $user->setUniqueName('previewuser');
     $user->activate();
     $user->setEmail('*****@*****.**');
     $user->setFirstName('Preview');
     $user->setLastName('Application User');
     $user->addRole($newRole);
     $user->setDefaultCycle($cycle);
     $user->setDefaultProgram($program);
     $em->persist($user);
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\Template')->findByApplication($this->_application) as $template) {
         $newTemplate = new \Jazzee\Entity\Template($template->getType());
         $newTemplate->setApplication($newApplication);
         $newTemplate->setText($template->getText());
         $newTemplate->setTitle($template->getTitle());
         $em->persist($newTemplate);
     }
     $em->flush();
     return $newApplication;
 }
 /**
  * Setup the current application and cycle
  */
 public function actionIndex()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("setup/copyapplication"));
     $field = $form->newField();
     $field->setLegend('Import Application');
     $element = $field->newElement('SelectList', 'application');
     $element->setLabel('Cycle to Copy');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $applications = $this->_em->getRepository('\\Jazzee\\Entity\\Application')->findByProgram($this->_program);
     foreach ($applications as $application) {
         $element->newItem($application->getId(), $application->getCycle()->getName());
     }
     $form->newButton('submit', 'Copy');
     if ($input = $form->processInput($this->post)) {
         $previousApplication = $this->_em->getRepository('\\Jazzee\\Entity\\Application')->find($input->get('application'));
         $this->_application = new \Jazzee\Entity\Application();
         $this->_application->setProgram($this->_program);
         $this->_application->setCycle($this->_cycle);
         $this->_application->inVisible();
         $this->_application->unPublish();
         if ($previousApplication->isByInvitationOnly()) {
             $this->_application->byInvitationOnly();
         }
         $this->_application->setContactName($previousApplication->getContactName());
         $this->_application->setContactEmail($previousApplication->getContactEmail());
         $this->_application->setWelcome($previousApplication->getWelcome());
         $this->_application->setOpen($previousApplication->getOpen()->format('c'));
         $this->_application->setClose($previousApplication->getClose()->format('c'));
         $this->_application->setBegin($previousApplication->getBegin()->format('c'));
         $this->_application->setStatusIncompleteText($previousApplication->getStatusIncompleteText());
         $this->_application->setStatusNoDecisionText($previousApplication->getStatusNoDecisionText());
         $this->_application->setStatusAdmitText($previousApplication->getStatusAdmitText());
         $this->_application->setStatusDenyText($previousApplication->getStatusDenyText());
         $this->_application->setStatusAcceptText($previousApplication->getStatusAcceptText());
         $this->_application->setStatusDeclineText($previousApplication->getStatusDeclineText());
         foreach ($previousApplication->getApplicationPages() as $previousPage) {
             $page = $this->addPage($previousPage->getPage());
             $applicationPage = new \Jazzee\Entity\ApplicationPage();
             $applicationPage->setApplication($this->_application);
             $applicationPage->setPage($page);
             $applicationPage->setKind($previousPage->getKind());
             $applicationPage->setTitle($previousPage->getTitle());
             $applicationPage->setMin($previousPage->getMin());
             $applicationPage->setMax($previousPage->getMax());
             $applicationPage->setName($previousPage->getName());
             if ($previousPage->isRequired()) {
                 $applicationPage->required();
             } else {
                 $applicationPage->optional();
             }
             if ($previousPage->answerStatusDisplay()) {
                 $applicationPage->showAnswerStatus();
             } else {
                 $applicationPage->hideAnswerStatus();
             }
             $applicationPage->setInstructions($previousPage->getInstructions());
             $applicationPage->setLeadingText($previousPage->getLeadingText());
             $applicationPage->setTrailingText($previousPage->getTrailingText());
             $applicationPage->setWeight($previousPage->getWeight());
             $this->_em->persist($applicationPage);
         }
         $templates = $this->_em->getRepository('Jazzee\\Entity\\Template')->findBy(array('application' => $previousApplication));
         foreach ($templates as $previousTemplate) {
             $template = new \Jazzee\Entity\Template($previousTemplate->getType());
             $template->setApplication($this->_application);
             $template->setTitle($previousTemplate->getTitle());
             $template->setText($previousTemplate->getText());
             $this->_em->persist($template);
         }
         $this->_em->persist($this->_application);
         $this->addMessage('success', 'Application copied successfully');
         unset($this->_store->AdminControllerGetNavigation);
         $this->redirectPath('setup/application');
     }
     $this->setVar('form', $form);
 }
 /**
  * Setup the current application and cycle
  */
 public function actionIndex()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("setup/importapplication"));
     $field = $form->newField();
     $field->setLegend('Import Application');
     $element = $field->newElement('FileInput', 'file');
     $element->setLabel('XML Configuration');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\Blob($element));
     $form->newButton('submit', 'Import');
     if ($input = $form->processInput($this->post)) {
         $xml = simplexml_load_string($input->get('file'));
         if (!$this->_application) {
             $this->_application = new \Jazzee\Entity\Application();
             $this->_application->setProgram($this->_program);
             $this->_application->setCycle($this->_cycle);
         }
         if ($this->_application->isPublished()) {
             $this->addMessage('error', 'This application is already published.  No changes can be made.');
             $this->redirectPath('setup/importapplication');
         }
         $pages = $this->_application->getApplicationPages();
         if (count($pages)) {
             $this->addMessage('error', 'This application already has pages.  You cannot import a configuration for an application with pages.');
             $this->redirectPath('setup/importapplication');
         }
         $preferences = $xml->xpath('/response/application/preferences');
         $arr = array();
         foreach ($preferences[0]->children() as $element) {
             $arr[$element->getName()] = (string) $element;
         }
         $this->_application->setContactName($arr['contactName']);
         $this->_application->setContactEmail($arr['contactEmail']);
         $this->_application->setWelcome(html_entity_decode($arr['welcome']));
         $this->_application->setOpen($arr['open']);
         $this->_application->setClose($arr['close']);
         $this->_application->setBegin($arr['begin']);
         $this->_application->setStatusIncompleteText($arr['statusIncompleteText']);
         $this->_application->setStatusNoDecisionText($arr['statusNoDecisionText']);
         $this->_application->setStatusAdmitText($arr['statusAdmitText']);
         $this->_application->setStatusDenyText($arr['statusDenyText']);
         $this->_application->setStatusAcceptText($arr['statusAcceptText']);
         $this->_application->setStatusDeclineText($arr['statusDeclineText']);
         if ($arr['visible'] == '1') {
             $this->_application->visible();
         }
         if ($arr['byinvitationonly'] == '1') {
             $this->_application->byInvitationOnly();
         } else {
             $this->_application->notByInvitationOnly();
         }
         if (array_key_exists('externalIdValidationExpression', $arr) and !empty($arr['externalIdValidationExpression'])) {
             $this->_application->setExternalIdValidationExpression($arr['externalIdValidationExpression']);
         }
         foreach ($xml->xpath('/response/application/preferences/templates/template') as $templates) {
             $arr2 = array();
             foreach ($templates[0]->children() as $element) {
                 $arr2[$element->getName()] = (string) $element;
             }
             $template = new \Jazzee\Entity\Template($arr2['type']);
             $template->setApplication($this->_application);
             $template->setTitle($arr2['title']);
             $template->setText($arr2['text']);
             $this->_em->persist($template);
         }
         foreach ($xml->xpath('/response/application/pages/page') as $element) {
             $attributes = $element->attributes();
             $page = $this->addPageFromXml($element);
             $applicationPage = new \Jazzee\Entity\ApplicationPage();
             $applicationPage->setApplication($this->_application);
             $applicationPage->setPage($page);
             $applicationPage->setKind((string) $attributes['kind']);
             $applicationPage->setName((string) $attributes['name']);
             $applicationPage->setTitle(html_entity_decode((string) $attributes['title']));
             $applicationPage->setMin((string) $attributes['min']);
             $applicationPage->setMax((string) $attributes['max']);
             if ((string) $attributes['required']) {
                 $applicationPage->required();
             } else {
                 $applicationPage->optional();
             }
             if ((string) $attributes['answerStatusDisplay']) {
                 $applicationPage->showAnswerStatus();
             } else {
                 $applicationPage->hideAnswerStatus();
             }
             $eattr = $element->xpath('instructions');
             $applicationPage->setInstructions((string) $eattr[0]);
             $eattr = $element->xpath('leadingText');
             $applicationPage->setLeadingText((string) $eattr[0]);
             $eattr = $element->xpath('trailingText');
             $applicationPage->setTrailingText((string) $eattr[0]);
             $applicationPage->setWeight((string) $attributes['weight']);
             $this->_em->persist($applicationPage);
         }
         $this->_em->persist($this->_application);
         $this->addMessage('success', 'Application imported successfully');
         unset($this->_store->AdminControllerGetNavigation);
     }
     $this->setVar('form', $form);
 }
Beispiel #6
0
 /**
  * Preview a page
  *
  * We use a fake page to construct a preview
  */
 public function actionPreviewPage()
 {
     $data = json_decode($this->post['data']);
     $page = new \Jazzee\Entity\Page();
     $this->genericPage($page, $data);
     $this->layout = 'blank';
     $applicant = new \Jazzee\Entity\Applicant();
     $applicant->setFirstName('John');
     $applicant->setLastName('Smith');
     $applicant->setMiddleName('T');
     $applicant->setSuffix('Jr.');
     $applicant->setEmail('*****@*****.**');
     $application = is_null($this->_application) ? new \Jazzee\Entity\Application() : $this->_application;
     $applicant->setApplication($application);
     $applicationPage = new \Jazzee\Entity\ApplicationPage();
     $applicationPage->setPage($page);
     $applicationPage->setApplication($application);
     $applicationPage->getJazzeePage()->setController($this);
     $applicationPage->getJazzeePage()->setApplicant($applicant);
     $this->setVar('page', $applicationPage);
     $this->setVar('applicant', $applicant);
 }