26 require_once DOL_DOCUMENT_ROOT.
'/core/triggers/dolibarrtriggers.class.php';
43 $this->
name = preg_replace(
'/^Interface/i',
'', get_class($this));
44 $this->family =
"core";
45 $this->
description =
"Triggers of this module allows to add security event records inside Dolibarr.";
47 $this->version = self::VERSION_DOLIBARR;
48 $this->picto =
'technic';
64 if (!empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) {
68 $key =
'MAIN_LOGEVENTS_'.$action;
70 if (empty($conf->global->$key)) {
74 if (empty($conf->entity)) {
75 $conf->entity = $entity;
81 if ($action ==
'USER_LOGIN') {
82 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
84 $langs->
load(
"users");
86 $text =
"(UserLogged,".$object->login.
")";
87 $text .= (empty($object->trigger_mesg) ?
'' :
' - '.$object->trigger_mesg);
88 $desc =
"(UserLogged,".$object->login.
")";
89 $desc .= (empty($object->trigger_mesg) ?
'' :
' - '.$object->trigger_mesg);
90 } elseif ($action ==
'USER_LOGIN_FAILED') {
91 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
94 $text = $object->trigger_mesg;
95 $desc = $object->trigger_mesg;
96 } elseif ($action ==
'USER_LOGOUT') {
97 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
99 $langs->
load(
"users");
101 $text =
"(UserLogoff,".$object->login.
")";
102 $desc =
"(UserLogoff,".$object->login.
")";
103 } elseif ($action ==
'USER_CREATE') {
104 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
105 $langs->
load(
"users");
110 } elseif ($action ==
'USER_MODIFY') {
111 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
112 $langs->
load(
"users");
117 } elseif ($action ==
'USER_NEW_PASSWORD') {
118 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
119 $langs->
load(
"users");
124 } elseif ($action ==
'USER_ENABLEDISABLE') {
125 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
126 $langs->
load(
"users");
128 if ($object->statut == 0) {
132 if ($object->statut == 1) {
136 } elseif ($action ==
'USER_DELETE') {
137 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
138 $langs->
load(
"users");
142 } elseif ($action ==
'USERGROUP_CREATE') {
144 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
145 $langs->
load(
"users");
149 } elseif ($action ==
'USERGROUP_MODIFY') {
150 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
151 $langs->
load(
"users");
155 } elseif ($action ==
'USERGROUP_DELETE') {
156 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
157 $langs->
load(
"users");
173 if (!empty($desc) && !empty($object->context[
'audit'])) {
174 $desc .=
' - '.$object->context[
'audit'];
178 include_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
181 $event->type = $action;
182 $event->dateevent = $date;
183 $event->label = $text;
184 $event->description = $desc;
185 $event->user_agent = (empty($_SERVER[
"HTTP_USER_AGENT"]) ?
'' : $_SERVER[
"HTTP_USER_AGENT"]);
187 $result = $event->create($user);
191 $error =
"Failed to insert security event: ".$event->error;
192 $this->errors[] = $error;
193 $this->error = $error;
195 dol_syslog(get_class($this).
": ".$error, LOG_ERR);
Class to stock current configuration.
transnoentities($key, $param1= '', $param2= '', $param3= '', $param4= '', $param5= '')
Return translated value of a text string If there is no match for this text, we look in alternative f...
$conf db
API class for accounts.
runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
Function called when a Dolibarrr security audit event is done.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Class of triggers for security audit events.
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage translations.
Class that all the triggers must extend.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
load($domain, $alt=0, $stopafterdirection=0, $forcelangdir= '', $loadfromfileonly=0, $forceloadifalreadynotfound=0)
Load translation key-value for a particular file, into a memory array.
__construct($db)
Constructor.