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
1 change: 1 addition & 0 deletions administrator/components/com_cache/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
13 changes: 11 additions & 2 deletions administrator/components/com_cache/models/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\Utilities\ArrayHelper;

/**
Expand Down Expand Up @@ -251,7 +252,7 @@ public function clean($group = '')
{
try
{
return $this->getCache()->clean($group);
$this->getCache()->clean($group);
}
catch (JCacheExceptionConnecting $exception)
{
Expand All @@ -261,6 +262,10 @@ public function clean($group = '')
{
return false;
}

Factory::getApplication()->triggerEvent('onAfterPurge', array($group));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be an array?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be an array.

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

alikon marked this conversation as resolved.
Show resolved Hide resolved

return true;
}

/**
Expand Down Expand Up @@ -294,7 +299,7 @@ public function purge()
{
try
{
return JFactory::getCache('')->gc();
JFactory::getCache('')->gc();
}
catch (JCacheExceptionConnecting $exception)
{
Expand All @@ -304,5 +309,9 @@ public function purge()
{
return false;
}

Factory::getApplication()->triggerEvent('onAfterPurge', array());

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
35 changes: 35 additions & 0 deletions plugins/actionlog/joomla/joomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,4 +1001,39 @@ public function onAfterLogExport($group = '')
);
$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);
}
}