26 require_once DOL_DOCUMENT_ROOT.
'/core/triggers/dolibarrtriggers.class.php';
37 public $picto =
'technic';
39 public $family =
'core';
41 public $description =
"Triggers of this module allows to add security event records inside Dolibarr.";
47 public $version = self::VERSION_DOLIBARR;
62 if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL))
return 0;
64 $key=
'MAIN_LOGEVENTS_'.$action;
66 if (empty($conf->global->$key))
return 0;
68 if (empty($conf->entity)) $conf->entity = $entity;
73 if ($action ==
'USER_LOGIN')
75 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
77 $langs->
load(
"users");
79 $text=
"(UserLogged,".$object->login.
")";
80 $text.=(empty($object->trigger_mesg)?
'':
' - '.$object->trigger_mesg);
81 $desc=
"(UserLogged,".$object->login.
")";
82 $desc.=(empty($object->trigger_mesg)?
'':
' - '.$object->trigger_mesg);
84 if ($action ==
'USER_LOGIN_FAILED')
86 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
89 $text=$object->trigger_mesg;
90 $desc=$object->trigger_mesg;
92 if ($action ==
'USER_LOGOUT')
94 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
96 $langs->
load(
"users");
98 $text=
"(UserLogoff,".$object->login.
")";
99 $desc=
"(UserLogoff,".$object->login.
")";
101 if ($action ==
'USER_CREATE')
103 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
104 $langs->
load(
"users");
110 elseif ($action ==
'USER_MODIFY')
112 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
113 $langs->
load(
"users");
119 elseif ($action ==
'USER_NEW_PASSWORD')
121 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
122 $langs->
load(
"users");
128 elseif ($action ==
'USER_ENABLEDISABLE')
130 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
131 $langs->
load(
"users");
133 if ($object->statut == 0)
138 if ($object->statut == 1)
144 elseif ($action ==
'USER_DELETE')
146 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
147 $langs->
load(
"users");
154 elseif ($action ==
'GROUP_CREATE')
156 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
157 $langs->
load(
"users");
162 elseif ($action ==
'GROUP_MODIFY')
164 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
165 $langs->
load(
"users");
170 elseif ($action ==
'GROUP_DELETE')
172 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
173 $langs->
load(
"users");
189 if (! empty($desc) && ! empty($object->context[
'audit'])) $desc.=
' - '.$object->context[
'audit'];
192 include_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
194 $event=
new Events($this->db);
195 $event->type=$action;
196 $event->dateevent=$date;
198 $event->description=$desc;
199 $event->user_agent=$_SERVER[
"HTTP_USER_AGENT"];
201 $result=$event->create($user);
208 $error =
"Failed to insert security event: ".$event->error;
211 dol_syslog(get_class($this).
": ".$this->error, LOG_ERR);
transnoentities($key, $param1='', $param2='', $param3='', $param4='', $param5='')
Return translated value of a text string Si il n'y a pas de correspondance pour ce texte...
Class to stock current configuration.
runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
Function called when a Dolibarrr business event is done.
Class to manage Dolibarr users.
Class of triggers for security events.
$conf db name
Only used if Module[ID]Name translation string is not found.
load($domain, $alt=0, $stopafterdirection=0, $forcelangdir='', $loadfromfileonly=0)
Load translation key-value for a particular file, into a memory array.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Class to manage translations.
dol_now($mode='gmt')
Return date for now.
Class that all the triggers must extend.