29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-26 07:13:21 +00:00

[com_actionlogs] - log cache actions (#22739)

This commit is contained in:
Nicola Galgano 2019-03-07 22:36:41 +01:00 committed by Harald
parent 2a3fa5f7ce
commit 2d2a756186
4 changed files with 48 additions and 2 deletions

View File

@ -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');
}

View File

@ -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;
}
}

View File

@ -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 <a href='{accountlink}'>{username}</a> deleted cache group {group}"
PLG_ACTIONLOG_JOOMLA_USER_CHECKIN="User <a href='{accountlink}'>{username}</a> performed a check in to table {table}"
PLG_ACTIONLOG_JOOMLA_USER_LOG="User <a href='{accountlink}'>{username}</a> purged one or more rows from the action log"
PLG_ACTIONLOG_JOOMLA_USER_LOGEXPORT="User <a href='{accountlink}'>{username}</a> exported one or more rows from the action log"

View File

@ -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);
}
}