Index: typo3/classes/class.clearcachemenu.php =================================================================== --- typo3/classes/class.clearcachemenu.php (revision 8444) +++ typo3/classes/class.clearcachemenu.php (working copy) @@ -58,7 +58,7 @@ $this->optionValues = array('all', 'pages'); // Clear cache for ALL tables! - if($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.all')) { + if($this->isAllowedToClearCache('options.clearCache.all')) { $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCacheMenu_all', true); $this->cacheActions[] = array( 'id' => 'all', @@ -69,7 +69,7 @@ } // Clear cache for either ALL pages - if($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.pages')) { + if($this->isAllowedToClearCache('options.clearCache.pages')) { $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCacheMenu_pages', true); $this->cacheActions[] = array( 'id' => 'pages', @@ -170,6 +170,28 @@ return ' id="clear-cache-actions-menu"'; } + /** + * Check if the current user is allowed to clear the given cache + * + * @param String TSConfig option + * @return Boolean + */ + protected function isAllowedToClearCache($cache) { + $isAllowedToClearCache = FALSE; + + $isAdmin = $GLOBALS['BE_USER']->isAdmin(); + $clearCacheEnabled = $GLOBALS['BE_USER']->getTSConfigVal($cache); + + // Admins are allowed to clear caches by default, so we have to check if the TSConfig option is anything but 0 + if($isAdmin && $clearCacheEnabled != '0') { + $isAllowedToClearCache = TRUE; + } elseif($clearCacheEnabled) { + $isAllowedToClearCache = TRUE; + } + + return $isAllowedToClearCache; + } + } if(defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.clearcachemenu.php']) { Index: t3lib/class.t3lib_tcemain.php =================================================================== --- t3lib/class.t3lib_tcemain.php (revision 8444) +++ t3lib/class.t3lib_tcemain.php (working copy) @@ -7398,6 +7398,28 @@ } /** + * Check if the current user is allowed to clear the given cache + * + * @param String TSConfig option + * @return Boolean + */ + protected function isAllowedToClearCache($cache) { + $isAllowedToClearCache = FALSE; + + $isAdmin = $this->admin; + $clearCacheEnabled = $this->BE_USER->getTSConfigVal($cache); + + // Admins are allowed to clear caches by default, so we have to check if the TSConfig option is anything but 0 + if($isAdmin && $clearCacheEnabled != '0') { + $isAllowedToClearCache = TRUE; + } elseif($clearCacheEnabled) { + $isAllowedToClearCache = TRUE; + } + + return $isAllowedToClearCache; + } + + /** * Clears the cache based on the command $cacheCmd. * * $cacheCmd='pages': Clears cache for all pages. Requires admin-flag to @@ -7435,12 +7457,12 @@ // Clear cache for either ALL pages or ALL tables! switch($cacheCmd) { case 'pages': - if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.pages')) { + if ($this->isAllowedToClearCache('options.clearCache.pages')) { $this->internal_clearPageCache(); } break; case 'all': - if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) { + if ($this->isAllowedToClearCache('options.clearCache.all')) { // Clear all caching framework caches if it is initialized: // (it could be disabled by initialized by an extension)