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 <?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 * 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 * it under the terms of the GNU General Public License as published by
@ -175,7 +175,15 @@ if ($result)
print '</td>'; print '</td>';
// Description // 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 '<td>&nbsp;</td>';

View File

@ -1,5 +1,5 @@
<?php <?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 * 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 * it under the terms of the GNU General Public License as published by
@ -17,18 +17,17 @@
*/ */
/** /**
\file htdocs/includes/triggers/interface_all_Logevents.class.php * \file htdocs/includes/triggers/interface_all_Logevents.class.php
\ingroup core * \ingroup core
\brief Trigger file for * \brief Trigger file for
\version $Id$ * \version $Id$
*/ */
/** /**
\class InterfaceLogevents * \class InterfaceLogevents
\brief Classe des fonctions triggers des actions agenda * \brief Classe des fonctions triggers des actions agenda
*/ */
class InterfaceLogevents class InterfaceLogevents
{ {
var $db; var $db;
@ -108,25 +107,23 @@ class InterfaceLogevents
if ($action == 'USER_LOGIN') if ($action == 'USER_LOGIN')
{ {
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("users");
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->date=time(); $this->date=time();
$this->duree=0; $this->duree=0;
$this->texte=$langs->transnoentities("UserLogged",$object->login); $this->texte="(UserLogged,".$object->login.")";
$this->desc=$langs->transnoentities("UserLogged",$object->login); $this->desc="(UserLogged,".$object->login.")";
} }
if ($action == 'USER_LOGIN_FAILED') if ($action == 'USER_LOGIN_FAILED')
{ {
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("users");
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->date=time(); $this->date=time();
$this->duree=0; $this->duree=0;
$this->texte=$object->trigger_mesg; // Message direct $this->texte=$object->trigger_mesg; // Message direct
$this->desc=$object->trigger_mesg; // Message direct $this->desc=$object->trigger_mesg; // Message direct
} }
if ($action == 'USER_CREATE') if ($action == 'USER_CREATE')
{ {
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);

View File

@ -309,7 +309,6 @@ if (! isset($_SESSION["dol_login"]))
session_name($sessionname); session_name($sessionname);
session_start(); session_start();
$langs->load('main');
if ($resultFetchUser == 0) if ($resultFetchUser == 0)
{ {
$langs->load('main'); $langs->load('main');
@ -350,7 +349,6 @@ else
session_name($sessionname); session_name($sessionname);
session_start(); session_start();
$langs->load('main');
if ($resultFetchUser == 0) if ($resultFetchUser == 0)
{ {
$langs->load('main'); $langs->load('main');

View File

@ -69,8 +69,8 @@ function llxHeader($head = "")
if ($user->rights->propale->lire) if ($user->rights->propale->lire)
{ {
$langs->load("propal"); $langs->load("propal");
$menu->add_submenu(DOL_URL_ROOT."/comm/propal.php", $langs->trans("Prop")); $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. * \brief Load in a memory array, translation key-value for a particular file.
* If data for file already loaded, do nothing. * 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 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 * \param alt Use alternate file even if file in target language is found
* \return int <0 if KO, >0 if OK * \return int <0 if KO, >0 if OK
@ -176,7 +176,7 @@ class Translate {
*/ */
function Load($domain,$alt=0) function Load($domain,$alt=0)
{ {
// dolibarr_syslog("Translate::Load domain=".$domain." alt=".$alt); dolibarr_syslog("Translate::Load domain=".$domain." alt=".$alt);
// Check parameters // Check parameters
if (empty($domain)) 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 * \brief Retourne la liste des domaines charg<EFBFBD>es en memoire
* \return array Tableau des domaines charg<EFBFBD>es * \return array Tableau des domaines charg<EFBFBD>es

View File

@ -1086,15 +1086,15 @@ class User extends CommonObject
*/ */
function update_last_login_date() function update_last_login_date()
{ {
dolibarr_syslog ("Mise a jour date derniere connexion pour user->id=".$this->id); $now=gmmktime();
$now=time();
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
$sql.= " datepreviouslogin = datelastlogin,"; $sql.= " datepreviouslogin = datelastlogin,";
$sql.= " datelastlogin = ".$this->db->idate($now).","; $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.= " 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; $sql.= " WHERE rowid = ".$this->id;
dolibarr_syslog ("Update last login date for user->id=".$this->id." ".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {