Example #1
0
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report5Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_REPORTPLANKIND');
     $e = new Zend_Form_Element_Select('reportplankind', array('label' => 'Звіт/план', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUFORM', false);
     $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUBASIS', false);
     $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRYTYPE', true);
     $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     if (@(!$this->params['establishment'])) {
         $e = new Zend_Form_Element_Checkbox('indpapers', array('label' => 'Індивідуальні аркуші'));
         $form->addElement($e);
     }
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 5));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
 /**
  * Initialize controller
  *
  * @return void
  */
 function init()
 {
     $this->db = Zend_Registry::get('db');
     $this->logger = Zend_Registry::get('logger');
     $this->config = Zend_Registry::get('config');
     $this->viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
 }
Example #3
0
 protected function _initView()
 {
     // Start initail view
     $this->bootstrap('layout');
     $config = $this->getOption('views');
     $resources = $this->getOption('resources');
     $view = new Zend_View();
     if (isset($resources['layout']['layoutPath'])) {
         $view->assign('layoutRootPath', $resources['layout']['layoutPath']);
     }
     $this->bootstrap('db');
     Zend_Loader::loadClass('Ht_Utils_SystemSetting');
     $sysSetting = Ht_Utils_SystemSetting::getSettings();
     $view->assign('sysSetting', $sysSetting);
     $view->assign('profile', Zend_Auth::getInstance()->getIdentity());
     Zend_Loader::loadClass("Ht_Model_SystemSetting");
     $this->setSystemLogConfiguration($sysSetting);
     // use the viewrenderer to keep the code DRY
     // instantiate and add the helper in one go
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     $viewRenderer->setView($view);
     $viewRenderer->setViewSuffix('phtml');
     // add it to the action helper broker
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     /**
      * Set inflector for Zend_Layout
      */
     $inflector = new Zend_Filter_Inflector(':script.:suffix');
     $inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml'));
     // Initialise Zend_Layout's MVC helpers
     $this->getResource('layout')->setLayoutPath(realpath($resources['layout']['layoutPath']))->setView($view)->setContentKey('content')->setInflector($inflector);
     return $this->getResource('layout')->getView();
 }
Example #4
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $loginController = 'authentication';
     $loginAction = 'login';
     $auth = Zend_Auth::getInstance();
     // If user is not logged in and is not requesting login page
     // - redirect to login page.
     if (!$auth->hasIdentity() && $request->getControllerName() != $loginController && $request->getActionName() != $loginAction) {
         $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
         $redirector->gotoSimpleAndExit($loginAction, $loginController);
     }
     // User is logged in or on login page.
     if ($auth->hasIdentity()) {
         // Is logged in
         // Let's check the credential
         $acl = new Tynex_Models_TynexAcl();
         $identity = $auth->getIdentity();
         // role is a column in the user table (database)
         $isAllowed = $acl->isAllowed($identity->role, $request->getControllerName(), $request->getActionName());
         if (!$isAllowed) {
             $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
             $redirector->gotoUrlAndExit('/');
         }
     }
 }
Example #5
0
 public function init()
 {
     $bootstrap = $this->getBootstrap();
     $bootstrap->bootstrap('FrontController');
     $bootstrap->bootstrap('View');
     $bootstrap->bootstrap('Layout');
     $front = $bootstrap->getResource('FronController');
     Zend_Controller_Action_HelperBroker::addPrefix('Bc_Controller_Action_Helper');
     $bootstrap->bootstrap('Doctrine');
     $manager = Zend_Registry::get('db_manager');
     $options = $this->getOptions();
     if (!isset($options[self::OPTION_PLUGINS_PATH])) {
         throw new Exception('Bad Config! pluginsPath shoud be setted');
     }
     $pluginManager = Bc_Application_Plugin_Manager::getInstance();
     $pluginManager->setPluginsPath($options[self::OPTION_PLUGINS_PATH]);
     $pluginManager->initializePlugins();
     if (!isset($options[self::OPTION_THEMES_PATH])) {
         throw new Exception('Bad Config! themesPath shoud be setted');
     }
     $themesManager = Bc_Application_Theme_Manager::getInstance();
     $themesManager->setThemesPath($options[self::OPTION_THEMES_PATH]);
     $themesManager->setView($bootstrap->getResource('View'));
     $themesManager->setActiveThemeName('minimal');
     $themesManager->setLayout($bootstrap->getResource('Layout'));
     $themesManager->initializeTheme();
 }
