34 public $element =
'events';
39 public $table_element =
'events';
91 public $prefix_session;
96 public $authentication_method;
100 public $eventstolog = array(
101 array(
'id'=>
'USER_LOGIN',
'test'=>1),
102 array(
'id'=>
'USER_LOGIN_FAILED',
'test'=>1),
103 array(
'id'=>
'USER_LOGOUT',
'test'=>1),
104 array(
'id'=>
'USER_CREATE',
'test'=>1),
105 array(
'id'=>
'USER_MODIFY',
'test'=>1),
106 array(
'id'=>
'USER_NEW_PASSWORD',
'test'=>1),
107 array(
'id'=>
'USER_ENABLEDISABLE',
'test'=>1),
108 array(
'id'=>
'USER_DELETE',
'test'=>1),
109 array(
'id'=>
'USERGROUP_CREATE',
'test'=>1),
110 array(
'id'=>
'USERGROUP_MODIFY',
'test'=>1),
111 array(
'id'=>
'USERGROUP_DELETE',
'test'=>1),
119 public $fields = array(
120 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-2,
'noteditable'=>1,
'notnull'=> 1,
'index'=>1,
'position'=>1,
'comment'=>
'Id'),
121 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>1,
'visible'=>0,
'notnull'=> 1,
'default'=>1,
'index'=>1,
'position'=>20),
122 'prefix_session'=>array(
'type'=>
'varchar(255)',
'label'=>
'PrefixSession',
'enabled'=>1,
'visible'=>-1,
'notnull'=>-1,
'index'=>0,
'position'=>1000),
123 'user_agent' =>array(
'type'=>
'varchar(255)',
'label'=>
'UserAgent',
'enabled'=>1,
'visible'=>-1,
'notnull'=> 1,
'default'=>0,
'index'=>1,
'position'=>1000),
150 if (empty($this->user_agent)) {
151 $this->user_agent = (empty($_SERVER[
'HTTP_USER_AGENT']) ?
'' : $_SERVER[
'HTTP_USER_AGENT']);
156 $this->error =
'ErrorBadValueForParameterCreateEventDesc';
161 $sql =
"INSERT INTO ".$this->db->prefix().
"events(";
165 $sql .=
"user_agent,";
166 $sql .=
"dateevent,";
168 $sql .=
"description,";
169 $sql .=
"prefix_session";
170 $sql .=
") VALUES (";
171 $sql .=
" '".$this->db->escape($this->
type).
"',";
172 $sql .=
" ".((int) $conf->entity).
",";
174 $sql .=
" ".($this->user_agent ?
"'".$this->db->escape(
dol_trunc($this->user_agent, 250)).
"'" :
'NULL').
",";
175 $sql .=
" '".$this->db->idate($this->dateevent).
"',";
176 $sql .=
" ".($user->id > 0 ? ((int) $user->id) :
'NULL').
",";
178 $sql .=
" '".$this->db->escape(dol_getprefix()).
"'";
181 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
182 $resql = $this->db->query($sql);
184 $this->
id = $this->db->last_insert_id($this->db->prefix().
"events");
187 $this->error =
"Error ".$this->db->lasterror();
200 public function update($user =
null, $notrigger = 0)
203 $this->
id = (int) $this->
id;
211 $sql =
"UPDATE ".$this->db->prefix().
"events SET";
212 $sql .=
" type='".$this->db->escape($this->
type).
"',";
213 $sql .=
" dateevent='".$this->db->idate($this->dateevent).
"',";
214 $sql .=
" description='".$this->db->escape($this->
description).
"'";
215 $sql .=
" WHERE rowid=".((int) $this->
id);
217 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
218 $resql = $this->db->query($sql);
220 $this->error =
"Error ".$this->db->lasterror();
234 public function fetch($id, $user =
null)
240 $sql .=
" t.entity,";
241 $sql .=
" t.dateevent,";
242 $sql .=
" t.description,";
244 $sql .=
" t.user_agent,";
245 $sql .=
" t.prefix_session";
246 $sql .=
" FROM ".$this->db->prefix().
"events as t";
247 $sql .=
" WHERE t.rowid = ".((int) $id);
249 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
250 $resql = $this->db->query($sql);
252 if ($this->db->num_rows($resql)) {
253 $obj = $this->db->fetch_object($resql);
255 $this->
id = $obj->rowid;
256 $this->tms = $this->db->jdate($obj->tms);
257 $this->
type = $obj->type;
258 $this->entity = $obj->entity;
259 $this->dateevent = $this->db->jdate($obj->dateevent);
261 $this->ip = $obj->ip;
262 $this->user_agent = $obj->user_agent;
263 $this->prefix_session = $obj->prefix_session;
265 $this->db->free($resql);
269 $this->error =
"Error ".$this->db->lasterror();
281 public function delete($user)
283 $sql =
"DELETE FROM ".$this->db->prefix().
"events";
284 $sql .=
" WHERE rowid=".((int) $this->
id);
286 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
287 $resql = $this->db->query($sql);
289 $this->error =
"Error ".$this->db->lasterror();
310 $this->dateevent = time();
312 $this->ip =
'1.2.3.4';
313 $this->user_agent =
'Mozilla specimen User Agent X.Y';
314 $this->prefix_session = dol_getprefix();
initAsSpecimen()
Initialise an instance with random values.
__construct($db)
Constructor.
create($user)
Create in database.
fetch($id, $user=null)
Load object in memory from database.
update($user=null, $notrigger=0)
Update database.
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_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getUserRemoteIP()
Return the IP of remote user.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type