mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 17:39:06 +02:00
Log the name of the CLI user, when actions were done from the CLI.
This commit is contained in:
parent
c91a6640ff
commit
6443d8e2bf
6 changed files with 124 additions and 2 deletions
|
@ -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).
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue