Qual: deprecate dol_json_encode() and dol_json_decode()
PHP > 5.3 supports json_encode() and json_decode() natively
This commit is contained in:
parent
3f9270ea78
commit
ea798c2315
@ -96,7 +96,7 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')
|
|||||||
{
|
{
|
||||||
$idtoremove=GETPOST('removedassigned');
|
$idtoremove=GETPOST('removedassigned');
|
||||||
|
|
||||||
if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=dol_json_decode($_SESSION['assignedtouser'],1);
|
if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=json_decode($_SESSION['assignedtouser'],1);
|
||||||
else $tmpassigneduserids=array();
|
else $tmpassigneduserids=array();
|
||||||
|
|
||||||
foreach ($tmpassigneduserids as $key => $val)
|
foreach ($tmpassigneduserids as $key => $val)
|
||||||
@ -104,7 +104,7 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')
|
|||||||
if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]);
|
if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]);
|
||||||
}
|
}
|
||||||
//var_dump($_POST['removedassigned']);exit;
|
//var_dump($_POST['removedassigned']);exit;
|
||||||
$_SESSION['assignedtouser']=dol_json_encode($tmpassigneduserids);
|
$_SESSION['assignedtouser']=json_encode($tmpassigneduserids);
|
||||||
$donotclearsession=1;
|
$donotclearsession=1;
|
||||||
if ($action == 'add') $action = 'create';
|
if ($action == 'add') $action = 'create';
|
||||||
if ($action == 'update') $action = 'edit';
|
if ($action == 'update') $action = 'edit';
|
||||||
@ -119,10 +119,10 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
|
|||||||
$assignedtouser=array();
|
$assignedtouser=array();
|
||||||
if (! empty($_SESSION['assignedtouser']))
|
if (! empty($_SESSION['assignedtouser']))
|
||||||
{
|
{
|
||||||
$assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true);
|
$assignedtouser=json_decode($_SESSION['assignedtouser'], true);
|
||||||
}
|
}
|
||||||
$assignedtouser[GETPOST('assignedtouser')]=array('id'=>GETPOST('assignedtouser'), 'transparency'=>GETPOST('transparency'),'mandatory'=>1);
|
$assignedtouser[GETPOST('assignedtouser')]=array('id'=>GETPOST('assignedtouser'), 'transparency'=>GETPOST('transparency'),'mandatory'=>1);
|
||||||
$_SESSION['assignedtouser']=dol_json_encode($assignedtouser);
|
$_SESSION['assignedtouser']=json_encode($assignedtouser);
|
||||||
}
|
}
|
||||||
$donotclearsession=1;
|
$donotclearsession=1;
|
||||||
if ($action == 'add') $action = 'create';
|
if ($action == 'add') $action = 'create';
|
||||||
@ -215,7 +215,7 @@ if ($action == 'add')
|
|||||||
$object->duree=((float) (GETPOST('dureehour') * 60) + (float) GETPOST('dureemin')) * 60;
|
$object->duree=((float) (GETPOST('dureehour') * 60) + (float) GETPOST('dureemin')) * 60;
|
||||||
|
|
||||||
$listofuserid=array();
|
$listofuserid=array();
|
||||||
if (! empty($_SESSION['assignedtouser'])) $listofuserid=dol_json_decode($_SESSION['assignedtouser']);
|
if (! empty($_SESSION['assignedtouser'])) $listofuserid=json_decode($_SESSION['assignedtouser']);
|
||||||
$i=0;
|
$i=0;
|
||||||
foreach($listofuserid as $key => $value)
|
foreach($listofuserid as $key => $value)
|
||||||
{
|
{
|
||||||
@ -387,7 +387,7 @@ if ($action == 'update')
|
|||||||
if (! empty($_SESSION['assignedtouser'])) // Now concat assigned users
|
if (! empty($_SESSION['assignedtouser'])) // Now concat assigned users
|
||||||
{
|
{
|
||||||
// Restore array with key with same value than param 'id'
|
// Restore array with key with same value than param 'id'
|
||||||
$tmplist1=dol_json_decode($_SESSION['assignedtouser'], true); $tmplist2=array();
|
$tmplist1=json_decode($_SESSION['assignedtouser'], true); $tmplist2=array();
|
||||||
foreach($tmplist1 as $key => $val)
|
foreach($tmplist1 as $key => $val)
|
||||||
{
|
{
|
||||||
if ($val['id'] > 0 && $val['id'] != $assignedtouser) $listofuserid[$val['id']]=$val;
|
if ($val['id'] > 0 && $val['id'] != $assignedtouser) $listofuserid[$val['id']]=$val;
|
||||||
@ -677,13 +677,13 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
$assignedtouser=GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
|
$assignedtouser=GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
|
||||||
if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser,'mandatory'=>0,'transparency'=>$object->transparency); // Owner first
|
if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser,'mandatory'=>0,'transparency'=>$object->transparency); // Owner first
|
||||||
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
|
$_SESSION['assignedtouser']=json_encode($listofuserid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!empty($_SESSION['assignedtouser']))
|
if (!empty($_SESSION['assignedtouser']))
|
||||||
{
|
{
|
||||||
$listofuserid=dol_json_decode($_SESSION['assignedtouser'], true);
|
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0');
|
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0');
|
||||||
@ -929,13 +929,13 @@ if ($id > 0)
|
|||||||
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
|
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
|
$_SESSION['assignedtouser']=json_encode($listofuserid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!empty($_SESSION['assignedtouser']))
|
if (!empty($_SESSION['assignedtouser']))
|
||||||
{
|
{
|
||||||
$listofuserid=dol_json_decode($_SESSION['assignedtouser'], true);
|
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0');
|
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0');
|
||||||
@ -1101,13 +1101,13 @@ if ($id > 0)
|
|||||||
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
|
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
|
$_SESSION['assignedtouser']=json_encode($listofuserid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!empty($_SESSION['assignedtouser']))
|
if (!empty($_SESSION['assignedtouser']))
|
||||||
{
|
{
|
||||||
$listofuserid=dol_json_decode($_SESSION['assignedtouser'], true);
|
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print $form->select_dolusers_forevent('view','assignedtouser',1);
|
print $form->select_dolusers_forevent('view','assignedtouser',1);
|
||||||
|
|||||||
@ -186,13 +186,13 @@ if ($object->id > 0)
|
|||||||
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
|
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
|
$_SESSION['assignedtouser']=json_encode($listofuserid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!empty($_SESSION['assignedtouser']))
|
if (!empty($_SESSION['assignedtouser']))
|
||||||
{
|
{
|
||||||
$listofuserid=dol_json_decode($_SESSION['assignedtouser'], true);
|
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print $form->select_dolusers_forevent('view','assignedtouser',1);
|
print $form->select_dolusers_forevent('view','assignedtouser',1);
|
||||||
|
|||||||
@ -1462,7 +1462,7 @@ class Form
|
|||||||
$assignedtouser=array();
|
$assignedtouser=array();
|
||||||
if (!empty($_SESSION['assignedtouser']))
|
if (!empty($_SESSION['assignedtouser']))
|
||||||
{
|
{
|
||||||
$assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true);
|
$assignedtouser=json_decode($_SESSION['assignedtouser'], true);
|
||||||
}
|
}
|
||||||
$nbassignetouser=count($assignedtouser);
|
$nbassignetouser=count($assignedtouser);
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@ if (! function_exists('json_encode'))
|
|||||||
*
|
*
|
||||||
* @param mixed $elements PHP Object to json encode
|
* @param mixed $elements PHP Object to json encode
|
||||||
* @return string Json encoded string
|
* @return string Json encoded string
|
||||||
|
* @deprecated PHP >= 5.3 supports native json_encode
|
||||||
*/
|
*/
|
||||||
function dol_json_encode($elements)
|
function dol_json_encode($elements)
|
||||||
{
|
{
|
||||||
@ -219,6 +220,7 @@ if (! function_exists('json_decode'))
|
|||||||
* @param string $json Json encoded to PHP Object or Array
|
* @param string $json Json encoded to PHP Object or Array
|
||||||
* @param bool $assoc False return an object, true return an array. Try to always use it with true !
|
* @param bool $assoc False return an object, true return an array. Try to always use it with true !
|
||||||
* @return mixed Object or Array or false on error
|
* @return mixed Object or Array or false on error
|
||||||
|
* @deprecated PHP >= 5.3 supports native json_decode
|
||||||
*/
|
*/
|
||||||
function dol_json_decode($json, $assoc=false)
|
function dol_json_decode($json, $assoc=false)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -37,13 +37,8 @@ if (! defined('EURO')) define('EURO',chr(128));
|
|||||||
// Define syslog constants
|
// Define syslog constants
|
||||||
if (! defined('LOG_DEBUG'))
|
if (! defined('LOG_DEBUG'))
|
||||||
{
|
{
|
||||||
if (function_exists("define_syslog_variables"))
|
if (! function_exists("syslog")) {
|
||||||
{
|
// For PHP versions without syslog (like running on Windows OS)
|
||||||
define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Pour PHP sans syslog (comme sous Windows)
|
|
||||||
define('LOG_EMERG',0);
|
define('LOG_EMERG',0);
|
||||||
define('LOG_ALERT',1);
|
define('LOG_ALERT',1);
|
||||||
define('LOG_CRIT',2);
|
define('LOG_CRIT',2);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user