Add your application-wide methods in the class below, your controllers will inherit them.
Inheritance: extends Controller
Esempio n. 1
0
 /**
  * Build SEO title
  *
  * @param string $pageTitle Title of the current item/page/posts...
  */
 function title($pageTitle = null)
 {
     if (!is_object($this->controller)) {
         return;
     }
     if (!$pageTitle) {
         $pageTitle = $this->controller->pageTitle;
     }
     if (!$pageTitle) {
         $pageTitle = ucwords($this->controller->params['controller']);
     }
     $description = Configure::read('AppSettings.description');
     $nameAndDescription = hsc(Configure::read('AppSettings.site_name'));
     if ($description) {
         $description = hsc($description);
         $nameAndDescription = "{$nameAndDescription} - {$description}";
     }
     if ($this->controller->isHome) {
         $this->controller->pageTitle = $nameAndDescription;
     } else {
         $this->controller->pageTitle = "{$pageTitle} • {$nameAndDescription}";
     }
     $this->controller->set('page_title_for_layout', $pageTitle);
     $this->controller->set('site_title_for_layout', $nameAndDescription);
 }
Esempio n. 2
0
 function modify()
 {
     global $lll, $siteDemo, $allowedMethods;
     $found = FALSE;
     if ($siteDemo || !class_exists('rss')) {
         // It is disabled to save these attributes in the demo version:
         foreach (array("extraHead", "extraBody", "extraTopContent", "extraBottomContent", "extraFooter", "logoImage", "headerBackground") as $attr) {
             if (!empty($this->{$attr})) {
                 $found = TRUE;
                 $this->{$attr} = "";
             }
         }
     }
     foreach (array("homeLocation", "redirectFirstLogin", "redirectLogin", "redirectAdminLogin") as $attr) {
         $ctrl = new AppController();
         if ($this->{$attr}) {
             if (!$ctrl->init($this->{$attr}) || !isset($allowedMethods[$ctrl->method]) || !class_exists($ctrl->getClass())) {
                 return Roll::setFormInvalid("invalidInternalLink", $this->{$attr});
             }
         }
     }
     modify($this);
     $this->uploadImages();
     if ($found) {
         Roll::setInfoText("This feature is not available in the Lite (and demo) version of the program!");
     }
 }
Esempio n. 3
0
 function beforeFilter()
 {
     $this->Auth->allow('logout', 'reg', 'password_reset', 'view', 'acoset', 'aroset', 'permset', 'buildAcl');
     parent::beforeFilter();
     $this->Auth->autoRedirect = false;
     //debug($this->Session->read() );
 }
