diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 01cdfde69fe..410ecfe7399 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -359,7 +359,7 @@ class Conf $modulename = 'supplier_proposal'; } $this->modules[$modulename] = $modulename; // Add this module in list of enabled modules - // deprecated + // deprecated in php 8.2 if (!isset($this->$modulename) || !is_object($this->$modulename)) { $this->$modulename = new stdClass(); } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index aa065dcbceb..e7b9bdbf844 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -257,6 +257,12 @@ class User extends CommonObject */ public $clicktodial_poste; + /** + * @var string 0 by default, 1 if click to dial data were already loaded for this user + */ + public $clicktodial_loaded; + + public $datelastlogin; public $datepreviouslogin; public $flagdelsessionsbefore; diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 29c8025758c..818f2676af6 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -95,13 +95,7 @@ $now = dol_now(); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." - userlogin=".$userlogin." - ".dol_print_date($now, 'dayhourrfc')." - ".gethostname()." *****\n"; // Check module cron is activated -if (empty($conf->cron->enabled)) { - print "Error: module Scheduled jobs (cron) not activated\n"; - exit(-1); -} - -// Check module cron is activated -if (empty($conf->cron->enabled)) { +if (!isModEnabled('cron')) { print "Error: module Scheduled jobs (cron) not activated\n"; exit(-1); } diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 464a127ce15..63f10782978 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -234,13 +234,13 @@ if ($resql) { $substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.dol_hash($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY."-".$obj->tag."-".$obj->email."-".$obj->rowid, "md5").'&email='.urlencode($obj->email).'&mtid='.((int) $obj->rowid); $onlinepaymentenabled = 0; - if (!empty($conf->paypal->enabled)) { + if (isModEnabled('paypal')) { $onlinepaymentenabled++; } - if (!empty($conf->paybox->enabled)) { + if (isModEnabled('paybox')) { $onlinepaymentenabled++; } - if (!empty($conf->stripe->enabled)) { + if (isModEnabled('stripe')) { $onlinepaymentenabled++; } if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { @@ -258,7 +258,7 @@ if ($resql) { } } /* For backward compatibility */ - if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { + if (isModEnabled('paypal') && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { diff --git a/test/phpunit/ActionCommTest.php b/test/phpunit/ActionCommTest.php index 2499841d671..12be63af3e4 100644 --- a/test/phpunit/ActionCommTest.php +++ b/test/phpunit/ActionCommTest.php @@ -83,7 +83,7 @@ class ActionCommTest 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 (empty($conf->agenda->enabled)) { + if (!isModEnabled('agenda')) { print __METHOD__." module agenda must be enabled.\n"; die(1); } diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 84ea7a42a6e..9a6934da2f4 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -37,7 +37,7 @@ if ($langs->defaultlang != 'en_US') { print "Error: Default language for company to run tests must be set to en_US or auto. Current is ".$langs->defaultlang."\n"; exit(1); } -if (empty($conf->adherent->enabled)) { +if (!isModEnabled('adherent')) { print "Error: Module member must be enabled to have significant results.\n"; exit(1); } @@ -45,7 +45,7 @@ if (isModEnabled('ldap')) { print "Error: LDAP module should not be enabled.\n"; exit(1); } -if (!empty($conf->google->enabled)) { +if (isModEnabled('google')) { print "Warning: Google module should not be enabled.\n"; } if (empty($user->id)) { diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index bf61ba38fbd..4d12760a1ba 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -112,25 +112,25 @@ class BuildDocTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (! $conf->facture->enabled) { + if (!isModEnabled('facture')) { print __METHOD__." invoice module not enabled\n"; die(1); } - if (! $conf->commande->enabled) { + if (!isModEnabled('commande')) { print __METHOD__." order module not enabled\n"; die(1); } - if (! $conf->propal->enabled) { + if (!isModEnabled('propal')) { print __METHOD__." propal module not enabled\n"; die(1); } - if (! $conf->project->enabled) { + if (!isModEnabled('project')) { print __METHOD__." project module not enabled\n"; die(1); } - if (! $conf->expedition->enabled) { + if (!isModEnabled('expedition')) { print __METHOD__." shipment module not enabled\n"; die(1); } - if (! $conf->ficheinter->enabled) { + if (!isModEnabled('ficheinter')) { print __METHOD__." intervention module not enabled\n"; die(1); } - if (! $conf->expensereport->enabled) { + if (!isModEnabled('expensereport')) { print __METHOD__." expensereport module not enabled\n"; die(1); } diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index cb439fe2c84..196ec351d2f 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -83,7 +83,7 @@ class CommandeTest 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 (empty($conf->commande->enabled)) { + if (!isModEnabled('commande')) { print __METHOD__." module customer order must be enabled.\n"; die(1); } diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index 8ee0c537f8a..d3cdd2d52d4 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -82,7 +82,7 @@ class EntrepotTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (empty($conf->stock->enabled)) { + if (!isModEnabled('stock')) { print __METHOD__." Module Stock must be enabled.\n"; die(1); } diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index 5f12eacdd60..6f1dacf0aab 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -86,7 +86,7 @@ class FactureTest extends PHPUnit\Framework\TestCase if (!isModEnabled('facture')) { print __METHOD__." module customer invoice must be enabled.\n"; die(1); } - if (!empty($conf->ecotaxdeee->enabled)) { + if (isModEnabled('ecotaxdeee')) { print __METHOD__." ecotaxdeee module must not be enabled.\n"; die(1); } diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 8ba2022c111..3af5c36023a 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -417,7 +417,10 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $errorstring = ''; dol_mkdir($conf->admin->dir_temp); - $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; $conf->syslog->enabled=1; $_REQUEST['logtohtml']=1; + $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; + $conf->syslog->enabled=1; + $conf->modules['syslog'] = 'syslog'; + $_REQUEST['logtohtml']=1; $conf->logbuffer=array(); $result=dol_compress_file($filein, $fileout, $format, $errorstring); @@ -427,6 +430,7 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $result=dol_uncompress($fileout, $dirout); print __METHOD__." uncompress result=".join(',', $result)."\n"; + print join(', ', $conf->logbuffer); $this->assertEquals(0, count($result), "Pb with dol_uncompress_file of file ".$fileout); // Format gz @@ -445,7 +449,10 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $errorstring = ''; dol_mkdir($conf->admin->dir_temp); - $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; $conf->syslog->enabled=1; $_REQUEST['logtohtml']=1; + $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; + $conf->syslog->enabled=1; + $conf->modules['syslog'] = 'syslog'; + $_REQUEST['logtohtml']=1; $conf->logbuffer=array(); $result=dol_compress_file($filein, $fileout, $format, $errorstring); diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index e635e449379..c361698a501 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -1141,10 +1141,10 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $verifcond=verifCond('1==2'); $this->assertFalse($verifcond, 'Test a false comparison'); - $verifcond=verifCond('$conf->facture->enabled'); + $verifcond=verifCond('isModEnabled("facture")'); $this->assertTrue($verifcond, 'Test that the conf property of a module reports true when enabled'); - $verifcond=verifCond('$conf->moduledummy->enabled'); + $verifcond=verifCond('isModEnabled("moduledummy")'); $this->assertFalse($verifcond, 'Test that the conf property of a module reports false when disabled'); $verifcond=verifCond(0); diff --git a/test/phpunit/KnowledgeRecordTest.php b/test/phpunit/KnowledgeRecordTest.php index ffa189adc48..d071ea7b024 100644 --- a/test/phpunit/KnowledgeRecordTest.php +++ b/test/phpunit/KnowledgeRecordTest.php @@ -86,7 +86,7 @@ class KnowledgeRecordTest 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 (empty($conf->knowledgemanagement->enabled)) { + if (!isModEnabled('knowledgemanagement')) { print __METHOD__." module knowledgemanagement must be enabled.\n"; die(1); } } diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index d084f50d6e0..da3afc0d070 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -114,7 +114,7 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - if (empty($conf->productbatch->enabled)) { + if (!isModEnabled('productbatch')) { print "\n".__METHOD__." module Lot/Serial must be enabled.\n"; die(1); } diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index 378c703684b..fdcc17fd48d 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -83,7 +83,7 @@ class PaypalTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (empty($conf->paypal->enabled)) { + if (!isModEnabled('paypal')) { print __METHOD__." Module Paypal must be enabled.\n"; die(1); } diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 5378407c2b4..7d88fa69897 100644 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -149,11 +149,6 @@ class PricesTest extends PHPUnit\Framework\TestCase global $mysoc; $mysoc=new Societe($db); - // To force status that say module multicompany is on - //$conf->multicurrency=new stdClass(); - //$conf->multicurrency->enabled = 0; - - /* * Country France */ diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index d23d2562f22..79685e5fab5 100644 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -82,7 +82,7 @@ class ProductTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (empty($conf->produit->enabled)) { + if (!isModEnabled('produit')) { print __METHOD__." Module Product must be enabled.\n"; die(1); } diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index a1214c1a047..4de0557c561 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -73,7 +73,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase $this->savlangs=$langs; $this->savdb=$db; - if (empty($conf->api->enabled)) { + if (!isModEnabled('api')) { print __METHOD__." module api must be enabled.\n"; die(1); } diff --git a/test/phpunit/StripeTest.php b/test/phpunit/StripeTest.php index 08eb585b7f7..e26b023a38e 100644 --- a/test/phpunit/StripeTest.php +++ b/test/phpunit/StripeTest.php @@ -83,7 +83,7 @@ class StripeTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - if (empty($conf->stripe->enabled)) { + if (!isModEnabled('stripe')) { print __METHOD__." Module Stripe must be enabled.\n"; die(1); } diff --git a/test/phpunit/WebservicesProductsTest.php b/test/phpunit/WebservicesProductsTest.php index f79bdc6313c..021c305f7e2 100644 --- a/test/phpunit/WebservicesProductsTest.php +++ b/test/phpunit/WebservicesProductsTest.php @@ -42,7 +42,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; $conf->global->MAIN_UMASK='0666'; -if (empty($conf->service->enabled)) { +if (!isModEnabled('service')) { print "Error: Module service must be enabled.\n"; exit(1); }