diff --git a/administrator/components/com_cache/controller.php b/administrator/components/com_cache/controller.php index 13fc6797d9b..65986e60119 100644 --- a/administrator/components/com_cache/controller.php +++ b/administrator/components/com_cache/controller.php @@ -138,6 +138,7 @@ class CacheController extends JControllerLegacy $app->enqueueMessage(JText::_('COM_CACHE_MSG_SOME_CACHE_GROUPS_CLEARED'), 'warning'); } + $app->triggerEvent('onAfterPurge', array()); $this->setRedirect('index.php?option=com_cache&view=cache'); } diff --git a/administrator/components/com_cache/models/cache.php b/administrator/components/com_cache/models/cache.php index 16498a7ed9d..29a2bb2f9b5 100644 --- a/administrator/components/com_cache/models/cache.php +++ b/administrator/components/com_cache/models/cache.php @@ -9,6 +9,7 @@ defined('_JEXEC') or die; +use Joomla\CMS\Factory; use Joomla\Utilities\ArrayHelper; /** @@ -251,7 +252,7 @@ class CacheModelCache extends JModelList { try { - return $this->getCache()->clean($group); + $this->getCache()->clean($group); } catch (JCacheExceptionConnecting $exception) { @@ -261,6 +262,10 @@ class CacheModelCache extends JModelList { return false; } + + Factory::getApplication()->triggerEvent('onAfterPurge', array($group)); + + return true; } /** @@ -294,7 +299,7 @@ class CacheModelCache extends JModelList { try { - return JFactory::getCache('')->gc(); + JFactory::getCache('')->gc(); } catch (JCacheExceptionConnecting $exception) { @@ -304,5 +309,9 @@ class CacheModelCache extends JModelList { return false; } + + Factory::getApplication()->triggerEvent('onAfterPurge', array()); + + return true; } } diff --git a/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini b/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini index f396f5a406d..8f4d455a220 100644 --- a/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini +++ b/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini @@ -35,6 +35,7 @@ PLG_ACTIONLOG_JOOMLA_TYPE_TEMPLATE="template" PLG_ACTIONLOG_JOOMLA_TYPE_USER="user" PLG_ACTIONLOG_JOOMLA_TYPE_USER_GROUP="user group" PLG_ACTIONLOG_JOOMLA_TYPE_USER_NOTE="user note" +PLG_ACTIONLOG_JOOMLA_USER_CACHE="User {username} deleted cache group {group}" PLG_ACTIONLOG_JOOMLA_USER_CHECKIN="User {username} performed a check in to table {table}" PLG_ACTIONLOG_JOOMLA_USER_LOG="User {username} purged one or more rows from the action log" PLG_ACTIONLOG_JOOMLA_USER_LOGEXPORT="User {username} exported one or more rows from the action log" diff --git a/plugins/actionlog/joomla/joomla.php b/plugins/actionlog/joomla/joomla.php index 69b8aa18874..933f63936b8 100644 --- a/plugins/actionlog/joomla/joomla.php +++ b/plugins/actionlog/joomla/joomla.php @@ -1001,4 +1001,39 @@ class PlgActionlogJoomla extends ActionLogPlugin ); $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_LOGEXPORT', $context, $user->id); } + + /** + * On after Cache purge + * + * Method is called after user request to clean cached items. + * + * @param string $group Holds the group name. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function onAfterPurge($group = 'all') + { + $context = $this->app->input->get('option'); + $user = JFactory::getUser(); + + if (!$this->checkLoggable($context)) + { + return; + } + + $message = array( + 'action' => 'cache', + 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', + 'id' => $user->id, + 'title' => $user->name, + 'itemlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'userid' => $user->id, + 'username' => $user->name, + 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'group' => $group, + ); + $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_CACHE', $context, $user->id); + } }