Merge branch 'patch-2' of github.com:marcosgdf/dolibarr into
marcosgdf-patch-2 Conflicts: test/phpunit/Functions2LibTest.php
This commit is contained in:
commit
8e5cbb1f6c
@ -32,7 +32,6 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't nee
|
|||||||
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
|
||||||
|
|
||||||
$langs->load('compta');
|
$langs->load('compta');
|
||||||
|
|
||||||
@ -115,4 +114,4 @@ $toJsonArray['result'] = price($result); // Return value to user format
|
|||||||
$toJsonArray['resultnum'] = price2num($result); // Return value to numeric format
|
$toJsonArray['resultnum'] = price2num($result); // Return value to numeric format
|
||||||
|
|
||||||
// Encode to JSON to return
|
// Encode to JSON to return
|
||||||
echo dol_json_encode($toJsonArray); // Printing the call's result
|
echo json_encode($toJsonArray); // Printing the call's result
|
||||||
|
|||||||
@ -104,8 +104,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
||||||
$tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
|
||||||
$endyear=$tmparray['year'];
|
$endyear=$tmparray['year'];
|
||||||
$shownb=$tmparray['shownb'];
|
$shownb=$tmparray['shownb'];
|
||||||
$showtot=$tmparray['showtot'];
|
$showtot=$tmparray['showtot'];
|
||||||
|
|||||||
@ -103,8 +103,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
||||||
$tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
|
||||||
$endyear=$tmparray['year'];
|
$endyear=$tmparray['year'];
|
||||||
$shownb=$tmparray['shownb'];
|
$shownb=$tmparray['shownb'];
|
||||||
$showtot=$tmparray['showtot'];
|
$showtot=$tmparray['showtot'];
|
||||||
|
|||||||
@ -104,8 +104,7 @@ class box_graph_orders_permonth extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
||||||
$tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
|
||||||
$endyear=$tmparray['year'];
|
$endyear=$tmparray['year'];
|
||||||
$shownb=$tmparray['shownb'];
|
$shownb=$tmparray['shownb'];
|
||||||
$showtot=$tmparray['showtot'];
|
$showtot=$tmparray['showtot'];
|
||||||
|
|||||||
@ -103,8 +103,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
||||||
$tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
|
||||||
$endyear=$tmparray['year'];
|
$endyear=$tmparray['year'];
|
||||||
$shownb=$tmparray['shownb'];
|
$shownb=$tmparray['shownb'];
|
||||||
$showtot=$tmparray['showtot'];
|
$showtot=$tmparray['showtot'];
|
||||||
|
|||||||
@ -96,8 +96,7 @@ class box_graph_product_distribution extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
||||||
$tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
|
||||||
$year=$tmparray['year'];
|
$year=$tmparray['year'];
|
||||||
$showinvoicenb=$tmparray['showinvoicenb'];
|
$showinvoicenb=$tmparray['showinvoicenb'];
|
||||||
$showpropalnb=$tmparray['showpropalnb'];
|
$showpropalnb=$tmparray['showpropalnb'];
|
||||||
|
|||||||
@ -104,8 +104,7 @@ class box_graph_propales_permonth extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
||||||
$tmparray=dol_json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode],true);
|
|
||||||
$endyear=$tmparray['year'];
|
$endyear=$tmparray['year'];
|
||||||
$shownb=$tmparray['shownb'];
|
$shownb=$tmparray['shownb'];
|
||||||
$showtot=$tmparray['showtot'];
|
$showtot=$tmparray['showtot'];
|
||||||
|
|||||||
@ -81,7 +81,7 @@ abstract class Stats
|
|||||||
if ($foundintocache) // Cache file found and is not too old
|
if ($foundintocache) // Cache file found and is not too old
|
||||||
{
|
{
|
||||||
dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
|
dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
|
||||||
$data = dol_json_decode(file_get_contents($newpathofdestfile), true);
|
$data = json_decode(file_get_contents($newpathofdestfile), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -112,7 +112,7 @@ abstract class Stats
|
|||||||
dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
|
dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
|
||||||
if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
|
if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
|
||||||
$fp = fopen($newpathofdestfile, 'w');
|
$fp = fopen($newpathofdestfile, 'w');
|
||||||
fwrite($fp, dol_json_encode($data));
|
fwrite($fp, json_encode($data));
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
||||||
@chmod($newpathofdestfile, octdec($newmask));
|
@chmod($newpathofdestfile, octdec($newmask));
|
||||||
@ -172,7 +172,7 @@ abstract class Stats
|
|||||||
if ($foundintocache) // Cache file found and is not too old
|
if ($foundintocache) // Cache file found and is not too old
|
||||||
{
|
{
|
||||||
dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
|
dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
|
||||||
$data = dol_json_decode(file_get_contents($newpathofdestfile), true);
|
$data = json_decode(file_get_contents($newpathofdestfile), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -203,7 +203,7 @@ abstract class Stats
|
|||||||
dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
|
dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
|
||||||
if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
|
if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
|
||||||
$fp = fopen($newpathofdestfile, 'w');
|
$fp = fopen($newpathofdestfile, 'w');
|
||||||
fwrite($fp, dol_json_encode($data));
|
fwrite($fp, json_encode($data));
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
||||||
@chmod($newpathofdestfile, octdec($newmask));
|
@chmod($newpathofdestfile, octdec($newmask));
|
||||||
@ -295,7 +295,7 @@ abstract class Stats
|
|||||||
if ($foundintocache) // Cache file found and is not too old
|
if ($foundintocache) // Cache file found and is not too old
|
||||||
{
|
{
|
||||||
dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
|
dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate.".");
|
||||||
$data = dol_json_decode(file_get_contents($newpathofdestfile), true);
|
$data = json_decode(file_get_contents($newpathofdestfile), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -309,7 +309,7 @@ abstract class Stats
|
|||||||
dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
|
dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk.");
|
||||||
if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
|
if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
|
||||||
$fp = fopen($newpathofdestfile, 'w');
|
$fp = fopen($newpathofdestfile, 'w');
|
||||||
fwrite($fp, dol_json_encode($data));
|
fwrite($fp, json_encode($data));
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
||||||
@chmod($newpathofdestfile, octdec($newmask));
|
@chmod($newpathofdestfile, octdec($newmask));
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||||
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
|
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -32,11 +33,7 @@
|
|||||||
* This file contains all frequently used functions.
|
* This file contains all frequently used functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
include_once DOL_DOCUMENT_ROOT .'/core/lib/json.lib.php';
|
||||||
if (! function_exists('json_encode'))
|
|
||||||
{
|
|
||||||
include_once DOL_DOCUMENT_ROOT .'/core/lib/json.lib.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to return value of a static property when class
|
* Function to return value of a static property when class
|
||||||
@ -46,26 +43,16 @@ if (! function_exists('json_encode'))
|
|||||||
* @param string $class Class name
|
* @param string $class Class name
|
||||||
* @param string $member Name of property
|
* @param string $member Name of property
|
||||||
* @return mixed Return value of static property
|
* @return mixed Return value of static property
|
||||||
|
* @deprecated PHP 5.3 is now the minimum requirement, this is no longer necessary
|
||||||
*/
|
*/
|
||||||
function getStaticMember($class, $member)
|
function getStaticMember($class, $member)
|
||||||
{
|
{
|
||||||
if (is_object($class)) $class = get_class($class);
|
if (isset($class::$member)) {
|
||||||
$classObj = new ReflectionClass($class);
|
return $class::$member;
|
||||||
$result = null;
|
|
||||||
|
|
||||||
$found=0;
|
|
||||||
foreach($classObj->getStaticProperties() as $prop => $value)
|
|
||||||
{
|
|
||||||
if ($prop == $member)
|
|
||||||
{
|
|
||||||
$result = $value;
|
|
||||||
$found++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $found) dol_print_error('','Try to get a static member "'.$member.'" in class "'.$class.'" that does not exists or is not static.');
|
dol_print_error('','Try to get a static member "'.$member.'" in class "'.$class.'" that does not exists or is not static.');
|
||||||
return $result;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1495,19 +1482,11 @@ function dol_print_address($address, $htmlid, $mode, $id)
|
|||||||
*/
|
*/
|
||||||
function isValidEmail($address)
|
function isValidEmail($address)
|
||||||
{
|
{
|
||||||
if (preg_match("/.*<(.+)>/i", $address, $regs)) {
|
if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
|
||||||
$address = $regs[1];
|
|
||||||
}
|
|
||||||
// 2 letters domains extensions are for countries
|
|
||||||
// 3 letters domains extensions: biz|com|edu|gov|int|mil|net|org|pro|...
|
|
||||||
if (preg_match("/^[^@\s\t]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2,3}|asso|aero|coop|info|name)\$/i",$address))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3654,24 +3633,19 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace CRLF in string with a HTML BR tag
|
* Replace CRLF in string with a HTML BR tag
|
||||||
*
|
*
|
||||||
* @param string $stringtoencode String to encode
|
* @param string $stringtoencode String to encode
|
||||||
* @param string $nl2brmode 0=Adding br before \n, 1=Replacing \n by br
|
* @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br
|
||||||
* @param string $forxml false=Use <br>, true=Use <br />
|
* @param bool $forxml false=Use <br>, true=Use <br />
|
||||||
* @return string String encoded
|
* @return string String encoded
|
||||||
*/
|
*/
|
||||||
function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
|
function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
|
||||||
{
|
{
|
||||||
if (! $nl2brmode)
|
if (!$nl2brmode) {
|
||||||
{
|
return nl2br($stringtoencode, $forxml);
|
||||||
// We use @ to avoid warning on PHP4 that does not support entity encoding from UTF8;
|
} else {
|
||||||
if (version_compare(PHP_VERSION, '5.3.0') < 0) return @nl2br($stringtoencode);
|
$ret=preg_replace('/(\r\n|\r|\n)/i', ($forxml?'<br />':'<br>'), $stringtoencode);
|
||||||
else return @nl2br($stringtoencode,$forxml);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ret=preg_replace('/(\r\n|\r|\n)/i',($forxml?'<br />':'<br>'),$stringtoencode);
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3767,12 +3741,11 @@ function dol_html_entity_decode($a,$b,$c='UTF-8')
|
|||||||
* @param string $encoding Encoding
|
* @param string $encoding Encoding
|
||||||
* @param bool $double_encode When double_encode is turned off PHP will not encode existing html entities
|
* @param bool $double_encode When double_encode is turned off PHP will not encode existing html entities
|
||||||
* @return string $ret Encoded string
|
* @return string $ret Encoded string
|
||||||
|
* @deprecated Since PHP4 support is no longer available, this function does not make sense
|
||||||
*/
|
*/
|
||||||
function dol_htmlentities($string, $flags=null, $encoding='UTF-8', $double_encode=false)
|
function dol_htmlentities($string, $flags=null, $encoding='UTF-8', $double_encode=false)
|
||||||
{
|
{
|
||||||
// We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8;
|
return htmlentities($string, $flags, $encoding, $double_encode);
|
||||||
$ret=@htmlentities($string, $flags, $encoding, $double_encode);
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3803,7 +3776,7 @@ function dol_string_is_good_iso($s)
|
|||||||
* Return nb of lines of a clear text
|
* Return nb of lines of a clear text
|
||||||
*
|
*
|
||||||
* @param string $s String to check
|
* @param string $s String to check
|
||||||
* @param string $maxchar Not yet used
|
* @param int $maxchar Not yet used
|
||||||
* @return int Number of lines
|
* @return int Number of lines
|
||||||
*/
|
*/
|
||||||
function dol_nboflines($s,$maxchar=0)
|
function dol_nboflines($s,$maxchar=0)
|
||||||
@ -3858,12 +3831,12 @@ function dol_nboflines_bis($text,$maxlinesize=0,$charset='UTF-8')
|
|||||||
/**
|
/**
|
||||||
* Same function than microtime in PHP 5 but compatible with PHP4
|
* Same function than microtime in PHP 5 but compatible with PHP4
|
||||||
*
|
*
|
||||||
* @return float Time (millisecondes) with microsecondes in decimal part
|
* @return float Time (millisecondes) with microsecondes in decimal part
|
||||||
|
* @deprecated Dolibarr does not support PHP4, you should use native function
|
||||||
*/
|
*/
|
||||||
function dol_microtime_float()
|
function dol_microtime_float()
|
||||||
{
|
{
|
||||||
list($usec, $sec) = explode(" ", microtime());
|
return microtime(true);
|
||||||
return ((float) $usec + (float) $sec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -256,15 +256,7 @@ class ImportCsv extends ModeleImports
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$arrayres=array();
|
$arrayres=fgetcsv($this->handle,100000,$this->separator,$this->enclosure,$this->escape);
|
||||||
if (version_compare(phpversion(), '5.3') < 0)
|
|
||||||
{
|
|
||||||
$arrayres=fgetcsv($this->handle,100000,$this->separator,$this->enclosure);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$arrayres=fgetcsv($this->handle,100000,$this->separator,$this->enclosure,$this->escape);
|
|
||||||
}
|
|
||||||
|
|
||||||
// End of file
|
// End of file
|
||||||
if ($arrayres === false) return false;
|
if ($arrayres === false) return false;
|
||||||
|
|||||||
@ -166,7 +166,6 @@ require_once 'filefunc.inc.php';
|
|||||||
// If there is a POST parameter to tell to save automatically some POST parameters into a cookies, we do it
|
// If there is a POST parameter to tell to save automatically some POST parameters into a cookies, we do it
|
||||||
if (! empty($_POST["DOL_AUTOSET_COOKIE"]))
|
if (! empty($_POST["DOL_AUTOSET_COOKIE"]))
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
|
||||||
$tmpautoset=explode(':',$_POST["DOL_AUTOSET_COOKIE"],2);
|
$tmpautoset=explode(':',$_POST["DOL_AUTOSET_COOKIE"],2);
|
||||||
$tmplist=explode(',',$tmpautoset[1]);
|
$tmplist=explode(',',$tmpautoset[1]);
|
||||||
$cookiearrayvalue='';
|
$cookiearrayvalue='';
|
||||||
@ -177,7 +176,7 @@ if (! empty($_POST["DOL_AUTOSET_COOKIE"]))
|
|||||||
if (! empty($_POST[$postkey])) $cookiearrayvalue[$tmpkey]=$_POST[$postkey];
|
if (! empty($_POST[$postkey])) $cookiearrayvalue[$tmpkey]=$_POST[$postkey];
|
||||||
}
|
}
|
||||||
$cookiename=$tmpautoset[0];
|
$cookiename=$tmpautoset[0];
|
||||||
$cookievalue=dol_json_encode($cookiearrayvalue);
|
$cookievalue=json_encode($cookiearrayvalue);
|
||||||
//var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue);
|
//var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue);
|
||||||
setcookie($cookiename, empty($cookievalue)?'':$cookievalue, empty($cookievalue)?0:(time()+(86400*354)), '/'); // keep cookie 1 year
|
setcookie($cookiename, empty($cookievalue)?'':$cookievalue, empty($cookievalue)?0:(time()+(86400*354)), '/'); // keep cookie 1 year
|
||||||
if (empty($cookievalue)) unset($_COOKIE[$cookiename]);
|
if (empty($cookievalue)) unset($_COOKIE[$cookiename]);
|
||||||
|
|||||||
@ -25,7 +25,6 @@
|
|||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
||||||
@ -65,7 +64,7 @@ $limit = $conf->liste_limit;
|
|||||||
$offset = $limit * $page ;
|
$offset = $limit * $page ;
|
||||||
|
|
||||||
$listofdata=array();
|
$listofdata=array();
|
||||||
if (! empty($_SESSION['massstockmove'])) $listofdata=dol_json_decode($_SESSION['massstockmove'],true);
|
if (! empty($_SESSION['massstockmove'])) $listofdata=json_decode($_SESSION['massstockmove'],true);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -106,7 +105,7 @@ if ($action == 'addline')
|
|||||||
if (count(array_keys($listofdata)) > 0) $id=max(array_keys($listofdata)) + 1;
|
if (count(array_keys($listofdata)) > 0) $id=max(array_keys($listofdata)) + 1;
|
||||||
else $id=1;
|
else $id=1;
|
||||||
$listofdata[$id]=array('id'=>$id, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw);
|
$listofdata[$id]=array('id'=>$id, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw);
|
||||||
$_SESSION['massstockmove']=dol_json_encode($listofdata);
|
$_SESSION['massstockmove']=json_encode($listofdata);
|
||||||
|
|
||||||
unset($id_product);
|
unset($id_product);
|
||||||
//unset($id_sw);
|
//unset($id_sw);
|
||||||
@ -118,7 +117,7 @@ if ($action == 'addline')
|
|||||||
if ($action == 'delline' && $idline != '')
|
if ($action == 'delline' && $idline != '')
|
||||||
{
|
{
|
||||||
if (! empty($listofdata[$idline])) unset($listofdata[$idline]);
|
if (! empty($listofdata[$idline])) unset($listofdata[$idline]);
|
||||||
if (count($listofdata) > 0) $_SESSION['massstockmove']=dol_json_encode($listofdata);
|
if (count($listofdata) > 0) $_SESSION['massstockmove']=json_encode($listofdata);
|
||||||
else unset($_SESSION['massstockmove']);
|
else unset($_SESSION['massstockmove']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -146,12 +146,54 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIsValidUrl()
|
public function testIsValidUrl()
|
||||||
{
|
{
|
||||||
$result=isValidUrl('http://www.google.com',1);
|
//Simple check
|
||||||
print __METHOD__." result=".$result."\n";
|
$result = isValidUrl('http://google.com');
|
||||||
$this->assertEquals(1,$result);
|
$this->assertEquals($result, 1);
|
||||||
$result=isValidUrl('www.google.com',2);
|
|
||||||
print __METHOD__." result=".$result."\n";
|
$result = isValidUrl('gooçgle');
|
||||||
$this->assertEquals(0,$result);
|
$this->assertEquals($result, 0);
|
||||||
|
|
||||||
|
//With scheme check
|
||||||
|
$result = isValidUrl('http://www.google.com', 1);
|
||||||
|
$this->assertEquals($result, 1);
|
||||||
|
|
||||||
|
$result = isValidUrl('ftp://www.google.com', 1);
|
||||||
|
$this->assertEquals($result, 0);
|
||||||
|
|
||||||
|
//With password check
|
||||||
|
$result = isValidUrl('http://user:password@http://www.google.com', 1, 1);
|
||||||
|
$this->assertEquals($result, 1);
|
||||||
|
|
||||||
|
$result = isValidUrl('http://www.google.com', 1, 1);
|
||||||
|
$this->assertEquals($result, 0);
|
||||||
|
|
||||||
|
//With port check
|
||||||
|
$result = isValidUrl('http://google.com:8080', 0, 0, 1);
|
||||||
|
$this->assertEquals($result, 1);
|
||||||
|
|
||||||
|
$result = isValidUrl('http://google.com', 0, 0, 1);
|
||||||
|
$this->assertEquals($result, 0);
|
||||||
|
|
||||||
|
//With path check
|
||||||
|
$result = isValidUrl('http://google.com/search', 0, 0, 0, 1);
|
||||||
|
$this->assertEquals($result, 1);
|
||||||
|
|
||||||
|
$result = isValidUrl('http://google.com', 0, 0, 0, 1);
|
||||||
|
$this->assertEquals($result, 0);
|
||||||
|
|
||||||
|
//With query check
|
||||||
|
$result = isValidUrl('http://google.com/search?test=test', 0, 0, 0, 0, 1);
|
||||||
|
$this->assertEquals($result, 1);
|
||||||
|
|
||||||
|
$result = isValidUrl('http://google.com', 0, 0, 0, 0, 1);
|
||||||
|
$this->assertEquals($result, 0);
|
||||||
|
|
||||||
|
//With anchor check
|
||||||
|
$result = isValidUrl('http://google.com/search#done', 0, 0, 0, 0, 0, 1);
|
||||||
|
$this->assertEquals($result, 1);
|
||||||
|
|
||||||
|
$result = isValidUrl('http://google.com/search', 0, 0, 0, 0, 0, 1);
|
||||||
|
$this->assertEquals($result, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -787,4 +787,26 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}',json_encode($tmp));
|
$this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}',json_encode($tmp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dol_nl2br
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testDolNl2Br() {
|
||||||
|
|
||||||
|
//String to encode
|
||||||
|
$string = "a\na";
|
||||||
|
|
||||||
|
$this->assertEquals(dol_nl2br($string), "a<br>\na");
|
||||||
|
|
||||||
|
//With $forxml parameter
|
||||||
|
$this->assertEquals(dol_nl2br($string, 0, 1), "a<br />\na");
|
||||||
|
|
||||||
|
//Replacing \n by br
|
||||||
|
$this->assertEquals(dol_nl2br($string, 1), "a<br>a");
|
||||||
|
|
||||||
|
//With $forxml parameter
|
||||||
|
$this->assertEquals(dol_nl2br($string, 1, 1), "a<br />a");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,6 @@ global $conf,$user,$langs,$db;
|
|||||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||||
//require_once 'PHPUnit/Autoload.php';
|
//require_once 'PHPUnit/Autoload.php';
|
||||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||||
require_once dirname(__FILE__).'/../../htdocs/core/lib/json.lib.php';
|
|
||||||
|
|
||||||
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||||
if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user