Esempio n. 4
0
 /**
  * Displays a view
  *
  * @param mixed What page to display
  * @access public
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     if (isset($this->Auth)) {
         $this->Auth->allow('display');
     }
 }
Esempio n. 5
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     // what pages are allowed for non-logged-in users
     $this->Auth->allow('xml');
     $this->Auth->allow('csv');
     $this->Auth->allow('nids');
     $this->Auth->allow('hids_md5');
     $this->Auth->allow('hids_sha1');
     $this->Auth->allow('text');
     $this->Auth->allow('dot');
     $this->Auth->allow('restSearch');
     $this->Auth->allow('stix');
     // TODO Audit, activate logable in a Controller
     if (count($this->uses) && $this->{$this->modelClass}->Behaviors->attached('SysLogLogable')) {
         $this->{$this->modelClass}->setUserData($this->activeUser);
     }
     // convert uuid to id if present in the url, and overwrite id field
     if (isset($this->params->query['uuid'])) {
         $params = array('conditions' => array('Event.uuid' => $this->params->query['uuid']), 'recursive' => 0, 'fields' => 'Event.id');
         $result = $this->Event->find('first', $params);
         if (isset($result['Event']) && isset($result['Event']['id'])) {
             $id = $result['Event']['id'];
             $this->params->addParams(array('pass' => array($id)));
             // FIXME find better way to change id variable if uuid is found. params->url and params->here is not modified accordingly now
         }
     }
     // if not admin or own org, check private as well..
     if (!$this->_isSiteAdmin()) {
         $this->paginate = Set::merge($this->paginate, array('conditions' => array("OR" => array(array('Event.org =' => $this->Auth->user('org')), "AND" => array(array('Event.distribution >' => 0), Configure::read('MISP.unpublishedprivate') ? array('Event.published =' => 1) : array())))));
     }
 }
 public function beforeFilter()
 {
     parent::beforeFilter();
     $this->Auth->allow();
     $this->set('logged_user', $this->Auth->user());
     $this->layout = 'cultural';
 }
 public function __construct()
 {
     parent::__construct();
     $this->TiposPagamento = new TiposPagamento();
     $this->SituacaoConta = new SituacaoConta();
     $this->layout = 'painel';
 }
Esempio n. 8
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     if ($this->action == 'admin_edit') {
         $this->Security->disabledFields = array('alias');
     }
 }
 public function beforeRender()
 {
     AppController::beforeRender();
     $subMenu = array(array("Autorisations", array('controller' => 'Autorisation', 'action' => 'index'), $this->params['action'] == 'index'), array("Membres", array('controller' => 'Autorisation', 'action' => 'members'), $this->params['action'] == 'members'));
     $this->set('subMenu', $subMenu);
     $this->layout = 'connected';
 }
 function beforeFilter()
 {
     parent::beforeFilter();
     // $this->Auth->allow('*');
     //$this->set('menuTab', 'kelas');
     //$this->set('menuTabChild', 'kuis');
 }
Esempio n. 11
0
 function beforeRender()
 {
     parent::beforeRender();
     $this->set('service_titles', $this->service_titles);
     $this->set('service_status', $this->service_status);
     $this->set('service_schedule', $this->service_schedule);
 }
 /**
  * Get request object for current request. Returns null if no request is available 
  * (if, for example, the plugin is being run in a batch script - scripts don't use the request/response model)
  *
  * @return Request object or null if no request object is available
  */
 public function getRequest()
 {
     if (($o_app = AppController::getInstance()) && ($o_req = $o_app->getRequest())) {
         return $o_req;
     }
     return null;
 }
 /**
  * beforeFilter
  *
  * @return void
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     if (!empty($this->siteConfigs['editor']) && $this->siteConfigs['editor'] != 'none') {
         $this->helpers[] = $this->siteConfigs['editor'];
     }
 }
 public function beforeFilter()
 {
     parent::beforeFilter();
     // We're doing a backend request, require backend access
     $this->requireBackend();
     $this->set('at_backendpanel', true);
 }
Esempio n. 15
0
 /**
  * Displays a view
  *
  * @return void
  * @throws NotFoundException When the view file could not be found
  *	or MissingViewException in debug mode.
  */
 function beforeFilter()
 {
     parent::beforeFilter();
     $this->layout = 'homepage';
     //allows pages without auth so you dont have 2 login :):):):):):)
     $this->Auth->allow('display');
 }
 /**
  * isAuthorized Method
  * Allows Hippa Admin to Add, Edit, Delete Everything
  * Client Managers & MU MAnagers can only Add Edit Delete to their own group
  * Users cannot see
  * @return void
  */
 public function isAuthorized($user)
 {
     $group = $this->Session->read('Auth.User.group_id');
     // Test group role. Is admin?
     $client = $this->Session->read('Auth.User.client_id');
     // Test Client.
     $acct = $this->Session->read('Auth.User.Client.account_type');
     // Get account type
     if ($group == 2) {
         if (in_array($this->action, array('index', 'view', 'add'))) {
             // Allow Managers to Add
             return true;
         }
         if (in_array($this->action, array('edit', 'delete', 'sendFile'))) {
             // Allow Managers to Edit, delete their own
             $id = $this->request->params['pass'][0];
             if ($this->BusinessAssociateAgreement->isOwnedBy($id, $client)) {
                 return true;
             }
         }
     }
     if ($group == 3 || $acct == 'Initial') {
         $this->Session->setFlash('You are not authorized to view that!');
         $this->redirect(array('controller' => 'dashboard', 'action' => 'index'));
         return false;
     }
     return parent::isAuthorized($user);
 }
Esempio n. 17
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     //親(Appcontroller)をふまえた上
     // ユーザー自身による登録とログアウトを許可する
     $this->Auth->allow('add', 'logout');
 }
Esempio n. 18
0
 public function isAuthorized($user)
 {
     if (isset($user['role']) && $user['role'] === 'storekeeper') {
         return true;
     }
     return parent::isAuthorized($user);
 }
 public function __construct()
 {
     parent::__construct();
     add_filter('wp_edit_nav_menu_walker', array(&$this, 'addMenuEditWalker'), 10, 2);
     add_action('wp_update_nav_menu_item', array(&$this, 'beforeSave'), 10, 3);
     add_filter('wp_setup_nav_menu_item', array(&$this, 'afterFind'));
 }
Esempio n. 20
0
 public function beforeFilter()
 {
     $this->RequestHandler->respondAs('json');
     $this->response->disableCache();
     $this->Auth->allow(array('view'));
     parent::beforeFilter();
 }
Esempio n. 21
0
 function beforeFilter()
 {
     parent::beforeFilter();
     if ('json' == $this->params['url']['ext']) {
         $this->RequestHandler->setContent('json', 'text/x-json');
     }
 }
Esempio n. 22
0
 /**
  * リダイレクト処理を行う
  * @param string $type	$this->redirectUrlのキーまたはURLを指定する
  * @param string $flashMessage リダイレクト先で表示したいメッセージ
  * @param boolean $forceRedirect 強制リダイレクトフラグ
  * @access private
  */
 function _redirect($type, $flashMessage = null, $forceRedirect = false)
 {
     $redirectFlag = $this->redirect;
     if ($redirectFlag === false && $forceRedirect === true) {
         $redirectFlag = true;
     }
     if ($redirectFlag) {
         $url = $type;
         if (isset($this->redirectUrl[$type])) {
             $url = $this->redirectUrl[$type];
             if (is_null($url)) {
                 return null;
             }
         }
         if (!is_null($flashMessage)) {
             $this->Session->setFlash($flashMessage);
         }
         $this->_controller->redirect($url);
     }
     if ($forceRedirect) {
         if (!is_null($flashMessage)) {
             $this->Session->setFlash($flashMessage);
         }
         $this->_controller->redirect($type);
     }
 }
 function beforeFilter()
 {
     parent::beforeFilter();
     if (!empty($this->Auth)) {
         $this->Auth->allowedActions = array();
     }
 }
 function beforeFilter()
 {
     $this->logo_dir_path = WWW_ROOT . 'img' . DS . 'logo' . DS;
     $this->logo_dir = '/img' . DS . 'logo' . DS;
     $this->set('title_for_layout', __('Configurazione', true));
     return parent::beforeFilter();
 }
Esempio n. 25
0
 public function __construct()
 {
     $this->redis = new Redis();
     if (!$this->redis->connect(AppConfig::getValue('redis_socket'))) {
         AppController::fatalError('unable to connect to Redis server');
     }
 }
Esempio n. 26
0
 public function isAuthorized($user = null)
 {
     $owner_allowed = array();
     $user_allowed = array();
     $admin_allowed = array_merge($owner_allowed, $user_allowed, array('display'));
     $developer_allowed = array_merge($admin_allowed, array());
     # All registered users can:
     if (in_array($this->action, $user_allowed)) {
         return true;
     }
     # Admin users can:
     // if ($user['rol'] === 'admin')
     if ($user['Rol']['weight'] >= User::ADMIN) {
         if (in_array($this->action, $admin_allowed)) {
             return true;
         }
     }
     # Developer users can:
     if ($user['Rol']['weight'] >= User::DEVELOPER) {
         if (in_array($this->action, $developer_allowed)) {
             return true;
         }
     }
     # The owner of an user can:
     if (in_array($this->action, $owner_allowed)) {
         $userId = $this->request->params['pass'][0];
         if ($this->Event->isOwnedBy($userId, $user['id'])) {
             return true;
         }
     }
     return parent::isAuthorized($user);
 }
Esempio n. 27
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     // Update current semester, if needed
     if (date('m') < 5) {
         // Winter semester
         $this->currentSemester = date('Y') . '01';
     } elseif (date('m') < 9) {
         // Summer semester
         $this->currentSemester = date('Y') . '05';
     } else {
         // Autumn semester
         $this->currentSemester = date('Y') . '09';
     }
     if ($this->Session->read('Registration.semester') != '') {
         $this->registrationSemester = $this->Session->read('Registration.semester');
     } else {
         $this->registrationSemester = '201501';
         $this->Session->write('Registration.semester', $this->registrationSemester);
     }
     // If unregistration is still possible for current semester, add it to the registration semesters list
     if (!in_array($this->currentSemester, $this->registrationSemesters) && $this->deadlines[$this->currentSemester]['drop_fee'] >= date('Ymd')) {
         $this->registrationSemesters[] = $this->currentSemester;
         sort($this->registrationSemesters);
     }
 }
Esempio n. 28
0
 private function _createFromReflection($projectName)
 {
     $this->_name = $projectName;
     $this->_dir = \Fstab::instance()->projectDirectory($projectName);
     $controllerBasePath = rtrim(\Path::instance()->evaluate(":{$this->_name}.apps.controller"), "/\\");
     foreach (glob($controllerBasePath . "/*.php") as $filePath) {
         $fileName = pathinfo($filePath, PATHINFO_FILENAME);
         $controllerClassName = $fileName . 'Controller';
         if (!class_exists($controllerClassName)) {
             require $filePath;
         }
         if (class_exists($controllerClassName)) {
             $reflection = new \ReflectionClass($controllerClassName);
             $this->_controllers[] = AppController::create($this, $reflection);
         }
     }
     $spiritBasePath = rtrim(\Path::instance()->evaluate(":{$this->_name}.spiritPath"), "/\\");
     foreach (glob($spiritBasePath . "/*", GLOB_ONLYDIR) as $dirName) {
         $spiritName = pathinfo($dirName, PATHINFO_FILENAME);
         $spiritFileName = rtrim($dirName, "/\\") . '/abstractor.php';
         $spiritAbstractorClassName = $spiritName . 'Abstractor';
         if (!class_exists($spiritAbstractorClassName) && file_exists($spiritFileName)) {
             require $spiritFileName;
         }
         if (class_exists($spiritAbstractorClassName)) {
             $reflection = new \ReflectionClass($spiritAbstractorClassName);
             $this->_spirits[] = SpiritController::create($this, $reflection);
         }
     }
 }
Esempio n. 29
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     if (isset($this->Auth)) {
         $this->Auth->allow('index', 'view');
     }
 }
Esempio n. 30
0
 public static function dispatch($request = null)
 {
     $request = self::normalize($request);
     try {
         $class = Inflector::camelize($request['controller']) . 'Controller';
         $controller = Controller::load($class, true);
         return $controller->callAction($request);
     } catch (MissingControllerException $e) {
         if (Controller::hasViewForAction($request)) {
             $controller = new AppController();
             return $controller->callAction($request);
         } else {
             throw $e;
         }
     }
 }