Feature #23302 ยป cache_menu_for_admins.patch
typo3/classes/class.clearcachemenu.php (working copy) | ||
---|---|---|
$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',
|
||
... | ... | |
}
|
||
// 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',
|
||
... | ... | |
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']) {
|
t3lib/class.t3lib_tcemain.php (working copy) | ||
---|---|---|
}
|
||
/**
|
||
* 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
|
||
... | ... | |
// 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)
|