Add useragent in llx_events

This commit is contained in:
Laurent Destailleur 2009-10-20 12:45:52 +00:00
parent 5ff8353fc2
commit 192fea4164
7 changed files with 169 additions and 153 deletions

View File

@ -81,7 +81,7 @@ $form=new Form($db);
$userstatic=new User($db); $userstatic=new User($db);
$usefilter=0; $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.= " e.fk_user, e.description,";
$sql.= " u.login"; $sql.= " u.login";
$sql.= " FROM ".MAIN_DB_PREFIX."events as e"; $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_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_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_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->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit+1, $offset); $sql.= $db->plimit($conf->liste_limit+1, $offset);
//print $sql; //print $sql;
@ -193,7 +194,11 @@ if ($result)
print $text; print $text;
print '</td>'; print '</td>';
print '<td>&nbsp;</td>'; // More informations
print '<td align="right">';
$htmltext='<b>'.$langs->trans("UserAgent").'</b>: '.$obj->user_agent;
print $form->textwithpicto('',$htmltext);
print '</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;

View File

@ -36,7 +36,7 @@
\class Events \class Events
\brief Events class \brief Events class
\remarks Initialy built by build_class_from_table on 2008-02-28 17:25 \remarks Initialy built by build_class_from_table on 2008-02-28 17:25
*/ */
class Events // extends CommonObject class Events // extends CommonObject
{ {
var $db; //!< To store db handler var $db; //!< To store db handler
@ -87,6 +87,7 @@ class Events // extends CommonObject
$sql.= "type,"; $sql.= "type,";
$sql.= "entity,"; $sql.= "entity,";
$sql.= "ip,"; $sql.= "ip,";
$sql.= "user_agent,";
$sql.= "dateevent,"; $sql.= "dateevent,";
$sql.= "fk_user,"; $sql.= "fk_user,";
$sql.= "description"; $sql.= "description";
@ -94,6 +95,7 @@ class Events // extends CommonObject
$sql.= " '".$this->type."',"; $sql.= " '".$this->type."',";
$sql.= " ".$conf->entity.","; $sql.= " ".$conf->entity.",";
$sql.= " '".$_SERVER['REMOTE_ADDR']."',"; $sql.= " '".$_SERVER['REMOTE_ADDR']."',";
$sql.= " ".($_SERVER['HTTP_USER_AGENT']?"'".$_SERVER['HTTP_USER_AGENT']."'":'NULL').",";
$sql.= " ".$this->db->idate($this->dateevent).","; $sql.= " ".$this->db->idate($this->dateevent).",";
$sql.= " ".($user->id?"'".$user->id."'":'NULL').","; $sql.= " ".($user->id?"'".$user->id."'":'NULL').",";
$sql.= " '".addslashes($this->description)."'"; $sql.= " '".addslashes($this->description)."'";
@ -115,7 +117,7 @@ class Events // extends CommonObject
} }
/* /**
* \brief Update database * \brief Update database
* \param user User that modify * \param user User that modify
* \param notrigger 0=no, 1=yes (no update trigger) * \param notrigger 0=no, 1=yes (no update trigger)
@ -152,7 +154,7 @@ class Events // extends CommonObject
} }
/* /**
* \brief Load object in memory from database * \brief Load object in memory from database
* \param id id object * \param id id object
* \param user User that load * \param user User that load
@ -168,7 +170,9 @@ class Events // extends CommonObject
$sql.= " t.type,"; $sql.= " t.type,";
$sql.= " t.entity,"; $sql.= " t.entity,";
$sql.= " ".$this->db->pdate('t.dateevent').","; $sql.= " ".$this->db->pdate('t.dateevent').",";
$sql.= " t.description"; $sql.= " t.description,";
$sql.= " t.ip,";
$sql.= " t.user_agent";
$sql.= " FROM ".MAIN_DB_PREFIX."events as t"; $sql.= " FROM ".MAIN_DB_PREFIX."events as t";
$sql.= " WHERE t.rowid = ".$id; $sql.= " WHERE t.rowid = ".$id;
@ -186,6 +190,8 @@ class Events // extends CommonObject
$this->entity = $obj->entity; $this->entity = $obj->entity;
$this->dateevent = $obj->dateevent; $this->dateevent = $obj->dateevent;
$this->description = $obj->description; $this->description = $obj->description;
$this->ip = $obj->ip;
$this->user_agent = $obj->user_agent;
} }
$this->db->free($resql); $this->db->free($resql);
@ -200,7 +206,7 @@ class Events // extends CommonObject
} }
/* /**
* \brief Delete object in database * \brief Delete object in database
* \param user User that delete * \param user User that delete
* \return int <0 if KO, >0 if OK * \return int <0 if KO, >0 if OK

View File

@ -74,7 +74,7 @@ class Form
/** /**
* \brief Show a text and picto with tooltip on text or picto * \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 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 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 * \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 width Width of tooltip
* \param shiftX Shift of tooltip * \param shiftX Shift of tooltip
* \return string Code html du tooltip (texte+picto) * \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') function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$i=1,$width='200',$shiftX='10')
{ {

View File

@ -241,6 +241,7 @@ class InterfaceLogevents
$event->dateevent=$this->date; $event->dateevent=$this->date;
$event->label=$this->texte; $event->label=$this->texte;
$event->description=$this->desc; $event->description=$this->desc;
$event->user_agent=$_SERVER["HTTP_USER_AGENT"];
$result=$event->create($user); $result=$event->create($user);
if ($result > 0) if ($result > 0)

View File

@ -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 drop primary KEY;
ALTER TABLE llx_dolibarr_modules ADD PRIMARY KEY pk_dolibarr_modules (numero, entity); 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; alter table llx_commande_fournisseur add column ref_supplier varchar(30) after entity;

View File

@ -33,6 +33,7 @@ create table llx_events
fk_user integer, -- id user fk_user integer, -- id user
description varchar(250) NOT NULL, -- full description of action description varchar(250) NOT NULL, -- full description of action
ip varchar(32) NOT NULL, -- ip ip varchar(32) NOT NULL, -- ip
user_agent varchar(128) NULL, -- user agent
fk_object integer -- id of related object fk_object integer -- id of related object
) type=innodb; ) type=innodb;

View File

@ -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'; if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
// Set authmode // Set authmode
$authmode=split(',',$dolibarr_main_authentication); $authmode=explode(',',$dolibarr_main_authentication);
// No authentication mode // No authentication mode
if (! sizeof($authmode)) if (! sizeof($authmode))