public function actionIndex() { if ($this->semaphore()) { $this->setLimits(); $this->log('Cron run started'); foreach ($this->listControllers() as $controller) { \Foundation\VC\Config::includeController($controller); $class = \Foundation\VC\Config::getControllerClassName($controller); if (method_exists($class, 'runCron')) { if (self::VERBOSE_LOGS) { $this->log("Admin controller {$controller} job started"); } $class::runCron($this); $this->_em->flush(); } //reset the max execution time and memory limit after every admin script is included because some override this $this->setLimits(); } foreach ($this->_em->getRepository('\\Jazzee\\Entity\\PageType')->findAll() as $pageType) { $class = $pageType->getClass(); if (method_exists($class, 'runCron')) { if (self::VERBOSE_LOGS) { $this->log("Page type {$class} job started"); } $class::runCron($this); $this->_em->flush(); } $this->setLimits(); } foreach ($this->_em->getRepository('\\Jazzee\\Entity\\ElementType')->findAll() as $elementType) { $class = $elementType->getClass(); if (method_exists($class, 'runCron')) { if (self::VERBOSE_LOGS) { $this->log("Element type {$class} job started"); } $class::runCron($this); $this->_em->flush(); } $this->setLimits(); } //Perform applicant actions \Foundation\VC\Config::includeController('apply_applicant'); if (self::VERBOSE_LOGS) { $this->log("Controller apply_applicant job started"); } ApplyApplicantController::runCron($this); //File store actions \Jazzee\FileStore::runCron($this); //clear the semephore $this->setVar('adminCronSemephore', false); $this->log('Cron run finished'); } }
/** * @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); }
/** * Get some information */ public function actionIndex() { $result = false; if (!empty($this->post['service'])) { switch ($this->post['service']) { case 'checkIsAllowed': $this->setLayoutVar('status', 'success'); $result = $this->checkIsAllowed($this->post['controller'], $this->post['action']); break; case 'pathToController': $this->setLayoutVar('status', 'success'); \Foundation\VC\Config::includeController($this->post['controller']); if ($class = \Foundation\VC\Config::getControllerClassName($this->post['controller'])) { $result = $this->path($class::PATH); } break; case 'currentApplicationId': $result = $this->_application->getId(); break; case 'listDisplays': $this->setLayoutVar('status', 'success'); $result = $this->listDisplays(); break; case 'maximumDisplay': $this->setLayoutVar('status', 'success'); $userMaximumDisplay = $this->_user->getMaximumDisplayForApplication($this->_application); $result = array('type' => 'maximum', 'id' => $userMaximumDisplay->getId(), 'name' => $userMaximumDisplay->getName(), 'pageIds' => $userMaximumDisplay->getPageIds(), 'elementIds' => $userMaximumDisplay->getElementIds(), 'elements' => array()); foreach ($userMaximumDisplay->listElements() as $displayElement) { $result['elements'][] = array('type' => $displayElement->getType(), 'title' => $displayElement->getTitle(), 'weight' => $displayElement->getWeight(), 'name' => $displayElement->getName(), 'pageId' => $displayElement->getPageId()); } break; case 'currentApplication': if ($this->_application) { $this->setLayoutVar('status', 'success'); $result = $this->_em->getRepository('Jazzee\\Entity\\Application')->findArray($this->_application->getId()); } else { $this->setLayoutVar('status', 'error'); $this->addMessage('error', 'You do not have an application in this program and cycle. Or you have not selected a program or cycle.'); } break; default: $this->addMessage('error', 'Invalid service requested'); } } else { $this->addMessage('error', 'No service requested'); } $this->setVar('result', $result); }
/** * Get All of the possible controllers and actions * * only allow the ones the user has access to * @return array of ControllerAuths */ protected function getControllerActions() { $controllers = array(); foreach ($this->listControllers() as $controller) { \Foundation\VC\Config::includeController($controller); $class = \Foundation\VC\Config::getControllerClassName($controller); $arr = array('name' => $controller, 'title' => $class::TITLE, 'actions' => array()); foreach (get_class_methods($class) as $method) { if (substr($method, 0, 6) == 'action') { $constant = 'ACTION_' . strtoupper(substr($method, 6)); $actionName = strtolower(substr($method, 6)); if ($this->checkIsAllowed($controller, $actionName) and defined("{$class}::{$constant}")) { $arr['actions'][strtolower(substr($method, 6))] = constant("{$class}::{$constant}"); } } } if (!empty($arr['actions'])) { $controllers[$class::MENU][] = $arr; } } return $controllers; }
/** * Get Navigation */ public function getNavigation() { if (isset($this->_store->AdminControllerGetNavigation)) { return $this->_store->AdminControllerGetNavigation; } $navigation = new \Foundation\Navigation\Container(); $link = new \Foundation\Navigation\Link('Home'); $link->setHref($this->path('welcome')); $navigation->addLink($link); $menus = array(); foreach ($this->listControllers() as $controller) { if ($this->checkIsAllowed($controller)) { \Foundation\VC\Config::includeController($controller); $class = \Foundation\VC\Config::getControllerClassName($controller); if (!is_null($class::MENU)) { if (!isset($menus[$class::MENU])) { $menus[$class::MENU] = new \Foundation\Navigation\Menu(); $menus[$class::MENU]->setTitle($class::MENU); $navigation->addMenu($menus[$class::MENU]); } $link = new \Foundation\Navigation\Link($class::TITLE); $link->setHref($this->path($class::PATH)); $menus[$class::MENU]->addLink($link); } } } foreach ($menus as $menu) { $menu->sortLinks(); } if (empty($menus)) { return false; //if there are no controllers or no authorization there are no menus } $this->_store->AdminControllerGetNavigation = $navigation; return $navigation; }