Unverified Commit cd5e5181 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(logging) Fix logging of paste action

Only log successful paste with pasted dn.
Otherwise we get an audit line before the actual paste happens.

issue #6046
Showing with 8 additions and 14 deletions
+8 -14
......@@ -211,7 +211,6 @@ class CopyPasteHandler
foreach ($this->clean_objects as $key => $entry) {
$this->current = $entry;
$errors = $this->current['object']->save();
logging::log('copy', 'paste', $this->current['object']->dn, [], reset($errors));
if (empty($errors)) {
$this->current_saved();
......@@ -231,7 +230,6 @@ class CopyPasteHandler
/* Save current object if edition is finished */
if (isset($_POST['edit_finish'])) {
$errors = $this->current['object']->save();
logging::log('copy', 'paste', $this->current['object']->dn, [], reset($errors));
if (empty($errors)) {
$this->current_saved();
......@@ -272,6 +270,7 @@ class CopyPasteHandler
private function current_saved ()
{
$this->lastdn = $this->current['object']->dn;
logging::log('copy', 'paste', $this->lastdn);
$this->handleReferences();
$this->current = FALSE;
}
......
......@@ -40,32 +40,27 @@ class logging
/*!
* \brief logging method
*
* \param $action One of these values (modify|create|remove|copy|snapshot|security|error)
* \param string $action One of these values (modify|create|remove|copy|snapshot|security|error)
*
* \param $objecttype represents the current edited objecttype, like user/user, or the event, like logout
* \param string $objecttype represents the current edited objecttype, like user/user, or the event, like logout
*
* \param $object represents the current edited object dn, or the target of the operation
* \param string $object represents the current edited object dn, or the target of the operation
*
* \param $changes_array An array containing names of all touched attributes
* \param array $changes An array containing names of all touched attributes
*
* \param $result A status message, containing errors or success messages
* \param string $result A status message, containing errors or success messages
*/
static function log ($action, $objecttype, $object, array $changes_array = [], $result = '')
static function log (string $action, string $objecttype, string $object, array $changes = [], string $result = '')
{
global $config, $ui;
if ($result === NULL) {
trigger_error('"Result" parameter should not be NULL');
$result = '';
}
/* Create data object */
$entry = [
'timestamp' => microtime(TRUE),
'action' => $action,
'objecttype' => $objecttype,
'object' => $object,
'changes' => $changes_array,
'changes' => $changes,
'result' => $result
];
if (isset($ui->dn) && !empty($ui->dn)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment