/** * Return a list of all cache items in the system. * * @return array The list of cache items */ static function fetchList() { static $cacheList = null; if ($cacheList === null) { $ini = eZINI::instance(); $textToImageIni = eZINI::instance('texttoimage.ini'); $cacheList = array(array('name' => ezpI18n::tr('kernel/cache', 'Content view cache'), 'id' => 'content', 'is-clustered' => true, 'tag' => array('content'), 'expiry-key' => 'content-view-cache', 'enabled' => $ini->variable('ContentSettings', 'ViewCaching') == 'enabled', 'path' => $ini->variable('ContentSettings', 'CacheDir'), 'function' => array('eZCache', 'clearContentCache')), array('name' => ezpI18n::tr('kernel/cache', 'Global INI cache'), 'id' => 'global_ini', 'tag' => array('ini'), 'enabled' => true, 'path' => 'var/cache/ini', 'function' => array('eZCache', 'clearGlobalINICache'), 'purge-function' => array('eZCache', 'clearGlobalINICache')), array('name' => ezpI18n::tr('kernel/cache', 'INI cache'), 'id' => 'ini', 'tag' => array('ini'), 'enabled' => true, 'path' => 'ini'), array('name' => ezpI18n::tr('kernel/cache', 'Codepage cache'), 'id' => 'codepage', 'tag' => array('codepage'), 'enabled' => true, 'path' => 'codepages'), array('name' => ezpI18n::tr('kernel/cache', 'Class identifier cache'), 'id' => 'classid', 'tag' => array('content'), 'expiry-key' => 'class-identifier-cache', 'enabled' => true, 'path' => false, 'is-clustered' => true, 'function' => array('eZCache', 'clearClassID'), 'purge-function' => array('eZCache', 'clearClassID')), array('name' => ezpI18n::tr('kernel/cache', 'Sort key cache'), 'id' => 'sortkey', 'tag' => array('content'), 'expiry-key' => 'sort-key-cache', 'enabled' => true, 'path' => false, 'function' => array('eZCache', 'clearSortKey'), 'purge-function' => array('eZCache', 'clearSortKey'), 'is-clustered' => true), array('name' => ezpI18n::tr('kernel/cache', 'URL alias cache'), 'id' => 'urlalias', 'is-clustered' => true, 'tag' => array('content'), 'enabled' => true, 'path' => 'wildcard'), array('name' => ezpI18n::tr('kernel/cache', 'Character transformation cache'), 'id' => 'chartrans', 'tag' => array('i18n'), 'enabled' => true, 'path' => 'trans'), array('name' => ezpI18n::tr('kernel/cache', 'Image alias'), 'id' => 'imagealias', 'tag' => array('image'), 'path' => false, 'enabled' => true, 'function' => array('eZCache', 'clearImageAlias'), 'purge-function' => array('eZCache', 'purgeImageAlias'), 'is-clustered' => true), array('name' => ezpI18n::tr('kernel/cache', 'Template cache'), 'id' => 'template', 'tag' => array('template'), 'enabled' => $ini->variable('TemplateSettings', 'TemplateCompile') == 'enabled', 'path' => 'template'), array('name' => ezpI18n::tr('kernel/cache', 'Template block cache'), 'id' => 'template-block', 'is-clustered' => true, 'tag' => array('template', 'content'), 'expiry-key' => 'global-template-block-cache', 'enabled' => $ini->variable('TemplateSettings', 'TemplateCache') == 'enabled', 'path' => 'template-block', 'function' => array('eZCache', 'clearTemplateBlockCache')), array('name' => ezpI18n::tr('kernel/cache', 'Template override cache'), 'id' => 'template-override', 'tag' => array('template'), 'enabled' => true, 'path' => 'override', 'function' => array('eZCache', 'clearTemplateOverrideCache')), array('name' => ezpI18n::tr('kernel/cache', 'Text to image cache'), 'id' => 'texttoimage', 'tag' => array('template'), 'enabled' => $textToImageIni->variable('ImageSettings', 'UseCache') == 'enabled', 'path' => $textToImageIni->variable('PathSettings', 'CacheDir'), 'function' => array('eZCache', 'clearTextToImageCache'), 'purge-function' => array('eZCache', 'purgeTextToImageCache'), 'is-clustered' => true), array('name' => ezpI18n::tr('kernel/cache', 'RSS cache'), 'id' => 'rss_cache', 'is-clustered' => true, 'tag' => array('content'), 'enabled' => true, 'path' => 'rss'), array('name' => ezpI18n::tr('kernel/cache', 'User info cache'), 'id' => 'user_info_cache', 'is-clustered' => true, 'tag' => array('user'), 'expiry-key' => 'user-info-cache', 'enabled' => true, 'path' => 'user-info', 'function' => array('eZCache', 'clearUserInfoCache')), array('name' => ezpI18n::tr('kernel/cache', 'Content tree menu (browser cache)'), 'id' => 'content_tree_menu', 'tag' => array('content'), 'path' => false, 'enabled' => true, 'function' => array('eZCache', 'clearContentTreeMenu'), 'purge-function' => array('eZCache', 'clearContentTreeMenu')), array('name' => ezpI18n::tr('kernel/cache', 'State limitations cache'), 'is-clustered' => true, 'id' => 'state_limitations', 'tag' => array('content'), 'expiry-key' => 'state-limitations', 'enabled' => true, 'path' => false, 'function' => array('eZCache', 'clearStateLimitations'), 'purge-function' => array('eZCache', 'clearStateLimitations')), array('name' => ezpI18n::tr('kernel/cache', 'Design base cache'), 'id' => 'design_base', 'tag' => array('template'), 'enabled' => $ini->variable('DesignSettings', 'DesignLocationCache') == 'enabled', 'path' => false, 'function' => array('eZCache', 'clearDesignBaseCache'), 'purge-function' => array('eZCache', 'clearDesignBaseCache')), array('name' => ezpI18n::tr('kernel/cache', 'Active extensions cache'), 'id' => 'active_extensions', 'tag' => array('ini'), 'expiry-key' => 'active-extensions-cache', 'enabled' => true, 'path' => false, 'function' => array('eZCache', 'clearActiveExtensions'), 'purge-function' => array('eZCache', 'clearActiveExtensions')), array('name' => ezpI18n::tr('kernel/cache', 'TS Translation cache'), 'id' => 'translation', 'tag' => array('i18n'), 'enabled' => true, 'expiry-key' => 'ts-translation-cache', 'path' => 'translation', 'function' => array('eZCache', 'clearTSTranslationCache')), array('name' => ezpI18n::tr('kernel/cache', 'SSL Zones cache'), 'id' => 'sslzones', 'tag' => array('ini'), 'enabled' => eZSSLZone::enabled(), 'path' => false, 'function' => array('eZSSLZone', 'clearCache'), 'purge-function' => array('eZSSLZone', 'clearCache'))); // Append cache items defined (in ini) by extensions, see site.ini[Cache] for details foreach ($ini->variable('Cache', 'CacheItems') as $cacheItemKey) { $name = 'Cache_' . $cacheItemKey; if (!$ini->hasSection($name)) { eZDebug::writeWarning("Missing site.ini section: '{$name}', skipping!", __METHOD__); continue; } $cacheItem = array(); if ($ini->hasVariable($name, 'name')) { $cacheItem['name'] = $ini->variable($name, 'name'); } else { $cacheItem['name'] = ucwords($cacheItemKey); } if ($ini->hasVariable($name, 'id')) { $cacheItem['id'] = $ini->variable($name, 'id'); } else { $cacheItem['id'] = $cacheItemKey; } if ($ini->hasVariable($name, 'isClustered')) { $cacheItem['is-clustered'] = $ini->variable($name, 'isClustered'); } else { $cacheItem['is-clustered'] = false; } if ($ini->hasVariable($name, 'tags')) { $cacheItem['tag'] = $ini->variable($name, 'tags'); } else { $cacheItem['tag'] = array(); } if ($ini->hasVariable($name, 'expiryKey')) { $cacheItem['expiry-key'] = $ini->variable($name, 'expiryKey'); } if ($ini->hasVariable($name, 'enabled')) { $cacheItem['enabled'] = $ini->variable($name, 'enabled'); } else { $cacheItem['enabled'] = true; } if ($ini->hasVariable($name, 'path')) { $cacheItem['path'] = $ini->variable($name, 'path'); } else { $cacheItem['path'] = false; } if ($ini->hasVariable($name, 'class')) { $cacheItem['function'] = array($ini->variable($name, 'class'), 'clearCache'); } if ($ini->hasVariable($name, 'purgeClass')) { $cacheItem['purge-function'] = array($ini->variable($name, 'purgeClass'), 'purgeCache'); } $cacheList[] = $cacheItem; } } return $cacheList; }
static function clearContentCache( $objectIDList, $versionNum = true, $additionalNodeList = false ) { if ( !is_array($objectIDList) ) { return false; } eZDebug::accumulatorStart( 'check_cache', '', 'Check cache' ); KeZCacheManager::clearObjectViewCache( $objectIDList, $versionNum, $additionalNodeList ); foreach ($objectIDList as $objectID) { eZContentCacheManager::clearTemplateBlockCache( $objectID ); } // Clear cached path strings of content SSL zones. eZSSLZone::clearCache(); eZDebug::accumulatorStop( 'check_cache' ); return true; }
<?php /** * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 * @version 2012.6 * @package kernel */ $Module = $Params['Module']; $http = eZHTTPTool::instance(); $NodeID = $Params['NodeID']; $Offset = $Params['Offset']; $viewParameters = array('offset' => $Offset); eZSSLZone::checkNodeID('content', 'urlalias', $NodeID); $tpl = eZTemplate::factory(); $limit = 20; $node = eZContentObjectTreeNode::fetch($NodeID); if (!$node) { return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } $infoCode = 'no-errors'; // This will be modified if info/warning is given to user. $infoData = array(); // Extra parameters can be added to this array $aliasText = false; if ($Module->isCurrentAction('RemoveAllAliases')) { $filter = new eZURLAliasQuery(); $filter->actions = array('eznode:' . $node->attribute('node_id')); $filter->type = 'alias'; $filter->offset = 0; $filter->limit = 50;
require 'kernel/content/state_edit.php'; initializeStateEdit( $Module ); $obj = eZContentObject::fetch( $ObjectID ); if ( !$obj ) return $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' ); // If the object has status Archived (trash) we redirect to content/restore // which can handle this status properly. if ( $obj->attribute( 'status' ) == eZContentObject::STATUS_ARCHIVED ) { return $Module->redirectToView( 'restore', array( $ObjectID ) ); } // Check if we should switch access mode (http/https) for this object. eZSSLZone::checkObject( 'content', 'edit', $obj ); // This controls if the final access check is done. // Some code will turn it off since they do the checking themselves. $isAccessChecked = false; $classID = $obj->attribute( 'contentclass_id' ); $class = eZContentClass::fetch( $classID ); $http = eZHTTPTool::instance(); // Action for the edit_draft.tpl/edit_languages.tpl page. // CancelDraftButton is set for the Cancel button. // Note: This code is safe to place before permission checking. if( $http->hasPostVariable( 'CancelDraftButton' ) ) { $nodes = $obj->assignedNodes(); $chosenNode = null;
// // // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## // $http = eZHTTPTool::instance(); $tpl = eZTemplate::factory(); $ViewMode = $Params['ViewMode']; $NodeID = $Params['NodeID']; $Module = $Params['Module']; $LanguageCode = $Params['Language']; $Offset = $Params['Offset']; $Year = $Params['Year']; $Month = $Params['Month']; $Day = $Params['Day']; // Check if we should switch access mode (http/https) for this node. eZSSLZone::checkNodeID('content', 'view', $NodeID); if (isset($Params['UserParameters'])) { $UserParameters = $Params['UserParameters']; } else { $UserParameters = array(); } if ($Offset) { $Offset = (int) $Offset; } if ($Year) { $Year = (int) $Year; } if ($Month) { $Month = (int) $Month; } if ($Day) {
/** * Clears content cache for specified object: view cache, template-block cache, template-block with subtree_expiry parameter cache * without checking of ini settings. * * @param int|array $objectID (list of) object ID * @param bool|int $versionNum * @param bool|array $additionalNodeList */ static function clearContentCache($objectID, $versionNum = true, $additionalNodeList = false) { eZDebug::accumulatorStart('check_cache', '', 'Check cache'); if (is_array($objectID)) { if ($versionNum !== true || $additionalNodeList !== false) { trigger_error("This method does not support second and third parameters when operating on many objects!"); return false; } self::clearObjectViewCacheArray($objectID); } else { self::clearObjectViewCache($objectID, $versionNum, $additionalNodeList); } self::clearTemplateBlockCache($objectID); // Clear cached path strings of content SSL zones. eZSSLZone::clearCache(); eZDebug::accumulatorStop('check_cache'); return true; }
/** * 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; }
} if (isset($accessList)) { $moduleResult = $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array('AccessList' => $accessList)); } else { $moduleResult = $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($module->attribute('name'), $function_name); $moduleResult = $module->run($function_name, $params, false, $userParameters); if ($module->exitStatus() == eZModule::STATUS_FAILED and $moduleResult == null) { $moduleResult = $module->handleError(eZError::KERNEL_MODULE_VIEW_NOT_FOUND, 'kernel', array('module' => $module_name, 'view' => $function_name)); } } } } } else { if ($moduleCheck['result']) { eZDebug::writeError("Undefined module: {$module_name}", "index"); $module = new eZModule("", "", $module_name); $GLOBALS['eZRequestedModule'] = $module; $moduleResult = $module->handleError(eZError::KERNEL_MODULE_NOT_FOUND, 'kernel', array('module' => $module_name)); } else { if ($moduleCheck['view_checked']) {
/** * \static * Decide whether we should change access mode for this module view or not. * Called from index.php. */ static function checkModuleView($module, $view) { if (!eZSSLZone::enabled()) { return; } $ini = eZINI::instance(); $viewsModes = $ini->variable('SSLZoneSettings', 'ModuleViewAccessMode'); $sslViews = array_keys($viewsModes, 'ssl'); $keepModeViews = array_keys($viewsModes, 'keep'); $sslPriority = eZSSLZone::viewIsInArray($module, $view, $sslViews); $keepModePriority = eZSSLZone::viewIsInArray($module, $view, $keepModeViews); if ($sslPriority && $keepModePriority && $sslPriority == $keepModePriority) { eZDebug::writeError("Configuration error: view {$module}/{$view} is defined both as 'ssl' and 'keep'", 'eZSSLZone'); return; } /* If the view belongs to the list of views we should not change access mode for, * then do nothing. * (however, the view may do access mode switch itself later) */ if ($keepModePriority > $sslPriority) { eZDebugSetting::writeDebug('kernel-ssl-zone', 'Keeping current access mode...'); return; } /* Otherwise we look if the view is in the list of SSL views, * and if it is, we switch to SSL. Else, if it's not, we switch to plain HTTP. */ $inSSL = $sslPriority > 0; eZDebugSetting::writeDebug('kernel-ssl-zone', isset($inSSL) ? $inSSL ? 'yes' : 'no' : 'dunno', 'Should we use SSL for this view?'); // Change access mode if we need to. eZSSLZone::switchIfNeeded($inSSL); }