Example #6
0
 public function doRequest($request)
 {
     // redirector should not exit
     $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $redirector->setExit(false);
     // json helper should not exit
     $json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $zendRequest = new \Zend_Controller_Request_HttpTestCase();
     $zendRequest->setMethod($request->getMethod());
     $zendRequest->setCookies($request->getCookies());
     $zendRequest->setParams($request->getParameters());
     // Sf2's BrowserKit does not distinguish between GET, POST, PUT etc.,
     // so we set all parameters in ZF's request here to not break apps
     // relying on $request->getPost()
     $zendRequest->setPost($request->getParameters());
     $zendRequest->setRawBody($request->getContent());
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($this->extractHeaders($request));
     $_FILES = $this->remapFiles($request->getFiles());
     $_SERVER = array_merge($_SERVER, $request->getServer());
     $zendResponse = new \Zend_Controller_Response_HttpTestCase();
     $this->front->setRequest($zendRequest)->setResponse($zendResponse);
     ob_start();
     try {
         $this->bootstrap->run();
     } catch (\Exception $e) {
         ob_end_clean();
         throw $e;
     }
     ob_end_clean();
     $this->zendRequest = $zendRequest;
     $response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $this->formatResponseHeaders($zendResponse));
     return $response;
 }
 public function authenticate($type, $role, $module, $controller, $action)
 {
     // escape error handler
     $front = Zend_Controller_Front::getInstance();
     $params = array($type, $role, $module, $controller, $action);
     $count = count($params);
     $plugins = new Base_Php_Overloader($front->getParam("bootstrap")->getOption('plugins'));
     $errorModule = $plugins->errorHandler->params->module;
     $errorController = $plugins->errorHandler->params->controller;
     $errorAction = $plugins->errorHandler->params->action;
     $redirecting = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     /*
      * the conditions are for to be passed or redirected, default is passed
      * array(typeCondition, roleCondition, moduleCondition, controllerCondition, actionCondition, redirectOrNot, url)
      * order by typeCondition ASC, roleCondition ASC, moduleCondition ASC, controllerCondition ASC, actionCondition ASC
      */
     $permission = array(array(null, null, $errorModule, $errorController, $errorAction, FALSE, null), array(Auth_Constant_Server::GUEST_TYPE, null, 'admin', 'index', 'login', false, null), array(Auth_Constant_Server::GUEST_TYPE, null, 'admin', 'index', 'logout', true, '/admin/index/login'), array(Auth_Constant_Server::GUEST_TYPE, null, 'admin', null, null, true, '/admin/index/login'), array(Auth_Constant_Server::ADMIN_TYPE, null, 'admin', 'index', 'login', true, '/admin'), array(null, null, 'home', null, null, false, null));
     foreach ($permission as $permission) {
         for ($i = 0; $i <= 4; $i++) {
             if (isset($permission[$i]) && $params[$i] != $permission[$i]) {
                 continue 2;
             }
         }
         if ($permission[5] == true) {
             $redirecting->gotoUrl($permission[6])->redirectAndExit();
         }
         // if a rule is matched, not check remain rules
         return;
     }
 }
Example #8
0
 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $sysCache = $registry->get("sysCache");
     $cacheFiles = new Ml_Cache_Files($sysCache);
     Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/controllers/helpers');
     $frontController = $this->getBootstrap()->getResource('FrontController');
     $dispatcher = $frontController->getDispatcher();
     $request = $frontController->getRequest();
     $router = $frontController->getRouter();
     $router->removeDefaultRoutes();
     $compat = new Zend_Controller_Router_Route_Module(array(), $dispatcher, $request);
     $router->addRoute(HOST_MODULE, $compat);
     $routerConfig = $cacheFiles->getConfigIni(APPLICATION_PATH . '/configs/' . HOST_MODULE . 'Routes.ini');
     $router->addConfig($routerConfig, "apiroutes");
     Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/modules/' . HOST_MODULE . '/controllers/helpers');
     $loadOauthStore = Zend_Controller_Action_HelperBroker::getStaticHelper("LoadOauthstore");
     $loadOauthStore->setinstance();
     $loadOauthStore->preloadServer();
     $frontController->setBaseUrl($config['apiroot'])->setParam('noViewRenderer', true)->addModuleDirectory(APPLICATION_PATH . '/modules')->addControllerDirectory(APPLICATION_PATH . '/modules/' . HOST_MODULE . '/controllers');
     $response = new Zend_Controller_Response_Http();
     if (filter_input(INPUT_GET, "responseformat", FILTER_UNSAFE_RAW) == 'json') {
         $contentType = 'application/json';
     } else {
         $contentType = 'text/xml';
     }
     $response->setHeader('Content-Type', $contentType . '; charset=utf-8', true);
     $frontController->setResponse($response);
 }
