Added follow up to #7588: Accesscheck for clearCache, credits Steffen Kamper
authorIngo Renner <ingo.renner@typo3.org>
Sat, 15 Mar 2008 16:43:57 +0000 (16:43 +0000)
committerIngo Renner <ingo.renner@typo3.org>
Sat, 15 Mar 2008 16:43:57 +0000 (16:43 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3426 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/alt_menu.php
typo3/classes/class.clearcachemenu.php

index ed72147..dbf508a 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-03-15  Ingo Renner  <ingo@typo3.org>
+
+       * Added follow up to #7588: Accesscheck for clearCache, credits Steffen Kamper
+
 2008-03-15  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #7857: htmlArea RTE: hidePStyleItems does not work anymore
index 7797561..71e1aab 100755 (executable)
@@ -131,8 +131,10 @@ class SC_alt_menu {
                $alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
                $this->content.= $alt_menuObj->topMenu($this->loadModules->modules);
 
-                       // clear cache commands for Admins
-               if($BE_USER->isAdmin()) {       //  && $BE_USER->workspace===0 NOT used anyway because under a workspace developers might still like to clear cache!
+                       // clear cache commands for Admins and allowed users
+               if($GLOBALS['BE_USER']->isAdmin()
+               || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.pages')
+               || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.all')) {     //  && $BE_USER->workspace===0 NOT used anyway because under a workspace developers might still like to clear cache!
                        $functionsArray = $alt_menuObj->adminFunctions($backPath);
 
                        $this->content.='
@@ -154,12 +156,15 @@ class SC_alt_menu {
                                        </tr>';
 
                        $rows=array();
-                       foreach($functionsArray as $functionsArraySetup)        {
-                               $rows[]='
-                                       <tr class="c-subitem">
-                                               <td valign="top" align="center" class="icon">'.$functionsArraySetup['icon'].'</td>
-                                               <td><a href="'.htmlspecialchars($functionsArraySetup['href']).'">'.htmlspecialchars($functionsArraySetup['title']).'</a></td>
-                                       </tr>';
+                       foreach($functionsArray as $functionsArraySetup) {
+                               if(($functionsArraySetup['id'] == 'all' && ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.all')))
+                               || ($functionsArraySetup['id'] == 'temp_CACHED' && $GLOBALS['BE_USER']->isAdmin())) {
+                                       $rows[]='
+                                               <tr class="c-subitem">
+                                                       <td valign="top" align="center" class="icon">'.$functionsArraySetup['icon'].'</td>
+                                                       <td><a href="'.htmlspecialchars($functionsArraySetup['href']).'">'.htmlspecialchars($functionsArraySetup['title']).'</a></td>
+                                               </tr>';
+                                       }
                        }
 
                                // Imploding around the divider table row:
index f783946..8394946 100644 (file)
@@ -65,6 +65,7 @@ class ClearCacheMenu implements backend_toolbarItem {
                                'icon'  => '<img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/lightning_red.png', 'width="16" height="16"').' title="'.htmlspecialchars($title).'" alt="" />'
                        );
                }
+
                        // Clear cache for either ALL pages
                if($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.pages')) {
                        $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCacheMenu_pages');
@@ -77,7 +78,7 @@ class ClearCacheMenu implements backend_toolbarItem {
                }
 
                        // Clearing of cache-files in typo3conf/ + menu
-               if ($GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache'])   {
+               if($GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache']) {
                        $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCacheMenu_allTypo3Conf');
                        $this->cacheActions[] = array(
                                'id'    => 'temp_CACHED',
@@ -95,7 +96,11 @@ class ClearCacheMenu implements backend_toolbarItem {
         * @return  boolean  true if user has access, false if not
         */
        public function checkAccess() {
-               return ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.pages') || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.pages'));
+               return (
+                       $GLOBALS['BE_USER']->isAdmin()
+                       || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.pages')
+                       || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.all')
+               );
        }
 
        /**