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,8 @@ public function deleteAll()
$app->enqueueMessage(JText::_('COM_CACHE_MSG_SOME_CACHE_GROUPS_CLEARED'), 'warning');
}
$dispatcher = \JEventDispatcher::getInstance();
$dispatcher->trigger('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,11 @@ public function clean($group = '')
{
return false;
}
$dispatcher = \JEventDispatcher::getInstance();
$dispatcher->trigger('onAfterPurge', array($group));
return true;
}
/**
@@ -294,7 +299,7 @@ public function purge()
{
try
{
return JFactory::getCache('')->gc();
JFactory::getCache('')->gc();
}
catch (JCacheExceptionConnecting $exception)
{
@@ -304,5 +309,10 @@ public function purge()
{
return false;
}
$dispatcher = \JEventDispatcher::getInstance();
$dispatcher->trigger('onAfterPurge', array($group));
This conversation was marked as resolved by alikon

This comment has been minimized.

Copy link
@laoneo

laoneo Oct 20, 2018

Member

Can you use triggerEvent from the app instead of using the dispatcher. Makes merging into 4 then easier. Thanks.

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 chaced items.
This conversation was marked as resolved by alikon

This comment has been minimized.

Copy link
@brianteeman

brianteeman Oct 20, 2018

Contributor
Suggested change
* Method is called after user request to clean chaced items.
* Method is called after user request to clean cached items.
*
* @param array $group Holds the group name.
This conversation was marked as resolved by alikon

This comment has been minimized.

Copy link
@Quy

Quy Oct 22, 2018

Contributor

Should type be string?

*
* @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.