Example #9
0
 public function restContext()
 {
     if (!$this->getAutoSerialization()) {
         return;
     }
     $view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view;
     if ($view instanceof Zend_View_Interface) {
         if (method_exists($view, 'getVars')) {
             $vars = $view->getVars();
             if (isset($vars['apiresults'])) {
                 $data = $vars['apiresults'];
                 if (count($data) !== 0) {
                     $serializer = new $this->_availableAdapters[$this->_currentContext]();
                     $body = $serializer->serialize($data);
                     if ($this->_currentContext == 'xml') {
                         $stylesheet = $this->getRequest()->getHeader('X-XSL-Stylesheet');
                         if ($stylesheet !== false and !empty($stylesheet)) {
                             $body = str_replace('<?xml version="1.0"?>', sprintf('<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="%s"?>', $stylesheet), $body);
                         }
                     }
                     if ($this->_currentContext == 'json') {
                         $callback = $this->getRequest()->getParam('jsonp-callback', false);
                         if ($callback !== false and !empty($callback)) {
                             $body = sprintf('%s(%s)', $callback, $body);
                         }
                     }
                     if ($this->_currentContext == 'html') {
                         $body = self::prettyPrint($body, array('format' => 'html'));
                     }
                     $this->getResponse()->setBody($body);
                 }
             }
         }
     }
 }
 /**
  * Gets content panel for the Debugbar
  *
  * @return string
  */
 public function getPanel()
 {
     $this->_request = Zend_Controller_Front::getInstance()->getRequest();
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
     if ($viewRenderer->view && method_exists($viewRenderer->view, 'getVars')) {
         $viewVars = $this->_cleanData($viewRenderer->view->getVars());
     } else {
         $viewVars = "No 'getVars()' method in view class";
     }
     $vars = '<div style="width:50%;float:left;">';
     $vars .= '<h4>View variables</h4>' . '<div id="ZFDebug_vars" style="margin-left:-22px">' . $viewVars . '</div>' . '<h4>Request parameters</h4>' . '<div id="ZFDebug_requests" style="margin-left:-22px">' . $this->_cleanData($this->_request->getParams()) . '</div>';
     $vars .= '</div><div style="width:45%;float:left;">';
     if ($this->_request->isPost()) {
         $vars .= '<h4>Post variables</h4>' . '<div id="ZFDebug_post" style="margin-left:-22px">' . $this->_cleanData($this->_request->getPost()) . '</div>';
     }
     $vars .= '<h4>Constants</h4>';
     $constants = get_defined_constants(true);
     ksort($constants['user']);
     $vars .= '<div id="ZFDebug_constants" style="margin-left:-22px">' . $this->_cleanData($constants['user']) . '</div>';
     $registry = Zend_Registry::getInstance();
     $vars .= '<h4>Zend Registry</h4>';
     $registry->ksort();
     $vars .= '<div id="ZFDebug_registry" style="margin-left:-22px">' . $this->_cleanData($registry) . '</div>';
     $cookies = $this->_request->getCookie();
     $vars .= '<h4>Cookies</h4>' . '<div id="ZFDebug_cookie" style="margin-left:-22px">' . $this->_cleanData($cookies) . '</div>';
     $vars .= '</div><div style="clear:both">&nbsp;</div>';
     return $vars;
 }
Example #11
0
 public function _initView()
 {
     $view = new Twig_Adapter_Zend();
     $view->setScriptPath(APPLICATION_PATH . '/views/scripts/');
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     $viewRenderer->setView($view);
 }
