From 2279fa5d2d293353fba4157bfd44af4eb3c4e8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 21 May 2024 17:06:26 +0200 Subject: [PATCH] clean code (#29713) * clean code * fix typo * fix --------- Co-authored-by: Laurent Destailleur --- htdocs/adherents/type.php | 5 +++-- htdocs/core/lib/date.lib.php | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 8e2e94aa82f..c8807066da6 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -9,6 +9,7 @@ * Copyright (C) 2020 Josep Lluís Amador * Copyright (C) 2021 Waël Almoman * Copyright (C) 2024 MDW + * Copyright (C) 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 @@ -176,7 +177,7 @@ if ($action == 'add' && $user->hasRight('adherent', 'configurer')) { if ($id > 0) { $backurlforlist = $_SERVER["PHP_SELF"]; - $urltogo = $backtopage ? str_replace('__ID__', $id, $backtopage) : $backurlforlist; + $urltogo = $backtopage ? str_replace('__ID__', (string) $id, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', (string) $object->id, $urltogo); // New method to autoselect field created after a New on another form object creation header("Location: " . $urltogo); @@ -271,7 +272,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $param = ''; if (!empty($mode)) { - $param .= '&mode'.urlencode($mode); + $param .= '&mode='.urlencode($mode); } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.$contextpage; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index b3d71145ab2..e5d3c95f218 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -1,11 +1,12 @@ - * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2011-2015 Juanjo Menent - * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018 Charlene Benke +/* Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2011-2015 Juanjo Menent + * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2018 Charlene Benke * Copyright (C) 2024 MDW -* + * Copyright (C) 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 * the Free Software Foundation; either version 3 of the License, or @@ -775,16 +776,16 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $country_code = $mysoc->country_code; } if ($includemonday < 0) { - $includemonday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY : 0); + $includemonday = getDolGlobalInt('MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY', 0); } if ($includefriday < 0) { - $includefriday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY : 0); + $includefriday = getDolGlobalInt('MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY', 0); } if ($includesaturday < 0) { - $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1); + $includesaturday = getDolGlobalInt('MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', 1); } if ($includesunday < 0) { - $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1); + $includesunday = getDolGlobalInt('MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', 1); } $country_id = dol_getIdFromCode($db, $country_code, 'c_country', 'code', 'rowid');