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
This commit is contained in:
MDW 2025-02-18 16:08:09 +01:00
parent b1e975c797
commit 891e11d692
No known key found for this signature in database
31 changed files with 144 additions and 121 deletions

View File

@ -304,6 +304,7 @@ return [
// your application should be included in this list. // your application should be included in this list.
'directory_list' => [ 'directory_list' => [
'htdocs', 'htdocs',
'scripts',
PHAN_DIR . '/stubs/', PHAN_DIR . '/stubs/',
], ],

View File

@ -1051,8 +1051,8 @@ class BonPrelevement extends CommonObject
* - Link the order with the prelevement_demande lines * - Link the order with the prelevement_demande lines
* TODO delete params banque and agence when not necessary * TODO delete params banque and agence when not necessary
* *
* @param int $banque dolibarr mysoc bank * @param string $banque dolibarr mysoc bank
* @param int $agence dolibarr mysoc bank office (guichet) * @param string $agence dolibarr mysoc bank office (guichet)
* @param string $mode real=do action, simu=test only * @param string $mode real=do action, simu=test only
* @param string $format FRST, RCUR or ALL * @param string $format FRST, RCUR or ALL
* @param int $executiondate Date to execute the transfer * @param int $executiondate Date to execute the transfer
@ -1063,7 +1063,7 @@ class BonPrelevement extends CommonObject
* @param string $sourcetype 'invoice' or 'salary' * @param string $sourcetype 'invoice' or 'salary'
* @return int Return integer <0 if KO, No of invoice included into file if OK * @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 // phpcs:enable
global $conf, $langs, $user; global $conf, $langs, $user;

View File

@ -3,7 +3,7 @@
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr> * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.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
@ -311,7 +311,7 @@ class ExportExcel2007 extends ModeleExports
* Output record line into file * Output record line into file
* *
* @param array<string,string> $array_selected_sorted Array with list of field to export * @param array<string,string> $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 Translate $outputlangs Object lang to translate values
* @param array<string,string> $array_types Array with types of fields * @param array<string,string> $array_types Array with types of fields
* @return int Return integer <0 if KO, >0 if OK * @return int Return integer <0 if KO, >0 if OK

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.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
@ -255,7 +255,7 @@ class ExportTsv extends ModeleExports
* Output record line into file * Output record line into file
* *
* @param array<string,string> $array_selected_sorted Array with list of field to export * @param array<string,string> $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 Translate $outputlangs Object lang to translate values
* @param array<string,string> $array_types Array with types of fields * @param array<string,string> $array_types Array with types of fields
* @return int Return integer <0 if KO, >0 if OK * @return int Return integer <0 if KO, >0 if OK

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.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
@ -235,7 +235,7 @@ class ExportCsv extends ModeleExports
* Output record line into file * Output record line into file
* *
* @param array<string,string> $array_selected_sorted Array with list of field to export * @param array<string,string> $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 Translate $outputlangs Object lang to translate values
* @param array<string,string> $array_types Array with types of fields * @param array<string,string> $array_types Array with types of fields
* @return int Return integer <0 if KO, >0 if OK * @return int Return integer <0 if KO, >0 if OK

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.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
@ -239,7 +239,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
* Output record line into file * Output record line into file
* *
* @param array<string,string> $array_selected_sorted Array with list of field to export * @param array<string,string> $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 Translate $outputlangs Object lang to translate values
* @param array<string,string> $array_types Array with types of fields * @param array<string,string> $array_types Array with types of fields
* @return int Return integer <0 if KO, >0 if OK * @return int Return integer <0 if KO, >0 if OK

View File

@ -96,7 +96,7 @@ $long_options = array(
* @param string $header the message to signal to the user * @param string $header the message to signal to the user
* @return void * @return void
*/ */
function usage($program, $header) function install_usage($program, $header)
{ {
echo $header."\n"; echo $header."\n";
echo " php ".$program." [options] [script options]\n"; echo " php ".$program." [options] [script options]\n";
@ -149,7 +149,7 @@ if (php_sapi_name() === "cli" && (float) PHP_VERSION > 7.0) {
break; break;
case 'h': case 'h':
case 'help': case 'help':
usage($argv[0], "Usage:"); install_usage($argv[0], "Usage:");
exit(0); exit(0);
} }
} }
@ -189,7 +189,7 @@ if (php_sapi_name() === "cli" && (float) PHP_VERSION > 7.0) {
// typo right now. // typo right now.
if (count($unknown_options) > 0) { if (count($unknown_options) > 0) {
echo "Unknown option: ".array_values($unknown_options)[0]."\n"; echo "Unknown option: ".array_values($unknown_options)[0]."\n";
usage($argv[0], "Usage:"); install_usage($argv[0], "Usage:");
exit(1); exit(1);
} }

View File

@ -2,7 +2,7 @@
<?php <?php
/* /*
* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -73,7 +73,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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]) { if (!isset($argv[3]) || !$argv[3]) {
print "Usage: ".$script_file." bank_ref [bank_receipt_number|all] (csv|tsv|excel|excel2007) [lang=xx_XX]\n"; 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")); $outputlangs->loadLangs(array("main", "companies", "bills", "banks", "members", "compta"));
$acct = new Account($db); $acct = new Account($db);
$result = $acct->fetch('', $bankref); $result = $acct->fetch(0, $bankref);
if ($result <= 0) { if ($result <= 0) {
print "Failed to find bank account with ref ".$bankref.".\n"; print "Failed to find bank account with ref ".$bankref.".\n";
exit(1); exit(1);
@ -138,6 +138,7 @@ if (!dol_is_file($dir.$file)) {
} }
require_once $dir.$file; require_once $dir.$file;
$objmodel = new $classname($db); $objmodel = new $classname($db);
'@phan-var-force ModeleExports|ExportCsv $objmodel';
// Define target path // Define target path
$dirname = $conf->bank->dir_temp; $dirname = $conf->bank->dir_temp;
@ -247,7 +248,7 @@ if ($resql) {
} }
$totalbefore = $total; $totalbefore = $total;
$total = $total + $objp->amount; $total += $objp->amount;
// Date operation // Date operation
$dateop = $db->jdate($objp->do); $dateop = $db->jdate($objp->do);
@ -375,10 +376,10 @@ if ($resql) {
$debit = $credit = ''; $debit = $credit = '';
if ($objp->amount < 0) { if ($objp->amount < 0) {
$totald = $totald + abs($objp->amount); $totald += abs($objp->amount);
$debit = price2num($objp->amount * -1); $debit = price2num($objp->amount * -1);
} else { } else {
$totalc = $totalc + abs($objp->amount); $totalc += abs($objp->amount);
$credit = price2num($objp->amount); $credit = price2num($objp->amount);
} }

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -67,7 +68,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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]) { if (!isset($argv[1]) || !$argv[1]) {
print "Usage: $script_file now [-y]\n"; print "Usage: $script_file now [-y]\n";

View File

@ -5,7 +5,7 @@
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.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
@ -80,7 +80,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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'); $now = dol_now('tzserver');
$duration_value = isset($argv[3]) ? $argv[3] : 'none'; $duration_value = isset($argv[3]) ? $argv[3] : 'none';
@ -162,7 +162,7 @@ if ($resql) {
if ($startbreak) { if ($startbreak) {
// Break onto sales representative (new email or cid) // Break onto sales representative (new email or cid)
if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { 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; $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid;
} else { } else {
if ($oldemail != 'none') { if ($oldemail != 'none') {
@ -216,7 +216,7 @@ if ($resql) {
// If there are remaining messages to send in the buffer // If there are remaining messages to send in the buffer
if ($foundtoprocess) { if ($foundtoprocess) {
if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { // Break onto email (new email) 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; $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid;
} else { } else {
if ($oldemail != 'none') { if ($oldemail != 'none') {
@ -252,7 +252,7 @@ if ($resql) {
* @param int $duration_value duration value * @param int $duration_value duration value
* @return int Int <0 if KO, >0 if OK * @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; global $conf, $langs;
@ -267,9 +267,9 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget,
if ($duration_value) { if ($duration_value) {
if ($duration_value > 0) { if ($duration_value > 0) {
$title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", $duration_value); $title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", (string) $duration_value);
} else { } else {
$title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", $duration_value); $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", (string) $duration_value);
} }
} else { } else {
$title = $newlangs->transnoentities("ListOfServicesToExpire"); $title = $newlangs->transnoentities("ListOfServicesToExpire");

View File

@ -5,7 +5,7 @@
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.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
@ -78,7 +78,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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'); $now = dol_now('tzserver');
$duration_value = isset($argv[2]) ? $argv[2] : 'none'; $duration_value = isset($argv[2]) ? $argv[2] : 'none';
@ -123,7 +123,7 @@ if ($resql) {
if (($obj->email != $oldemail || $obj->uid != $olduid) || $oldemail == 'none') { if (($obj->email != $oldemail || $obj->uid != $olduid) || $oldemail == 'none') {
// Break onto sales representative (new email or uid) // Break onto sales representative (new email or uid)
if (dol_strlen($oldemail) && $oldemail != 'none') { 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 { } else {
if ($oldemail != 'none') { if ($oldemail != 'none') {
print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; 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 there are remaining messages to send in the buffer
if ($foundtoprocess) { if ($foundtoprocess) {
if (dol_strlen($oldemail) && $oldemail != 'none') { // Break onto email (new email) 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 { } else {
if ($oldemail != 'none') { if ($oldemail != 'none') {
print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n";
@ -202,7 +202,7 @@ if ($resql) {
* @param int $duration_value Duration value * @param int $duration_value Duration value
* @return int Int <0 if KO, >0 if OK * @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; global $conf, $langs;
@ -217,9 +217,9 @@ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget,
if ($duration_value) { if ($duration_value) {
if ($duration_value > 0) { if ($duration_value > 0) {
$title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", $duration_value); $title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", (string) $duration_value);
} else { } else {
$title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", $duration_value); $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", (string) $duration_value);
} }
} else { } else {
$title = $newlangs->transnoentities("ListOfServicesToExpire"); $title = $newlangs->transnoentities("ListOfServicesToExpire");

View File

@ -5,6 +5,7 @@
* Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro * Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -75,13 +76,13 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
// Check parameters // Check parameters
if (!isset($argv[1]) || !$argv[1]) { if (!isset($argv[1]) || !$argv[1]) {
usage($path, $script_file); usageCron($path, $script_file);
exit(1); exit(1);
} }
$key = $argv[1]; $key = $argv[1];
if (!isset($argv[2]) || !$argv[2]) { if (!isset($argv[2]) || !$argv[2]) {
usage($path, $script_file); usageCron($path, $script_file);
exit(1); exit(1);
} }
@ -142,7 +143,7 @@ if ($userlogin == 'firstadmin') {
// Check user login // Check user login
$user = new User($db); $user = new User($db);
$result = $user->fetch('', $userlogin, '', 1); $result = $user->fetch(0, $userlogin, '', 1);
if ($result < 0) { if ($result < 0) {
echo "User Error: ".$user->error; echo "User Error: ".$user->error;
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); 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 // Loop over job
foreach ($object->lines as $line) { 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); 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; 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 // Force recheck that user is ok for the entity to process and reload permission for entity
if ($conf->entity != $user->entity) { if ($conf->entity != $user->entity) {
$result = $user->fetch('', $userlogin, '', 1); $result = $user->fetch(0, $userlogin, '', 1);
if ($result < 0) { if ($result < 0) {
echo "\nUser Error: ".$user->error."\n"; echo "\nUser Error: ".$user->error."\n";
dol_syslog("cron_run_jobs.php: User Error:".$user->error, LOG_ERR); 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 $path Path
* @param string $script_file Filename * @param string $script_file Filename
* @return void * @return void
*/ */
function usage($path, $script_file) function usageCron($path, $script_file)
{ {
print "Usage: ".$script_file." securitykey userlogin|'firstadmin' [cronjobid] [--force]\n"; print "Usage: ".$script_file." securitykey userlogin|'firstadmin' [cronjobid] [--force]\n";
print "The script return 0 when everything worked successfully.\n"; print "The script return 0 when everything worked successfully.\n";

View File

@ -3,6 +3,7 @@
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean Heimburger <http://tiaris.eu> * Copyright (C) 2015 Jean Heimburger <http://tiaris.eu>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -74,7 +75,7 @@ $hookmanager->initHooks(array('cli'));
*/ */
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." - dir=".DOL_DATA_ROOT." *****\n"; 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])) { if (empty($argv[1])) {
print "Usage: $script_file subdirtoscan (test|confirm)\n"; print "Usage: $script_file subdirtoscan (test|confirm)\n";
@ -110,14 +111,14 @@ if ($subdir == 'propale' || $subdir == 'proposal') {
print 'Error, module not enabled'."\n"; print 'Error, module not enabled'."\n";
} }
} elseif ($subdir == 'commande' || $subdir == 'order') { } elseif ($subdir == 'commande' || $subdir == 'order') {
if (isModEnabled('commande')) { if (isModEnabled('order')) {
require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"; require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php";
$tmpobject = new Commande($db); $tmpobject = new Commande($db);
} else { } else {
print 'Error, module not enabled'."\n"; print 'Error, module not enabled'."\n";
} }
} elseif ($subdir == 'facture' || $subdir == 'invoice') { } elseif ($subdir == 'facture' || $subdir == 'invoice') {
if (isModEnabled('facture')) { if (isModEnabled('invoice')) {
require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
$tmpobject = new Facture($db); $tmpobject = new Facture($db);
} else { } else {

View File

@ -6,7 +6,7 @@
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2016 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.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
@ -102,8 +102,8 @@ if (getDolGlobalInt('MAILING_DELAY')) {
print 'A delay of '.((float) getDolGlobalInt('MAILING_DELAY')).' seconds has been set between each email'."\n"; 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)) { if (!empty($dolibarr_main_db_readonly)) {
print "Error: instance in read-only mode\n"; print "Error: instance in read-only mode\n";
@ -113,7 +113,7 @@ if (!empty($dolibarr_main_db_readonly)) {
$user = new User($db); $user = new User($db);
// for signature, we use user send as parameter // for signature, we use user send as parameter
if (!empty($login)) { if (!empty($login)) {
$user->fetch('', $login); $user->fetch(0, $login);
} }
/** @var DoliDB $db */ /** @var DoliDB $db */
// We get list of emailing id to process // We get list of emailing id to process

View File

@ -2,6 +2,7 @@
<?php <?php
/* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -178,7 +179,7 @@ while ($tmp != null) {
$numerasedtotal += $numerased; $numerasedtotal += $numerased;
print $numerased." emails cleared.\n"; print $numerased." emails cleared.\n";
$counter = $counter + $nbingroup; $counter += $nbingroup;
} }
if (!$error && $mode == 'confirm') { if (!$error && $mode == 'confirm') {

View File

@ -5,7 +5,7 @@
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.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
@ -78,7 +78,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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'); $now = dol_now('tzserver');
$duration_value = isset($argv[3]) ? $argv[3] : 'none'; $duration_value = isset($argv[3]) ? $argv[3] : 'none';
@ -165,7 +165,7 @@ if ($resql) {
if ($startbreak) { if ($startbreak) {
// Break onto sales representative (new email or cid) // Break onto sales representative (new email or cid)
if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { 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; $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid;
} else { } else {
if ($oldemail != 'none') { if ($oldemail != 'none') {
@ -219,7 +219,7 @@ if ($resql) {
// If there are remaining messages to send in the buffer // If there are remaining messages to send in the buffer
if ($foundtoprocess) { if ($foundtoprocess) {
if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { // Break onto email (new email) 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; $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid;
} else { } else {
if ($oldemail != 'none') { if ($oldemail != 'none') {
@ -254,7 +254,7 @@ if ($resql) {
* @param string $oldtarget Target name * @param string $oldtarget Target name
* @return int Int <0 if KO, >0 if OK * @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; global $conf, $langs;

View File

@ -4,7 +4,7 @@
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -76,7 +76,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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'); $now = dol_now('tzserver');
$duration_value = isset($argv[2]) ? $argv[2] : 'none'; $duration_value = isset($argv[2]) ? $argv[2] : 'none';
@ -118,10 +118,10 @@ if ($resql) {
$total = 0; $total = 0;
$foundtoprocess = 0; $foundtoprocess = 0;
print "We found ".$num." couples (unpayed validated invoice - sale representative) qualified\n"; print "We found ".$num." couples (unpaid validated invoice - sale representative) qualified\n";
dol_syslog("We found ".$num." couples (unpayed validated invoice - sale representative) qualified"); dol_syslog("We found ".$num." couples (unpaid validated invoice - sale representative) qualified");
$message = ''; $message = '';
$oldsalerepresentative = 0; $oldsalerepresentative = '';
if ($num) { if ($num) {
while ($i < $num) { while ($i < $num) {
@ -130,7 +130,7 @@ if ($resql) {
if (($obj->email != $oldemail || $obj->uid != $olduid) || $oldemail == 'none') { if (($obj->email != $oldemail || $obj->uid != $olduid) || $oldemail == 'none') {
// Break onto sales representative (new email or uid) // Break onto sales representative (new email or uid)
if (dol_strlen($oldemail) && $oldemail != 'none') { if (dol_strlen($oldemail) && $oldemail != 'none') {
envoi_mail($mode, $oldemail, $message, price2num($total), $oldlang, $oldsalerepresentative); sendMailRepresentativeUnpaid($mode, $oldemail, $message, price2num($total), $oldlang, $oldsalerepresentative);
} else { } else {
if ($oldemail != 'none') { if ($oldemail != 'none') {
print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; 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 there are remaining messages to send in the buffer
if ($foundtoprocess) { if ($foundtoprocess) {
if (dol_strlen($oldemail) && $oldemail != 'none') { // Break onto email (new email) 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 { } else {
if ($oldemail != 'none') { if ($oldemail != 'none') {
print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n";
@ -203,12 +203,12 @@ if ($resql) {
* @param string $mode Mode (test | confirm) * @param string $mode Mode (test | confirm)
* @param string $oldemail Target email * @param string $oldemail Target email
* @param string $message Message to send * @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 $userlang Code lang to use for email output.
* @param string $oldtarget Target name of sale representative * @param string $oldtarget Target name of sale representative
* @return int Int <0 if KO, >0 if OK * @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; global $conf, $langs;

View File

@ -3,7 +3,7 @@
/* /*
* Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.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
@ -69,7 +69,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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 // Check parameters
if (!isset($argv[1])) { if (!isset($argv[1])) {
@ -222,18 +222,18 @@ foreach ($argv as $key => $value) {
$filter[] = 'excludethirdparties'; $filter[] = 'excludethirdparties';
$thirdpartiesid = explode(',', $argv[$key + 1]); $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') { if ($value == 'filter=onlythirdparties') {
$found = true; $found = true;
$filter[] = 'onlythirdparties'; $filter[] = 'onlythirdparties';
$thirdpartiesid = explode(',', $argv[$key + 1]); $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)) { if (!$found && preg_match('/filter=/i', $value)) {

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -67,7 +68,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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]) { if (!isset($argv[1]) || !$argv[1]) {
print "Usage: $script_file now [-y]\n"; print "Usage: $script_file now [-y]\n";

View File

@ -3,7 +3,7 @@
/** /**
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -71,7 +71,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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 // List of fields to get from LDAP
$required_fields = array( $required_fields = array(
@ -104,7 +104,7 @@ $required_fields = array(
); );
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated // 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])) { if (!isset($argv[2]) || !is_numeric($argv[2])) {
print "Usage: $script_file (nocommitiferror|commitiferror) id_member_type [--server=ldapserverhost] [-y]\n"; 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 "database=".$conf->db->name."\n";
print "----- Options:\n"; print "----- Options:\n";
print "commitiferror=".$forcecommit."\n"; print "commitiferror=".$forcecommit."\n";
print "Mapped LDAP fields=".join(',', $required_fields)."\n"; print "Mapped LDAP fields=".implode(',', $required_fields)."\n";
print "\n"; print "\n";
// Check parameters // Check parameters
@ -312,7 +312,7 @@ if ($result >= 0) {
} }
$db->commit(); $db->commit();
} else { } else {
print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", (string) $error)."\n";
$db->rollback(); $db->rollback();
} }
print "\n"; print "\n";
@ -334,7 +334,7 @@ exit($error);
* @param string $element Value to test * @param string $element Value to test
* @return boolean True of false * @return boolean True of false
*/ */
function dolValidElement($element) function dolValidLdapElement($element)
{ {
return (trim($element) != ''); return (trim($element) != '');
} }

View File

@ -5,6 +5,7 @@
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -72,7 +73,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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')) { * if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) {

View File

@ -6,6 +6,7 @@
* Copyright (C) 2013 Maxime Kohlhaas <maxime@atm-consulting.fr> * Copyright (C) 2013 Maxime Kohlhaas <maxime@atm-consulting.fr>
* Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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 // 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')); $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 "database=".$conf->db->name."\n";
print "----- Options:\n"; print "----- Options:\n";
print "commitiferror=".$forcecommit."\n"; print "commitiferror=".$forcecommit."\n";
print "Mapped LDAP fields=".join(',', $required_fields)."\n"; print "Mapped LDAP fields=".implode(',', $required_fields)."\n";
print "\n"; print "\n";
if (!$confirmed) { if (!$confirmed) {
@ -151,7 +152,7 @@ if ($result >= 0) {
// Warning $ldapuser has a key in lowercase // Warning $ldapuser has a key in lowercase
foreach ($ldaprecords as $key => $ldapgroup) { foreach ($ldaprecords as $key => $ldapgroup) {
$membertype = new AdherentType($db); $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->label = $ldapgroup[getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_FULLNAME')];
$membertype->description = $ldapgroup[getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_DESCRIPTION')]; $membertype->description = $ldapgroup[getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_DESCRIPTION')];
$membertype->entity = $conf->entity; $membertype->entity = $conf->entity;
@ -193,7 +194,7 @@ if ($result >= 0) {
} }
$db->commit(); $db->commit();
} else { } else {
print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", (string) $error)."\n";
$db->rollback(); $db->rollback();
} }
print "\n"; print "\n";

View File

@ -4,6 +4,7 @@
* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean Heimburger <http://tiaris.eu> * Copyright (C) 2015 Jean Heimburger <http://tiaris.eu>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli'));
*/ */
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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') { if (!isset($argv[1]) || $argv[1] != 'product') {
print "Usage: $script_file product\n"; print "Usage: $script_file product\n";

View File

@ -3,6 +3,7 @@
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean Heimburger <http://tiaris.eu> * Copyright (C) 2015 Jean Heimburger <http://tiaris.eu>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -70,7 +71,7 @@ $hookmanager->initHooks(array('cli'));
*/ */
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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])) { if (empty($argv[1])) {
print "Usage: $script_file subdirtoscan\n"; print "Usage: $script_file subdirtoscan\n";

View File

@ -4,6 +4,7 @@
* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean Heimburger <http://tiaris.eu> * Copyright (C) 2015 Jean Heimburger <http://tiaris.eu>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli'));
*/ */
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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') { if (!isset($argv[1]) || $argv[1] != 'user') {
print "Usage: $script_file user\n"; print "Usage: $script_file user\n";
@ -113,7 +114,7 @@ function migrate_user_filespath($u)
{ {
global $conf; 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; $dir = $conf->user->dir_output;
$origin = $dir.'/'.get_exdir($u->id, 2, 0, 0, $u, 'user'); $origin = $dir.'/'.get_exdir($u->id, 2, 0, 0, $u, 'user');
$destin = $dir.'/'.$u->id; $destin = $dir.'/'.$u->id;

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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')) { * if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) {

View File

@ -5,6 +5,7 @@
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Maxime Kohlhaas <maxime@atm-consulting.fr> * Copyright (C) 2013 Maxime Kohlhaas <maxime@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -72,13 +73,13 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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 // 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')); $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 // 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])) { if (!isset($argv[1])) {
// print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n"; // 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 "database=".$conf->db->name."\n";
print "----- Options:\n"; print "----- Options:\n";
print "commitiferror=".$forcecommit."\n"; print "commitiferror=".$forcecommit."\n";
print "Mapped LDAP fields=".join(',', $required_fields)."\n"; print "Mapped LDAP fields=".implode(',', $required_fields)."\n";
print "\n"; print "\n";
if (!$confirmed) { if (!$confirmed) {
@ -151,10 +152,10 @@ if ($result >= 0) {
// Warning $ldapuser has a key in lowercase // Warning $ldapuser has a key in lowercase
foreach ($ldaprecords as $key => $ldapgroup) { foreach ($ldaprecords as $key => $ldapgroup) {
$group = new UserGroup($db); $group = new UserGroup($db);
$group->fetch('', $ldapgroup[getDolGlobalString('LDAP_KEY_GROUPS')]); $group->fetch(0, $ldapgroup[getDolGlobalString('LDAP_KEY_GROUPS')]);
$group->name = $ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_FULLNAME')] ?? null; $group->name = $ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_FULLNAME')] ?? '';
$group->nom = $group->name; // For backward compatibility $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; $group->entity = $conf->entity;
// print_r($ldapgroup); // print_r($ldapgroup);
@ -189,8 +190,12 @@ if ($result >= 0) {
// 1 - Association of users in the LDAP group with the Dolibarr group // 1 - Association of users in the LDAP group with the Dolibarr group
$userList = array(); $userList = array();
$userIdList = array(); $userIdList = array();
foreach ($ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_GROUPMEMBERS')] as $tmpkey => $userdn) { $groupMembers = $ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_GROUPMEMBERS')];
if ($tmpkey === 'count') { if (!is_array($groupMembers)) {
$groupMembers = array();
}
foreach ($groupMembers as $tmpkey => $userdn) { // @phpstan-ignore-line
if ($tmpkey === 'count') { // @phpstan-ignore-line
continue; continue;
} }
if (empty($userList[$userdn])) { // Récupération de l'utilisateur if (empty($userList[$userdn])) { // Récupération de l'utilisateur
@ -208,9 +213,9 @@ if ($result >= 0) {
$fuser = new User($db); $fuser = new User($db);
if (getDolGlobalString('LDAP_KEY_USERS') == getDolGlobalString('LDAP_FIELD_SID')) { 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')) { } 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; $userList[$userdn] = $fuser;
@ -244,7 +249,7 @@ if ($result >= 0) {
} }
$db->commit(); $db->commit();
} else { } else {
print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", (string) $error)."\n";
$db->rollback(); $db->rollback();
} }
print "\n"; print "\n";
@ -266,7 +271,7 @@ exit($error);
* @param string $element Value to test * @param string $element Value to test
* @return boolean True of false * @return boolean True of false
*/ */
function dolValidElement($element) function dolValidLdapElement2($element)
{ {
return (trim($element) != ''); return (trim($element) != '');
} }

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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')) { * if (! getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) {

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -71,7 +72,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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 // List of fields to get from LDAP
$required_fields = array( $required_fields = array(
@ -97,7 +98,7 @@ $required_fields = array(
); );
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated // 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])) { if (!isset($argv[1])) {
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n"; 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 "database=".$conf->db->name."\n";
print "----- Options:\n"; print "----- Options:\n";
print "commitiferror=".$forcecommit."\n"; print "commitiferror=".$forcecommit."\n";
print "excludeuser=".join(',', $excludeuser)."\n"; print "excludeuser=".implode(',', $excludeuser)."\n";
print "Mapped LDAP fields=".join(',', $required_fields)."\n"; print "Mapped LDAP fields=".implode(',', $required_fields)."\n";
print "\n"; print "\n";
if (!$confirmed) { if (!$confirmed) {
@ -205,17 +206,17 @@ if ($result >= 0) {
$fuser = new User($db); $fuser = new User($db);
if (getDolGlobalString('LDAP_KEY_USERS') == getDolGlobalString('LDAP_FIELD_SID')) { 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')) { } 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 // Propriete membre
$fuser->firstname = $ldapuser[getDolGlobalString('LDAP_FIELD_FIRSTNAME')] ?? null; $fuser->firstname = $ldapuser[getDolGlobalString('LDAP_FIELD_FIRSTNAME')] ?? '';
$fuser->lastname = $ldapuser[getDolGlobalString('LDAP_FIELD_NAME')] ?? null; $fuser->lastname = $ldapuser[getDolGlobalString('LDAP_FIELD_NAME')] ?? '';
$fuser->login = $ldapuser[getDolGlobalString('LDAP_FIELD_LOGIN')] ?? null; $fuser->login = $ldapuser[getDolGlobalString('LDAP_FIELD_LOGIN')] ?? '';
$fuser->pass = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD')] ?? null; $fuser->pass = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD')] ?? '';
$fuser->pass_indatabase_crypted = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD_CRYPTED')] ?? null; $fuser->pass_indatabase_crypted = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD_CRYPTED')] ?? '';
// $user->societe; // $user->societe;
/* /*
@ -227,13 +228,13 @@ if ($result >= 0) {
* $fuser->country_code=$countries[$hashlib2rowid[strtolower($fuser->country)]]['code']; * $fuser->country_code=$countries[$hashlib2rowid[strtolower($fuser->country)]]['code'];
*/ */
$fuser->office_phone = $ldapuser[getDolGlobalString('LDAP_FIELD_PHONE')] ?? null; $fuser->office_phone = $ldapuser[getDolGlobalString('LDAP_FIELD_PHONE')] ?? '';
$fuser->user_mobile = $ldapuser[getDolGlobalString('LDAP_FIELD_MOBILE')] ?? null; $fuser->user_mobile = $ldapuser[getDolGlobalString('LDAP_FIELD_MOBILE')] ?? '';
$fuser->office_fax = $ldapuser[getDolGlobalString('LDAP_FIELD_FAX')] ?? null; $fuser->office_fax = $ldapuser[getDolGlobalString('LDAP_FIELD_FAX')] ?? '';
$fuser->email = $ldapuser[getDolGlobalString('LDAP_FIELD_MAIL')] ?? null; $fuser->email = $ldapuser[getDolGlobalString('LDAP_FIELD_MAIL')] ?? '';
$fuser->ldap_sid = $ldapuser[getDolGlobalString('LDAP_FIELD_SID')] ?? null; $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->note = $ldapuser[getDolGlobalString('LDAP_FIELD_DESCRIPTION')] ?? null;
$fuser->admin = 0; $fuser->admin = 0;
$fuser->socid = 0; $fuser->socid = 0;
@ -296,7 +297,7 @@ if ($result >= 0) {
} }
$db->commit(); $db->commit();
} else { } else {
print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", (string) $error)."\n";
$db->rollback(); $db->rollback();
} }
print "\n"; print "\n";
@ -318,7 +319,7 @@ exit($error);
* @param string $element Value to test * @param string $element Value to test
* @return boolean True of false * @return boolean True of false
*/ */
function dolValidElement($element) function dolValidLdapElement3($element)
{ {
return (trim($element) != ''); return (trim($element) != '');
} }

View File

@ -2,6 +2,7 @@
<?php <?php
/* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -44,7 +45,7 @@ $error = 0;
$mode = empty($argv[1]) ? '' : $argv[1]; $mode = empty($argv[1]) ? '' : $argv[1];
$websiteref = empty($argv[2]) ? '' : $argv[2]; $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)) { if (empty($argv[2]) || !in_array($argv[1], array('test', 'confirm')) || empty($websiteref)) {
print '***** '.$script_file.' *****'."\n"; print '***** '.$script_file.' *****'."\n";

View File

@ -3,6 +3,7 @@
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.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
@ -62,7 +63,7 @@ $hookmanager->initHooks(array('cli'));
@set_time_limit(0); @set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; 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(); $datetimeprev = dol_now();
@ -70,7 +71,7 @@ $month = dol_print_date($datetimeprev, "%m");
$year = dol_print_date($datetimeprev, "%Y"); $year = dol_print_date($datetimeprev, "%Y");
$user = new User($db); $user = new User($db);
$user->fetch(getDolGlobalString('PRELEVEMENT_USER')); $user->fetch(getDolGlobalInt('PRELEVEMENT_USER'));
if (!isset($argv[1])) { // Check parameters if (!isset($argv[1])) { // Check parameters
print "This script check invoices with a withdrawal request and\n"; print "This script check invoices with a withdrawal request and\n";