Example #12
0
 /**
  * Na podstawie wybranego helpera wyjścia, przetwarza dane do ostatecznego formatu i wysyła je.
  * @todo metoda do przerobienia - mało elastyczne rozwiązanie.
  * @param Common_Db_Adapter_ListResult $oResult - wyniki/dane do wysłania
  * @param string $helper - helper wyjścia Zend_Controller_Action_Helper_Abstract
  * @param string $sLayout - sciezka do pliku phtml
  */
 public function _out(Common_Db_Adapter_ListResult $oResult)
 {
     Zend_Controller_Action_HelperBroker::addPrefix('Common_Controller_Action_Helper');
     if ($this->_sHelper == null) {
         $this->_sHelper = Common_Response_Grid::OUT_TYPE_JSON;
     }
     if (($sParam = $this->_oRequest->getParam(Common_Response_Grid::REQUEST_OUT_PARAM, null)) && $sParam != null) {
         switch ($sParam) {
             case Common_Response_Grid::OUT_TYPE_JSON:
                 $oHelper = $this->_oController->getHelper($sParam);
                 $oHelper->direct($oResult);
                 break;
             case Common_Response_Grid::OUT_TYPE_CSV:
                 $oHelper = $this->_oController->getHelper($sParam);
                 $oHelper->direct($oResult);
                 break;
             case Common_Response_Grid::OUT_TYPE_HTML:
                 $oHelper = $this->_oController->getHelper($sParam);
                 $oHelper->direct($oResult, $this->_sLayout);
                 break;
             case Common_Response_Grid::OUT_TYPE_PDF:
                 $oHelper = $this->_oController->getHelper($sParam);
                 $oHelper->direct($oResult, $this->_sLayout);
                 break;
             default:
                 throw new Exception('Brak wyjscie -> ' . $sParam);
                 break;
         }
     } else {
         $oHelper = $this->_oController->getHelper($this->_sHelper);
         $oHelper->direct($oResult);
     }
 }
Example #13
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $flash = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
     $mvc = Zend_Layout::getMvcInstance();
     $view = $mvc->getView();
     $view->flashMessages = $flash->getMessages();
 }
 public function testMissingViewScriptDoesDoubleRender()
 {
     Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-91, new Zend_Controller_Action_Helper_ViewRenderer());
     // go to the test controller for this funcitonal test
     $this->dispatch('/zend-layout-functional-test-test/missing-view-script');
     $this->assertEquals(trim($this->response->getBody()), "[DEFAULT_LAYOUT_START]\n[DEFAULT_LAYOUT_START]\n[DEFAULT_LAYOUT_END]\n(ErrorController::errorAction output)[DEFAULT_LAYOUT_END]");
 }
Example #15
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $params = $request->getParams();
     $auth = Zend_Auth::getInstance();
     Zend_Registry::set('Zend_Auth', $auth);
     if ($auth->hasIdentity()) {
         $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
         $identity = $auth->getIdentity();
         $userDb = new Users_Model_DbTable_User();
         $user = array('id' => $identity->id, 'username' => $identity->username, 'name' => $identity->name, 'email' => $identity->email, 'clientid' => $identity->clientid);
         $authNamespace = new Zend_Session_Namespace('Zend_Auth');
         $authNamespace->user = $user['username'];
         if ($_SESSION['__ZF']['Zend_Auth']['ENT'] - time() < 3600) {
             $authNamespace->setExpirationSeconds(3600);
         }
         Zend_Registry::set('User', $user);
         $view->user = $user;
         $clientDb = new Application_Model_DbTable_Client();
         $client = $clientDb->getClient($user['clientid']);
         Zend_Registry::set('Client', $client);
     } elseif ($params['module'] != 'users' && $params['action'] != 'login') {
         $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
         if (isset($params['id']) && $params['id']) {
             $redirector->gotoSimple('login', 'user', 'users', array('url' => $params['module'] . '|' . $params['controller'] . '|' . $params['action'] . '|' . $params['id']));
         } else {
             $redirector->gotoSimple('login', 'user', 'users', array('url' => $params['module'] . '|' . $params['controller'] . '|' . $params['action']));
         }
     }
 }
