diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php
index cce0cab24a3..a465456a168 100644
--- a/htdocs/admin/tools/listevents.php
+++ b/htdocs/admin/tools/listevents.php
@@ -81,7 +81,7 @@ $form=new Form($db);
$userstatic=new User($db);
$usefilter=0;
-$sql = "SELECT e.rowid, e.type, e.ip, e.dateevent,";
+$sql = "SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,";
$sql.= " e.fk_user, e.description,";
$sql.= " u.login";
$sql.= " FROM ".MAIN_DB_PREFIX."events as e";
@@ -91,6 +91,7 @@ if ($_GET["search_code"]) { $usefilter++; $sql.=" AND e.type like '%".$_GET["sea
if ($_GET["search_ip"]) { $usefilter++; $sql.=" AND e.ip like '%".$_GET["search_ip"]."%'"; }
if ($_GET["search_user"]) { $usefilter++; $sql.=" AND u.login like '%".$_GET["search_user"]."%'"; }
if ($_GET["search_desc"]) { $usefilter++; $sql.=" AND e.description like '%".$_GET["search_desc"]."%'"; }
+if ($_GET["search_ua"]) { $usefilter++; $sql.=" AND e.user_agent like '%".$_GET["search_ua"]."%'"; }
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit+1, $offset);
//print $sql;
@@ -193,7 +194,11 @@ if ($result)
print $text;
print '';
- print '
| ';
+ // More informations
+ print '';
+ $htmltext=''.$langs->trans("UserAgent").': '.$obj->user_agent;
+ print $form->textwithpicto('',$htmltext);
+ print ' | ';
print "\n";
$i++;
diff --git a/htdocs/core/events.class.php b/htdocs/core/events.class.php
index edf3ad91740..71397a1e4ff 100644
--- a/htdocs/core/events.class.php
+++ b/htdocs/core/events.class.php
@@ -33,10 +33,10 @@
/**
- \class Events
- \brief Events class
- \remarks Initialy built by build_class_from_table on 2008-02-28 17:25
-*/
+ \class Events
+ \brief Events class
+ \remarks Initialy built by build_class_from_table on 2008-02-28 17:25
+ */
class Events // extends CommonObject
{
var $db; //!< To store db handler
@@ -45,7 +45,7 @@ class Events // extends CommonObject
var $element='events'; //!< Id that identify managed objects
var $table_element='events'; //!< Name of table without prefix where object is stored
- var $id;
+ var $id;
var $tms;
var $type;
@@ -55,156 +55,162 @@ class Events // extends CommonObject
- /**
- * \brief Constructor
- * \param DB Database handler
- */
- function Events($DB)
- {
- $this->db = $DB;
- return 1;
- }
+ /**
+ * \brief Constructor
+ * \param DB Database handler
+ */
+ function Events($DB)
+ {
+ $this->db = $DB;
+ return 1;
+ }
- /**
- * \brief Create in database
- * \param user User that create
- * \return int <0 si ko, >0 si ok
- */
- function create($user)
- {
- global $conf, $langs;
-
- // Clean parameters
- $this->id=trim($this->id);
- $this->description=trim($this->description);
-
- // Check parameters
- if (! $this->description) { $this->error='ErrorBadValueForParameter'; return -1; }
-
- // Insert request
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."events(";
- $sql.= "type,";
- $sql.= "entity,";
- $sql.= "ip,";
- $sql.= "dateevent,";
- $sql.= "fk_user,";
- $sql.= "description";
- $sql.= ") VALUES (";
- $sql.= " '".$this->type."',";
- $sql.= " ".$conf->entity.",";
- $sql.= " '".$_SERVER['REMOTE_ADDR']."',";
- $sql.= " ".$this->db->idate($this->dateevent).",";
- $sql.= " ".($user->id?"'".$user->id."'":'NULL').",";
- $sql.= " '".addslashes($this->description)."'";
- $sql.= ")";
+ /**
+ * \brief Create in database
+ * \param user User that create
+ * \return int <0 si ko, >0 si ok
+ */
+ function create($user)
+ {
+ global $conf, $langs;
- dol_syslog("Events::create sql=".$sql, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."events");
- return $this->id;
- }
- else
- {
- $this->error="Error ".$this->db->lasterror();
- dol_syslog("Events::create ".$this->error, LOG_ERR);
- return -1;
- }
- }
+ // Clean parameters
+ $this->id=trim($this->id);
+ $this->description=trim($this->description);
+
+ // Check parameters
+ if (! $this->description) { $this->error='ErrorBadValueForParameter'; return -1; }
+
+ // Insert request
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."events(";
+ $sql.= "type,";
+ $sql.= "entity,";
+ $sql.= "ip,";
+ $sql.= "user_agent,";
+ $sql.= "dateevent,";
+ $sql.= "fk_user,";
+ $sql.= "description";
+ $sql.= ") VALUES (";
+ $sql.= " '".$this->type."',";
+ $sql.= " ".$conf->entity.",";
+ $sql.= " '".$_SERVER['REMOTE_ADDR']."',";
+ $sql.= " ".($_SERVER['HTTP_USER_AGENT']?"'".$_SERVER['HTTP_USER_AGENT']."'":'NULL').",";
+ $sql.= " ".$this->db->idate($this->dateevent).",";
+ $sql.= " ".($user->id?"'".$user->id."'":'NULL').",";
+ $sql.= " '".addslashes($this->description)."'";
+ $sql.= ")";
+
+ dol_syslog("Events::create sql=".$sql, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."events");
+ return $this->id;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dol_syslog("Events::create ".$this->error, LOG_ERR);
+ return -1;
+ }
+ }
- /*
- * \brief Update database
- * \param user User that modify
- * \param notrigger 0=no, 1=yes (no update trigger)
- * \return int <0 if KO, >0 if OK
- */
- function update($user=0, $notrigger=0)
- {
- global $conf, $langs;
-
- // Clean parameters
- $this->id=trim($this->id);
- $this->type=trim($this->type);
- $this->description=trim($this->description);
-
- // Check parameters
- // Put here code to add control on parameters values
-
- // Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX."events SET";
- $sql.= " type='".$this->type."',";
- $sql.= " dateevent=".$this->db->idate($this->dateevent).",";
- $sql.= " description='".addslashes($this->description)."'";
- $sql.= " WHERE rowid=".$this->id;
-
- dol_syslog("Events::update sql=".$sql, LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (! $resql)
- {
- $this->error="Error ".$this->db->lasterror();
- dol_syslog("Events::update ".$this->error, LOG_ERR);
- return -1;
- }
- return 1;
- }
+ /**
+ * \brief Update database
+ * \param user User that modify
+ * \param notrigger 0=no, 1=yes (no update trigger)
+ * \return int <0 if KO, >0 if OK
+ */
+ function update($user=0, $notrigger=0)
+ {
+ global $conf, $langs;
+
+ // Clean parameters
+ $this->id=trim($this->id);
+ $this->type=trim($this->type);
+ $this->description=trim($this->description);
+
+ // Check parameters
+ // Put here code to add control on parameters values
+
+ // Update request
+ $sql = "UPDATE ".MAIN_DB_PREFIX."events SET";
+ $sql.= " type='".$this->type."',";
+ $sql.= " dateevent=".$this->db->idate($this->dateevent).",";
+ $sql.= " description='".addslashes($this->description)."'";
+ $sql.= " WHERE rowid=".$this->id;
+
+ dol_syslog("Events::update sql=".$sql, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql)
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dol_syslog("Events::update ".$this->error, LOG_ERR);
+ return -1;
+ }
+ return 1;
+ }
- /*
- * \brief Load object in memory from database
- * \param id id object
- * \param user User that load
- * \return int <0 if KO, >0 if OK
- */
- function fetch($id, $user=0)
- {
- global $langs;
-
- $sql = "SELECT";
- $sql.= " t.rowid,";
- $sql.= " ".$this->db->pdate('t.tms').",";
- $sql.= " t.type,";
- $sql.= " t.entity,";
- $sql.= " ".$this->db->pdate('t.dateevent').",";
- $sql.= " t.description";
- $sql.= " FROM ".MAIN_DB_PREFIX."events as t";
- $sql.= " WHERE t.rowid = ".$id;
+ /**
+ * \brief Load object in memory from database
+ * \param id id object
+ * \param user User that load
+ * \return int <0 if KO, >0 if OK
+ */
+ function fetch($id, $user=0)
+ {
+ global $langs;
- dol_syslog("Events::fetch sql=".$sql, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
- $obj = $this->db->fetch_object($resql);
-
- $this->id = $obj->rowid;
- $this->tms = $obj->tms;
- $this->type = $obj->type;
- $this->entity = $obj->entity;
- $this->dateevent = $obj->dateevent;
- $this->description = $obj->description;
- }
- $this->db->free($resql);
-
- return 1;
- }
- else
- {
- $this->error="Error ".$this->db->lasterror();
- dol_syslog("Events::fetch ".$this->error, LOG_ERR);
- return -1;
- }
- }
+ $sql = "SELECT";
+ $sql.= " t.rowid,";
+ $sql.= " ".$this->db->pdate('t.tms').",";
+ $sql.= " t.type,";
+ $sql.= " t.entity,";
+ $sql.= " ".$this->db->pdate('t.dateevent').",";
+ $sql.= " t.description,";
+ $sql.= " t.ip,";
+ $sql.= " t.user_agent";
+ $sql.= " FROM ".MAIN_DB_PREFIX."events as t";
+ $sql.= " WHERE t.rowid = ".$id;
+
+ dol_syslog("Events::fetch sql=".$sql, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+ $this->tms = $obj->tms;
+ $this->type = $obj->type;
+ $this->entity = $obj->entity;
+ $this->dateevent = $obj->dateevent;
+ $this->description = $obj->description;
+ $this->ip = $obj->ip;
+ $this->user_agent = $obj->user_agent;
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dol_syslog("Events::fetch ".$this->error, LOG_ERR);
+ return -1;
+ }
+ }
- /*
- * \brief Delete object in database
- * \param user User that delete
- * \return int <0 if KO, >0 if OK
- */
+ /**
+ * \brief Delete object in database
+ * \param user User that delete
+ * \return int <0 if KO, >0 if OK
+ */
function delete($user)
{
global $conf, $langs;
@@ -212,12 +218,12 @@ class Events // extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."events";
$sql.= " WHERE rowid=".$this->id;
- dol_syslog("Events::delete sql=".$sql);
+ dol_syslog("Events::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
- dol_syslog("Events::delete ".$this->error, LOG_ERR);
+ dol_syslog("Events::delete ".$this->error, LOG_ERR);
return -1;
}
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index e7d379eb588..cbdbc580a54 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -74,7 +74,7 @@ class Form
/**
* \brief Show a text and picto with tooltip on text or picto
- * \param text Texte a afficher
+ * \param text Texte to show
* \param htmltext Contenu html du tooltip, code en Html / UTF8
* \param tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2, 4=tooltip sur les 2 et force en Ajax
* \param direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres
@@ -83,6 +83,7 @@ class Form
* \param width Width of tooltip
* \param shiftX Shift of tooltip
* \return string Code html du tooltip (texte+picto)
+ * \remarks Use function textwithpicto if you can.
*/
function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$i=1,$width='200',$shiftX='10')
{
diff --git a/htdocs/includes/triggers/interface_all_Logevents.class.php b/htdocs/includes/triggers/interface_all_Logevents.class.php
index 38549c82105..c2ce2980ee5 100644
--- a/htdocs/includes/triggers/interface_all_Logevents.class.php
+++ b/htdocs/includes/triggers/interface_all_Logevents.class.php
@@ -100,11 +100,11 @@ class InterfaceLogevents
function run_trigger($action,$object,$user,$langs,$conf,$entity=1)
{
if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features)
-
+
$key='MAIN_LOGEVENTS_'.$action;
//dol_syslog("xxxxxxxxxxx".$key);
if (empty($conf->global->$key)) return 0; // Log events not enabled for this action
-
+
if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form)
// Actions
@@ -241,6 +241,7 @@ class InterfaceLogevents
$event->dateevent=$this->date;
$event->label=$this->texte;
$event->description=$this->desc;
+ $event->user_agent=$_SERVER["HTTP_USER_AGENT"];
$result=$event->create($user);
if ($result > 0)
diff --git a/htdocs/install/mysql/migration/2.6.0-2.7.0.sql b/htdocs/install/mysql/migration/2.6.0-2.7.0.sql
index b87384640d9..ba26cfd873b 100644
--- a/htdocs/install/mysql/migration/2.6.0-2.7.0.sql
+++ b/htdocs/install/mysql/migration/2.6.0-2.7.0.sql
@@ -215,6 +215,8 @@ UPDATE llx_const SET entity=0 WHERE name='SYSLOG_LEVEL';
ALTER TABLE llx_dolibarr_modules drop primary KEY;
ALTER TABLE llx_dolibarr_modules ADD PRIMARY KEY pk_dolibarr_modules (numero, entity);
+ALTER TABLE llx_events add column user_agent varchar(128) NULL after ip;
+
alter table llx_commande_fournisseur add column ref_supplier varchar(30) after entity;
diff --git a/htdocs/install/mysql/tables/llx_events.sql b/htdocs/install/mysql/tables/llx_events.sql
index 31da56fdaf6..cb80ca65e71 100644
--- a/htdocs/install/mysql/tables/llx_events.sql
+++ b/htdocs/install/mysql/tables/llx_events.sql
@@ -33,6 +33,7 @@ create table llx_events
fk_user integer, -- id user
description varchar(250) NOT NULL, -- full description of action
ip varchar(32) NOT NULL, -- ip
+ user_agent varchar(128) NULL, -- user agent
fk_object integer -- id of related object
) type=innodb;
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 93999db7bf7..96064457f53 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -242,7 +242,7 @@ if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,do
if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
// Set authmode
-$authmode=split(',',$dolibarr_main_authentication);
+$authmode=explode(',',$dolibarr_main_authentication);
// No authentication mode
if (! sizeof($authmode))