Fix: Do not load language file before user lang has been set.

This commit is contained in:
Laurent Destailleur 2009-01-30 22:18:07 +00:00
parent d698e4b4d8
commit 4017a39162
6 changed files with 61 additions and 48 deletions

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,14 +22,14 @@
\brief List of security events
\version $Id$
*/
require_once("./pre.inc.php");
if (! $user->admin)
accessforbidden();
// Sécurité accés client
if ($user->societe_id > 0)
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
@ -103,7 +103,7 @@ if ($result)
$form->form_confirm($_SERVER["PHP_SELF"], $langs->trans('PurgeAuditEvents'), $langs->trans('ConfirmPurgeAuditEvents'), 'confirm_purge');
print '<br>';
}
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"e.dateevent","","",'align="left"',$sortfield,$sortorder);
@ -140,7 +140,7 @@ if ($result)
print '<td align="right" class="liste_titre">';
print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">';
print '</td>';
print "</tr>\n";
print '</form>';
@ -149,11 +149,11 @@ if ($result)
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
// Date
print '<td align="left" nowrap="nowrap">'.dolibarr_print_date($obj->dateevent,'%Y-%m-%d %H:%M:%S').'</td>';
@ -175,14 +175,22 @@ if ($result)
print '</td>';
// Description
print '<td>'.$obj->description.'</td>';
print '<td>';
$text=$langs->trans($obj->description);
if (eregi('\((.*)\)',$obj->description,$reg))
{
$val=split(',',$reg[1]);
$text=$langs->trans($val[0], isset($val[1])?$val[1]:'', isset($val[2])?$val[2]:'', isset($val[3])?$val[3]:'', isset($val[4])?$val[4]:'');
}
print $text;
print '</td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
$i++;
}
if ($num == 0)
{
if ($usefilter) print '<tr><td colspan="6">'.$langs->trans("NoEventFoundWithCriteria").'</td></tr>';
@ -190,7 +198,7 @@ if ($result)
}
print "</table>";
$db->free();
if ($num && $_GET["action"] != 'purge')
{
print '<div class="tabsAction">';

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,28 +17,27 @@
*/
/**
\file htdocs/includes/triggers/interface_all_Logevents.class.php
\ingroup core
\brief Trigger file for
\version $Id$
* \file htdocs/includes/triggers/interface_all_Logevents.class.php
* \ingroup core
* \brief Trigger file for
* \version $Id$
*/
/**
\class InterfaceLogevents
\brief Classe des fonctions triggers des actions agenda
*/
* \class InterfaceLogevents
* \brief Classe des fonctions triggers des actions agenda
*/
class InterfaceLogevents
{
var $db;
var $error;
var $date;
var $duree;
var $texte;
var $desc;
/**
* \brief Constructeur.
* \param DB Handler d'acces base
@ -46,7 +45,7 @@ class InterfaceLogevents
function InterfaceLogevents($DB)
{
$this->db = $DB ;
$this->name = eregi_replace('^Interface','',get_class($this));
$this->family = "core";
$this->description = "Triggers of this module allows to add security event records inside Dolibarr.";
@ -61,7 +60,7 @@ class InterfaceLogevents
{
return $this->name;
}
/**
* \brief Renvoi descriptif du lot de triggers
* \return string Descriptif du lot de triggers
@ -103,35 +102,33 @@ class InterfaceLogevents
$key='MAIN_LOGEVENTS_'.$action;
//dolibarr_syslog("xxxxxxxxxxx".$key);
if (empty($conf->global->$key)) return 0; // Log events not enabled for this action
// Actions
if ($action == 'USER_LOGIN')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("users");
// Initialisation donnees (date,duree,texte,desc)
$this->date=time();
$this->duree=0;
$this->texte=$langs->transnoentities("UserLogged",$object->login);
$this->desc=$langs->transnoentities("UserLogged",$object->login);
}
$this->texte="(UserLogged,".$object->login.")";
$this->desc="(UserLogged,".$object->login.")";
}
if ($action == 'USER_LOGIN_FAILED')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("users");
// Initialisation donnees (date,duree,texte,desc)
$this->date=time();
$this->duree=0;
$this->texte=$object->trigger_mesg; // Message direct
$this->desc=$object->trigger_mesg; // Message direct
}
}
if ($action == 'USER_CREATE')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("users");
// Initialisation donnees (date,duree,texte,desc)
$this->date=time();
$this->duree=0;
@ -255,7 +252,7 @@ class InterfaceLogevents
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other");
// Initialisation donnees (date,duree,texte,desc)
$this->date=time();
$this->duree=0;
@ -337,7 +334,7 @@ class InterfaceLogevents
$this->desc=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
}
// Invoices
elseif ($action == 'BILL_VALIDATE')
{
@ -500,7 +497,7 @@ class InterfaceLogevents
if ($this->date)
{
include_once(DOL_DOCUMENT_ROOT.'/core/events.class.php');
$event=new Events($this->db);
$event->type=$action;
$event->dateevent=$this->date;

View File

@ -309,7 +309,6 @@ if (! isset($_SESSION["dol_login"]))
session_name($sessionname);
session_start();
$langs->load('main');
if ($resultFetchUser == 0)
{
$langs->load('main');
@ -350,7 +349,6 @@ else
session_name($sessionname);
session_start();
$langs->load('main');
if ($resultFetchUser == 0)
{
$langs->load('main');
@ -901,13 +899,13 @@ function left_menu($menu_array, $helppagename='', $form_search='')
{
print $form_search;
}
// Zone d'affichage permanente des marque pages
if ($conf->bookmark->enabled && $user->rights->bookmark->lire)
{
include_once (DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php');
$langs->load("bookmarks");
$ret=printBookmarksList($db, $langs);
print "\n";
print "<!-- Begin Bookmarks -->\n";

View File

@ -69,8 +69,8 @@ function llxHeader($head = "")
if ($user->rights->propale->lire)
{
$langs->load("propal");
$menu->add_submenu(DOL_URL_ROOT."/comm/propal.php", $langs->trans("Prop"));
$langs->load("propal");
$menu->add_submenu(DOL_URL_ROOT."/comm/propal.php", $langs->trans("Prop"));
}
}

View File

@ -167,7 +167,7 @@ class Translate {
/**
* \brief Load in a memory array, translation key-value for a particular file.
* If data for file already loaded, do nothing.
* All data in translation array are stored in ISO-8859-1 format.
* All data in translation array are stored in UTF-8 format.
* \param domain File name to load (.lang file). Use @ before value if domain is in a module directory.
* \param alt Use alternate file even if file in target language is found
* \return int <0 if KO, >0 if OK
@ -176,7 +176,7 @@ class Translate {
*/
function Load($domain,$alt=0)
{
// dolibarr_syslog("Translate::Load domain=".$domain." alt=".$alt);
dolibarr_syslog("Translate::Load domain=".$domain." alt=".$alt);
// Check parameters
if (empty($domain))
@ -303,6 +303,16 @@ class Translate {
}
/**
* \brief Mark domain as not loaded to be able to load it again.
* \param domain File name to load (.lang file). Use @ before value if domain is in a module directory.
*/
function UnLoad($domain)
{
dolibarr_syslog("Translate::UnLoad domain=".$domain." marked as not loaded", LOG_DEBUG);
$this->tab_loaded[$domain]=0;
}
/**
* \brief Retourne la liste des domaines charg<EFBFBD>es en memoire
* \return array Tableau des domaines charg<EFBFBD>es

View File

@ -1086,15 +1086,15 @@ class User extends CommonObject
*/
function update_last_login_date()
{
dolibarr_syslog ("Mise a jour date derniere connexion pour user->id=".$this->id);
$now=time();
$now=gmmktime();
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
$sql.= " datepreviouslogin = datelastlogin,";
$sql.= " datelastlogin = ".$this->db->idate($now).",";
$sql.= " tms = tms"; // La date de derniere modif doit changer sauf pour la mise a jour de date de derniere connexion
$sql.= " WHERE rowid = ".$this->id;
dolibarr_syslog ("Update last login date for user->id=".$this->id." ".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{