From 4ecc64504d92c1cdeaf96e77ec84e2fd98d48f00 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 19:59:38 +0100 Subject: [PATCH 1/3] Fix: use the original json functions --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- .../deplacement/class/deplacement.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/conf.class.php | 2 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/functions.lib.php | 32 ------------------- htdocs/core/modules/DolibarrModules.class.php | 4 +-- htdocs/fichinter/class/fichinter.class.php | 2 +- .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 2 +- 13 files changed, 13 insertions(+), 45 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 89d172b48dacf..98b6337ec9716 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1037,7 +1037,7 @@ function fetch($rowid,$ref='') $this->cond_reglement = $obj->cond_reglement; $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; - $this->extraparams = (array) dol_json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->user_author_id = $obj->fk_user_author; $this->user_valid_id = $obj->fk_user_valid; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 1c1f3467f68e5..0f80894cb2be7 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1293,7 +1293,7 @@ function fetch($id, $ref='', $ref_ext='', $ref_int='') $this->fk_delivery_address = $obj->fk_adresse_livraison; $this->propale_id = $obj->fk_source; - $this->extraparams = (array) dol_json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->lines = array(); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 74840aa2188d1..8b24f22f2cdd1 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -232,7 +232,7 @@ function fetch($id) $this->note_public = $obj->note_public; $this->fk_project = $obj->fk_projet; - $this->extraparams = (array) dol_json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); return 1; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 044c39c6495cf..30ad1d0dff848 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -828,7 +828,7 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='') $this->user_valid = $obj->fk_user_valid; $this->modelpdf = $obj->model_pdf; - $this->extraparams = (array) dol_json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 40573e77a7f6e..7771520978d76 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -355,7 +355,7 @@ function fetch($id,$ref='') $this->socid = $result["fk_soc"]; $this->fk_soc = $result["fk_soc"]; - $this->extraparams = (array) dol_json_decode($result["extraparams"], true); + $this->extraparams = (array) json_decode($result["extraparams"], true); $this->db->free($resql); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b243de184ab78..27db87bc83b14 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2142,7 +2142,7 @@ function setExtraParameters() $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET extraparams = "'.$this->db->escape(dol_json_encode($this->extraparams)).'"'; + $sql.= ' SET extraparams = "'.$this->db->escape(json_encode($this->extraparams)).'"'; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 455ded86c93e5..dbff136ff3034 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -165,7 +165,7 @@ function setValues($db) $varname = $partname.'_modules'; // TODO deprecated if (! isset($this->$varname) || ! is_array($this->$varname)) { $this->$varname = array(); } // TODO deprecated if (! isset($this->modules_parts[$partname]) || ! is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } - $arrValue = dol_json_decode($value,true); + $arrValue = json_decode($value,true); if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue; else if (in_array($partname,array('login','menus','substitutions','triggers'))) $value = '/'.$modulename.'/core/'.$partname.'/'; else if (in_array($partname,array('models'))) $value = '/'.$modulename.'/'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 08787c8b1bc97..c0941ba7c483d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2791,7 +2791,7 @@ function load_cache_currencies() // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'')); - $this->cache_currencies[$obj->code_iso]['unicode'] = (array) dol_json_decode($obj->unicode, true); + $this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true); $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label']; $i++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 93827c7107c78..5814b271cbf3b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -145,38 +145,6 @@ function json_decode($json, $assoc=false) } } -/** - * Function that encodes data in json format. - * TODO Remove this function because the json_encode is already redesigned by dolibarr function and - * this functions was designed for compatibility between an instable 3.2 version with final 3.2 version. We must - * manage compatibility only between 2 stable versions. - * - * @param mixed $elements PHP object to json encode - * @return string Json encoded string - */ -function dol_json_encode($elements) -{ - return json_encode($elements); // This function is redesigned into functions.lib.php -} - -/** - * Function that decodes data from json format - * TODO Remove this function because the json_encode is already redesigned by dolibarr function and - * this functions was designed for compatibility between an instable 3.2 version with final 3.2 version. We must - * manage compatibility only between 2 stable versions. - * - * @param string $json Json encoded to PHP Object or Array - * @param bool $assoc False return an object, true return an array - * @return mixed Object or Array - */ -function dol_json_decode($json, $assoc=false) -{ - $out=''; - $out = @unserialize($json); // For compatibility, test if serialized - if (empty($out)) $out = json_decode($json, $assoc); // This function is redesigned into functions.lib.php - return $out; -} - /** * Function to return value of a static property when class * name is dynamically defined (not hard coded). diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 5ba0935124f98..5d60c70c4e62b 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1308,12 +1308,12 @@ function insert_module_parts() // Can defined other parameters if (is_array($value['data']) && ! empty($value['data'])) { - $newvalue = dol_json_encode($value['data']); + $newvalue = json_encode($value['data']); if (isset($value['entity'])) $entity = $value['entity']; } else { - $newvalue = dol_json_encode($value); + $newvalue = json_encode($value); } } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 650915aa654f4..4d43f0cd416db 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -245,7 +245,7 @@ function fetch($rowid,$ref='') $this->note_private = $obj->note_private; $this->modelpdf = $obj->model_pdf; - $this->extraparams = (array) dol_json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c9fe55b4a1ab1..bedafa87fdddc 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -169,7 +169,7 @@ function fetch($id,$ref='') $this->note_public = $obj->note_public; $this->modelpdf = $obj->model_pdf; - $this->extraparams = (array) dol_json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->db->free($resql); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 0edafd896f7e9..e6941ab7a336f 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -346,7 +346,7 @@ function fetch($id='',$ref='') $this->model_pdf = $obj->model_pdf; $this->import_key = $obj->import_key; - $this->extraparams = (array) dol_json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->socid = $obj->socid; $this->socnom = $obj->socnom; From 99ab46510bcc071bce83028721b2ce809bc87013 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 20:23:50 +0100 Subject: [PATCH 2/3] Fix: remove private status for external modules --- htdocs/core/class/commonobject.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 27db87bc83b14..679d380a40c62 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2416,7 +2416,7 @@ function printObjectLines($action,$seller,$buyer,$selected=0,$dateSelector=0,$ho } else { - $this->_printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$hookmanager); + $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$hookmanager); } $i++; @@ -2443,7 +2443,7 @@ function printObjectLines($action,$seller,$buyer,$selected=0,$dateSelector=0,$ho * @param HookManager $hookmanager Hook manager * @return void */ - private function _printObjectLine($action,$line,$var=true,$num=0,$i=0,$dateSelector=0,$seller,$buyer,$selected=0,$hookmanager=false) + function printObjectLine($action,$line,$var=true,$num=0,$i=0,$dateSelector=0,$seller,$buyer,$selected=0,$hookmanager=false) { global $conf,$langs,$user; global $form,$bc,$bcdd; @@ -2567,7 +2567,7 @@ function printOriginLinesList($hookmanager=false) } else { - $this->_printOriginLine($line,$var); + $this->printOriginLine($line,$var); } $i++; @@ -2584,7 +2584,7 @@ function printOriginLinesList($hookmanager=false) * @param string $var Var * @return void */ - private function _printOriginLine($line,$var) + function printOriginLine($line,$var) { global $langs,$bc; From 3afb2878c2655035637ab10975b9ca756ce3c7e9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Mar 2012 20:45:01 +0100 Subject: [PATCH 3/3] Fix: broken indentation --- htdocs/comm/propal/class/propal.class.php | 46 +++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 98b6337ec9716..39a602eadc5e0 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1,32 +1,32 @@ * Copyright (C) 2004 Eric Seigne -* Copyright (C) 2004-2011 Laurent Destailleur -* Copyright (C) 2005 Marc Barilley -* Copyright (C) 2005-2012 Regis Houssin -* Copyright (C) 2006 Andre Cianfarani -* Copyright (C) 2008 Raphael Bertrand -* Copyright (C) 2010-2011 Juanjo Menent -* Copyright (C) 2010-2011 Philippe Grand -* -* 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 -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2008 Raphael Bertrand + * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010-2011 Philippe Grand + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ /** * \file htdocs/comm/propal/class/propal.class.php -* \brief Fichier de la classe des propales -*/ + * \brief Fichier de la classe des propales + */ require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT ."/product/class/product.class.php");