Example #16
0
 protected function _initView()
 {
     $theme = 'default';
     $templatePath = APPLICATION_PATH . '/../public/themes/' . $theme . '/templates';
     Zend_Registry::set('user_date_format', 'm-d-Y');
     Zend_Registry::set('calendar_date_format', 'mm-dd-yy');
     Zend_Registry::set('db_date_format', 'Y-m-d');
     Zend_Registry::set('perpage', 10);
     Zend_Registry::set('menu', 'home');
     Zend_Registry::set('eventid', '');
     $dir_name = $_SERVER['DOCUMENT_ROOT'] . rtrim(str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']), '/');
     Zend_Registry::set('acess_file_path', $dir_name . SEPARATOR . "application" . SEPARATOR . "modules" . SEPARATOR . "default" . SEPARATOR . "plugins" . SEPARATOR . "AccessControl.php");
     Zend_Registry::set('siteconstant_file_path', $dir_name . SEPARATOR . "public" . SEPARATOR . "site_constants.php");
     Zend_Registry::set('emailconstant_file_path', $dir_name . SEPARATOR . "public" . SEPARATOR . "email_constants.php");
     Zend_Registry::set('emptab_file_path', $dir_name . SEPARATOR . "public" . SEPARATOR . "emptabconfigure.php");
     Zend_Registry::set('emailconfig_file_path', $dir_name . SEPARATOR . "public" . SEPARATOR . "mail_settings_constants.php");
     Zend_Registry::set('application_file_path', $dir_name . SEPARATOR . "public" . SEPARATOR . "application_constants.php");
     $date = new Zend_Date();
     Zend_Registry::set('currentdate', $date->get('yyyy-MM-dd HH:mm:ss'));
     Zend_Registry::set('currenttime', $date->get('HH:mm:ss'));
     Zend_Registry::set('logo_url', '/public/images/landing_header.jpg');
     $view = new Zend_View();
     $view->setEscape('stripslashes');
     $view->setBasePath($templatePath);
     $view->setScriptPath(APPLICATION_PATH);
     $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
     $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
     $viewRenderer->setView($view);
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     return $this;
 }
Example #17
0
 /**
  * Send email to all reviewers
  *
  * @return void
  */
 public function mailAction()
 {
     $request = $this->getRequest();
     $this->view->reminder = $reminder = $request->getParam('reminder');
     if (false == ($reviewers = $this->_reviewModel->getReviewersForMail($reminder))) {
         return;
     }
     $this->view->reviewers = count($reviewers);
     $this->view->dummy = $request->getParam('dummy');
     if (!$request->isPost()) {
         $this->view->mailForm = $this->_reviewModel->getForm('reviewMail');
         if ($reminder) {
             $this->view->mailForm->setAction('/core/review/mail/reminder/1');
         }
         return $this->render();
     }
     $conference = Zend_Registry::get('conference');
     Zend_Controller_Action_HelperBroker::addHelper(new TA_Controller_Action_Helper_SendEmail());
     $emailHelper = $this->_helper->sendEmail;
     $this->view->sent = array();
     $template = $reminder ? 'review/massmail-reminder' : 'review/massmail';
     foreach ($reviewers as $review) {
         $emailHelper->sendEmail(array('dummy' => $request->getParam('dummy'), 'template' => $template, 'html' => true, 'subject' => $conference['abbreviation'] . ' Review', 'to_email' => $review['email'], 'to_name' => $review['fname'] . ' ' . $review['lname']), $review);
         $this->view->sent[] = array('email' => $review['email']);
     }
     if ($this->view->dummy == 0) {
         $eventlogModel = new Core_Model_Eventlog();
         $eventlogModel->saveEventlog(array('event_type' => $reminder ? 'mail_reviewers-reminder' : 'mail_reviewers', 'timestamp' => 'now()'));
     }
 }
Example #18
0
 public static function run()
 {
     #echo get_include_path();
     #exit();
     try {
         // 設定ファイル読み込み
         $config = new Zend_Config_Ini(INSTALL_DIR . 'application/configs/config.ini', 'production');
         // Zend_Loader の設定(ファイル自動読み込み)
         require_once 'Zend/Loader/Autoloader.php';
         $loader = Zend_Loader_Autoloader::getInstance();
         $loader->setFallbackAutoloader(true);
         Zend_Registry::set($config->registry->config, $config);
         $view = new Tokyofr_View_Smarty($config->smarty->template_dir, $config->smarty->toArray());
         $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
         $viewRenderer->setView($view)->setViewBasePathSpec($view->getEngine()->template_dir[0]);
         $viewRenderer->setViewScriptPathSpec(':controller/:action.:suffix');
         $viewRenderer->setViewScriptPathNoControllerSpec(':action.:suffix');
         $viewRenderer->setViewSuffix('phtml');
         Tokyofr_Controller_Front::run($config->path->controller);
     } catch (Zend_Exception $e) {
         //var_dump($e->getMessage());
         exit("error.");
     } catch (Exception $e) {
         //var_dump($e->getMessage());
         exit('error02');
     }
 }
Example #19
0
 /**
  * @param Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $this->setSessionLifeTime();
     if (!in_array($request->getModuleName(), $this->modules)) {
         return;
     }
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $user = Zend_Registry::get('container')->getService('user')->getCurrentUser();
         if (!$user->isAdmin()) {
             // can't go into admin
             $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
             $redirector->direct('index', 'index', 'default');
         }
         // set user for application
         $GLOBALS['g_user'] = $user;
         Zend_Registry::set('user', $user);
         // set view user
         $view = Zend_Registry::get('view');
         $view->currentUser = $user;
         // set view navigation acl
         $acl = Zend_Registry::get('acl')->getAcl($user);
         /* @var $acl Zend_Acl */
         $view->navigation()->setAcl($acl);
         $view->navigation()->setRole($user);
         return;
     }
 }
