2
0
forked from Wavyzz/dolibarr

Fix: use the original json functions

This commit is contained in:
Regis Houssin
2012-03-18 19:59:38 +01:00
parent ed41e03589
commit 4ecc64504d
13 changed files with 13 additions and 45 deletions

View File

@@ -1037,7 +1037,7 @@ class Propal extends CommonObject
$this->cond_reglement = $obj->cond_reglement; $this->cond_reglement = $obj->cond_reglement;
$this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; $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_author_id = $obj->fk_user_author;
$this->user_valid_id = $obj->fk_user_valid; $this->user_valid_id = $obj->fk_user_valid;

View File

@@ -1293,7 +1293,7 @@ class Commande extends CommonObject
$this->fk_delivery_address = $obj->fk_adresse_livraison; $this->fk_delivery_address = $obj->fk_adresse_livraison;
$this->propale_id = $obj->fk_source; $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(); $this->lines = array();

View File

@@ -232,7 +232,7 @@ class Deplacement extends CommonObject
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->fk_project = $obj->fk_projet; $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; return 1;
} }

View File

@@ -828,7 +828,7 @@ class Facture extends CommonObject
$this->user_valid = $obj->fk_user_valid; $this->user_valid = $obj->fk_user_valid;
$this->modelpdf = $obj->model_pdf; $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; if ($this->statut == 0) $this->brouillon = 1;

View File

@@ -355,7 +355,7 @@ class Contrat extends CommonObject
$this->socid = $result["fk_soc"]; $this->socid = $result["fk_soc"];
$this->fk_soc = $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); $this->db->free($resql);

View File

@@ -2142,7 +2142,7 @@ abstract class CommonObject
$this->db->begin(); $this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $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; $sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG);

View File

@@ -165,7 +165,7 @@ class Conf
$varname = $partname.'_modules'; // TODO deprecated $varname = $partname.'_modules'; // TODO deprecated
if (! isset($this->$varname) || ! is_array($this->$varname)) { $this->$varname = array(); } // 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(); } 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; 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('login','menus','substitutions','triggers'))) $value = '/'.$modulename.'/core/'.$partname.'/';
else if (in_array($partname,array('models'))) $value = '/'.$modulename.'/'; else if (in_array($partname,array('models'))) $value = '/'.$modulename.'/';

View File

@@ -2791,7 +2791,7 @@ class Form
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut // 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]['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']; $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
$i++; $i++;
} }

View File

@@ -145,38 +145,6 @@ if (! function_exists('json_decode'))
} }
} }
/**
* 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 * Function to return value of a static property when class
* name is dynamically defined (not hard coded). * name is dynamically defined (not hard coded).

View File

@@ -1308,12 +1308,12 @@ abstract class DolibarrModules
// Can defined other parameters // Can defined other parameters
if (is_array($value['data']) && ! empty($value['data'])) 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']; if (isset($value['entity'])) $entity = $value['entity'];
} }
else else
{ {
$newvalue = dol_json_encode($value); $newvalue = json_encode($value);
} }
} }

View File

@@ -245,7 +245,7 @@ class Fichinter extends CommonObject
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->modelpdf = $obj->model_pdf; $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; if ($this->statut == 0) $this->brouillon = 1;

View File

@@ -169,7 +169,7 @@ class CommandeFournisseur extends Commande
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf; $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); $this->db->free($resql);

View File

@@ -346,7 +346,7 @@ class FactureFournisseur extends Facture
$this->model_pdf = $obj->model_pdf; $this->model_pdf = $obj->model_pdf;
$this->import_key = $obj->import_key; $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->socid = $obj->socid;
$this->socnom = $obj->socnom; $this->socnom = $obj->socnom;