28require_once DOL_DOCUMENT_ROOT.
'/core/triggers/dolibarrtriggers.class.php';
37 const EVENT_ACTION_DICT = array(
38 'USER_LOGIN' =>
'UserLogged',
39 'USER_LOGIN_FAILED' =>
'UserLoginFailed',
40 'USER_LOGOUT' =>
'UserLogoff',
41 'USER_CREATE' =>
'NewUserCreated',
42 'USER_MODIFY' =>
'EventUserModified',
43 'USER_NEW_PASSWORD' =>
'UserPasswordChange',
44 'USER_ENABLEDISABLE' =>
'UserEnabledDisabled',
45 'USER_DELETE' =>
'UserDeleted',
46 'USERGROUP_CREATE' =>
'NewGroupCreated',
47 'USERGROUP_MODIFY' =>
'GroupModified',
48 'USERGROUP_DELETE' =>
'GroupDeleted'
70 parent::__construct($db);
72 $this->family =
"core";
73 $this->
description =
"Triggers of this module allows to add security event records inside Dolibarr.";
74 $this->version = self::VERSIONS[
'prod'];
75 $this->picto =
'technic';
76 $this->event_label =
'';
77 $this->event_desc =
'';
78 $this->event_date = 0;
99 $key =
'MAIN_LOGEVENTS_'.$action;
100 if (empty(
$conf->global->$key)) {
104 if (empty(
$conf->entity)) {
106 $conf->entity = $entity;
110 dol_syslog(
"Trigger '" . $this->
name .
"' for action '$action' launched by " . __FILE__ .
". id=" .
$object->id);
117 include_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
119 $event =
new Events($this->db);
120 $event->type = $action;
121 $event->dateevent = $this->event_date;
122 $event->label = $this->event_label;
123 $event->description = $this->event_desc;
124 $event->user_agent = (empty($_SERVER[
"HTTP_USER_AGENT"]) ?
'' : $_SERVER[
"HTTP_USER_AGENT"]);
125 $event->authentication_method = (empty(
$object->context[
'authentication_method']) ?
'' :
$object->context[
'authentication_method']);
127 $result = $event->create($user);
131 $error =
"Failed to insert security event: ".$event->error;
132 $this->errors[] = $error;
133 $this->error = $error;
135 dol_syslog(get_class($this).
": ".$error, LOG_ERR);
151 $this->event_label = $this->event_desc = $key_text;
152 if (property_exists(
$object,
'login')) {
153 $this->event_label .=
' : ' .
$object->login;
155 if ($key_text == InterfaceLogevents::EVENT_ACTION_DICT[
'USER_ENABLEDISABLE']) {
156 $object->statut ? $this->event_desc .=
' - disabled' : $this->event_desc .=
' - enabled';
159 if (!empty(
$object->context[
'audit'])) {
160 $this->event_desc .= (empty($this->event_desc) ?
'' :
' - ').
$object->context[
'audit'];
172 foreach (InterfaceLogevents::EVENT_ACTION_DICT as $value) {
173 if (str_contains($event_text, $value)) {
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to stock current configuration.
Class to manage Dolibarr database access.
Class that all triggers must inherit.
Class of triggers for security audit events.
static isEventActionTextKey($event_text)
Check if text contains an event action key.
initEventData($key_text, $object)
Method called by runTrigger to initialize date, label & description data for event.
runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
Function called when a Dolibarr security audit event is done.
__construct(DoliDB $db)
Constructor.
Class to manage translations.
Class to manage Dolibarr users.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_now($mode='auto')
Return date for now.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$conf db name
Only used if Module[ID]Name translation string is not found.