/** * Start caching * * Determine if we have a cache hit. If so, return the response; else, * start caching. * * @param Zend_Controller_Request_Abstract $request * @return void */ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { $request = $this->getRequest(); // $request = new Zend_Controller_Request_Http(); $moduleName = $request->getModuleName(); $params = $request->getParams(); /** * On récupère la homeId uniquement si on arrive à la racine du site * @author GDE * @project Belgium Telecom * @since 10/01/2013 */ $pagstrDB = new Pagstructure(); if (count($params) == 3 && $params['module'] == 'publicms' && $params['controller'] == 'index' && $params['action'] == 'view') { $params['page'] = $pagstrDB->getHomeId(Sydney_Tools_Sydneyglobals::getSafinstancesId()); } if ($moduleName == 'publicms' && isset($params['page'])) { $pagstr = $pagstrDB->find($params['page']); if (count($pagstr) == 1) { /** * Enregistre en session le rootid courant * Utilisé pour savoir quel index de recherche utiliser * FAR: Utile aussi pour la séparation par langue * @author GDE * @project Belgium Telecom * @since 10/01/2013 */ $breadCrumData = $pagstrDB->getBreadCrumData(Sydney_Tools_Sydneyglobals::getSafinstancesId(), $this->_treatPageData($params['page'])); $rootid = $breadCrumData[0]['id']; $lucenesearch = new Zend_Session_Namespace('current-page-rootid'); if (!empty($rootid)) { $lucenesearch->rootid = $rootid; } $struct = $pagstr[0]; $struct->hits++; $struct->save(); if (!Sydney_Auth::getInstance()->hasIdentity() && $struct->iscachable != 0 && $struct->cachetime > 0) { $this->cache->setLifetime($struct->cachetime); if (!$request->isGet()) { self::$doNotCache = true; return; } $path = $request->getPathInfo(); $this->key = $moduleName . '_' . md5($path); if (false !== ($response = $this->getCache())) { $response->sendResponse(); exit; } } } } }
/** * Check the access rights agains the DB if we are in the publicms module * * @param $role * @return void */ private function checkRightsPublicms($role) { // check if instance is offline $safinstanceDB = new Safinstances(); $safinstances = $safinstanceDB->find($this->safinstancesId); if (count($safinstances) != 1) { print "FATAL ERROR 452 in Sydney_Controller_Plugin_Auth::checkRightsPublicms(" . $this->safinstancesId . ")"; header('Location: ' . Sydney_Tools_Paths::getRootUrlCdn() . '/install/instance/index.php/referrer/PluginAuth/checkRightsPublicms/noinstancefound'); exit; } elseif ($safinstances[0]->active == 0) { print $safinstances[0]->offlinemessage; if (empty($safinstances[0]->offlinemessage)) { print "This site is offline."; header('Location: ' . Sydney_Tools_Paths::getRootUrlCdn() . '/install/instance/index.php/referrer/PluginAuth/checkRightsPublicms'); } exit; } // get page data $d = $this->request->getParams(); if ($d['module'] == 'publicms' && $d['controller'] == 'index' && $d['action'] == 'view') { $nodes = new Pagstructure(); if (!isset($d['page']) || !preg_match("/^[0-9]{1,100}\$/", $d['page'])) { $nodeId = $nodes->getHomeId($this->safinstancesId); } else { $nodeId = $d['page']; } $node = $nodes->fetchAll(" id = '" . $nodeId . "' AND safinstances_id = '" . $this->safinstancesId . "' "); if (count($node) == 1) { $authorizedGroupId = $node[0]->usersgroups_id; if (!self::isContentAccessible($authorizedGroupId, $this->userNamespace->user['member_of_groups'])) { $this->redirecting('default', 'login', 'index', 'code04'); } } else { print "Node {$nodeId} not found! (FATAL ERROR 542 in Sydney_Controller_Plugin_Auth::checkRightsPublicms)"; header('Location: ' . Sydney_Tools_Paths::getRootUrlCdn() . '/install/instance/index.php/referrer/PluginAuth/checkRightsPublicms/nodenotfound'); exit; } } }
/** * Returns the ID of the home page for this SAF instance * @return int */ protected function _getPageId() { $nodes = new Pagstructure(); if (isset($this->getRequest()->slug)) { return $nodes->getIdBySlug($this->getRequest()->slug, $this->safinstancesId); } else { return $nodes->getHomeId($this->safinstancesId); } }
/** * Returns the ID of the home page for this SAF instance * @return int */ protected function _getPageId() { $pages = array(); $f = new Zend_Filter_Digits(); if (isset($this->getRequest()->page)) { foreach (preg_split('/,/', $this->getRequest()->page) as $page) { $pages[] = $f->filter($page); } } else { $nodes = new Pagstructure(); $pages[] = $nodes->getHomeId($this->safinstancesId); } return $pages; }