Fix: Data are always encoded in UTF8 in Dolibarr memory, so we must not use ut8_encode on this->property variables or we encode it twice (remove of utf8_encode call was forgotten in 2.6 for contacts).

This commit is contained in:
Laurent Destailleur 2009-08-11 12:51:33 +00:00
parent b1bb20c1bf
commit 9735c0c770
5 changed files with 483 additions and 486 deletions

View File

@ -142,13 +142,13 @@ if ($_POST["action"] == 'add_action')
{ {
if ($_POST["actioncode"] == 'AC_RDV' && $contact->getFullName($langs)) if ($_POST["actioncode"] == 'AC_RDV' && $contact->getFullName($langs))
{ {
$actioncomm->label = $langs->transnoentities("TaskRDVWith",$contact->getFullName($langs)); $actioncomm->label = $langs->transnoentitiesnoconv("TaskRDVWith",$contact->getFullName($langs));
} }
else else
{ {
if ($langs->trans("Action".$actioncomm->type_code) != "Action".$actioncomm->type_code) if ($langs->trans("Action".$actioncomm->type_code) != "Action".$actioncomm->type_code)
{ {
$actioncomm->label = $langs->transnoentities("Action".$actioncomm->type_code)."\n"; $actioncomm->label = $langs->transnoentitiesnoconv("Action".$actioncomm->type_code)."\n";
} }
else $actioncomm->label = $cactioncomm->libelle; else $actioncomm->label = $cactioncomm->libelle;
} }
@ -207,7 +207,7 @@ if ($_POST["action"] == 'add_action')
{ {
$error=1; $error=1;
$_GET["action"] = 'create'; $_GET["action"] = 'create';
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DateEnd")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")).'</div>';
} }
if ($datea && $_POST["percentage"] == 0) if ($datea && $_POST["percentage"] == 0)
{ {
@ -220,7 +220,7 @@ if ($_POST["action"] == 'add_action')
{ {
$error=1; $error=1;
$_GET["action"] = 'create'; $_GET["action"] = 'create';
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'</div>';
} }
if (! $error) if (! $error)

View File

@ -200,12 +200,12 @@ class Contact extends CommonObject
} }
/* /**
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
* \param info Info string loaded by _load_ldap_info * \param info Info string loaded by _load_ldap_info
* \param mode 0=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb) * \param mode 0=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
1=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb) * 1=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
2=Return key only (uid=qqq) * 2=Return key only (uid=qqq)
* \return string DN * \return string DN
*/ */
function _load_ldap_dn($info,$mode=0) function _load_ldap_dn($info,$mode=0)
@ -219,10 +219,9 @@ class Contact extends CommonObject
} }
/* /**
* \brief Initialise tableau info (tableau des attributs LDAP) * \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs * \return array Tableau info des attributs
* TODO tester si la suppression des utf8_encode affecte l'utilisation de active directory
*/ */
function _load_ldap_info() function _load_ldap_info()
{ {
@ -232,9 +231,9 @@ class Contact extends CommonObject
$info["objectclass"]=split(',',$conf->global->LDAP_CONTACT_OBJECT_CLASS); $info["objectclass"]=split(',',$conf->global->LDAP_CONTACT_OBJECT_CLASS);
// Champs // Champs
if ($this->getFullName($langs) && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = utf8_encode($this->getFullName($langs)); if ($this->getFullName($langs) && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->getFullName($langs);
if ($this->name && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = utf8_encode($this->name); if ($this->name && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->name;
if ($this->firstname && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = utf8_encode($this->firstname); if ($this->firstname && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->firstname;
if ($this->poste) $info["title"] = $this->poste; if ($this->poste) $info["title"] = $this->poste;
if ($this->socid > 0) if ($this->socid > 0)
@ -247,15 +246,15 @@ class Contact extends CommonObject
if ($soc->client == 2) $info["businessCategory"] = "Prospects"; if ($soc->client == 2) $info["businessCategory"] = "Prospects";
if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers"; if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
} }
if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = utf8_encode($this->address); if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp; if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp;
if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = utf8_encode($this->ville); if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville;
if ($this->pays && $conf->global->LDAP_FIELD_COUNTRY) $info[$conf->global->LDAP_FIELD_COUNTRY] = $this->pays_code; if ($this->pays && $conf->global->LDAP_FIELD_COUNTRY) $info[$conf->global->LDAP_FIELD_COUNTRY] = $this->pays_code;
if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro; if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro;
if ($this->phone_perso && $conf->global->LDAP_FIELD_HOMEPHONE) $info[$conf->global->LDAP_FIELD_HOMEPHONE] = $this->phone_perso; if ($this->phone_perso && $conf->global->LDAP_FIELD_HOMEPHONE) $info[$conf->global->LDAP_FIELD_HOMEPHONE] = $this->phone_perso;
if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile; if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile;
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax; if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
if ($this->note && $conf->global->LDAP_FIELD_DESCRIPTION) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = utf8_encode($this->note); if ($this->note && $conf->global->LDAP_FIELD_DESCRIPTION) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->note;
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email; if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
@ -744,8 +743,8 @@ class Contact extends CommonObject
/** /**
* \brief Return full name (name+' '+lastname) * \brief Return full name (civility+' '+name+' '+lastname)
* \param langs Lang object for output * \param langs Lang object for translation of civility
* \param option 0=No option, 1=Add civility * \param option 0=No option, 1=Add civility
* \param nameorder 0=Lastname+Firstname, 1=Firstname+Lastname * \param nameorder 0=Lastname+Firstname, 1=Firstname+Lastname
* \return string String with full name * \return string String with full name
@ -755,21 +754,21 @@ class Contact extends CommonObject
$ret=''; $ret='';
if ($option && $this->civilite_id) if ($option && $this->civilite_id)
{ {
if ($langs->transnoentities("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentities("Civility".$this->civilite_id).' '; if ($langs->transnoentitiesnoconv("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civilite_id).' ';
else $ret.=$this->civilite_id.' '; else $ret.=$this->civilite_id.' ';
} }
if ($nameorder) if ($nameorder)
{ {
if ($this->firstname) $ret.=$langs->convToOutputCharset($this->firstname); if ($this->firstname) $ret.=$this->firstname;
if ($this->firstname && $this->name) $ret.=' '; if ($this->firstname && $this->name) $ret.=' ';
if ($this->name) $ret.=$langs->convToOutputCharset($this->name); if ($this->name) $ret.=$this->name;
} }
else else
{ {
if ($this->name) $ret.=$langs->convToOutputCharset($this->name); if ($this->name) $ret.=$this->name;
if ($this->firstname && $this->name) $ret.=' '; if ($this->firstname && $this->name) $ret.=' ';
if ($this->firstname) $ret.=$langs->convToOutputCharset($this->firstname); if ($this->firstname) $ret.=$this->firstname;
} }
return trim($ret); return trim($ret);
} }

View File

@ -1563,12 +1563,12 @@ class User extends CommonObject
} }
/* /**
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
* \param info Info string loaded by _load_ldap_info * \param info Info string loaded by _load_ldap_info
* \param mode 0=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb) * \param mode 0=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
1=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb) * 1=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
2=Return key only (uid=qqq) * 2=Return key only (uid=qqq)
* \return string DN * \return string DN
*/ */
function _load_ldap_dn($info,$mode=0) function _load_ldap_dn($info,$mode=0)
@ -1582,7 +1582,7 @@ class User extends CommonObject
} }
/* /**
* \brief Initialise tableau info (tableau des attributs LDAP) * \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs * \return array Tableau info des attributs
*/ */

View File

@ -522,12 +522,12 @@ class UserGroup extends CommonObject
} }
/* /**
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
* \param info Info string loaded by _load_ldap_info * \param info Info string loaded by _load_ldap_info
* \param mode 0=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb) * \param mode 0=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
1=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb) * 1=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
2=Return key only (uid=qqq) * 2=Return key only (uid=qqq)
* \return string DN * \return string DN
*/ */
function _load_ldap_dn($info,$mode=0) function _load_ldap_dn($info,$mode=0)
@ -541,7 +541,7 @@ class UserGroup extends CommonObject
} }
/* /**
* \brief Initialise tableau info (tableau des attributs LDAP) * \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs * \return array Tableau info des attributs
*/ */

View File

@ -1,6 +1,6 @@
<?PHP <?PHP
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-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
@ -15,15 +15,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/ */
/** /**
\file scripts/company/sync_contacts_dolibarr2ldap.php * \file scripts/company/sync_contacts_dolibarr2ldap.php
\ingroup ldap company * \ingroup ldap company
\brief Script de mise a jour des contacts dans LDAP depuis base Dolibarr * \brief Script to update all contacts from Dolibarr into a LDAP database
* \version $Id$
*/ */
// Test si mode CLI // Test si mode CLI