From ff9b139705c666cf1796530344324de50cdd00e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Sun, 10 Jul 2011 16:50:40 +0000 Subject: [PATCH] Fix: Missing fields and missing encoding of special chars --- htdocs/contact/class/contact.class.php | 15 ++++++++------- htdocs/core/class/commonobject.class.php | 23 +++++++++++++---------- htdocs/core/class/html.form.class.php | 8 ++++---- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 0243d4669b9..aa588cdb286 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -25,7 +25,7 @@ * \file htdocs/contact/class/contact.class.php * \ingroup societe * \brief File of contacts class - * \version $Id: contact.class.php,v 1.30 2011/07/04 09:36:29 eldy Exp $ + * \version $Id: contact.class.php,v 1.31 2011/07/10 16:50:40 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); @@ -42,15 +42,16 @@ class Contact extends CommonObject var $table_element='socpeople'; var $id; - var $civilite_id; - var $name; - var $nom; + var $civilite_id; // In fact we stor civility_code + var $lastname; + var $name; // TODO deprecated + var $nom; // TODO deprecated var $firstname; - var $prenom; + var $prenom; // TODO deprecated var $address; - var $cp; // TODO deprecated + var $cp; // TODO deprecated var $zip; - var $ville; // TODO deprecated + var $ville; // TODO deprecated var $town; var $fk_departement; // Id of department diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cfe5baccb5b..e9ae1ea7e05 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -22,7 +22,7 @@ * \file htdocs/core/class/commonobject.class.php * \ingroup core * \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...) - * \version $Id: commonobject.class.php,v 1.144 2011/07/04 09:36:29 eldy Exp $ + * \version $Id: commonobject.class.php,v 1.145 2011/07/10 16:50:40 eldy Exp $ */ @@ -264,10 +264,10 @@ class CommonObject /** * Get array of all contacts for an object - * @param statut Status of lines to get (-1=all) - * @param source Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user) - * @param list 0:all, 1:just id - * @return array Array of contacts + * @param statut int Status of lines to get (-1=all) + * @param source string Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user) + * @param int list 0:Return array contains all properties, 1:Return array contains just id + * @return array Array of contacts */ function liste_contact($statut=-1,$source='external',$list=0) { @@ -278,7 +278,7 @@ class CommonObject $sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id"; if ($source == 'internal') $sql.=", '-1' as socid"; if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid"; - $sql.= ", t.name as nom, t.firstname"; + $sql.= ", t.civilite as civility, t.name as lastname, t.firstname, t.email"; $sql.= ", tc.source, tc.element, tc.code, tc.libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; $sql.= ", ".MAIN_DB_PREFIX."element_contact ec"; @@ -307,7 +307,9 @@ class CommonObject { $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); - $tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom, 'firstname'=>$obj->firstname, + $tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id, + 'nom'=>$obj->lastname, // For backward compatibility + 'civility'=>$obj->civility, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'email'=>$obj->email, 'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut); } else @@ -329,9 +331,10 @@ class CommonObject } /** - * \brief Le detail d'un contact - * \param rowid L'identifiant du contact - * \return object L'objet construit par DoliDb.fetch_object + * Return fetch cursor of a contact + * FIXME We should never return an open db cursor + * @param rowid L'identifiant du contact + * @return object L'objet construit par DoliDb.fetch_object */ function detail_contact($rowid) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ff89055281e..4863b52689e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -31,7 +31,7 @@ * \file htdocs/core/class/html.form.class.php * \ingroup core * \brief File of class with all html predefined components - * \version $Id: html.form.class.php,v 1.186 2011/07/04 11:33:22 eldy Exp $ + * \version $Id: html.form.class.php,v 1.187 2011/07/10 16:50:40 eldy Exp $ */ @@ -3146,7 +3146,7 @@ class Form * @param key_in_label 1 pour afficher la key dans la valeur "[key] value" * @param value_as_key 1 to use value as key * @param option Valeur de l'option en fonction du type choisi - * @param translate Traduire la valeur + * @param translate Translate and encode value * @param maxlen Length maximum for labels * @param disabled Html select box is disabled * @return string HTML select string @@ -3178,13 +3178,13 @@ class Form if ($key_in_label) { $newval=($translate?$langs->trans($value):$value); - $selectOptionValue = $key.' - '.($maxlen?dol_trunc($newval,$maxlen):$newval); + $selectOptionValue = dol_htmlentitiesbr($key.' - '.($maxlen?dol_trunc($newval,$maxlen):$newval)); $out.=$selectOptionValue; } else { $newval=($translate?$langs->trans($value):$value); - $selectOptionValue = ($maxlen?dol_trunc($newval,$maxlen):$newval); + $selectOptionValue = dol_htmlentitiesbr($maxlen?dol_trunc($newval,$maxlen):$newval); if ($value == '' || $value == '-') { $selectOptionValue=' '; } $out.=$selectOptionValue; } -- GitLab