예제 #1
0
파일: Defaults.php 프로젝트: Jazzee/Jazzee
 /**
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
 {
     $entityManager = $this->getHelper('em')->getEntityManager();
     $output->write('<comment>Installing default components...</comment>' . PHP_EOL);
     $pageTypes = array('\\Jazzee\\Page\\Branching' => 'Branching', '\\Jazzee\\Page\\ETSMatch' => 'ETS Score Matching', '\\Jazzee\\Page\\Education' => 'Education', '\\Jazzee\\Page\\ExternalId' => 'External ID', '\\Jazzee\\Page\\Lock' => 'Lock Application', '\\Jazzee\\Page\\Payment' => 'Payment', '\\Jazzee\\Page\\QASAddress' => 'Address Verification QAS', '\\Jazzee\\Page\\Recommenders' => 'Recommenders', '\\Jazzee\\Page\\Standard' => 'Standard', '\\Jazzee\\Page\\Text' => 'Plain Text');
     foreach ($pageTypes as $class => $name) {
         $pageType = new \Jazzee\Entity\PageType();
         $pageType->setName($name);
         $pageType->setClass($class);
         $entityManager->persist($pageType);
     }
     $entityManager->flush();
     $output->write('<info>Default Page types added</info>' . PHP_EOL);
     $elementTypes = array('\\Jazzee\\Element\\CheckboxList' => 'Checkboxes', '\\Jazzee\\Element\\Date' => 'Date', '\\Jazzee\\Element\\EmailAddress' => 'Email Address', '\\Jazzee\\Element\\EncryptedTextInput' => 'Encrypted Text Input', '\\Jazzee\\Element\\PDFFileInput' => 'PDF Upload', '\\Jazzee\\Element\\Phonenumber' => 'Phone Number', '\\Jazzee\\Element\\RadioList' => 'Radio Buttons', '\\Jazzee\\Element\\RankingList' => 'Rank Order Dropdown', '\\Jazzee\\Element\\SearchList' => 'Search', '\\Jazzee\\Element\\SelectList' => 'Dropdown List', '\\Jazzee\\Element\\ShortDate' => 'Short Date', '\\Jazzee\\Element\\TextInput' => 'Single Line Text', '\\Jazzee\\Element\\Textarea' => 'Text Area', '\\Jazzee\\Element\\USSocialSecurityNumber' => 'US Social Security Number');
     foreach ($elementTypes as $class => $name) {
         $elementType = new \Jazzee\Entity\ElementType();
         $elementType->setName($name);
         $elementType->setClass($class);
         $entityManager->persist($elementType);
     }
     $entityManager->flush();
     $output->write('<info>Default Element types added</info>' . PHP_EOL);
     $role = new \Jazzee\Entity\Role();
     $role->makeGlobal();
     $role->setName('Administrator');
     $entityManager->persist($role);
     \Foundation\VC\Config::addControllerPath(__DIR__ . '/../../controllers/');
     foreach (array('admin', 'applicants', 'manage', 'scores', 'setup') as $path) {
         $path = \realpath(__DIR__ . '/../../controllers/' . $path);
         \Foundation\VC\Config::addControllerPath($path . '/');
         //scan the directory but drop the relative paths
         foreach (array_diff(scandir($path), array('.', '..')) as $fileName) {
             $controller = basename($fileName, '.php');
             \Foundation\VC\Config::includeController($controller);
             $class = \Foundation\VC\Config::getControllerClassName($controller);
             foreach (get_class_methods($class) as $method) {
                 if (substr($method, 0, 6) == 'action') {
                     $constant = 'ACTION_' . strtoupper(substr($method, 6));
                     if (defined("{$class}::{$constant}")) {
                         $roleAction = new \Jazzee\Entity\RoleAction();
                         $roleAction->setController($controller);
                         $roleAction->setAction(substr($method, 6));
                         $roleAction->setRole($role);
                         $entityManager->persist($roleAction);
                     }
                 }
             }
         }
     }
     $entityManager->flush();
     $output->write("<info>Administrator role created</info>" . PHP_EOL);
 }
예제 #2
0
 /**
  * Create a new pagetype
  */
 public function actionNew()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path('setup/roles/new'));
     $field = $form->newField();
     $field->setLegend('New program role');
     $element = $field->newElement('TextInput', 'name');
     $element->setLabel('Role Name');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\Safe($element));
     $form->newButton('submit', 'Add Role');
     $this->setVar('form', $form);
     if ($input = $form->processInput($this->post)) {
         $role = new \Jazzee\Entity\Role();
         $role->notGLobal();
         $role->setProgram($this->_program);
         $role->setName($input->get('name'));
         $this->_em->persist($role);
         $display = new \Jazzee\Entity\Display('role');
         $display->setRole($role);
         $display->setApplication($this->_application);
         $display->setName($role->getName() . ' display');
         foreach ($this->_user->getMaximumDisplayForApplication($this->_application)->listElements() as $userDisplayElement) {
             $displayElement = \Jazzee\Entity\DisplayElement::createFromDisplayElement($userDisplayElement, $this->_application);
             $display->addElement($displayElement);
             $this->getEntityManager()->persist($displayElement);
         }
         $this->_em->persist($display);
         $this->_em->flush();
         $this->addMessage('success', "Role Saved Successfully");
         $this->redirectPath('setup/roles');
     }
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
 /**
  * Create a new role
  */
 public function actionNew()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("manage/roles/new"));
     $field = $form->newField();
     $field->setLegend('New Global Role');
     $element = $field->newElement('TextInput', 'name');
     $element->setLabel('Role Name');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\Safe($element));
     $form->newButton('submit', 'Add Role');
     $this->setVar('form', $form);
     if ($input = $form->processInput($this->post)) {
         $role = new \Jazzee\Entity\Role();
         $role->makeGlobal();
         $role->setName($input->get('name'));
         $this->_em->persist($role);
         $this->addMessage('success', "Role Saved Successfully");
         $this->redirectPath('manage/roles');
     }
 }