| '.$langs->trans("BankTransactionLine").' | ';
- if ($object->fk_bank) {
+ if ($object->fk_bank > 0) {
$bankline = new AccountLine($db);
$result = $bankline->fetch($object->fk_bank);
print $bankline->getNomUrl(1, 0, 'showall');
@@ -358,8 +362,8 @@ if ($rowid && $action != 'edit') {
print '';
if ($user->hasRight('adherent', 'cotisation', 'creer')) {
- if (!empty($bankline->rappro) || empty($bankline)) {
- print ' ";
+ if (empty($bankline->rappro) || empty($bankline)) {
+ print ' ";
} else {
print ' ";
}
diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php
index b2867203410..2e6974dff77 100644
--- a/htdocs/adherents/subscription/list.php
+++ b/htdocs/adherents/subscription/list.php
@@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
-$langs->loadLangs(array("members", "companies"));
+$langs->loadLangs(array("members", "companies", "banks"));
$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
@@ -172,7 +172,7 @@ $accountstatic = new Account($db);
$now = dol_now();
// List of subscriptions
-$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut,";
+$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut as status,";
$sql .= " d.gender, d.email, d.morphy,";
$sql .= " c.rowid as crowid, c.fk_type, c.subscription,";
$sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,";
@@ -611,7 +611,8 @@ while ($i < $imaxinloop) {
$adherent->firstname = $obj->firstname;
$adherent->ref = $obj->rowid;
$adherent->id = $obj->rowid;
- $adherent->statut = $obj->statut;
+ $adherent->statut = $obj->status;
+ $adherent->status = $obj->status;
$adherent->login = $obj->login;
$adherent->photo = $obj->photo;
$adherent->gender = $obj->gender;
@@ -672,14 +673,14 @@ while ($i < $imaxinloop) {
}
// Ref
if (!empty($arrayfields['d.ref']['checked'])) {
- print ' '.$subscription->getNomUrl(1).' | ';
+ print ' '.$subscription->getNomUrl(1).' | ';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Type
if (!empty($arrayfields['d.fk_type']['checked'])) {
- print ' ';
+ print ' | ';
if ($typeid > 0) {
print $adht->getNomUrl(1);
}
@@ -739,14 +740,14 @@ while ($i < $imaxinloop) {
// Date start
if (!empty($arrayfields['c.dateadh']['checked'])) {
- print ' | '.dol_print_date($db->jdate($obj->dateadh), 'day')." | \n";
+ print ' '.dol_print_date($db->jdate($obj->dateadh), 'day')." | \n";
if (!$i) {
$totalarray['nbfield']++;
}
}
// Date end
if (!empty($arrayfields['c.datef']['checked'])) {
- print ' '.dol_print_date($db->jdate($obj->datef), 'day')." | \n";
+ print ' '.dol_print_date($db->jdate($obj->datef), 'day')." | \n";
if (!$i) {
$totalarray['nbfield']++;
}
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index 91f3fc328d4..4a1ee4b36a6 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -8,6 +8,7 @@
* Copyright (C) 2019-2022 Thibault Foucart
* Copyright (C) 2020 Josep Lluís Amador
* Copyright (C) 2021 Waël Almoman
+ * Copyright (C) 2024 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
@@ -47,7 +48,7 @@ $cancel = GETPOST('cancel', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
-$mode = GETPOST('mode', 'alopha');
+$mode = GETPOST('mode', 'alpha');
$sall = GETPOST("sall", "alpha");
$filter = GETPOST("filter", 'alpha');
diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php
index bf7eb7d27bf..5c92e5acd14 100644
--- a/htdocs/admin/defaultvalues.php
+++ b/htdocs/admin/defaultvalues.php
@@ -40,7 +40,7 @@ if (!$user->admin) {
accessforbidden();
}
-$id = GETPOST('rowid', 'int');
+$id = GETPOSTINT('rowid');
$action = GETPOST('action', 'aZ09');
$optioncss = GETPOST('optionscss', 'alphanohtml');
diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php
index ea37636f882..f4cfce82217 100644
--- a/htdocs/admin/expensereport_ik.php
+++ b/htdocs/admin/expensereport_ik.php
@@ -21,7 +21,7 @@
/**
* \file htdocs/admin/expensereport_ik.php
* \ingroup expensereport
- * \brief Page to display expense tax ik
+ * \brief Page to display expense tax ik. Used when MAIN_USE_EXPENSE_IK is set.
*/
// Load Dolibarr environment
@@ -38,11 +38,11 @@ $error = 0;
$action = GETPOST('action', 'aZ09');
-$id = GETPOST('id', 'int');
-$ikoffset = GETPOST('ikoffset', 'int');
-$coef = GETPOST('coef', 'int');
-$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat');
-$fk_range = GETPOST('fk_range', 'int');
+$id = GETPOSTINT('id');
+$ikoffset = (float) price2num(GETPOST('ikoffset', 'alpha'));
+$coef = (float) price2num(GETPOST('coef', 'alpha'));
+$fk_c_exp_tax_cat = GETPOSTINT('fk_c_exp_tax_cat');
+$fk_range = GETPOSTINT('fk_range');
$expIk = new ExpenseReportIk($db);
@@ -59,7 +59,7 @@ if ($action == 'updateik') {
if ($id > 0) {
$result = $expIk->fetch($id);
if ($result < 0) {
- dol_print_error('', $expIk->error, $expIk->errors);
+ dol_print_error(null, $expIk->error, $expIk->errors);
}
}
@@ -85,7 +85,7 @@ if ($action == 'updateik') {
if ($id > 0) {
$result = $expIk->fetch($id);
if ($result < 0) {
- dol_print_error('', $expIk->error, $expIk->errors);
+ dol_print_error(null, $expIk->error, $expIk->errors);
}
$expIk->delete($user);
@@ -167,6 +167,7 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) {
echo $range->ik->ikoffset;
}
echo ' | ';
+
// Coef
echo '';
if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) {
diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php
index 968fdea81af..639fcf50077 100644
--- a/htdocs/admin/expensereport_rules.php
+++ b/htdocs/admin/expensereport_rules.php
@@ -65,17 +65,17 @@ if (empty($reshook)) {
$apply_to = GETPOST('apply_to');
$fk_user = GETPOST('fk_user', 'int');
$fk_usergroup = GETPOST('fk_usergroup', 'int');
- $restrictive = GETPOST('restrictive', 'int');
- $fk_c_type_fees = GETPOST('fk_c_type_fees', 'int');
+ $restrictive = GETPOSTINT('restrictive');
+ $fk_c_type_fees = GETPOSTINT('fk_c_type_fees');
$code_expense_rules_type = GETPOST('code_expense_rules_type');
$dates = dol_mktime(12, 0, 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear'));
$datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
- $amount = price2num(GETPOST('amount'), 'MT', 2);
+ $amount = (float) price2num(GETPOST('amount'), 'MT', 2);
if (!empty($id)) {
$result = $object->fetch($id);
if ($result < 0) {
- dol_print_error('', $object->error, $object->errors);
+ dol_print_error(null, $object->error, $object->errors);
}
}
@@ -166,7 +166,7 @@ if (empty($reshook)) {
$tab_apply = array(
'A' => $langs->trans('All'),
- 'G' => $langs->trans('Group'),
+ 'G' => $langs->trans('UserGroup'),
'U' => $langs->trans('User')
);
$tab_rules_type = array(
@@ -176,22 +176,24 @@ if (empty($reshook)) {
'EX_EXP' => $langs->trans('OnExpense')
);
}
- /*
- * View
- */
- llxHeader('', $langs->trans("ExpenseReportsSetup"));
- $form = new Form($db);
+/*
+ * View
+ */
- $linkback = '' . $langs->trans("BackToModuleList") . '';
- print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup');
+llxHeader('', $langs->trans("ExpenseReportsSetup"));
- $head = expensereport_admin_prepare_head();
- print dol_get_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip');
+$form = new Form($db);
- echo '' . $langs->trans('ExpenseReportRulesDesc') . '';
- print '
';
+$linkback = '' . $langs->trans("BackToModuleList") . '';
+print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup');
+
+$head = expensereport_admin_prepare_head();
+print dol_get_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip');
+
+echo '' . $langs->trans('ExpenseReportRulesDesc') . '';
+print '
';
if ($action != 'edit') {
echo '';
- echo '';
diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php
index bd265349c3f..b8a54ec53c7 100644
--- a/htdocs/core/class/link.class.php
+++ b/htdocs/core/class/link.class.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 2024 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
@@ -91,7 +92,7 @@ class Link extends CommonObject
// Check parameters
if (empty($this->url)) {
- $this->error = $langs->trans("NoUrl");
+ $this->error = $langs->trans("NoURL");
return -1;
}
@@ -207,11 +208,11 @@ class Link extends CommonObject
}
} else {
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
- // Doublon
+ // Duplicate
$this->error = $langs->trans("ErrorDuplicateField");
$result = -1;
} else {
- $this->error = $langs->trans("Error sql = ".$sql);
+ $this->error = $langs->trans("Error sql")."= $sql";
$result = -2;
}
$this->db->rollback();
diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php
index 1a590c51588..fd8ab10a3b5 100644
--- a/htdocs/core/class/stats.class.php
+++ b/htdocs/core/class/stats.class.php
@@ -77,7 +77,7 @@ abstract class Stats
/**
* @param int $year number
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
- * @return int value
+ * @return array array of values by month
*/
abstract protected function getNbByMonth($year, $format = 0);
@@ -172,7 +172,7 @@ abstract class Stats
/**
* @param int $year year number
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
- * @return int value
+ * @return array array of values by month
*/
abstract protected function getAmountByMonth($year, $format = 0);
diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php
index fdc8f939903..94b53cf494d 100644
--- a/htdocs/core/class/timespent.class.php
+++ b/htdocs/core/class/timespent.class.php
@@ -965,7 +965,7 @@ class TimeSpent extends CommonObject
}
if ($mybool === false) {
- dol_print_error('', "Failed to include file ".$file);
+ dol_print_error(null, "Failed to include file ".$file);
return '';
}
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index 03c2fc7f59d..20102ba29ff 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2001 Eric Seigne
* Copyright (C) 2004-2015 Destailleur Laurent
* Copyright (C) 2005-2010 Regis Houssin
+ * Copyright (C) 2024 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
@@ -211,7 +212,7 @@ class Translate
// Check parameters
if (empty($domain)) {
- dol_print_error('', get_class($this) . "::Load ErrorWrongParameters");
+ dol_print_error(null, get_class($this) . "::Load ErrorWrongParameters");
return -1;
}
if ($this->defaultlang === 'none_NONE') {
@@ -767,8 +768,9 @@ class Translate
*/
public function transcountry($str, $countrycode)
{
- if (!empty($this->tab_translate["$str$countrycode"])) {
- return $this->trans("$str$countrycode");
+ $strLocaleKey=$str.$countrycode;
+ if (!empty($this->tab_translate[$strLocaleKey])) {
+ return $this->trans($strLocaleKey);
} else {
return $this->trans($str);
}
@@ -785,8 +787,9 @@ class Translate
*/
public function transcountrynoentities($str, $countrycode)
{
- if (!empty($this->tab_translate["$str$countrycode"])) {
- return $this->transnoentities("$str$countrycode");
+ $strLocaleKey=$str.$countrycode;
+ if (!empty($this->tab_translate[$strLocaleKey])) {
+ return $this->transnoentities($strLocaleKey);
} else {
return $this->transnoentities($str);
}
@@ -980,7 +983,7 @@ class Translate
* @param string $fieldlabel Field for label. This value must always be a hardcoded string and not a value coming from user input.
* @param string $keyforselect Use another value than the translation key for the where into select
* @param int $filteronentity Use a filter on entity
- * @return string Label in UTF8 (but without entities)
+ * @return string|int Label in UTF8 (but without entities) or -1 if error
* @see dol_getIdFromCode()
*/
public function getLabelFromKey($db, $key, $tablename, $fieldkey, $fieldlabel, $keyforselect = '', $filteronentity = 0)
diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php
index 345ad056c4e..4b18465ae68 100644
--- a/htdocs/core/class/vcard.class.php
+++ b/htdocs/core/class/vcard.class.php
@@ -454,9 +454,12 @@ class vCard
$country = $object->country_code ? $object->country : '';
- if ($object->address || $object->town || $object->state || $object->zip || $object->country) {
- $this->setAddress("", "", $object->address, $object->town, $object->state, $object->zip, $country, "");
- //$this->setLabel("", "", $object->address, $object->town, $object->state, $object->zip, $country, "TYPE=HOME");
+ // User address
+ if (!($object->element != 'user') || getDolUserInt('USER_PUBLIC_SHOW_ADDRESS', 0, $object)) {
+ if ($object->address || $object->town || $object->state || $object->zip || $object->country) {
+ $this->setAddress("", "", $object->address, $object->town, $object->state, $object->zip, $country, "");
+ //$this->setLabel("", "", $object->address, $object->town, $object->state, $object->zip, $country, "TYPE=HOME");
+ }
}
if ($object->email) {
@@ -533,8 +536,10 @@ class vCard
}
// Birthday
- if ($object->birth) {
- $this->setBirthday($object->birth);
+ if (!($object->element != 'user') || getDolUserInt('USER_PUBLIC_SHOW_BIRTH', 0, $object)) {
+ if ($object->birth) {
+ $this->setBirthday($object->birth);
+ }
}
// Return VCard string
diff --git a/htdocs/core/commonfieldsinexport.inc.php b/htdocs/core/commonfieldsinexport.inc.php
index 3b201e4f10a..98838e623bf 100644
--- a/htdocs/core/commonfieldsinexport.inc.php
+++ b/htdocs/core/commonfieldsinexport.inc.php
@@ -2,7 +2,7 @@
if (empty($keyforclass) || empty($keyforclassfile) || empty($keyforelement)) {
//print $keyforclass.' - '.$keyforclassfile.' - '.$keyforelement;
- dol_print_error('', 'include of file commonfieldsinexport.inc.php was done but var $keyforclass or $keyforclassfile or $keyforelement was not set');
+ dol_print_error(null, 'include of file commonfieldsinexport.inc.php was done but var $keyforclass or $keyforclassfile or $keyforelement was not set');
exit;
}
if (empty($keyforalias)) {
diff --git a/htdocs/core/commonfieldsinimport.inc.php b/htdocs/core/commonfieldsinimport.inc.php
index 60716b8b109..cf41efc169d 100644
--- a/htdocs/core/commonfieldsinimport.inc.php
+++ b/htdocs/core/commonfieldsinimport.inc.php
@@ -2,7 +2,7 @@
if (empty($keyforclass) || empty($keyforclassfile) || empty($keyforelement)) {
//print $keyforclass.' - '.$keyforclassfile.' - '.$keyforelement;
- dol_print_error('', 'include of file commonfieldsinimport.inc.php was done but var $keyforclass or $keyforclassfile or $keyforelement was not set');
+ dol_print_error(null, 'include of file commonfieldsinimport.inc.php was done but var $keyforclass or $keyforclassfile or $keyforelement was not set');
exit;
}
if (empty($keyforalias)) {
diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php
index 99779e9ec5e..ce0b017cb25 100644
--- a/htdocs/core/datepicker.php
+++ b/htdocs/core/datepicker.php
@@ -128,7 +128,7 @@ if ($qualified) {
//print $_GET["cm"].",".$_GET["sd"].",".$_GET["m"].",".$_GET["y"];exit;
displayBox(GETPOST("sd", 'alpha'), GETPOST("m", 'int'), GETPOST("y", 'int'));
} else {
- dol_print_error('', 'ErrorBadParameters');
+ dol_print_error(null, 'ErrorBadParameters');
}
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index 7d28007ec81..d20d91462e6 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -2,6 +2,7 @@
/*
* Copyright (C) 2013-2015 Raphaël Doursenaud
* Copyright (C) 2014-2015 Laurent Destailleur
+ * Copyright (C) 2024 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
@@ -29,6 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/db/Database.interface.php';
*/
abstract class DoliDB implements Database
{
+ /** Force subclass to implement VERSIONMIN*/
+ const VERSIONMIN = self::VERSIONMIN;
+
/** @var bool|resource|mysqli|SQLite3|PgSql\Connection Database handler */
public $db;
/** @var string Database type */
diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php
index fae891e07ec..f5e791e35fd 100644
--- a/htdocs/core/db/mysqli.class.php
+++ b/htdocs/core/db/mysqli.class.php
@@ -249,7 +249,7 @@ class DoliDBMysqli extends DoliDB
$tmp = false;
try {
if (!class_exists('mysqli')) {
- dol_print_error('', 'Driver mysqli for PHP not available');
+ dol_print_error(null, 'Driver mysqli for PHP not available');
}
if (strpos($host, 'ssl://') === 0) {
$tmp = new mysqliDoli($host, $login, $passwd, $name, $port);
@@ -1270,7 +1270,11 @@ class mysqliDoli extends mysqli
public function __construct($host, $user, $pass, $name, $port = 0, $socket = "")
{
$flags = 0;
- parent::init();
+ if (PHP_VERSION_ID >= 80100) {
+ parent::__construct();
+ } else {
+ parent::init();
+ }
if (strpos($host, 'ssl://') === 0) {
$host = substr($host, 6);
parent::options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, false);
diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php
index c454c743626..7f79181f808 100644
--- a/htdocs/core/extrafieldsinexport.inc.php
+++ b/htdocs/core/extrafieldsinexport.inc.php
@@ -6,7 +6,7 @@
if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) {
//print $keyforselet.' - '.$keyforelement.' - '.$keyforaliasextra;
- dol_print_error('', 'include of file extrafieldsinexport.inc.php was done but var $keyforselect or $keyforelement or $keyforaliasextra was not set');
+ dol_print_error(null, 'include of file extrafieldsinexport.inc.php was done but var $keyforselect or $keyforelement or $keyforaliasextra was not set');
exit;
}
diff --git a/htdocs/core/extrafieldsinimport.inc.php b/htdocs/core/extrafieldsinimport.inc.php
index 224a3c893b9..a97a9c3d17a 100644
--- a/htdocs/core/extrafieldsinimport.inc.php
+++ b/htdocs/core/extrafieldsinimport.inc.php
@@ -6,7 +6,7 @@
if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) {
//print $keyforselet.' - '.$keyforelement.' - '.$keyforaliasextra;
- dol_print_error('', 'include of file extrafieldsinimport.inc.php was done but var $keyforselect or $keyforelement or $keyforaliasextra was not set');
+ dol_print_error(null, 'include of file extrafieldsinimport.inc.php was done but var $keyforselect or $keyforelement or $keyforaliasextra was not set');
exit;
}
diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php
index f051990b13e..ec8c11e0e65 100644
--- a/htdocs/core/js/lib_foot.js.php
+++ b/htdocs/core/js/lib_foot.js.php
@@ -119,7 +119,7 @@ if (empty($conf->dol_no_mouse_hover)) {
}, opendelay));
});
target.on("mouseout", function(event) {
- console.log("mouse out");
+ console.log("mouse out of a .classforajaxtooltip");
event.stopImmediatePropagation();
clearTimeout(elemtostoretooltiptimer.data("openTimeoutId"));
target.tooltip("close");
diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php
index b8d700ffb93..7b8cc48305e 100644
--- a/htdocs/core/lib/accounting.lib.php
+++ b/htdocs/core/lib/accounting.lib.php
@@ -3,7 +3,7 @@
* Copyright (C) 2013-2021 Alexandre Spangaro
* Copyright (C) 2014 Florian Henry
* Copyright (C) 2019 Eric Seigne
- * Copyright (C) 2021 Frédéric France
+ * Copyright (C) 2021-2024 Frédéric France
*
* 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
@@ -31,8 +31,8 @@
*
* @author Michael - https://www.php.net/manual/fr/function.empty.php#90767
* @param mixed $var Value to test
- * @param int|null $allow_false Setting this to true will make the function consider a boolean value of false as NOT empty. This parameter is false by default.
- * @param int|null $allow_ws Setting this to true will make the function consider a string with nothing but white space as NOT empty. This parameter is false by default.
+ * @param boolean $allow_false Setting this to true will make the function consider a boolean value of false as NOT empty. This parameter is false by default.
+ * @param boolean $allow_ws Setting this to true will make the function consider a string with nothing but white space as NOT empty. This parameter is false by default.
* @return boolean True of False
*/
function is_empty($var, $allow_false = false, $allow_ws = false)
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index 3afbc7bd247..24d69b93348 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -565,7 +565,7 @@ function dolibarr_del_const($db, $name, $entity = 1)
global $conf;
if (empty($name)) {
- dol_print_error('', 'Error call dolibar_del_const with parameter name empty');
+ dol_print_error(null, 'Error call dolibar_del_const with parameter name empty');
return -1;
}
@@ -1379,9 +1379,8 @@ function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tab
// phpcs:disable
// Complete the arrays &$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond
- // Note: "diction"."naries" to prevent codespell from detecting a spelling error.
- if (empty($objMod->dictionaries) && !empty($objMod->{"dicton"."naries"})) {
- $objMod->dictionaries = $objMod->{"diction"."naries"}; // For backward compatibility
+ if (empty($objMod->dictionaries) && !empty($objMod->{"dictionnaries"})) {
+ $objMod->dictionaries = $objMod->{"dictionnaries"}; // For backward compatibility
}
// phpcs:enable
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index bd33a0d2007..aeffdb434df 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -71,6 +71,7 @@ function societe_prepare_head(Societe $object)
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " WHERE p.fk_soc = ".((int) $object->id);
+ $sql .= " AND entity IN (".getEntity($object->element).")";
// Add where from hooks
$parameters = array('contacttab' => true);
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
@@ -1621,7 +1622,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
// Check parameters
if (!is_object($filterobj) && !is_object($objcon)) {
- dol_print_error('', 'BadParameter');
+ dol_print_error(null, 'BadParameter');
}
$out = '';
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index aa99d09dfe6..6ef05ecb79b 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -102,7 +102,7 @@ function getServerTimeZoneInt($refgmtdate = 'now')
//print $refgmtdate.'='.$tmp;
} else {
$tmp = 0;
- dol_print_error('', 'PHP version must be 5.3+');
+ dol_print_error(null, 'PHP version must be 5.3+');
}
$tz = round(($tmp < 0 ? 1 : -1) * abs($tmp / 3600));
return $tz;
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index cc48b80acc7..c842276835d 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -3264,7 +3264,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
if (preg_match('/^([a-z]+)_user_temp$/i', $modulepart, $reg)) {
$tmpmodule = $reg[1];
if (empty($conf->$tmpmodule->dir_temp)) { // modulepart not supported
- dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
+ dol_print_error(null, 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
exit;
}
if ($fuser->hasRight($tmpmodule, $lire) || $fuser->hasRight($tmpmodule, $read) || $fuser->hasRight($tmpmodule, $download)) {
@@ -3274,7 +3274,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
} elseif (preg_match('/^([a-z]+)_temp$/i', $modulepart, $reg)) {
$tmpmodule = $reg[1];
if (empty($conf->$tmpmodule->dir_temp)) { // modulepart not supported
- dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
+ dol_print_error(null, 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
exit;
}
if ($fuser->hasRight($tmpmodule, $lire) || $fuser->hasRight($tmpmodule, $read) || $fuser->hasRight($tmpmodule, $download)) {
@@ -3284,7 +3284,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
} elseif (preg_match('/^([a-z]+)_user$/i', $modulepart, $reg)) {
$tmpmodule = $reg[1];
if (empty($conf->$tmpmodule->dir_output)) { // modulepart not supported
- dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
+ dol_print_error(null, 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
exit;
}
if ($fuser->hasRight($tmpmodule, $lire) || $fuser->hasRight($tmpmodule, $read) || $fuser->hasRight($tmpmodule, $download)) {
@@ -3294,7 +3294,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
} elseif (preg_match('/^massfilesarea_([a-z]+)$/i', $modulepart, $reg)) {
$tmpmodule = $reg[1];
if (empty($conf->$tmpmodule->dir_output)) { // modulepart not supported
- dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
+ dol_print_error(null, 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
exit;
}
if ($fuser->hasRight($tmpmodule, $lire) || preg_match('/^specimen/i', $original_file)) {
@@ -3303,7 +3303,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$original_file = $conf->$tmpmodule->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
} else {
if (empty($conf->$modulepart->dir_output)) { // modulepart not supported
- dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.'). The module for this modulepart value may not be activated.');
+ dol_print_error(null, 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.'). The module for this modulepart value may not be activated.');
exit;
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 3282d916745..65693dae709 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -234,6 +234,25 @@ function isModEnabled($module)
//return !empty($conf->$module->enabled);
}
+/**
+ * isDolTms check if a timestamp is valid.
+ *
+ * @param int|string|null $timestamp timestamp to check
+ * @return bool
+ */
+function isDolTms($timestamp)
+{
+ if ($timestamp === '') {
+ dol_syslog('Using empty string for a timestamp is deprecated, prefer use of null when calling page '.$_SERVER["PHP_SELF"], LOG_NOTICE);
+ return false;
+ }
+ if (is_null($timestamp) || !is_numeric($timestamp)) {
+ return false;
+ }
+
+ return true;
+}
+
/**
* Return a DoliDB instance (database handler).
*
@@ -927,13 +946,13 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
}
/**
- * Return value of a param into GET or POST supervariable.
+ * Return the value of a $_GET or $_POST supervariable, converted into integer.
* Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder']
* Note: The property $user->default_values is loaded by main.php when loading the user.
*
- * @param string $paramname Name of parameter to found
- * @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get)
- * @return int Value found (int)
+ * @param string $paramname Name of the $_GET or $_POST parameter
+ * @param int $method Type of method (0 = $_GET then $_POST, 1 = only $_GET, 2 = only $_POST, 3 = $_POST then $_GET)
+ * @return int Value converted into integer
*/
function GETPOSTINT($paramname, $method = 0)
{
@@ -941,6 +960,20 @@ function GETPOSTINT($paramname, $method = 0)
}
+/**
+ * Return the value of a $_GET or $_POST supervariable, converted into float.
+ *
+ * @param string $paramname Name of the $_GET or $_POST parameter
+ * @param string|int $rounding Type of rounding ('', 'MU', 'MT, 'MS', 'CU', 'CT', integer) {@see price2num()}
+ * @return float Value converted into float
+ */
+function GETPOSTFLOAT($paramname, $rounding = '')
+{
+ // price2num() is used to sanitize any valid user input (such as "1 234.5", "1 234,5", "1'234,5", "1·234,5", "1,234.5", etc.)
+ return (float) price2num(GETPOST($paramname), $rounding, 2);
+}
+
+
/**
* Return a sanitized or empty value after checking value against a rule.
*
@@ -1072,7 +1105,8 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
}
break;
default:
- dol_syslog("Error, you call sanitizeVal() with a bad value for the check type. Data can't be sanitized.", LOG_ERR);
+ dol_syslog("Error, you call sanitizeVal() with a bad value for the check type. Data will be sanitized with alphanohtml.", LOG_ERR);
+ $out = GETPOST($out, 'alphanohtml');
break;
}
@@ -1352,6 +1386,7 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1)
return $tmp;
}
+
/**
* Clean a string to use it as a path name. Similare to dol_sanitizeFileName but accept / and \ chars.
* Replace also '--' and ' -' strings, they are used for parameters separation (Note: ' - ' is allowed).
@@ -2686,7 +2721,7 @@ function dol_bc($var, $moreclass = '')
* @return string Formatted string
* @see dol_print_address()
*/
-function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = '', $mode = 0, $extralangcode = '')
+function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = null, $mode = 0, $extralangcode = '')
{
global $conf, $langs, $hookmanager;
@@ -2775,15 +2810,15 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
*
* @param string $fmt Format of strftime function (http://php.net/manual/fr/function.strftime.php)
* @param int $ts Timestamp (If is_gmt is true, timestamp is already includes timezone and daylight saving offset, if is_gmt is false, timestamp is a GMT timestamp and we must compensate with server PHP TZ)
- * @param int $is_gmt See comment of timestamp parameter
+ * @param bool $is_gmt See comment of timestamp parameter
* @return string A formatted string
*/
function dol_strftime($fmt, $ts = false, $is_gmt = false)
{
if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
- return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
+ return dol_print_date($ts, $fmt, $is_gmt);
} else {
- return 'Error date into a not supported range';
+ return 'Error date outside supported range';
}
}
@@ -2798,7 +2833,7 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false)
* "%d/%m/%Y %H:%M:%S",
* "%B"=Long text of month, "%A"=Long text of day, "%b"=Short text of month, "%a"=Short text of day
* "day", "daytext", "dayhour", "dayhourldap", "dayhourtext", "dayrfc", "dayhourrfc", "...inputnoreduce", "...reduceformat"
- * @param string $tzoutput true or 'gmt' => string is for Greenwich location
+ * @param string|bool $tzoutput true or 'gmt' => string is for Greenwich location
* false or 'tzserver' => output string is for local PHP server TZ usage
* 'tzuser' => output string is for user TZ (current browser TZ with current dst) => In a future, we should have same behaviour than 'tzuserrel'
* 'tzuserrel' => output string is for user TZ (current browser TZ with dst or not, depending on date position)
@@ -2808,7 +2843,7 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false)
*
* @see dol_mktime(), dol_stringtotime(), dol_getdate(), selectDate()
*/
-function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = '', $encodetooutput = false)
+function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = null, $encodetooutput = false)
{
global $conf, $langs;
@@ -2926,7 +2961,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
// Analyze date
$reg = array();
if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) { // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000
- dol_print_error('', "Functions.lib::dol_print_date function called with a bad value from page ".(empty($_SERVER["PHP_SELF"]) ? 'unknown' : $_SERVER["PHP_SELF"]));
+ dol_print_error(null, "Functions.lib::dol_print_date function called with a bad value from page ".(empty($_SERVER["PHP_SELF"]) ? 'unknown' : $_SERVER["PHP_SELF"]));
return '';
} elseif (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) { // Still available to solve problems in extrafields of type date
// This part of code should not be used anymore.
@@ -4002,7 +4037,7 @@ function dol_user_country()
*
* @param string $address Address string, already formatted with dol_format_address()
* @param int $htmlid Html ID (for example 'gmap')
- * @param int $element 'thirdparty'|'contact'|'member'|'other'
+ * @param int $element 'thirdparty'|'contact'|'member'|'user'|'other'
* @param int $id Id of object
* @param int $noprint No output. Result is the function return
* @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br.
@@ -4039,6 +4074,9 @@ function dol_print_address($address, $htmlid, $element, $id, $noprint = 0, $char
if ($element == 'member' && isModEnabled('google') && getDolGlobalString('GOOGLE_ENABLE_GMAPS_MEMBERS')) {
$showgmap = 1;
}
+ if ($element == 'user' && isModEnabled('google') && getDolGlobalString('GOOGLE_ENABLE_GMAPS_USERS')) {
+ $showgmap = 1;
+ }
if (($element == 'thirdparty' || $element == 'societe') && isModEnabled('openstreetmap') && getDolGlobalString('OPENSTREETMAP_ENABLE_MAPS')) {
$showomap = 1;
}
@@ -4048,6 +4086,9 @@ function dol_print_address($address, $htmlid, $element, $id, $noprint = 0, $char
if ($element == 'member' && isModEnabled('openstreetmap') && getDolGlobalString('OPENSTREETMAP_ENABLE_MAPS_MEMBERS')) {
$showomap = 1;
}
+ if ($element == 'user' && isModEnabled('openstreetmap') && getDolGlobalString('OPENSTREETMAP_ENABLE_MAPS_USERS')) {
+ $showomap = 1;
+ }
if ($showgmap) {
$url = dol_buildpath('/google/gmaps.php?mode='.$element.'&id='.$id, 1);
$out .= ' ';
@@ -5326,13 +5367,13 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss
* This function must be called when a blocking technical error is encountered.
* However, one must try to call it only within php pages, classes must return their error through their property "error".
*
- * @param DoliDB|string $db Database handler
+ * @param DoliDB|null $db Database handler
* @param string|string[] $error String or array of errors strings to show
- * @param array $errors Array of errors
+ * @param string[]|null $errors Array of errors
* @return void
* @see dol_htmloutput_errors()
*/
-function dol_print_error($db = '', $error = '', $errors = null)
+function dol_print_error($db = null, $error = '', $errors = null)
{
global $conf, $langs, $argv;
global $dolibarr_main_prod;
@@ -5833,11 +5874,11 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
if ($cpt >= 1) {
if (empty($pagenavastextinput)) {
- $pagelist .= '';
+ $pagelist .= '';
if ($cpt > 2) {
$pagelist .= '';
} elseif ($cpt == 2) {
- $pagelist .= '';
+ $pagelist .= '';
}
}
}
@@ -5852,7 +5893,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
if ($cpt == $page) {
$pagelist .= '';
} else {
- $pagelist .= '';
+ $pagelist .= '';
}
}
$cpt++;
@@ -5863,13 +5904,13 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
if ($cpt < $nbpages - 2) {
$pagelist .= '';
} elseif ($cpt == $nbpages - 2) {
- $pagelist .= '';
+ $pagelist .= '';
}
- $pagelist .= '';
+ $pagelist .= '';
}
} else {
//var_dump($page.' '.$cpt.' '.$nbpages);
- $pagelist .= '';
+ $pagelist .= '';
}
} else {
$pagelist .= '";
@@ -5975,7 +6016,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
print '';
}
if ($page > 0) {
- print '';
+ print '';
}
if ($betweenarrows) {
print '';
@@ -5983,7 +6024,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
print '';
}
if ($nextpage > 0) {
- print '';
+ print '';
}
if ($afterarrows) {
print ' |