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; }
?> > <?php if (!is_null($element->getInstructions())) { echo '<p class="instructions">' . $element->getInstructions() . '</p>'; } ?> <div class='element yui-gf'> <div class='yui-u first label'> <?php if (!is_null($element->getLabel())) { echo '<label for="' . $element->getName() . '">' . $element->getLabel() . ':</label> '; } ?> </div> <div class='yui-u control'> <?php $view = \Foundation\VC\Config::findElementCacading(get_class($element), '', '.control'); $this->renderElement($view, array('element' => $element)); ?> <?php foreach ($element->getMessages() as $message) { echo "<p class='message'>{$message}</p>"; } if (!is_null($element->getFormat())) { echo '<p class="format">' . $element->getFormat() . '</p>'; } ?> </div> </div> </div>
/** * 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; }
/** * 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); }
\Foundation\VC\Config::addControllerPath(__DIR__ . '/controllers/apply/'); \Foundation\VC\Config::addControllerViewPath(__DIR__ . '/views/apply/'); //Load admin controllers and views \Foundation\VC\Config::addControllerPath(__DIR__ . '/controllers/admin/'); \Foundation\VC\Config::addControllerViewPath(__DIR__ . '/views/admin/'); //Load manage controllers and views \Foundation\VC\Config::addControllerPath(__DIR__ . '/controllers/manage/'); \Foundation\VC\Config::addControllerViewPath(__DIR__ . '/views/manage/'); //Load payments controllers and views \Foundation\VC\Config::addControllerPath(__DIR__ . '/controllers/payments/'); \Foundation\VC\Config::addControllerViewPath(__DIR__ . '/views/payments/'); //Load setup controllers and views \Foundation\VC\Config::addControllerPath(__DIR__ . '/controllers/setup/'); \Foundation\VC\Config::addControllerViewPath(__DIR__ . '/views/setup/'); //Load applicants controllers and views \Foundation\VC\Config::addControllerPath(__DIR__ . '/controllers/applicants/'); \Foundation\VC\Config::addControllerViewPath(__DIR__ . '/views/applicants/'); //Load scores controllers and views \Foundation\VC\Config::addControllerPath(__DIR__ . '/controllers/scores/'); \Foundation\VC\Config::addControllerViewPath(__DIR__ . '/views/scores/'); \Foundation\VC\Config::setViewClassName('\\Jazzee\\View'); \Foundation\VC\Config::setDefaultControllerName('error'); \Foundation\VC\Config::setDefaultControllerActionName('index'); \Foundation\VC\Config::setDefaultControllerActionParams(array('error' => 404, 'message' => 'Sorry the page you are looking for could not be found.')); //add the builtin admin controller directories \Jazzee\AdminController::addControllerPath(__DIR__ . '/controllers/manage'); \Jazzee\AdminController::addControllerPath(__DIR__ . '/controllers/payments'); \Jazzee\AdminController::addControllerPath(__DIR__ . '/controllers/setup'); \Jazzee\AdminController::addControllerPath(__DIR__ . '/controllers/scores'); \Jazzee\AdminController::addControllerPath(__DIR__ . '/controllers/applicants'); \Jazzee\AdminController::addControllerPath(__DIR__ . '/controllers/admin');