Log the name of the CLI user, when actions were done from the CLI.

This commit is contained in:
Jan Böhmer 2023-04-07 22:44:59 +02:00
parent c91a6640ff
commit 6443d8e2bf
6 changed files with 124 additions and 2 deletions

View file

@ -216,6 +216,26 @@ abstract class AbstractLogEntry extends AbstractDBElement
return $this;
}
public function setCLIUser(?string $cli_username): self
{
$this->user = null;
$this->username = '!!!CLI ' . $cli_username;
return $this;
}
public function isCLIUser(): bool
{
return strpos($this->username, '!!!CLI ') === 0;
}
public function getCLIUsername(): ?string
{
if ($this->isCLIUser()) {
return substr($this->username, 7);
}
return null;
}
/**
* Retuns the username of the user that caused the event (useful if the user was deleted).
*