/** * breadcrumb function * Create breadcrumb * @return string * @author joharijumali **/ public static function breadcrumb() { $Menu = Admin_Menu::menuGenerator(); $butternbread = array(); foreach ($Menu as $floor => $packet) { foreach ($packet->page->action as $key => $action) { if ($packet->packet == Str::lower(URI::segment(1)) && $packet->controller->name == Str::lower(URI::segment(2)) && $action->name == Str::lower(URI::segment(3)) || URI::segment(3) == NULL && $action->name == $packet->controller->name && Str::lower(URI::segment(2)) == $packet->controller->name) { $butternbread[Str::upper($packet->controller->alias)] = '#'; array_push($butternbread, Str::title($action->alias)); } } } return Breadcrumb::create($butternbread); }
/** * beforeFilter function called before filter * * @access public * @return void */ public function beforeFilter() { $timezone = $this->SysParameter->findByParameterCode('system.timezone'); // default to UTC if no timezone is set if (!(empty($timezone) || empty($timezone['SysParameter']['parameter_value']))) { $timezone = $timezone['SysParameter']['parameter_value']; // check that the timezone is valid if (isset($this->validTZ[$timezone])) { date_default_timezone_set($timezone); } else { $this->Session->setFlash(__('An invalid timezone is provided, please edit "system.timezone"', true)); } } $this->Auth->autoRedirect = false; // backward compatible with original ipeer hash method Security::setHash('md5'); Configure::write('Security.salt', ''); $locale = $this->SysParameter->findByParameterCode('display.locale'); // default to eng if no locale is set if (!(empty($locale) || empty($locale['SysParameter']['parameter_value']))) { $locale = $locale['SysParameter']['parameter_value']; // TODO: check that the locale is valid Configure::write('Config.language', $locale); } else { Configure::write('Config.language', 'eng'); } // if we have a session transfered to us if ($this->_hasSessionTransferData()) { if ($this->_authenticateWithSessionTransferData()) { if (method_exists($this, '_afterLogin')) { $this->_afterLogin(false); } } else { $this->Session->setFlash($this->Auth->loginError, $this->Auth->flashElement, array(), 'auth'); } } // store user in the singleton for global access User::store($this->Auth->user()); $this->breadcrumb = Breadcrumb::create(); if ($this->Auth->isAuthorized()) { // check if the user has permission to access the controller/action $permission = array_filter(array('controllers', ucwords($this->params['plugin']), ucwords($this->params['controller']), $this->params['action'])); if (!User::hasPermission(join('/', $permission))) { $this->Session->setFlash('Error: You do not have permission to access the page.'); $this->redirect('/home'); return; } $this->_checkSystemVersion(); } // for setting up google analytics $trackingId = $this->SysParameter->findByParameterCode('google_analytics.tracking_id'); $domain = $this->SysParameter->findByParameterCode('google_analytics.domain'); $customLogo = $this->SysParameter->findByParameterCode('banner.custom_logo'); $this->set('trackingId', $trackingId); $this->set('domain', $domain); $this->set('customLogo', $customLogo); parent::beforeFilter(); }