diff --git a/Classes/Controller/VarnishController.php b/Classes/Controller/VarnishController.php index aa7355e..72b5aa0 100644 --- a/Classes/Controller/VarnishController.php +++ b/Classes/Controller/VarnishController.php @@ -21,7 +21,9 @@ public static function ban($cacheObject) { 'Varnish-Ban-TYPO3-Pid: ' . (integer) $cacheObject, $siteName )); - } elseif ($cacheObject === 'pages' || $cacheObject === 'all' || $cacheObject === 'system') { + } elseif ($cacheObject === 'pages' || $cacheObject === 'all') { + // do nothing + } elseif ($cacheObject === 'banAll') { return HttpUtility::ban($url, array( 'Varnish-Ban-All: 1', $siteName diff --git a/Classes/Hooks/Ajax.php b/Classes/Hooks/Ajax.php index fbf6791..ca3c8a1 100644 --- a/Classes/Hooks/Ajax.php +++ b/Classes/Hooks/Ajax.php @@ -3,10 +3,9 @@ use Z7\Varnish\Controller\VarnishController; class Ajax { - public function banAll() { $logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__); $logger->info('User ' . $GLOBALS['BE_USER']->user['username'] . ' has cleared the varnish cache'); - VarnishController::ban('all'); + VarnishController::ban('banAll'); } } \ No newline at end of file diff --git a/Classes/Hooks/ClearCacheMenu.php b/Classes/Hooks/ClearCacheMenu.php index 5b1c1a3..0679adc 100644 --- a/Classes/Hooks/ClearCacheMenu.php +++ b/Classes/Hooks/ClearCacheMenu.php @@ -1,6 +1,7 @@ 'varnish', - 'title' => LocalizationUtility::translate('LLL:EXT:varnish/Resources/Private/Language/locallang.xlf:hooks.cache.title', $_EXTKEY), - 'href' => 'ajax.php?ajaxID=varnish::banAll', - 'icon' => '' - ); + if ($GLOBALS['BE_USER']->isAdmin()) { + $cacheActions[] = array( + 'id' => 'varnish', + 'title' => LocalizationUtility::translate('LLL:EXT:varnish/Resources/Private/Language/locallang.xlf:hooks.cache.title', $_EXTKEY), + 'href' => BackendUtility::getAjaxUrl('varnish::banAll'), + 'icon' => '' + ); + $optionValues[] = 'banAll'; + } } } \ No newline at end of file diff --git a/Classes/Utility/HttpUtility.php b/Classes/Utility/HttpUtility.php index 17d2eab..ad847a0 100755 --- a/Classes/Utility/HttpUtility.php +++ b/Classes/Utility/HttpUtility.php @@ -21,7 +21,7 @@ public static function ban($url, $headers = array()) { * @param array $headers * @return array */ - private function sendRequest($url, $verb, $headers) { + private static function sendRequest($url, $verb, $headers) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $verb); diff --git a/README.md b/README.md index 77cdf2d..04e3d74 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Install the extension. ## Thanks… * …to snowflake for their [varnish-typo3](https://github.com/snowflakech/typo3-varnish) extension. - Most of this extension is modeled after theirs, but simplified a bit and it also works on 7.2. + Most of this extension is modeled after theirs, but simplified a bit and it also works on 7 LTS. * …to varnish-software for openly sharing the superbunny graphics. diff --git a/ext_emconf.php b/ext_emconf.php index 45061ee..ce334cb 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,7 +8,7 @@ 'constraints' => array( 'depends' => array( 'php' => '5.3.0-0.0.0', - 'typo3' => '7.2.0-7.2.99', + 'typo3' => '7.2.0-7.6.99', ), 'conflicts' => array( ), diff --git a/ext_localconf.php b/ext_localconf.php index 64eb32b..5a64980 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -4,17 +4,17 @@ } if (TYPO3_MODE === 'BE') { - $TYPO3_CONF_VARS['SC_OPTIONS']['additionalBackendItems']['cacheActions'][] = - 'EXT:' . $_EXTKEY . '/Classes/Hooks/ClearCacheMenu.php:Z7\\Varnish\\Hooks\\ClearCacheMenu'; + $TYPO3_CONF_VARS['SC_OPTIONS']['additionalBackendItems']['cacheActions']['banAll'] = + 'Z7\\Varnish\\Hooks\\ClearCacheMenu'; $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'][] = - 'EXT:' . $_EXTKEY . '/Classes/Hooks/ClearCache.php:Z7\\Varnish\\Hooks\\ClearCache->clearCache'; - $TYPO3_CONF_VARS['BE']['AJAX']['varnish::banAll'] = array( - 'callbackMethod' => 'EXT:' . $_EXTKEY . '/Classes/Hooks/Ajax.php:Z7\\Varnish\\Hooks\Ajax->banAll', - 'csrfTokenCheck' => FALSE - ); + 'Z7\\Varnish\\Hooks\\ClearCache->clearCache'; + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerAjaxHandler( + 'varnish::banAll', + 'Z7\\Varnish\\Hooks\\Ajax->banAll' + ); } if (TYPO3_MODE === 'FE') { $TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'][] = - 'EXT:' . $_EXTKEY . '/Classes/Hooks/Frontend.php:Z7\\Varnish\\Hooks\\Frontend->sendHeader'; + 'Z7\\Varnish\\Hooks\\Frontend->sendHeader'; } \ No newline at end of file