Example #20
0
 /**
  *
  * @param Zend_Controller_Request_Abstract $request
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $options = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getApplication()->getOptions();
     $config = new Zend_Config($options);
     $acl = new My_Acl($config);
     $role = 'guest';
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $role = 'user';
         if (Zend_Auth::getInstance()->hasIdentity()) {
             return;
         } else {
             $login = Zend_Auth::getInstance()->getIdentity();
             $user = My_Model::get('Users')->getUserByEmail($login);
             if ($user->admin == 1) {
                 $role = 'admin';
             }
         }
     }
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $resource = $controller;
     $privilege = $action;
     if (!$acl->has($resource)) {
         $resource = null;
     }
     if (is_null($privilege)) {
         $privilege = 'index';
     }
     if (!$acl->isAllowed($role, $resource, $privilege)) {
         //            $flash = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
         //            $flash->addMessage('Access Denied');
         $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
         $redirector->gotoSimpleAndExit('login', 'admin');
     }
 }
Example #21
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $view = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer')->view;
     $locale = Zend_Registry::get('Zend_Locale');
     $view->locale = key($locale->getDefault());
     $view->date_format = Zend_Locale_Data::getContent($view->locale, 'date');
 }
 public function listAction()
 {
     $showAll = (int) $this->_getParam('showAll');
     $patientId = (int) $this->_getParam('patientId');
     $rows = array();
     $patientNote = new PatientNote();
     $patientNoteIterator = $patientNote->getIterator();
     $filters = array();
     $filters['patient_id'] = $patientId;
     $filters['posting'] = 1;
     if (!$showAll) {
         $filters['active'] = 1;
     }
     $patientNoteIterator->setFilters($filters);
     foreach ($patientNoteIterator as $note) {
         $tmp = array();
         $tmp['id'] = $note->patientNoteId;
         $tmp['data'][] = $note->priority;
         $tmp['data'][] = $note->noteDate;
         $tmp['data'][] = $note->user->username;
         $tmp['data'][] = $note->reason;
         $tmp['data'][] = $note->note;
         $tmp['data'][] = $note->active;
         $tmp['data'][] = $note->active;
         $rows[] = $tmp;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $rows));
 }
Example #23
0
    public static function display_success_message($namespace, $type)
    {
        ?>
    <script type="text/javascript">
        $(document).ready(function(){
<?php 
        $flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
        if ($flashMessenger->setNamespace($namespace)->hasMessages()) {
            foreach ($flashMessenger->getMessages() as $msg) {
                if ($type == 'success') {
                    ?>
                    successmessage('<?php 
                    echo trim($msg);
                    ?>
');                    
            <?php 
                } else {
                    ?>
        error_message('<?php 
                    echo trim($msg);
                    ?>
');
<?php 
                }
            }
            ?>
        <?php 
        }
        ?>
  
        });
    </script>
<?php 
    }
Example #24
0
 /**
  * Lazily fetches FlashMessenger Instance.
  *
  * @return Zend_Controller_Action_Helper_FlashMessenger
  */
 public function _getFlashMessenger()
 {
     if (NULL === $this->_flashMessenger) {
         $this->_flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
     }
     return $this->_flashMessenger;
 }
 public function __construct()
 {
     if ($this->_layoutService == null) {
         $serviceFinder = Zend_Controller_Action_HelperBroker::getStaticHelper('service');
         $this->_layoutService = $serviceFinder->getService('layout', 'layouts');
     }
 }
 public function postDispatch(Zend_Controller_Request_Abstract $request)
 {
     $layout = Zend_Layout::getMvcInstance();
     // the name "maintenanceMode" is also referred to in the Admin_MaintenanceController,
     // so if you change the filename, it needs to be changed there too
     $maintenanceModeFileName = 'maintenanceMode';
     $register = new Ot_Config_Register();
     $identity = Zend_Auth::getInstance()->getIdentity();
     $role = empty($identity->role) ? $register->defaultRole->getValue() : $identity->role;
     if (isset($identity->masquerading) && $identity->masquerading == true && isset($identity->realAccount) && !is_null($identity->realAccount) && isset($identity->realAccount->role)) {
         $role = $identity->realAccount->role;
     }
     $acl = Zend_Registry::get('acl');
     $view = $layout->getView();
     $viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer');
     if (is_file(APPLICATION_PATH . '/../overrides/' . $maintenanceModeFileName) && (!$request->isXmlHttpRequest() && !$viewRenderer->getNeverRender())) {
         if (!$acl->isAllowed($role, 'ot_maintenance', 'index')) {
             if (!($request->getModuleName() == 'ot' && $request->getControllerName() == 'login' && $request->getActionName() == 'index')) {
                 $response = $this->getResponse();
                 $layout->disableLayout();
                 $response->setBody($view->maintenanceMode()->publicLayout());
             }
         } else {
             $response = $this->getResponse();
             // there's no point in setting text here if it's a redirect
             if ($response->isRedirect()) {
                 $response->setBody('');
             } else {
                 $response->setBody($view->maintenanceMode()->header() . $response->getBody());
             }
         }
     }
 }
