From 891e11d692d7b233bcb29deac56328d2a579e77f Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 18 Feb 2025 16:08:09 +0100 Subject: [PATCH] Qual: Enable and fix phan notices for scripts # Qual: Enable and fix phan notices for scripts phpstan is already enable on scripts, so there is no reason to not enable phan. This enables phan and fixes the notices at the same time --- dev/tools/phan/config.php | 1 + .../class/bonprelevement.class.php | 6 +-- .../export/export_excel2007.modules.php | 4 +- .../modules/export/export_tsv.modules.php | 4 +- .../core/modules/export/exportcsv.class.php | 4 +- htdocs/core/modules/export/modules_export.php | 4 +- htdocs/install/inc.php | 6 +-- scripts/bank/export-bank-receipts.php | 13 ++++--- .../company/sync_contacts_dolibarr2ldap.php | 3 +- .../email_expire_services_to_customers.php | 14 +++---- ...ail_expire_services_to_representatives.php | 14 +++---- scripts/cron/cron_run_jobs.php | 14 ++++--- scripts/doc/regenerate_docs.php | 7 ++-- scripts/emailings/mailing-send.php | 8 ++-- scripts/emailings/reset-invalid-emails.php | 3 +- .../email_unpaid_invoices_to_customers.php | 10 ++--- ...ail_unpaid_invoices_to_representatives.php | 18 ++++----- scripts/invoices/rebuild_merge_pdf.php | 12 +++--- .../members/sync_members_dolibarr2ldap.php | 3 +- .../members/sync_members_ldap2dolibarr.php | 12 +++--- .../sync_members_types_dolibarr2ldap.php | 3 +- .../sync_members_types_ldap2dolibarr.php | 9 +++-- scripts/product/migrate_picture_path.php | 3 +- scripts/product/regenerate_thumbs.php | 3 +- scripts/user/migrate_picture_path.php | 5 ++- scripts/user/sync_groups_dolibarr2ldap.php | 3 +- scripts/user/sync_groups_ldap2dolibarr.php | 29 ++++++++------ scripts/user/sync_users_dolibarr2ldap.php | 3 +- scripts/user/sync_users_ldap2dolibarr.php | 39 ++++++++++--------- scripts/website/regenerate-pages.php | 3 +- scripts/withdrawals/build_withdrawal_file.php | 5 ++- 31 files changed, 144 insertions(+), 121 deletions(-) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 9c89cda3e88..87d6df0c9d9 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -304,6 +304,7 @@ return [ // your application should be included in this list. 'directory_list' => [ 'htdocs', + 'scripts', PHAN_DIR . '/stubs/', ], diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 861948151d6..ab40ad44003 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1051,8 +1051,8 @@ class BonPrelevement extends CommonObject * - Link the order with the prelevement_demande lines * TODO delete params banque and agence when not necessary * - * @param int $banque dolibarr mysoc bank - * @param int $agence dolibarr mysoc bank office (guichet) + * @param string $banque dolibarr mysoc bank + * @param string $agence dolibarr mysoc bank office (guichet) * @param string $mode real=do action, simu=test only * @param string $format FRST, RCUR or ALL * @param int $executiondate Date to execute the transfer @@ -1063,7 +1063,7 @@ class BonPrelevement extends CommonObject * @param string $sourcetype 'invoice' or 'salary' * @return int Return integer <0 if KO, No of invoice included into file if OK */ - public function create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = 0, $notrigger = 0, $type = 'direct-debit', $did = 0, $fk_bank_account = 0, $sourcetype = 'invoice') + public function create($banque = '', $agence = '', $mode = 'real', $format = 'ALL', $executiondate = 0, $notrigger = 0, $type = 'direct-debit', $did = 0, $fk_bank_account = 0, $sourcetype = 'invoice') { // phpcs:enable global $conf, $langs, $user; diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index 1f9a804da46..bcfc547fd4f 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -3,7 +3,7 @@ * Copyright (C) 2012 Marcos García * Copyright (C) 2024 William Mead * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -311,7 +311,7 @@ class ExportExcel2007 extends ModeleExports * Output record line into file * * @param array $array_selected_sorted Array with list of field to export - * @param Resource $objp A record from a fetch with all fields from select + * @param Resource|Object $objp A record from a fetch with all fields from select * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int Return integer <0 if KO, >0 if OK diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index 3e2eb85495c..3a40da916f3 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -1,7 +1,7 @@ * Copyright (C) 2012 Marcos García - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -255,7 +255,7 @@ class ExportTsv extends ModeleExports * Output record line into file * * @param array $array_selected_sorted Array with list of field to export - * @param Resource $objp A record from a fetch with all fields from select + * @param Resource|Object $objp A record from a fetch with all fields from select * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int Return integer <0 if KO, >0 if OK diff --git a/htdocs/core/modules/export/exportcsv.class.php b/htdocs/core/modules/export/exportcsv.class.php index 1e263a67284..4b9f8dcd361 100644 --- a/htdocs/core/modules/export/exportcsv.class.php +++ b/htdocs/core/modules/export/exportcsv.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -235,7 +235,7 @@ class ExportCsv extends ModeleExports * Output record line into file * * @param array $array_selected_sorted Array with list of field to export - * @param Resource $objp A record from a fetch with all fields from select + * @param Resource|Object $objp A record from a fetch with all fields from select * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int Return integer <0 if KO, >0 if OK diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index e1c2ff6f0a6..0f2c27dd95c 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2007 Regis Houssin - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -239,7 +239,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * Output record line into file * * @param array $array_selected_sorted Array with list of field to export - * @param Resource $objp A record from a fetch with all fields from select + * @param Resource|Object $objp A record from a fetch with all fields from select * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int Return integer <0 if KO, >0 if OK diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index b1c967e790e..fcc7c1aaf44 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -96,7 +96,7 @@ $long_options = array( * @param string $header the message to signal to the user * @return void */ -function usage($program, $header) +function install_usage($program, $header) { echo $header."\n"; echo " php ".$program." [options] [script options]\n"; @@ -149,7 +149,7 @@ if (php_sapi_name() === "cli" && (float) PHP_VERSION > 7.0) { break; case 'h': case 'help': - usage($argv[0], "Usage:"); + install_usage($argv[0], "Usage:"); exit(0); } } @@ -189,7 +189,7 @@ if (php_sapi_name() === "cli" && (float) PHP_VERSION > 7.0) { // typo right now. if (count($unknown_options) > 0) { echo "Unknown option: ".array_values($unknown_options)[0]."\n"; - usage($argv[0], "Usage:"); + install_usage($argv[0], "Usage:"); exit(1); } diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index e25a7c03b3c..09f10f3ca24 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -2,7 +2,7 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -73,7 +73,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); if (!isset($argv[3]) || !$argv[3]) { print "Usage: ".$script_file." bank_ref [bank_receipt_number|all] (csv|tsv|excel|excel2007) [lang=xx_XX]\n"; @@ -120,7 +120,7 @@ if (!empty($newlangid)) { $outputlangs->loadLangs(array("main", "companies", "bills", "banks", "members", "compta")); $acct = new Account($db); -$result = $acct->fetch('', $bankref); +$result = $acct->fetch(0, $bankref); if ($result <= 0) { print "Failed to find bank account with ref ".$bankref.".\n"; exit(1); @@ -138,6 +138,7 @@ if (!dol_is_file($dir.$file)) { } require_once $dir.$file; $objmodel = new $classname($db); +'@phan-var-force ModeleExports|ExportCsv $objmodel'; // Define target path $dirname = $conf->bank->dir_temp; @@ -247,7 +248,7 @@ if ($resql) { } $totalbefore = $total; - $total = $total + $objp->amount; + $total += $objp->amount; // Date operation $dateop = $db->jdate($objp->do); @@ -375,10 +376,10 @@ if ($resql) { $debit = $credit = ''; if ($objp->amount < 0) { - $totald = $totald + abs($objp->amount); + $totald += abs($objp->amount); $debit = price2num($objp->amount * -1); } else { - $totalc = $totalc + abs($objp->amount); + $totalc += abs($objp->amount); $credit = price2num($objp->amount); } diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index a802c522881..c209b799a12 100755 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006-2009 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -67,7 +68,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); if (!isset($argv[1]) || !$argv[1]) { print "Usage: $script_file now [-y]\n"; diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index c1740807a28..41c99b8da2d 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -80,7 +80,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); $now = dol_now('tzserver'); $duration_value = isset($argv[3]) ? $argv[3] : 'none'; @@ -162,7 +162,7 @@ if ($resql) { if ($startbreak) { // Break onto sales representative (new email or cid) if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { - sendEmailTo($mode, $oldemail, $message, price2num($total), $oldlang, $oldtarget, (int) $duration_value); + sendEmailToCustomer($mode, $oldemail, $message, price2num($total), $oldlang, $oldtarget, (int) $duration_value); $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid; } else { if ($oldemail != 'none') { @@ -216,7 +216,7 @@ if ($resql) { // If there are remaining messages to send in the buffer if ($foundtoprocess) { if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { // Break onto email (new email) - sendEmailTo($mode, $oldemail, $message, price2num($total), $oldlang, $oldtarget, (int) $duration_value); + sendEmailToCustomer($mode, $oldemail, $message, price2num($total), $oldlang, $oldtarget, (int) $duration_value); $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid; } else { if ($oldemail != 'none') { @@ -252,7 +252,7 @@ if ($resql) { * @param int $duration_value duration value * @return int Int <0 if KO, >0 if OK */ -function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, $duration_value) +function sendEmailToCustomer($mode, $oldemail, $message, $total, $userlang, $oldtarget, $duration_value) { global $conf, $langs; @@ -267,9 +267,9 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, if ($duration_value) { if ($duration_value > 0) { - $title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", $duration_value); + $title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", (string) $duration_value); } else { - $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", $duration_value); + $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", (string) $duration_value); } } else { $title = $newlangs->transnoentities("ListOfServicesToExpire"); diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index 4fee569ee2f..77fb386e6f9 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -78,7 +78,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); $now = dol_now('tzserver'); $duration_value = isset($argv[2]) ? $argv[2] : 'none'; @@ -123,7 +123,7 @@ if ($resql) { if (($obj->email != $oldemail || $obj->uid != $olduid) || $oldemail == 'none') { // Break onto sales representative (new email or uid) if (dol_strlen($oldemail) && $oldemail != 'none') { - sendEmailTo($mode, $oldemail, $message, price2num($total), $oldlang, $oldsalerepresentative, (int) $duration_value); + sendEmailToRepresentative($mode, $oldemail, $message, price2num($total), $oldlang, $oldsalerepresentative, (int) $duration_value); } else { if ($oldemail != 'none') { print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; @@ -171,7 +171,7 @@ if ($resql) { // If there are remaining messages to send in the buffer if ($foundtoprocess) { if (dol_strlen($oldemail) && $oldemail != 'none') { // Break onto email (new email) - sendEmailTo($mode, $oldemail, $message, price2num($total), $oldlang, $oldsalerepresentative, (int) $duration_value); + sendEmailToRepresentative($mode, $oldemail, $message, price2num($total), $oldlang, $oldsalerepresentative, (int) $duration_value); } else { if ($oldemail != 'none') { print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; @@ -202,7 +202,7 @@ if ($resql) { * @param int $duration_value Duration value * @return int Int <0 if KO, >0 if OK */ -function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, $duration_value) +function sendEmailToRepresentative($mode, $oldemail, $message, $total, $userlang, $oldtarget, $duration_value) { global $conf, $langs; @@ -217,9 +217,9 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, if ($duration_value) { if ($duration_value > 0) { - $title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", $duration_value); + $title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", (string) $duration_value); } else { - $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", $duration_value); + $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", (string) $duration_value); } } else { $title = $newlangs->transnoentities("ListOfServicesToExpire"); diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 77fcb33e726..59a6ef82aa7 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -5,6 +5,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -75,13 +76,13 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Check parameters if (!isset($argv[1]) || !$argv[1]) { - usage($path, $script_file); + usageCron($path, $script_file); exit(1); } $key = $argv[1]; if (!isset($argv[2]) || !$argv[2]) { - usage($path, $script_file); + usageCron($path, $script_file); exit(1); } @@ -142,7 +143,7 @@ if ($userlogin == 'firstadmin') { // Check user login $user = new User($db); -$result = $user->fetch('', $userlogin, '', 1); +$result = $user->fetch(0, $userlogin, '', 1); if ($result < 0) { echo "User Error: ".$user->error; dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); @@ -219,6 +220,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) { // Loop over job foreach ($object->lines as $line) { + '@phan-var-force CronJob $line'; dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG); echo "cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label; @@ -233,7 +235,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) { // Force recheck that user is ok for the entity to process and reload permission for entity if ($conf->entity != $user->entity) { - $result = $user->fetch('', $userlogin, '', 1); + $result = $user->fetch(0, $userlogin, '', 1); if ($result < 0) { echo "\nUser Error: ".$user->error."\n"; dol_syslog("cron_run_jobs.php: User Error:".$user->error, LOG_ERR); @@ -337,13 +339,13 @@ exit(0); /** - * script cron usage + * script cron usageCron * * @param string $path Path * @param string $script_file Filename * @return void */ -function usage($path, $script_file) +function usageCron($path, $script_file) { print "Usage: ".$script_file." securitykey userlogin|'firstadmin' [cronjobid] [--force]\n"; print "The script return 0 when everything worked successfully.\n"; diff --git a/scripts/doc/regenerate_docs.php b/scripts/doc/regenerate_docs.php index 975d1490840..bd372689c6b 100755 --- a/scripts/doc/regenerate_docs.php +++ b/scripts/doc/regenerate_docs.php @@ -3,6 +3,7 @@ /* Copyright (C) 2007-2016 Laurent Destailleur * Copyright (C) 2015 Jean Heimburger * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -74,7 +75,7 @@ $hookmanager->initHooks(array('cli')); */ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." - dir=".DOL_DATA_ROOT." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); if (empty($argv[1])) { print "Usage: $script_file subdirtoscan (test|confirm)\n"; @@ -110,14 +111,14 @@ if ($subdir == 'propale' || $subdir == 'proposal') { print 'Error, module not enabled'."\n"; } } elseif ($subdir == 'commande' || $subdir == 'order') { - if (isModEnabled('commande')) { + if (isModEnabled('order')) { require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"; $tmpobject = new Commande($db); } else { print 'Error, module not enabled'."\n"; } } elseif ($subdir == 'facture' || $subdir == 'invoice') { - if (isModEnabled('facture')) { + if (isModEnabled('invoice')) { require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; $tmpobject = new Facture($db); } else { diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 1433373fbd2..d115c1aa210 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -102,8 +102,8 @@ if (getDolGlobalInt('MAILING_DELAY')) { print 'A delay of '.((float) getDolGlobalInt('MAILING_DELAY')).' seconds has been set between each email'."\n"; } -if (getDolGlobalString('MAILING_LIMIT_SENDBYCLI') == '-1') { -} +//if (getDolGlobalString('MAILING_LIMIT_SENDBYCLI') == '-1') { +//} if (!empty($dolibarr_main_db_readonly)) { print "Error: instance in read-only mode\n"; @@ -113,7 +113,7 @@ if (!empty($dolibarr_main_db_readonly)) { $user = new User($db); // for signature, we use user send as parameter if (!empty($login)) { - $user->fetch('', $login); + $user->fetch(0, $login); } /** @var DoliDB $db */ // We get list of emailing id to process diff --git a/scripts/emailings/reset-invalid-emails.php b/scripts/emailings/reset-invalid-emails.php index 317c40abc16..e1793e8ad3d 100755 --- a/scripts/emailings/reset-invalid-emails.php +++ b/scripts/emailings/reset-invalid-emails.php @@ -2,6 +2,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -178,7 +179,7 @@ while ($tmp != null) { $numerasedtotal += $numerased; print $numerased." emails cleared.\n"; - $counter = $counter + $nbingroup; + $counter += $nbingroup; } if (!$error && $mode == 'confirm') { diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index 8a0534cc5c1..97cc77e4a89 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -78,7 +78,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); $now = dol_now('tzserver'); $duration_value = isset($argv[3]) ? $argv[3] : 'none'; @@ -165,7 +165,7 @@ if ($resql) { if ($startbreak) { // Break onto sales representative (new email or cid) if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { - envoi_mail($mode, $oldemail, $message, price2num($total), $oldlang, $oldtarget); + sendMailCustomerUnpaid($mode, $oldemail, $message, price2num($total), $oldlang, $oldtarget); $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid; } else { if ($oldemail != 'none') { @@ -219,7 +219,7 @@ if ($resql) { // If there are remaining messages to send in the buffer if ($foundtoprocess) { if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { // Break onto email (new email) - envoi_mail($mode, $oldemail, $message, price2num($total), $oldlang, $oldtarget); + sendMailCustomerUnpaid($mode, $oldemail, $message, price2num($total), $oldlang, $oldtarget); $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid; } else { if ($oldemail != 'none') { @@ -254,7 +254,7 @@ if ($resql) { * @param string $oldtarget Target name * @return int Int <0 if KO, >0 if OK */ -function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) +function sendMailCustomerUnpaid($mode, $oldemail, $message, $total, $userlang, $oldtarget) { global $conf, $langs; diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 42433c0fea0..f717f11db55 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -4,7 +4,7 @@ * Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2013 Juanjo Menent - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -76,7 +76,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); $now = dol_now('tzserver'); $duration_value = isset($argv[2]) ? $argv[2] : 'none'; @@ -118,10 +118,10 @@ if ($resql) { $total = 0; $foundtoprocess = 0; - print "We found ".$num." couples (unpayed validated invoice - sale representative) qualified\n"; - dol_syslog("We found ".$num." couples (unpayed validated invoice - sale representative) qualified"); + print "We found ".$num." couples (unpaid validated invoice - sale representative) qualified\n"; + dol_syslog("We found ".$num." couples (unpaid validated invoice - sale representative) qualified"); $message = ''; - $oldsalerepresentative = 0; + $oldsalerepresentative = ''; if ($num) { while ($i < $num) { @@ -130,7 +130,7 @@ if ($resql) { if (($obj->email != $oldemail || $obj->uid != $olduid) || $oldemail == 'none') { // Break onto sales representative (new email or uid) if (dol_strlen($oldemail) && $oldemail != 'none') { - envoi_mail($mode, $oldemail, $message, price2num($total), $oldlang, $oldsalerepresentative); + sendMailRepresentativeUnpaid($mode, $oldemail, $message, price2num($total), $oldlang, $oldsalerepresentative); } else { if ($oldemail != 'none') { print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; @@ -178,7 +178,7 @@ if ($resql) { // If there are remaining messages to send in the buffer if ($foundtoprocess) { if (dol_strlen($oldemail) && $oldemail != 'none') { // Break onto email (new email) - envoi_mail($mode, $oldemail, $message, price2num($total), $oldlang, $oldsalerepresentative); + sendMailRepresentativeUnpaid($mode, $oldemail, $message, price2num($total), $oldlang, $oldsalerepresentative); } else { if ($oldemail != 'none') { print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; @@ -203,12 +203,12 @@ if ($resql) { * @param string $mode Mode (test | confirm) * @param string $oldemail Target email * @param string $message Message to send - * @param string $total Total amount of unpayed invoices + * @param string $total Total amount of unpaid invoices * @param string $userlang Code lang to use for email output. * @param string $oldtarget Target name of sale representative * @return int Int <0 if KO, >0 if OK */ -function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) +function sendMailRepresentativeUnpaid($mode, $oldemail, $message, $total, $userlang, $oldtarget) { global $conf, $langs; diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index c636f9e129a..b8aad178988 100755 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -3,7 +3,7 @@ /* * Copyright (C) 2009-2012 Laurent Destailleur * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -69,7 +69,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); // Check parameters if (!isset($argv[1])) { @@ -222,18 +222,18 @@ foreach ($argv as $key => $value) { $filter[] = 'excludethirdparties'; $thirdpartiesid = explode(',', $argv[$key + 1]); - print 'Exclude thirdparties with id in list ('.join(',', $thirdpartiesid).").\n"; + print 'Exclude thirdparties with id in list ('.implode(',', $thirdpartiesid).").\n"; - $option .= (empty($option) ? '' : '_').'excludethirdparties'.join('-', $thirdpartiesid); + $option .= (empty($option) ? '' : '_').'excludethirdparties'.implode('-', $thirdpartiesid); } if ($value == 'filter=onlythirdparties') { $found = true; $filter[] = 'onlythirdparties'; $thirdpartiesid = explode(',', $argv[$key + 1]); - print 'Only thirdparties with id in list ('.join(',', $thirdpartiesid).").\n"; + print 'Only thirdparties with id in list ('.implode(',', $thirdpartiesid).").\n"; - $option .= (empty($option) ? '' : '_').'onlythirdparty'.join('-', $thirdpartiesid); + $option .= (empty($option) ? '' : '_').'onlythirdparty'.implode('-', $thirdpartiesid); } if (!$found && preg_match('/filter=/i', $value)) { diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index a4566fc73b7..4314076b1a6 100755 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006-2008 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -67,7 +68,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); if (!isset($argv[1]) || !$argv[1]) { print "Usage: $script_file now [-y]\n"; diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index d27dd29df3c..1f1bdf02e33 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -3,7 +3,7 @@ /** * Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006-2015 Laurent Destailleur - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -71,7 +71,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); // List of fields to get from LDAP $required_fields = array( @@ -104,7 +104,7 @@ $required_fields = array( ); // Remove from required_fields all entries not configured in LDAP (empty) and duplicated -$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElement"))); +$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidLdapElement"))); if (!isset($argv[2]) || !is_numeric($argv[2])) { print "Usage: $script_file (nocommitiferror|commitiferror) id_member_type [--server=ldapserverhost] [-y]\n"; @@ -146,7 +146,7 @@ print "login=".$conf->db->user."\n"; print "database=".$conf->db->name."\n"; print "----- Options:\n"; print "commitiferror=".$forcecommit."\n"; -print "Mapped LDAP fields=".join(',', $required_fields)."\n"; +print "Mapped LDAP fields=".implode(',', $required_fields)."\n"; print "\n"; // Check parameters @@ -312,7 +312,7 @@ if ($result >= 0) { } $db->commit(); } else { - print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; + print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", (string) $error)."\n"; $db->rollback(); } print "\n"; @@ -334,7 +334,7 @@ exit($error); * @param string $element Value to test * @return boolean True of false */ -function dolValidElement($element) +function dolValidLdapElement($element) { return (trim($element) != ''); } diff --git a/scripts/members/sync_members_types_dolibarr2ldap.php b/scripts/members/sync_members_types_dolibarr2ldap.php index 003786aaadb..92ef4b90fcf 100755 --- a/scripts/members/sync_members_types_dolibarr2ldap.php +++ b/scripts/members/sync_members_types_dolibarr2ldap.php @@ -5,6 +5,7 @@ * Copyright (C) 2006 Laurent Destailleur * Copyright (C) 2017 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -72,7 +73,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); /* * if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) { diff --git a/scripts/members/sync_members_types_ldap2dolibarr.php b/scripts/members/sync_members_types_ldap2dolibarr.php index e6f7b2b7a8a..eccb04d0b90 100755 --- a/scripts/members/sync_members_types_ldap2dolibarr.php +++ b/scripts/members/sync_members_types_ldap2dolibarr.php @@ -6,6 +6,7 @@ * Copyright (C) 2013 Maxime Kohlhaas * Copyright (C) 2017 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); // List of fields to get from LDAP $required_fields = array(getDolGlobalString('LDAP_KEY_MEMBERS_TYPES'), getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_FULLNAME'), getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_DESCRIPTION'), getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS')); @@ -123,7 +124,7 @@ print "login=".$conf->db->user."\n"; print "database=".$conf->db->name."\n"; print "----- Options:\n"; print "commitiferror=".$forcecommit."\n"; -print "Mapped LDAP fields=".join(',', $required_fields)."\n"; +print "Mapped LDAP fields=".implode(',', $required_fields)."\n"; print "\n"; if (!$confirmed) { @@ -151,7 +152,7 @@ if ($result >= 0) { // Warning $ldapuser has a key in lowercase foreach ($ldaprecords as $key => $ldapgroup) { $membertype = new AdherentType($db); - $membertype->fetch($ldapgroup[getDolGlobalString('LDAP_KEY_MEMBERS_TYPES')]); + $membertype->fetch((int) $ldapgroup[getDolGlobalString('LDAP_KEY_MEMBERS_TYPES')]); $membertype->label = $ldapgroup[getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_FULLNAME')]; $membertype->description = $ldapgroup[getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_DESCRIPTION')]; $membertype->entity = $conf->entity; @@ -193,7 +194,7 @@ if ($result >= 0) { } $db->commit(); } else { - print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; + print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", (string) $error)."\n"; $db->rollback(); } print "\n"; diff --git a/scripts/product/migrate_picture_path.php b/scripts/product/migrate_picture_path.php index 724f8bf21bf..5695f67edc6 100755 --- a/scripts/product/migrate_picture_path.php +++ b/scripts/product/migrate_picture_path.php @@ -4,6 +4,7 @@ * Copyright (C) 2007-2016 Laurent Destailleur * Copyright (C) 2015 Jean Heimburger * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli')); */ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); if (!isset($argv[1]) || $argv[1] != 'product') { print "Usage: $script_file product\n"; diff --git a/scripts/product/regenerate_thumbs.php b/scripts/product/regenerate_thumbs.php index 07b202d7d9b..5aefed4bf6c 100755 --- a/scripts/product/regenerate_thumbs.php +++ b/scripts/product/regenerate_thumbs.php @@ -3,6 +3,7 @@ /* Copyright (C) 2007-2016 Laurent Destailleur * Copyright (C) 2015 Jean Heimburger * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -70,7 +71,7 @@ $hookmanager->initHooks(array('cli')); */ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); if (empty($argv[1])) { print "Usage: $script_file subdirtoscan\n"; diff --git a/scripts/user/migrate_picture_path.php b/scripts/user/migrate_picture_path.php index bf7b7d843ac..54ba0ccf8b3 100755 --- a/scripts/user/migrate_picture_path.php +++ b/scripts/user/migrate_picture_path.php @@ -4,6 +4,7 @@ * Copyright (C) 2007-2016 Laurent Destailleur * Copyright (C) 2015 Jean Heimburger * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli')); */ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); if (!isset($argv[1]) || $argv[1] != 'user') { print "Usage: $script_file user\n"; @@ -113,7 +114,7 @@ function migrate_user_filespath($u) { global $conf; - // Les fichiers joints des users sont toujours sur l'entité 1 + // Les fichiers implodets des users sont toujours sur l'entité 1 $dir = $conf->user->dir_output; $origin = $dir.'/'.get_exdir($u->id, 2, 0, 0, $u, 'user'); $destin = $dir.'/'.$u->id; diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php index c9b23786405..ab1e2a0d032 100755 --- a/scripts/user/sync_groups_dolibarr2ldap.php +++ b/scripts/user/sync_groups_dolibarr2ldap.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); /* * if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) { diff --git a/scripts/user/sync_groups_ldap2dolibarr.php b/scripts/user/sync_groups_ldap2dolibarr.php index ed3e7415010..e51e85d9deb 100755 --- a/scripts/user/sync_groups_ldap2dolibarr.php +++ b/scripts/user/sync_groups_ldap2dolibarr.php @@ -5,6 +5,7 @@ * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2013 Maxime Kohlhaas * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -72,13 +73,13 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); // List of fields to get from LDAP $required_fields = array(getDolGlobalString('LDAP_KEY_GROUPS'), getDolGlobalString('LDAP_GROUP_FIELD_FULLNAME'), getDolGlobalString('LDAP_GROUP_FIELD_DESCRIPTION'), getDolGlobalString('LDAP_GROUP_FIELD_GROUPMEMBERS')); // Remove from required_fields all entries not configured in LDAP (empty) and duplicated -$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElement"))); +$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidLdapElement2"))); if (!isset($argv[1])) { // print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n"; @@ -123,7 +124,7 @@ print "login=".$conf->db->user."\n"; print "database=".$conf->db->name."\n"; print "----- Options:\n"; print "commitiferror=".$forcecommit."\n"; -print "Mapped LDAP fields=".join(',', $required_fields)."\n"; +print "Mapped LDAP fields=".implode(',', $required_fields)."\n"; print "\n"; if (!$confirmed) { @@ -151,10 +152,10 @@ if ($result >= 0) { // Warning $ldapuser has a key in lowercase foreach ($ldaprecords as $key => $ldapgroup) { $group = new UserGroup($db); - $group->fetch('', $ldapgroup[getDolGlobalString('LDAP_KEY_GROUPS')]); - $group->name = $ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_FULLNAME')] ?? null; + $group->fetch(0, $ldapgroup[getDolGlobalString('LDAP_KEY_GROUPS')]); + $group->name = $ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_FULLNAME')] ?? ''; $group->nom = $group->name; // For backward compatibility - $group->note = $ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_DESCRIPTION')] ?? null; + $group->note = $ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_DESCRIPTION')] ?? ''; $group->entity = $conf->entity; // print_r($ldapgroup); @@ -189,8 +190,12 @@ if ($result >= 0) { // 1 - Association of users in the LDAP group with the Dolibarr group $userList = array(); $userIdList = array(); - foreach ($ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_GROUPMEMBERS')] as $tmpkey => $userdn) { - if ($tmpkey === 'count') { + $groupMembers = $ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_GROUPMEMBERS')]; + if (!is_array($groupMembers)) { + $groupMembers = array(); + } + foreach ($groupMembers as $tmpkey => $userdn) { // @phpstan-ignore-line + if ($tmpkey === 'count') { // @phpstan-ignore-line continue; } if (empty($userList[$userdn])) { // Récupération de l'utilisateur @@ -208,9 +213,9 @@ if ($result >= 0) { $fuser = new User($db); if (getDolGlobalString('LDAP_KEY_USERS') == getDolGlobalString('LDAP_FIELD_SID')) { - $fuser->fetch('', '', $userKey[0]); // Chargement du user concerné par le SID + $fuser->fetch(0, '', $userKey[0]); // Chargement du user concerné par le SID } elseif (getDolGlobalString('LDAP_KEY_USERS') == getDolGlobalString('LDAP_FIELD_LOGIN')) { - $fuser->fetch('', $userKey[0]); // Chargement du user concerné par le login + $fuser->fetch(0, $userKey[0]); // Chargement du user concerné par le login } $userList[$userdn] = $fuser; @@ -244,7 +249,7 @@ if ($result >= 0) { } $db->commit(); } else { - print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; + print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", (string) $error)."\n"; $db->rollback(); } print "\n"; @@ -266,7 +271,7 @@ exit($error); * @param string $element Value to test * @return boolean True of false */ -function dolValidElement($element) +function dolValidLdapElement2($element) { return (trim($element) != ''); } diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index 5a21b9f5a61..30399784316 100755 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); /* * if (! getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) { diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 3e7625fdf11..6197d995a27 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); // List of fields to get from LDAP $required_fields = array( @@ -97,7 +98,7 @@ $required_fields = array( ); // Remove from required_fields all entries not configured in LDAP (empty) and duplicated -$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElement"))); +$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidLdapElement3"))); if (!isset($argv[1])) { print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n"; @@ -141,8 +142,8 @@ print "login=".$conf->db->user."\n"; print "database=".$conf->db->name."\n"; print "----- Options:\n"; print "commitiferror=".$forcecommit."\n"; -print "excludeuser=".join(',', $excludeuser)."\n"; -print "Mapped LDAP fields=".join(',', $required_fields)."\n"; +print "excludeuser=".implode(',', $excludeuser)."\n"; +print "Mapped LDAP fields=".implode(',', $required_fields)."\n"; print "\n"; if (!$confirmed) { @@ -205,17 +206,17 @@ if ($result >= 0) { $fuser = new User($db); if (getDolGlobalString('LDAP_KEY_USERS') == getDolGlobalString('LDAP_FIELD_SID')) { - $fuser->fetch('', '', $ldapuser[getDolGlobalString('LDAP_KEY_USERS')]); // Chargement du user concerné par le SID + $fuser->fetch(0, '', $ldapuser[getDolGlobalString('LDAP_KEY_USERS')]); // Chargement du user concerné par le SID } elseif (getDolGlobalString('LDAP_KEY_USERS') == getDolGlobalString('LDAP_FIELD_LOGIN')) { - $fuser->fetch('', $ldapuser[getDolGlobalString('LDAP_KEY_USERS')]); // Chargement du user concerné par le login + $fuser->fetch(0, $ldapuser[getDolGlobalString('LDAP_KEY_USERS')]); // Chargement du user concerné par le login } // Propriete membre - $fuser->firstname = $ldapuser[getDolGlobalString('LDAP_FIELD_FIRSTNAME')] ?? null; - $fuser->lastname = $ldapuser[getDolGlobalString('LDAP_FIELD_NAME')] ?? null; - $fuser->login = $ldapuser[getDolGlobalString('LDAP_FIELD_LOGIN')] ?? null; - $fuser->pass = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD')] ?? null; - $fuser->pass_indatabase_crypted = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD_CRYPTED')] ?? null; + $fuser->firstname = $ldapuser[getDolGlobalString('LDAP_FIELD_FIRSTNAME')] ?? ''; + $fuser->lastname = $ldapuser[getDolGlobalString('LDAP_FIELD_NAME')] ?? ''; + $fuser->login = $ldapuser[getDolGlobalString('LDAP_FIELD_LOGIN')] ?? ''; + $fuser->pass = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD')] ?? ''; + $fuser->pass_indatabase_crypted = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD_CRYPTED')] ?? ''; // $user->societe; /* @@ -227,13 +228,13 @@ if ($result >= 0) { * $fuser->country_code=$countries[$hashlib2rowid[strtolower($fuser->country)]]['code']; */ - $fuser->office_phone = $ldapuser[getDolGlobalString('LDAP_FIELD_PHONE')] ?? null; - $fuser->user_mobile = $ldapuser[getDolGlobalString('LDAP_FIELD_MOBILE')] ?? null; - $fuser->office_fax = $ldapuser[getDolGlobalString('LDAP_FIELD_FAX')] ?? null; - $fuser->email = $ldapuser[getDolGlobalString('LDAP_FIELD_MAIL')] ?? null; - $fuser->ldap_sid = $ldapuser[getDolGlobalString('LDAP_FIELD_SID')] ?? null; + $fuser->office_phone = $ldapuser[getDolGlobalString('LDAP_FIELD_PHONE')] ?? ''; + $fuser->user_mobile = $ldapuser[getDolGlobalString('LDAP_FIELD_MOBILE')] ?? ''; + $fuser->office_fax = $ldapuser[getDolGlobalString('LDAP_FIELD_FAX')] ?? ''; + $fuser->email = $ldapuser[getDolGlobalString('LDAP_FIELD_MAIL')] ?? ''; + $fuser->ldap_sid = $ldapuser[getDolGlobalString('LDAP_FIELD_SID')] ?? ''; - $fuser->job = $ldapuser[getDolGlobalString('LDAP_FIELD_TITLE')] ?? null; + $fuser->job = $ldapuser[getDolGlobalString('LDAP_FIELD_TITLE')] ?? ''; $fuser->note = $ldapuser[getDolGlobalString('LDAP_FIELD_DESCRIPTION')] ?? null; $fuser->admin = 0; $fuser->socid = 0; @@ -296,7 +297,7 @@ if ($result >= 0) { } $db->commit(); } else { - print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; + print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", (string) $error)."\n"; $db->rollback(); } print "\n"; @@ -318,7 +319,7 @@ exit($error); * @param string $element Value to test * @return boolean True of false */ -function dolValidElement($element) +function dolValidLdapElement3($element) { return (trim($element) != ''); } diff --git a/scripts/website/regenerate-pages.php b/scripts/website/regenerate-pages.php index c75424049fe..0ad4f772a34 100755 --- a/scripts/website/regenerate-pages.php +++ b/scripts/website/regenerate-pages.php @@ -2,6 +2,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -44,7 +45,7 @@ $error = 0; $mode = empty($argv[1]) ? '' : $argv[1]; $websiteref = empty($argv[2]) ? '' : $argv[2]; -$max = (!isset($argv[3]) || (empty($argv[3]) && $argv[3] !== '0')) ? '10' : $argv[3]; +$max = (int) ((!isset($argv[3]) || (empty($argv[3]) && $argv[3] !== '0')) ? '10' : $argv[3]); if (empty($argv[2]) || !in_array($argv[1], array('test', 'confirm')) || empty($websiteref)) { print '***** '.$script_file.' *****'."\n"; diff --git a/scripts/withdrawals/build_withdrawal_file.php b/scripts/withdrawals/build_withdrawal_file.php index 7395ad4fffd..0bfe7efeb92 100755 --- a/scripts/withdrawals/build_withdrawal_file.php +++ b/scripts/withdrawals/build_withdrawal_file.php @@ -3,6 +3,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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 @@ -62,7 +63,7 @@ $hookmanager->initHooks(array('cli')); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; -dol_syslog($script_file." launched with arg ".join(',', $argv)); +dol_syslog($script_file." launched with arg ".implode(',', $argv)); $datetimeprev = dol_now(); @@ -70,7 +71,7 @@ $month = dol_print_date($datetimeprev, "%m"); $year = dol_print_date($datetimeprev, "%Y"); $user = new User($db); -$user->fetch(getDolGlobalString('PRELEVEMENT_USER')); +$user->fetch(getDolGlobalInt('PRELEVEMENT_USER')); if (!isset($argv[1])) { // Check parameters print "This script check invoices with a withdrawal request and\n";