/** * Runs the dispatch loop */ protected function dispatchLoop() { $ini = eZINI::instance(); // Start the module loop while ($this->siteBasics['module-run-required']) { $objectHasMovedError = false; $objectHasMovedURI = false; $this->actualRequestedURI = $this->uri->uriString(); // Extract user specified parameters $userParameters = $this->uri->userParameters(); // Generate a URI which also includes the user parameters $this->completeRequestedURI = $this->uri->originalURIString(); // Check for URL translation if ($this->siteBasics['url-translator-allowed'] && eZURLAliasML::urlTranslationEnabledByUri($this->uri)) { $translateResult = eZURLAliasML::translate($this->uri); if (!is_string($translateResult) && $ini->variable('URLTranslator', 'WildcardTranslation') === 'enabled') { $translateResult = eZURLWildcard::translate($this->uri); } // Check if the URL has moved if (is_string($translateResult)) { $objectHasMovedURI = $translateResult; foreach ($userParameters as $name => $value) { $objectHasMovedURI .= '/(' . $name . ')/' . $value; } $objectHasMovedError = true; } } if ($this->uri->isEmpty()) { $tmp_uri = new eZURI($ini->variable("SiteSettings", "IndexPage")); $moduleCheck = eZModule::accessAllowed($tmp_uri); } else { $moduleCheck = eZModule::accessAllowed($this->uri); } if (!$moduleCheck['result']) { if ($ini->variable("SiteSettings", "ErrorHandler") == "defaultpage") { $defaultPage = $ini->variable("SiteSettings", "DefaultPage"); $this->uri->setURIString($defaultPage); $moduleCheck['result'] = true; } } $displayMissingModule = false; $this->oldURI = $this->uri; if ($this->uri->isEmpty()) { if (!fetchModule($tmp_uri, $this->check, $this->module, $moduleName, $functionName, $params)) { $displayMissingModule = true; } } else { if (!fetchModule($this->uri, $this->check, $this->module, $moduleName, $functionName, $params)) { if ($ini->variable("SiteSettings", "ErrorHandler") == "defaultpage") { $tmp_uri = new eZURI($ini->variable("SiteSettings", "DefaultPage")); if (!fetchModule($tmp_uri, $this->check, $this->module, $moduleName, $functionName, $params)) { $displayMissingModule = true; } } else { $displayMissingModule = true; } } } if (!$displayMissingModule && $moduleCheck['result'] && $this->module instanceof eZModule) { // Run the module/function eZDebug::addTimingPoint("Module start '" . $this->module->attribute('name') . "'"); $moduleAccessAllowed = true; $omitPolicyCheck = true; $runModuleView = true; $availableViewsInModule = $this->module->attribute('views'); if (!isset($availableViewsInModule[$functionName]) && !$objectHasMovedError && !isset($this->module->Module['function']['script'])) { $moduleResult = $this->module->handleError(eZError::KERNEL_MODULE_VIEW_NOT_FOUND, 'kernel', array("check" => $moduleCheck)); $runModuleView = false; $this->siteBasics['policy-check-required'] = false; $omitPolicyCheck = true; } if ($this->siteBasics['policy-check-required']) { $omitPolicyCheck = false; $moduleName = $this->module->attribute('name'); if (in_array($moduleName, $this->siteBasics['policy-check-omit-list'])) { $omitPolicyCheck = true; } else { $policyCheckViewMap = $this->getPolicyCheckViewMap($this->siteBasics['policy-check-omit-list']); if (isset($policyCheckViewMap[$moduleName][$functionName])) { $omitPolicyCheck = true; } } } if (!$omitPolicyCheck) { $currentUser = eZUser::currentUser(); $siteAccessResult = $currentUser->hasAccessTo('user', 'login'); $hasAccessToSite = false; if ($siteAccessResult['accessWord'] === 'limited') { $policyChecked = false; foreach (array_keys($siteAccessResult['policies']) as $key) { $policy = $siteAccessResult['policies'][$key]; if (isset($policy['SiteAccess'])) { $policyChecked = true; $crc32AccessName = eZSys::ezcrc32($this->access['name']); eZDebugSetting::writeDebug('kernel-siteaccess', $policy['SiteAccess'], $crc32AccessName); if (in_array($crc32AccessName, $policy['SiteAccess'])) { $hasAccessToSite = true; break; } } if ($hasAccessToSite) { break; } } if (!$policyChecked) { $hasAccessToSite = true; } } else { if ($siteAccessResult['accessWord'] === 'yes') { eZDebugSetting::writeDebug('kernel-siteaccess', "access is yes"); $hasAccessToSite = true; } else { if ($siteAccessResult['accessWord'] === 'no') { $accessList = $siteAccessResult['accessList']; } } } if ($hasAccessToSite) { $accessParams = array(); $moduleAccessAllowed = $currentUser->hasAccessToView($this->module, $functionName, $accessParams); if (isset($accessParams['accessList'])) { $accessList = $accessParams['accessList']; } } else { eZDebugSetting::writeDebug('kernel-siteaccess', $this->access, 'not able to get access to siteaccess'); $moduleAccessAllowed = false; if ($ini->variable("SiteAccessSettings", "RequireUserLogin") == "true") { $this->module = eZModule::exists('user'); if ($this->module instanceof eZModule) { $moduleResult = $this->module->run('login', array(), array('SiteAccessAllowed' => false, 'SiteAccessName' => $this->access['name'])); $runModuleView = false; } } } } $GLOBALS['eZRequestedModule'] = $this->module; if ($runModuleView) { if ($objectHasMovedError == true) { $moduleResult = $this->module->handleError(eZError::KERNEL_MOVED, 'kernel', array('new_location' => $objectHasMovedURI)); } else { if (!$moduleAccessAllowed) { if (isset($availableViewsInModule[$functionName]['default_navigation_part'])) { $defaultNavigationPart = $availableViewsInModule[$functionName]['default_navigation_part']; } if (isset($accessList)) { $moduleResult = $this->module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array('AccessList' => $accessList)); } else { $moduleResult = $this->module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel'); } if (isset($defaultNavigationPart)) { $moduleResult['navigation_part'] = $defaultNavigationPart; unset($defaultNavigationPart); } } else { if (!isset($userParameters)) { $userParameters = false; } // Check if we should switch access mode (http/https) for this module view. eZSSLZone::checkModuleView($this->module->attribute('name'), $functionName); $moduleResult = $this->module->run($functionName, $params, false, $userParameters); if ($this->module->exitStatus() == eZModule::STATUS_FAILED && $moduleResult == null) { $moduleResult = $this->module->handleError(eZError::KERNEL_MODULE_VIEW_NOT_FOUND, 'kernel', array('module' => $moduleName, 'view' => $functionName)); } } } } } else { if ($moduleCheck['result']) { eZDebug::writeError("Undefined module: {$moduleName}", "index"); $this->module = new eZModule("", "", $moduleName); $GLOBALS['eZRequestedModule'] = $this->module; $moduleResult = $this->module->handleError(eZError::KERNEL_MODULE_NOT_FOUND, 'kernel', array('module' => $moduleName)); } else { if ($moduleCheck['view_checked']) { eZDebug::writeError("View '" . $moduleCheck['view'] . "' in module '" . $moduleCheck['module'] . "' is disabled", "index"); } else { eZDebug::writeError("Module '" . $moduleCheck['module'] . "' is disabled", "index"); } $GLOBALS['eZRequestedModule'] = $this->module = new eZModule("", "", $moduleCheck['module']); $moduleResult = $this->module->handleError(eZError::KERNEL_MODULE_DISABLED, 'kernel', array('check' => $moduleCheck)); } } $this->siteBasics['module-run-required'] = false; if ($this->module->exitStatus() == eZModule::STATUS_RERUN) { if (isset($moduleResult['rerun_uri'])) { $this->uri = eZURI::instance($moduleResult['rerun_uri']); $this->siteBasics['module-run-required'] = true; } else { eZDebug::writeError('No rerun URI specified, cannot continue', 'index.php'); } } if (is_array($moduleResult)) { if (isset($moduleResult["pagelayout"])) { $this->siteBasics['show-page-layout'] = $moduleResult["pagelayout"]; $GLOBALS['eZCustomPageLayout'] = $moduleResult["pagelayout"]; } if (isset($moduleResult["external_css"])) { $this->siteBasics['external-css'] = $moduleResult["external_css"]; } } } return $moduleResult; }
$uri->setURIString($defaultPage); $moduleCheck['result'] = true; } } $http = eZHTTPTool::instance(); $displayMissingModule = false; $oldURI = $uri; if ($uri->isEmpty()) { if (!fetchModule($tmp_uri, $check, $module, $module_name, $function_name, $params)) { $displayMissingModule = true; } } else { if (!fetchModule($uri, $check, $module, $module_name, $function_name, $params)) { if ($ini->variable("SiteSettings", "ErrorHandler") == "defaultpage") { $tmp_uri = new eZURI($ini->variable("SiteSettings", "DefaultPage")); if (!fetchModule($tmp_uri, $check, $module, $module_name, $function_name, $params)) { $displayMissingModule = true; } } else { $displayMissingModule = true; } } } if (!$displayMissingModule && $moduleCheck['result'] && $module instanceof eZModule) { // Run the module/function eZDebug::addTimingPoint("Module start '" . $module->attribute('name') . "'"); $moduleAccessAllowed = true; $omitPolicyCheck = true; $runModuleView = true; $availableViewsInModule = $module->attribute('views'); if (!isset($availableViewsInModule[$function_name]) && !$objectHasMovedError && !isset($module->Module['function']['script'])) {