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;
84 if ($action ==
'USER_LOGIN') {
85 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
87 $langs->load(
"users");
89 $text =
"(UserLogged,".$object->login.
")";
90 $desc =
"(UserLogged,".$object->login.
")";
91 } elseif ($action ==
'USER_LOGIN_FAILED') {
92 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
93 } elseif ($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.
")";
100 } elseif ($action ==
'USER_CREATE') {
101 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
102 $langs->load(
"users");
105 $text = $langs->transnoentities(
"NewUserCreated", $object->login);
106 $desc = $langs->transnoentities(
"NewUserCreated", $object->login);
107 } elseif ($action ==
'USER_MODIFY') {
108 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
109 $langs->load(
"users");
112 $text = $langs->transnoentities(
"EventUserModified", $object->login);
113 $desc = $langs->transnoentities(
"EventUserModified", $object->login);
114 } elseif ($action ==
'USER_NEW_PASSWORD') {
115 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
116 $langs->load(
"users");
119 $text = $langs->transnoentities(
"NewUserPassword", $object->login);
120 $desc = $langs->transnoentities(
"NewUserPassword", $object->login);
121 } elseif ($action ==
'USER_ENABLEDISABLE') {
122 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
123 $langs->load(
"users");
125 if ($object->statut == 0) {
126 $text = $langs->transnoentities(
"UserEnabled", $object->login);
127 $desc = $langs->transnoentities(
"UserEnabled", $object->login);
129 if ($object->statut == 1) {
130 $text = $langs->transnoentities(
"UserDisabled", $object->login);
131 $desc = $langs->transnoentities(
"UserDisabled", $object->login);
133 } elseif ($action ==
'USER_DELETE') {
134 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
135 $langs->load(
"users");
137 $text = $langs->transnoentities(
"UserDeleted", $object->login);
138 $desc = $langs->transnoentities(
"UserDeleted", $object->login);
139 } elseif ($action ==
'USERGROUP_CREATE') {
141 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
142 $langs->load(
"users");
144 $text = $langs->transnoentities(
"NewGroupCreated", $object->name);
145 $desc = $langs->transnoentities(
"NewGroupCreated", $object->name);
146 } elseif ($action ==
'USERGROUP_MODIFY') {
147 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
148 $langs->load(
"users");
150 $text = $langs->transnoentities(
"GroupModified", $object->name);
151 $desc = $langs->transnoentities(
"GroupModified", $object->name);
152 } elseif ($action ==
'USERGROUP_DELETE') {
153 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
154 $langs->load(
"users");
156 $text = $langs->transnoentities(
"GroupDeleted", $object->name);
157 $desc = $langs->transnoentities(
"GroupDeleted", $object->name);
170 if (!empty($object->context[
'audit'])) {
171 $desc .= (empty($desc) ?
'' :
' - ').$object->context[
'audit'];
175 include_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
177 $event =
new Events($this->db);
178 $event->type = $action;
179 $event->dateevent = $date;
180 $event->label = $text;
181 $event->description = $desc;
182 $event->user_agent = (empty($_SERVER[
"HTTP_USER_AGENT"]) ?
'' : $_SERVER[
"HTTP_USER_AGENT"]);
183 $event->authentication_method = (empty($object->context[
'authentication_method']) ?
'' : $object->context[
'authentication_method']);
185 $result = $event->create($user);
189 $error =
"Failed to insert security event: ".$event->error;
190 $this->errors[] = $error;
191 $this->error = $error;
193 dol_syslog(get_class($this).
": ".$error, LOG_ERR);