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 actionlog purge/export #22740

Merged
merged 19 commits into from
Mar 7, 2019
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public function exportLogs()
}

fclose($output);


alikon marked this conversation as resolved.
Show resolved Hide resolved
$app->triggerEvent('onAfterLogExport', array());
$app->close();
}
else
Expand Down
12 changes: 8 additions & 4 deletions administrator/components/com_actionlogs/models/actionlogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,17 @@ public function delete(&$pks)
try
{
$db->execute();

return true;
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());

return false;
}

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

return true;
}

/**
Expand All @@ -312,13 +314,15 @@ public function purge()
try
{
$this->getDbo()->truncateTable('#__action_logs');

return true;
}
catch (Exception $e)
{
return false;
}

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

return true;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ 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_LOG="User <a href='{accountlink}'>{username}</a> purged the action log"
PLG_ACTIONLOG_JOOMLA_USER_LOGEXPORT="User <a href='{accountlink}'>{username}</a> exported the action log"
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}"
Expand Down
60 changes: 60 additions & 0 deletions plugins/actionlog/joomla/joomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -907,4 +907,64 @@ public function onUserAfterRemind($user)

$this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_REMIND', $context, $user->id);
}

/**
* On after log action purge
*
* Method is called after user request to clean action log items.
*
* @param array $group Holds the group name.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function onAfterLogPurge($group = '')
{
$context = $this->app->input->get('option');
$user = JFactory::getUser();

$message = array(
'action' => 'actionlogs',
'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,
);

$this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_LOG', $context, $user->id);
}

/**
* On after log export
*
* Method is called after user request to export action log items.
*
* @param array $group Holds the group name.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function onAfterLogExport($group = '')
{
$context = $this->app->input->get('option');
$user = JFactory::getUser();

$message = array(
'action' => 'actionlogs',
'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,
);

$this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_LOGEXPORT', $context, $user->id);
}
}