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))
return 0;
66 $key =
'MAIN_LOGEVENTS_'.$action;
68 if (empty($conf->global->$key))
return 0;
70 if (empty($conf->entity)) $conf->entity = $entity;
75 if ($action ==
'USER_LOGIN') {
76 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
78 $langs->
load(
"users");
80 $text =
"(UserLogged,".$object->login.
")";
81 $text .= (empty($object->trigger_mesg) ?
'' :
' - '.$object->trigger_mesg);
82 $desc =
"(UserLogged,".$object->login.
")";
83 $desc .= (empty($object->trigger_mesg) ?
'' :
' - '.$object->trigger_mesg);
84 } elseif ($action ==
'USER_LOGIN_FAILED') {
85 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
88 $text = $object->trigger_mesg;
89 $desc = $object->trigger_mesg;
90 } elseif ($action ==
'USER_LOGOUT') {
91 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
93 $langs->
load(
"users");
95 $text =
"(UserLogoff,".$object->login.
")";
96 $desc =
"(UserLogoff,".$object->login.
")";
97 } elseif ($action ==
'USER_CREATE') {
98 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
99 $langs->
load(
"users");
104 } elseif ($action ==
'USER_MODIFY') {
105 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
106 $langs->
load(
"users");
111 } elseif ($action ==
'USER_NEW_PASSWORD') {
112 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
113 $langs->
load(
"users");
118 } elseif ($action ==
'USER_ENABLEDISABLE') {
119 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
120 $langs->
load(
"users");
122 if ($object->statut == 0) {
126 if ($object->statut == 1) {
130 } elseif ($action ==
'USER_DELETE') {
131 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
132 $langs->
load(
"users");
136 } elseif ($action ==
'USERGROUP_CREATE') {
138 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
139 $langs->
load(
"users");
143 } elseif ($action ==
'USERGROUP_MODIFY') {
144 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
145 $langs->
load(
"users");
149 } elseif ($action ==
'USERGROUP_DELETE') {
150 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
151 $langs->
load(
"users");
167 if (!empty($desc) && !empty($object->context[
'audit'])) $desc .=
' - '.$object->context[
'audit'];
170 include_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
173 $event->type = $action;
174 $event->dateevent = $date;
175 $event->label = $text;
176 $event->description = $desc;
177 $event->user_agent = (empty(
$_SERVER[
"HTTP_USER_AGENT"]) ?
'' :
$_SERVER[
"HTTP_USER_AGENT"]);
179 $result = $event->create($user);
183 $error =
"Failed to insert security event: ".$event->error;
184 $this->errors[] = $error;
185 $this->error = $error;
187 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...
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
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.
$conf db
API class for accounts.
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 $_SERVER["PHP_SELF"]
Edit parameters.
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.