diff --git a/administrator/components/com_actionlogs/controllers/actionlogs.php b/administrator/components/com_actionlogs/controllers/actionlogs.php index 748e75a27918e..d5a57afa74cc5 100644 --- a/administrator/components/com_actionlogs/controllers/actionlogs.php +++ b/administrator/components/com_actionlogs/controllers/actionlogs.php @@ -121,7 +121,7 @@ public function exportLogs() } fclose($output); - + $app->triggerEvent('onAfterLogExport', array()); $app->close(); } else diff --git a/administrator/components/com_actionlogs/models/actionlogs.php b/administrator/components/com_actionlogs/models/actionlogs.php index 13cefc356e1b4..345352ceba72b 100644 --- a/administrator/components/com_actionlogs/models/actionlogs.php +++ b/administrator/components/com_actionlogs/models/actionlogs.php @@ -330,8 +330,6 @@ public function delete(&$pks) try { $db->execute(); - - return true; } catch (RuntimeException $e) { @@ -339,6 +337,10 @@ public function delete(&$pks) return false; } + + Factory::getApplication()->triggerEvent('onAfterLogPurge', array()); + + return true; } /** @@ -353,13 +355,15 @@ public function purge() try { $this->getDbo()->truncateTable('#__action_logs'); - - return true; } catch (Exception $e) { return false; } + + Factory::getApplication()->triggerEvent('onAfterLogPurge', array()); + + return true; } /** diff --git a/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini b/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini index f61590b1453d5..f396f5a406d27 100644 --- a/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini +++ b/administrator/language/en-GB/en-GB.plg_actionlog_joomla.ini @@ -36,6 +36,8 @@ 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_CHECKIN="User {username} performed a check in to table {table}" +PLG_ACTIONLOG_JOOMLA_USER_LOG="User {username} purged one or more rows from the action log" +PLG_ACTIONLOG_JOOMLA_USER_LOGEXPORT="User {username} exported one or more rows from the action log" PLG_ACTIONLOG_JOOMLA_USER_LOGGED_IN="User {username} logged in to {app}" PLG_ACTIONLOG_JOOMLA_USER_LOGGED_OUT="User {username} logged out from {app}" PLG_ACTIONLOG_JOOMLA_USER_LOGIN_FAILED="User {username} tried to login to {app}" diff --git a/plugins/actionlog/joomla/joomla.php b/plugins/actionlog/joomla/joomla.php index 2b7d72fcd4f79..69b8aa1887460 100644 --- a/plugins/actionlog/joomla/joomla.php +++ b/plugins/actionlog/joomla/joomla.php @@ -945,4 +945,60 @@ public function onAfterCheckin($table) $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_CHECKIN', $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 = Factory::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 = Factory::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); + } }