Example #27
0
 /**
  * Dispatch the requested action
  *
  * @param string $action Method name of action
  * @return void
  */
 public function dispatch($action)
 {
     // Notify helpers of action preDispatch state
     $this->_helper->notifyPreDispatch();
     $this->preDispatch();
     if ($this->getRequest()->isDispatched()) {
         if (null === $this->_classMethods) {
             $this->_classMethods = get_class_methods($this);
         }
         // If pre-dispatch hooks introduced a redirect then stop dispatch
         // @see ZF-7496
         if (!$this->getResponse()->isRedirect()) {
             // preDispatch() didn't change the action, so we can continue
             if ($this->getInvokeArg('useCaseSensitiveActions') || in_array($action, $this->_classMethods)) {
                 if ($this->getInvokeArg('useCaseSensitiveActions')) {
                     trigger_error('Using case sensitive actions without word separators is deprecated; please do not rely on this "feature"');
                 }
                 $this->{$action}();
             } else {
                 $this->__call($action, array());
             }
         }
         $this->postDispatch();
     }
     // whats actually important here is that this action controller is
     // shutting down, regardless of dispatching; notify the helpers of this
     // state
     $this->_helper->notifyPostDispatch();
 }
Example #28
0
 public function setUp()
 {
     // Make sure only our fake Helper is available
     Zend_Controller_Action_HelperBroker::resetHelpers();
     Zend_Controller_Action_HelperBroker::addHelper(new Waf_Zend_Controller_ActionTest_TestHelper());
     $this->controller = new Waf_Zend_Controller_Action($this->getMock('Zend_Controller_Request_Abstract'), $this->getMock('Zend_Controller_Response_Abstract'));
 }
Example #29
0
 /**
  * Defined by Zend_Application_Resource_Resource
  *
  * @return Zend_View
  */
 public function init()
 {
     $view = $this->getView();
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
     $viewRenderer->setView($view);
     return $view;
 }
 public function listAction()
 {
     $rows = array();
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $rows));
 }