Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[com_actionlogs] - log cache actions #22739

Merged
merged 15 commits into from Mar 7, 2019
@@ -138,6 +138,7 @@ public function deleteAll()
$app->enqueueMessage(JText::_('COM_CACHE_MSG_SOME_CACHE_GROUPS_CLEARED'), 'warning');
}
$app->triggerEvent('onAfterPurge', array());
$this->setRedirect('index.php?option=com_cache&view=cache');
}
@@ -251,7 +251,7 @@ public function clean($group = '')
{
try
{
return $this->getCache()->clean($group);
$this->getCache()->clean($group);
}
catch (JCacheExceptionConnecting $exception)
{
@@ -261,6 +261,10 @@ public function clean($group = '')
{
return false;
}
Factory::getApplication()->triggerEvent('onAfterPurge', array($group));

This comment has been minimized.

Copy link
@Quy

Quy Oct 23, 2018

Contributor

Should not be an array?

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Nov 10, 2018

Contributor

Must be an array.

public function triggerEvent($event, array $args = null)

This conversation was marked as resolved by alikon

This comment has been minimized.

Copy link
@SharkyKZ

SharkyKZ Nov 10, 2018

Contributor

Missing Joomla\CMS\Factory import.

This comment has been minimized.

Copy link
@alikon

alikon Nov 11, 2018

Author Contributor

added

return true;
}
/**
@@ -294,7 +298,7 @@ public function purge()
{
try
{
return JFactory::getCache('')->gc();
JFactory::getCache('')->gc();
}
catch (JCacheExceptionConnecting $exception)
{
@@ -304,5 +308,9 @@ public function purge()
{
return false;
}
Factory::getApplication()->triggerEvent('onAfterPurge', array());
return true;
}
}
@@ -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_LOGGED_IN="User <a href='{accountlink}'>{username}</a> logged in to {app}"
PLG_ACTIONLOG_JOOMLA_USER_LOGGED_OUT="User <a href='{accountlink}'>{username}</a> logged out from {app}"
PLG_ACTIONLOG_JOOMLA_USER_LOGIN_FAILED="User <a href='{accountlink}'>{username}</a> tried to login to {app}"
@@ -907,4 +907,40 @@ public function onUserAfterRemind($user)
$this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_REMIND', $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);
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.