mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 09:08:09 +01:00
Merge remote-tracking branch 'uptream/develop' into 6.0-pcard
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -569,7 +569,7 @@ class Account extends CommonObject
|
||||
$sql.= ", '".$this->db->escape($this->label)."'";
|
||||
$sql.= ", ".$conf->entity;
|
||||
$sql.= ", '".$this->db->escape($this->account_number)."'";
|
||||
$sql.= ", '".$this->db->escape($this->fk_accountancy_journal)."'";
|
||||
$sql.= ", ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null");
|
||||
$sql.= ", '".$this->db->escape($this->bank)."'";
|
||||
$sql.= ", '".$this->code_banque."'";
|
||||
$sql.= ", '".$this->code_guichet."'";
|
||||
@@ -702,8 +702,7 @@ class Account extends CommonObject
|
||||
$sql.= ",rappro = ".$this->rappro;
|
||||
$sql.= ",url = ".($this->url?"'".$this->url."'":"null");
|
||||
$sql.= ",account_number = '".$this->db->escape($this->account_number)."'";
|
||||
$sql.= ",fk_accountancy_journal = '".$this->db->escape($this->fk_accountancy_journal)."'";
|
||||
|
||||
$sql.= ",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null");
|
||||
$sql.= ",bank = '".$this->db->escape($this->bank)."'";
|
||||
$sql.= ",code_banque='".$this->db->escape($this->code_banque)."'";
|
||||
$sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'";
|
||||
|
||||
@@ -657,6 +657,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
|
||||
* @param string $destfile Destination file (can't be a directory. use native php @rename() to move a directory)
|
||||
* @param integer $newmask Mask in octal string for new file (0 by default means $conf->global->MAIN_UMASK)
|
||||
* @param int $overwriteifexists Overwrite file if exists (1 by default)
|
||||
* @param int $testvirus Do an antivirus test. Move is canceled if a virus is found.
|
||||
* @return boolean True if OK, false if KO
|
||||
* @see dol_move_uploaded_file
|
||||
*/
|
||||
@@ -1624,12 +1625,12 @@ function dol_compress_file($inputfile, $outputfile, $mode="gz")
|
||||
*/
|
||||
function dol_uncompress($inputfile,$outputdir)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $langs;
|
||||
|
||||
if (! empty($conf->global->ODTPHP_PATHTOPCLZIP))
|
||||
if (defined('ODTPHP_PATHTOPCLZIP'))
|
||||
{
|
||||
dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".$conf->global->ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
|
||||
include_once $conf->global->ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
|
||||
dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
|
||||
include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
|
||||
$archive = new PclZip($inputfile);
|
||||
$result=$archive->extract(PCLZIP_OPT_PATH, $outputdir);
|
||||
//var_dump($result);
|
||||
@@ -1698,7 +1699,7 @@ function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta
|
||||
* @param string $entity Restrict onto entity (0=no restriction)
|
||||
* @param User $fuser User object (forced)
|
||||
* @param string $refname Ref of object to check permission for external users (autodetect if not provided)
|
||||
* @param string $more Check permission for 'read' or 'write'
|
||||
* @param string $mode Check permission for 'read' or 'write'
|
||||
* @return mixed Array with access information : 'accessallowed' & 'sqlprotectagainstexternals' & 'original_file' (as a full path name)
|
||||
* @see restrictedArea
|
||||
*/
|
||||
|
||||
@@ -281,7 +281,7 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
|
||||
$relativepathstring = preg_replace('/^\//', '', $relativepathstring);
|
||||
|
||||
// Retrieve values if restore_lastsearch_values is set and there is saved values
|
||||
if ($_GET['restore_lastsearch_values'] && ! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // Keep $_GET here
|
||||
if (! empty($_GET['restore_lastsearch_values']) && ! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // Keep $_GET here
|
||||
{
|
||||
$tmp=json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true);
|
||||
if (is_array($tmp))
|
||||
@@ -615,19 +615,20 @@ function dol_buildpath($path, $type=0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a clone of instance of object (new instance with same properties)
|
||||
* This function works for both PHP4 and PHP5
|
||||
* Create a clone of instance of object (new instance with same value for properties)
|
||||
* Property that are reference are also new object (true clone)
|
||||
*
|
||||
* @param object $object Object to clone
|
||||
* @return object Object clone
|
||||
* @deprecated Dolibarr no longer supports PHP4, use PHP5 native clone construct
|
||||
* @see https://php.net/manual/language.oop5.cloning.php
|
||||
*/
|
||||
function dol_clone($object)
|
||||
{
|
||||
dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
|
||||
//dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
|
||||
|
||||
$myclone = clone $object;
|
||||
//$myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable
|
||||
$myclone=unserialize(serialize($object));
|
||||
|
||||
return $myclone;
|
||||
}
|
||||
|
||||
@@ -2469,7 +2470,7 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo
|
||||
if ($trunc == 'right')
|
||||
{
|
||||
$newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string;
|
||||
if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:1)))
|
||||
if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:1)))
|
||||
return dol_substr($newstring,0,$size,$stringencoding).($nodot?'':'...');
|
||||
else
|
||||
return $string;
|
||||
|
||||
@@ -781,7 +781,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
}
|
||||
|
||||
// Personalized field {XXX-1} à {XXX-9}
|
||||
$maskperso=array();
|
||||
/*$maskperso=array();
|
||||
$maskpersonew=array();
|
||||
$tmpmask=$mask;
|
||||
while (preg_match('/\{([A-Z]+)\-([1-9])\}/i',$tmpmask,$regKey))
|
||||
@@ -789,17 +789,17 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
$maskperso[$regKey[1]]='\{'.$regKey[1]+'\-'.$regKey[2].'\}';
|
||||
$maskpersonew[$regKey[1]]=str_pad('', '_', $regKey[2], STR_PAD_RIGHT);
|
||||
$tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew, $tmpmask);
|
||||
}
|
||||
}*/
|
||||
|
||||
$maskwithonlyymcode=$mask;
|
||||
$maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{(c+)(0*)\}/i',$maskrefclient,$maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{(t+)\}/i',$masktype_value,$maskwithonlyymcode);
|
||||
foreach($maskperso as $key => $val)
|
||||
/*foreach($maskperso as $key => $val)
|
||||
{
|
||||
$maskwithonlyymcode=preg_replace('/'.$val.'/i', $maskpersonew[$key], $maskwithonlyymcode);
|
||||
}
|
||||
}*/
|
||||
$maskwithnocode=$maskwithonlyymcode;
|
||||
$maskwithnocode=preg_replace('/\{yyyy\}/i','yyyy',$maskwithnocode);
|
||||
$maskwithnocode=preg_replace('/\{yy\}/i','yy',$maskwithnocode);
|
||||
|
||||
@@ -848,8 +848,8 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql) $err++;
|
||||
|
||||
$note=json_encode(array('authorid'=>$user->id, 'ip'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])));
|
||||
|
||||
$note=json_encode(array('authorid'=>(is_object($user)?$user->id:0), 'ip'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])));
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, value, visible, entity, note) VALUES";
|
||||
$sql.= " (".$this->db->encrypt($this->const_name,1);
|
||||
$sql.= ", ".$this->db->encrypt('1',1);
|
||||
|
||||
@@ -841,7 +841,7 @@ class Societe extends CommonObject
|
||||
$sql .= ",fk_effectif = ".(! empty($this->effectif_id)?"'".$this->db->escape($this->effectif_id)."'":"null");
|
||||
if (isset($this->stcomm_id))
|
||||
{
|
||||
$sql .= ",fk_stcomm=".($this->stcomm_id > 0 ? $this->stcomm_id : "null");
|
||||
$sql .= ",fk_stcomm=".($this->stcomm_id > 0 ? $this->stcomm_id : "0");
|
||||
}
|
||||
$sql .= ",fk_typent = ".(! empty($this->typent_id)?"'".$this->db->escape($this->typent_id)."'":"0");
|
||||
|
||||
|
||||
@@ -83,7 +83,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
print "\n".__METHOD__." Company must be setup to have name-firstname in order 'Firstname Lastname'\n";
|
||||
die();
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_MODULE_LDAP)) { print "\n".__METHOD__." module LDAP must be disabled.\n"; die(); }
|
||||
if (! empty($conf->global->MAIN_MODULE_MAILMANSPIP)) { print "\n".__METHOD__." module MailmanSpip must be disabled.\n"; die(); }
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
@@ -320,6 +322,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
'%ADDRESS%,%ZIP%,%TOWN%,%COUNTRY%,%EMAIL%,%BIRTH%,%PHOTO%,%LOGIN%,%PASSWORD%,%PRENOM%,'.
|
||||
'%NOM%,%SOCIETE%,%ADDRESS%,%ZIP%,%TOWN%,%COUNTRY%';
|
||||
|
||||
// If option to store clear password has been set, we get 'dolibspec' into PASSWORD field.
|
||||
$expected = DOL_MAIN_URL_ROOT.','.$localobject->id.',,New firstname,New name,New firstname New name,'.
|
||||
'New company,New address,New zip,New town,Belgium,newemail@newemail.com,'.dol_print_date($localobject->birth,'day').',,'.
|
||||
'newlogin,dolibspec,New firstname,New name,New company,New address,New zip,New town,Belgium';
|
||||
|
||||
@@ -121,7 +121,7 @@ class AllTests
|
||||
$suite->addTestSuite('BuildDocTest');
|
||||
require_once dirname(__FILE__).'/CMailFileTest.php';
|
||||
$suite->addTestSuite('CMailFileTest');
|
||||
|
||||
|
||||
require_once dirname(__FILE__).'/CommonObjectTest.php';
|
||||
$suite->addTestSuite('CommonObjectTest');
|
||||
|
||||
|
||||
@@ -431,10 +431,17 @@ class FilesLibTest extends PHPUnit_Framework_TestCase
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
|
||||
|
||||
//$dummyuser=new User($db);
|
||||
//$result=restrictedArea($dummyuser,'societe');
|
||||
|
||||
// We save user properties
|
||||
$savpermlire = $user->rights->facture->lire;
|
||||
$savpermcreer = $user->rights->facture->creer;
|
||||
|
||||
|
||||
// Check access to SPECIMEN
|
||||
$user->rights->facture->lire = 0;
|
||||
$user->rights->facture->creer = 0;
|
||||
$filename='SPECIMEN.pdf'; // Filename relative to module part
|
||||
@@ -473,6 +480,11 @@ class FilesLibTest extends PHPUnit_Framework_TestCase
|
||||
$filename='FA010101/FA010101.pdf'; // Filename relative to module part
|
||||
$result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write');
|
||||
$this->assertEquals(0,$result['accessallowed']);
|
||||
|
||||
|
||||
// We restore user properties
|
||||
$user->rights->facture->lire = $savpermlire;
|
||||
$user->rights->facture->creer = $savpermcreer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,6 +81,8 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
global $conf,$user,$langs,$db;
|
||||
//$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
if (! function_exists('mb_substr')) { print "\n".__METHOD__." function mb_substr must be enabled.\n"; die(); }
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,11 @@ class ModulesTest extends PHPUnit_Framework_TestCase
|
||||
$result=$mod->init();
|
||||
$this->assertLessThan($result, 0, $modlabel);
|
||||
print __METHOD__." test remove/init for module ".$modlabel.", result=".$result."\n";
|
||||
|
||||
if (in_array($modlabel, array('Ldap', 'MailmanSpip')))
|
||||
{
|
||||
$result=$mod->remove();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -128,7 +128,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
|
||||
require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/mod_facture_mercure.php';
|
||||
|
||||
@@ -138,20 +138,22 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}';
|
||||
$conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0;
|
||||
|
||||
$localobject=new Facture($this->savdb);
|
||||
|
||||
$localobject=new Facture($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user,1);
|
||||
$result3=$localobject->validate($user, $result); // create invoice by forcing ref
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1
|
||||
$result2=$localobject->create($user,1);
|
||||
print __METHOD__." result2=".$result."\n";
|
||||
$result3=$localobject->validate($user, $result); // create invoice by forcing ref
|
||||
print __METHOD__." result3=".$result."\n";
|
||||
$this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1
|
||||
$result=$localobject->is_erasable();
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted
|
||||
|
||||
$this->assertEquals(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted
|
||||
$localobject2=new Facture($this->savdb);
|
||||
$localobject2->initAsSpecimen();
|
||||
$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask)
|
||||
@@ -160,10 +162,13 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1915-0001', $result, "Test to get last value with param 'last'");
|
||||
$result=$numbering->getNextValue($mysoc, $localobject2);
|
||||
$result2=$localobject2->create($user,1);
|
||||
$result3=$localobject2->validate($user, $result); // create invoice by forcing ref
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1916-0002', $result); // counter must be now 2 (not reseted)
|
||||
$result2=$localobject2->create($user,1);
|
||||
print __METHOD__." result2=".$result."\n";
|
||||
$result3=$localobject2->validate($user, $result); // create invoice by forcing ref
|
||||
print __METHOD__." result3=".$result."\n";
|
||||
$this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1
|
||||
$result=$localobject2->is_erasable();
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertEquals(1, $result); // Can be deleted
|
||||
|
||||
@@ -79,7 +79,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
if ($conf->global->SOCIETE_CODECLIENT_ADDON != 'mod_codeclient_monkey') { print "\n".__METHOD__." third party ref checker must be setup to 'mod_codeclient_monkey' not to '".$conf->global->SOCIETE_CODECLIENT_ADDON."'.\n"; die(); }
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) { print "\n".__METHOD__." constant MAIN_DISABLEPROFIDRULE must be empty (if a module set it, disable module).\n"; die(); }
|
||||
if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) { print "\n".__METHOD__." constant MAIN_DISABLEPROFIDRULES must be empty (if a module set it, disable module).\n"; die(); }
|
||||
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
|
||||
@@ -75,6 +75,9 @@ class UserTest extends PHPUnit_Framework_TestCase
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
if (! empty($conf->global->MAIN_MODULE_LDAP)) { print "\n".__METHOD__." module LDAP must be disabled.\n"; die(); }
|
||||
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
@@ -187,7 +190,7 @@ class UserTest extends PHPUnit_Framework_TestCase
|
||||
$newlocalobject=new User($this->savdb);
|
||||
$newlocalobject->initAsSpecimen();
|
||||
$this->changeProperties($newlocalobject);
|
||||
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('id','socid','societe_id','ref','pass_indatabase','pass_indatabase_crypted','datec','datem','datelastlogin','datepreviouslogin')), array()); // Actual, Expected
|
||||
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('id','socid','societe_id','ref','pass','pass_indatabase','pass_indatabase_crypted','datec','datem','datelastlogin','datepreviouslogin')), array()); // Actual, Expected
|
||||
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ if (empty($user->id))
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
|
||||
|
||||
/**
|
||||
* Class for PHPUnit tests
|
||||
|
||||
@@ -38,6 +38,8 @@ if (empty($user->id)) {
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
|
||||
|
||||
/**
|
||||
* Class for PHPUnit tests
|
||||
|
||||
@@ -38,6 +38,8 @@ if (empty($user->id)) {
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
|
||||
|
||||
/**
|
||||
* Class for PHPUnit tests
|
||||
|
||||
@@ -40,6 +40,8 @@ if (empty($user->id)) {
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
|
||||
if (empty($conf->service->enabled))
|
||||
{
|
||||
print "Error: Module service must be enabled.\n";
|
||||
@@ -167,7 +169,9 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase
|
||||
'ref'=>'NewProductFromWS'.$datestring,
|
||||
'label'=>'New Product From WS '.$datestring,
|
||||
'type'=>1,
|
||||
'description'=>'This is a new product created from WS PHPUnit test case'
|
||||
'description'=>'This is a new product created from WS PHPUnit test case',
|
||||
'barcode'=>'123456789012',
|
||||
'barcode_type'=>2
|
||||
)
|
||||
);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
|
||||
@@ -38,6 +38,8 @@ if (empty($user->id)) {
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
|
||||
|
||||
/**
|
||||
* Class for PHPUnit tests
|
||||
|
||||
@@ -38,6 +38,8 @@ if (empty($user->id)) {
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
|
||||
|
||||
/**
|
||||
* Class for PHPUnit tests
|
||||
|
||||
Reference in New Issue
Block a user