diff --git a/dev/tools/phan/PHAN.BAT b/dev/tools/phan/PHAN.BAT new file mode 100644 index 00000000000..930dc30595d --- /dev/null +++ b/dev/tools/phan/PHAN.BAT @@ -0,0 +1,46 @@ +@ECHO OFF +REM Usage (use from root of project): +REM - Standard checks: +REM PHAN.BAT +REM - Extended checks: +REM PHAN.BAT extended +REM - Use fixer configuration: +REM PHAN.BAT fix +REM +REM Standard phan options can be added on the command line. + +set MEMOPT=--memory-limit=4G +set CONFIG=--config-file +set CONFIG_FILE=dev/tools/phan/config.php +set FIX= +set USERARGS= +SET TWICE=--analyze-twice + +rem Iterate through each argument +for %%i in (%*) do ( + if "%%i"=="--memory-limit" ( + set MEMOPT="" + ) + if "%%i"=="extended" ( + set CONFIG="--config-file" + set CONFIG_FILE=dev/tools/phan/config_extended.php + goto :nextloop + ) + if "%%i"=="fix" ( + set FIX="--automatic-fix" + set CONFIG="--config-file" + set CONFIG_FILE=dev/tools/phan/config_fixer.php + set TWICE= + goto :nextloop + ) + if "%%i"=="--config-file" ( + set CONFIG= + set CONFIG_FILE= + ) + set "USERARGS=%USERARGS% %%i" + + :nextloop + REM NEXTLOOP +) + +../phan/vendor/bin/phan.bat %TWICE% %MEMOPT% %FIX% %CONFIG% %CONFIG_FILE% %USERARGS% diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index b5ac3bfafd8..2031e32501c 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -184,6 +184,7 @@ $VALID_MODULE_MAPPING = array( ); $moduleNameRegex = '/^(?:'.implode('|', array_merge(array_keys($DEPRECATED_MODULE_MAPPING), array_keys($VALID_MODULE_MAPPING), array('\$modulename'))).')$/'; +$deprecatedModuleNameRegex = '/^(?!(?:'.implode('|', array_keys($DEPRECATED_MODULE_MAPPING)).')$).*/'; /** * This configuration will be read and overlaid on top of the @@ -266,12 +267,15 @@ return [ // with the plugin's implementation (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php') 'ParamMatchRegexPlugin' => [ '/^GETPOST$/' => [1, $sanitizeRegex], - '/^isModEnabled$/' => [0, $moduleNameRegex], + '/^isModEnabled$/' => [0, $moduleNameRegex, 'UnknownModuleName'], + // Note: trick to have different key for same regex: + '/^isModEnable[d]$/' => [0, $deprecatedModuleNameRegex, "DeprecatedModuleName"], '/^sanitizeVal$/' => [1, $sanitizeRegex], ], 'plugins' => [ __DIR__.'/plugins/NoVarDumpPlugin.php', __DIR__.'/plugins/ParamMatchRegexPlugin.php', + __DIR__.'/plugins/GetPostFixerPlugin.php', // Only detects without --automatic-fix // checks if a function, closure or method unconditionally returns. // can also be written as 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php' //'DeprecateAliasPlugin', diff --git a/dev/tools/phan/config_extended.php b/dev/tools/phan/config_extended.php index 3b46fa7a49d..c6dbc07a314 100644 --- a/dev/tools/phan/config_extended.php +++ b/dev/tools/phan/config_extended.php @@ -185,6 +185,8 @@ $VALID_MODULE_MAPPING = array( $moduleNameRegex = '/^(?:'.implode('|', array_merge(array_keys($DEPRECATED_MODULE_MAPPING), array_keys($VALID_MODULE_MAPPING))).')$/'; +$deprecatedModuleNameRegex = '/^(?!(?:'.implode('|', array_keys($DEPRECATED_MODULE_MAPPING)).')$).*/'; + /** * This configuration will be read and overlaid on top of the * default configuration. Command line arguments will be applied @@ -265,12 +267,15 @@ return [ // with the plugin's implementation (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php') 'ParamMatchRegexPlugin' => [ '/^GETPOST$/' => [1, $sanitizeRegex], - '/^isModEnabled$/' => [0, $moduleNameRegex], + '/^isModEnabled$/' => [0, $moduleNameRegex, 'UnknownModuleName'], + // Note: trick to have different key for same regex: + '/^isModEnable[d]$/' => [0, $deprecatedModuleNameRegex, "DeprecatedModuleName"], '/^sanitizeVal$/' => [1, $sanitizeRegex], ], 'plugins' => [ __DIR__.'/plugins/NoVarDumpPlugin.php', __DIR__.'/plugins/ParamMatchRegexPlugin.php', + __DIR__.'/plugins/GetPostFixerPlugin.php', // Only detects without --automatic-fix 'DeprecateAliasPlugin', //'EmptyMethodAndFunctionPlugin', 'InvalidVariableIssetPlugin', diff --git a/dev/tools/phan/config_fixer.php b/dev/tools/phan/config_fixer.php index 841495e2a53..04ae1d7207c 100644 --- a/dev/tools/phan/config_fixer.php +++ b/dev/tools/phan/config_fixer.php @@ -1,4 +1,7 @@ */ define('DOL_PROJECT_ROOT', __DIR__.'/../../..'); diff --git a/dev/tools/phan/plugins/GetPostFixerPlugin/fixers.php b/dev/tools/phan/plugins/GetPostFixerPlugin/fixers.php index 662a553eb62..a20c92a448e 100644 --- a/dev/tools/phan/plugins/GetPostFixerPlugin/fixers.php +++ b/dev/tools/phan/plugins/GetPostFixerPlugin/fixers.php @@ -46,7 +46,7 @@ call_user_func(static function (): void { continue; } $arguments = $node->children; - if (count($arguments) != 3) { + if (!in_array(count($arguments), [3, 5])) { // ',' included ! print "Arg Count is ".count($arguments)." - Skip $instance".PHP_EOL; continue; } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 4eb7fa3ad6b..5c3a365d883 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -9,6 +9,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2019 Ferran Marcet + * 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 @@ -145,13 +146,13 @@ if ($reshook < 0) { $TRemindTypes = array(); if (getDolGlobalString('AGENDA_REMINDER_BROWSER')) { - $TRemindTypes['browser'] = array('label'=>$langs->trans('BrowserPush'), 'disabled'=>(!getDolGlobalString('AGENDA_REMINDER_BROWSER') ? 1 : 0)); + $TRemindTypes['browser'] = array('label' => $langs->trans('BrowserPush'), 'disabled' => (!getDolGlobalString('AGENDA_REMINDER_BROWSER') ? 1 : 0)); } if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) { - $TRemindTypes['email'] = array('label'=>$langs->trans('EMail'), 'disabled'=>(!getDolGlobalString('AGENDA_REMINDER_EMAIL') ? 1 : 0)); + $TRemindTypes['email'] = array('label' => $langs->trans('EMail'), 'disabled' => (!getDolGlobalString('AGENDA_REMINDER_EMAIL') ? 1 : 0)); } -$TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes')); +$TDurationTypes = array('y' => $langs->trans('Years'), 'm' => $langs->trans('Month'), 'w' => $langs->trans('Weeks'), 'd' => $langs->trans('Days'), 'h' => $langs->trans('Hours'), 'i' => $langs->trans('Minutes')); $result = restrictedArea($user, 'agenda', $object, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); @@ -229,7 +230,7 @@ if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedt if (!empty($_SESSION['assignedtouser'])) { $assignedtouser = json_decode($_SESSION['assignedtouser'], true); } - $assignedtouser[GETPOST('assignedtouser')] = array('id'=>GETPOSTINT('assignedtouser'), 'transparency'=>GETPOST('transparency'), 'mandatory'=>1); + $assignedtouser[GETPOST('assignedtouser')] = array('id' => GETPOSTINT('assignedtouser'), 'transparency' => GETPOST('transparency'), 'mandatory' => 1); $_SESSION['assignedtouser'] = json_encode($assignedtouser); } $donotclearsession = 1; @@ -251,7 +252,7 @@ if (empty($reshook) && (GETPOST('addassignedtoresource') || GETPOST('updateassig if (!empty($_SESSION['assignedtoresource'])) { $assignedtoresource = json_decode($_SESSION['assignedtoresource'], true); } - $assignedtoresource[GETPOST('assignedtoresource')] = array('id'=>GETPOSTINT('assignedtoresource'), 'transparency'=>GETPOST('transparency'), 'mandatory'=>1); + $assignedtoresource[GETPOST('assignedtoresource')] = array('id' => GETPOSTINT('assignedtoresource'), 'transparency' => GETPOST('transparency'), 'mandatory' => 1); $_SESSION['assignedtoresource'] = json_encode($assignedtoresource); } $donotclearsession = 1; @@ -419,7 +420,7 @@ if (empty($reshook) && $action == 'add') { $object->transparency = $transparency; } - $object->userassigned[$value['id']] = array('id'=>$value['id'], 'transparency'=>$transparency); + $object->userassigned[$value['id']] = array('id' => $value['id'], 'transparency' => $transparency); $i++; } @@ -476,7 +477,8 @@ if (empty($reshook) && $action == 'add') { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error++; $donotclearsession = 1; + $error++; + $donotclearsession = 1; $action = 'create'; } @@ -857,7 +859,7 @@ if (empty($reshook) && $action == 'update') { } else { $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0); if ($assignedtouser) { - $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first + $listofuserid[$assignedtouser] = array('id' => $assignedtouser, 'mandatory' => 0, 'transparency' => ($user->id == $assignedtouser ? $transparency : '')); // Owner first } } $object->userassigned = array(); @@ -867,7 +869,7 @@ if (empty($reshook) && $action == 'update') { if ($i == 0) { $object->userownerid = $val['id']; } - $object->userassigned[$val['id']] = array('id'=>$val['id'], 'mandatory'=>0, 'transparency'=>($user->id == $val['id'] ? $transparency : '')); + $object->userassigned[$val['id']] = array('id' => $val['id'], 'mandatory' => 0, 'transparency' => ($user->id == $val['id'] ? $transparency : '')); $i++; } @@ -1180,9 +1182,9 @@ $form = new Form($db); $formproject = new FormProjets($db); $arrayrecurrulefreq = array( - 'no'=>$langs->trans("OnceOnly"), - 'MONTHLY'=>$langs->trans("EveryMonth"), - 'WEEKLY'=>$langs->trans("EveryWeek") + 'no' => $langs->trans("OnceOnly"), + 'MONTHLY' => $langs->trans("EveryMonth"), + 'WEEKLY' => $langs->trans("EveryWeek") // 'DAILY'=>$langs->trans("EveryDay") ); @@ -1386,12 +1388,12 @@ if ($action == 'create') { print ''; $datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep)); - if (GETPOST('datep', 'int', 1)) { - $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuserrel'); + if (GETPOSTINT('datep', 1)) { + $datep = dol_stringtotime(GETPOSTINT('datep', 1), 'tzuserrel'); } $datef = ($datef ? $datef : $object->datef); - if (GETPOST('datef', 'int', 1)) { - $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuserrel'); + if (GETPOSTINT('datef', 1)) { + $datef = dol_stringtotime(GETPOSTINT('datef', 1), 'tzuserrel'); } if (empty($datef) && !empty($datep)) { if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || !getDolGlobalString('AGENDA_USE_EVENT_TYPE_DEFAULT')) { @@ -1426,7 +1428,7 @@ if ($action == 'create') { if (empty($donotclearsession)) { $assignedtouser = GETPOST("assignedtouser") ? GETPOST("assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id); if ($assignedtouser) { - $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0); // Owner first + $listofuserid[$assignedtouser] = array('id' => $assignedtouser, 'mandatory' => 0); // Owner first } //$listofuserid[$user->id] = array('id'=>$user->id, 'mandatory'=>0, 'transparency'=>(GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1)); // 1 by default at first init $listofuserid[$assignedtouser]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1); // 1 by default at first init @@ -1473,7 +1475,7 @@ if ($action == 'create') { if (empty($donotclearsession)) { $assignedtoresource = GETPOST("assignedtoresource"); if ($assignedtoresource) { - $listofresourceid[$assignedtoresource] = array('id'=>$assignedtoresource, 'mandatory'=>0); // Owner first + $listofresourceid[$assignedtoresource] = array('id' => $assignedtoresource, 'mandatory' => 0); // Owner first } $_SESSION['assignedtoresource'] = json_encode($listofresourceid); } else { @@ -1494,7 +1496,7 @@ if ($action == 'create') { // Status print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; print ''; - $percent = $complete !=='' ? $complete : -1; + $percent = $complete !== '' ? $complete : -1; if (GETPOSTISSET('status')) { $percent = GETPOST('status'); } elseif (GETPOSTISSET('percentage')) { @@ -1543,7 +1545,7 @@ if ($action == 'create') { if (GETPOSTINT('contactid')) { $preselectedids[GETPOSTINT('contactid')] = GETPOSTINT('contactid'); } - if ($origin=='contact') { + if ($origin == 'contact') { $preselectedids[GETPOSTINT('originid')] = GETPOSTINT('originid'); } // select "all" or "none" contact by default @@ -1970,12 +1972,12 @@ if ($id > 0) { if (empty($donotclearsession)) { if ($object->userownerid > 0) { $listofuserid[$object->userownerid] = array( - 'id'=>$object->userownerid, - 'type'=>'user', + 'id' => $object->userownerid, + 'type' => 'user', //'transparency'=>$object->userassigned[$user->id]['transparency'], - 'transparency'=>$object->transparency, // Force transparency on ownerfrom event - 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], - 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] + 'transparency' => $object->transparency, // Force transparency on ownerfrom event + 'answer_status' => $object->userassigned[$object->userownerid]['answer_status'], + 'mandatory' => $object->userassigned[$object->userownerid]['mandatory'] ); } if (!empty($object->userassigned)) { // Now concat assigned users @@ -2253,9 +2255,9 @@ if ($id > 0) { $parameters = array(); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - $formconfirm.=$hookmanager->resPrint; + $formconfirm .= $hookmanager->resPrint; } elseif ($reshook > 0) { - $formconfirm=$hookmanager->resPrint; + $formconfirm = $hookmanager->resPrint; } // Print form confirm @@ -2403,10 +2405,10 @@ if ($id > 0) { if (empty($donotclearsession)) { if ($object->userownerid > 0) { $listofuserid[$object->userownerid] = array( - 'id'=>$object->userownerid, - 'transparency'=>$object->transparency, // Force transparency on owner from property of event - 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], - 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] + 'id' => $object->userownerid, + 'transparency' => $object->transparency, // Force transparency on owner from property of event + 'answer_status' => $object->userassigned[$object->userownerid]['answer_status'], + 'mandatory' => $object->userassigned[$object->userownerid]['mandatory'] ); } if (!empty($object->userassigned)) { // Now concat assigned users diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 338887acab2..a2b18358c1d 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Open-DSI * Copyright (C) 2018-2021 Frédéric France + * 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 @@ -55,10 +56,10 @@ $disabledefaultvalues = GETPOSTINT('disabledefaultvalues'); $check_holiday = GETPOSTINT('check_holiday'); $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); -$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); +$filtert = GETPOSTINT("search_filtert", 3) ? GETPOSTINT("search_filtert", 3) : GETPOSTINT("filtert", 3); +$usergroup = GETPOSTINT("search_usergroup", 3) ? GETPOSTINT("search_usergroup", 3) : GETPOSTINT("usergroup", 3); $showbirthday = empty($conf->use_javascript_ajax) ? GETPOSTINT("showbirthday") : 1; -$search_categ_cus = GETPOST("search_categ_cus", "int", 3) ? GETPOST("search_categ_cus", "int", 3) : 0; +$search_categ_cus = GETPOSTINT("search_categ_cus", 3) ? GETPOSTINT("search_categ_cus", 3) : 0; // If not choice done on calendar owner (like on left menu link "Agenda"), we filter on user. if (empty($filtert) && !getDolGlobalString('AGENDA_ALL_CALENDARS')) { @@ -113,7 +114,7 @@ $year = GETPOSTINT("year") ? GETPOSTINT("year") : date("Y"); $month = GETPOSTINT("month") ? GETPOSTINT("month") : date("m"); $week = GETPOSTINT("week") ? GETPOSTINT("week") : date("W"); $day = GETPOSTINT("day") ? GETPOSTINT("day") : date("d"); -$pid = GETPOST("search_projectid", "int", 3) ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); +$pid = GETPOSTINT("search_projectid", 3) ? GETPOSTINT("search_projectid", 3) : GETPOSTINT("projectid", 3); $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo', 'na' or -1 $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09'); $maxprint = GETPOSTISSET("maxprint") ? GETPOSTINT("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW; @@ -523,7 +524,8 @@ $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', ' $viewmode .= ''.$langs->trans("ViewPerUser").''; // Add more views from hooks -$parameters = array(); $object = null; +$parameters = array(); +$object = null; $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); if (empty($reshook)) { $viewmode .= $hookmanager->resPrint; @@ -550,7 +552,8 @@ if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda' } // Define the legend/list of calendard to show -$s = ''; $link = ''; +$s = ''; +$link = ''; $showextcals = $listofextcals; $bookcalcalendars = array(); @@ -1455,7 +1458,8 @@ if (count($listofextcals)) { // Complete $eventarray with events coming from external module -$parameters = array(); $object = null; +$parameters = array(); +$object = null; $reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action); if (!empty($hookmanager->resArray['eventarray'])) { foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { @@ -1486,7 +1490,7 @@ if (!is_array($theme_datacolor)) { $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); } -$massactionbutton =''; +$massactionbutton = ''; print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); @@ -1520,7 +1524,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month print ' '; $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7); if (!empty($conf->dol_optimize_smallscreen)) { - $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin'); + $labelshort = array(0 => 'SundayMin', 1 => 'MondayMin', 2 => 'TuesdayMin', 3 => 'WednesdayMin', 4 => 'ThursdayMin', 5 => 'FridayMin', 6 => 'SaturdayMin'); print $langs->trans($labelshort[$numdayinweek]); } else { print $langs->trans("Day".$numdayinweek); diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 30a690b38cc..bb80ee84540 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -6,6 +6,7 @@ * Copyright (C) 2017 Open-DSI * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2020 Tobias Sekan + * 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 @@ -57,7 +58,7 @@ if (empty($mode) && preg_match('/show_/', $action)) { $mode = $action; // For backward compatibility } $resourceid = GETPOSTINT("search_resourceid") ? GETPOSTINT("search_resourceid") : GETPOSTINT("resourceid"); -$pid = GETPOST("search_projectid", 'int', 3) ? GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3); +$pid = GETPOSTINT("search_projectid", 3) ? GETPOSTINT("search_projectid", 3) : GETPOSTINT("projectid", 3); $search_status = (GETPOST("search_status", 'aZ09') != '') ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); $type = GETPOST('search_type', 'alphanohtml') ? GETPOST('search_type', 'alphanohtml') : GETPOST('type', 'alphanohtml'); $year = GETPOSTINT("year"); @@ -93,10 +94,10 @@ if (empty($mode) && !GETPOSTISSET('mode')) { } $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); -$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); +$filtert = GETPOSTINT("search_filtert", 3) ? GETPOSTINT("search_filtert", 3) : GETPOSTINT("filtert", 3); +$usergroup = GETPOSTINT("search_usergroup", 3) ? GETPOSTINT("search_usergroup", 3) : GETPOSTINT("usergroup", 3); $showbirthday = empty($conf->use_javascript_ajax) ? (GETPOSTINT("search_showbirthday") ? GETPOSTINT("search_showbirthday") : GETPOSTINT("showbirthday")) : 1; -$search_categ_cus = GETPOST("search_categ_cus", "int", 3) ? GETPOST("search_categ_cus", "int", 3) : 0; +$search_categ_cus = GETPOSTINT("search_categ_cus", 3) ? GETPOSTINT("search_categ_cus", 3) : 0; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new ActionComm($db); @@ -157,19 +158,19 @@ if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // } $arrayfields = array( - 'a.id'=>array('label'=>"Ref", 'checked'=>1), - 'owner'=>array('label'=>"Owner", 'checked'=>1), - 'c.libelle'=>array('label'=>"Type", 'checked'=>1), - 'a.label'=>array('label'=>"Title", 'checked'=>1), - 'a.note'=>array('label'=>'Description', 'checked'=>0), - 'a.datep'=>array('label'=>"DateStart", 'checked'=>1), - 'a.datep2'=>array('label'=>"DateEnd", 'checked'=>1), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), - 'a.fk_contact'=>array('label'=>"Contact", 'checked'=>0), - 'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>1, 'enabled'=>(getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT'))), - 'a.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>510), - 'a.tms'=>array('label'=>'DateModification', 'checked'=>0, 'position'=>520), - 'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) + 'a.id' => array('label' => "Ref", 'checked' => 1), + 'owner' => array('label' => "Owner", 'checked' => 1), + 'c.libelle' => array('label' => "Type", 'checked' => 1), + 'a.label' => array('label' => "Title", 'checked' => 1), + 'a.note' => array('label' => 'Description', 'checked' => 0), + 'a.datep' => array('label' => "DateStart", 'checked' => 1), + 'a.datep2' => array('label' => "DateEnd", 'checked' => 1), + 's.nom' => array('label' => "ThirdParty", 'checked' => 1), + 'a.fk_contact' => array('label' => "Contact", 'checked' => 0), + 'a.fk_element' => array('label' => "LinkedObject", 'checked' => 1, 'enabled' => (getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT'))), + 'a.datec' => array('label' => 'DateCreation', 'checked' => 0, 'position' => 510), + 'a.tms' => array('label' => 'DateModification', 'checked' => 0, 'position' => 520), + 'a.percent' => array('label' => "Status", 'checked' => 1, 'position' => 1000) ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -204,7 +205,7 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { exit; } -$parameters = array('id'=>$socid); +$parameters = array('id' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -814,7 +815,7 @@ if (!empty($arrayfields['a.fk_element']['checked'])) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -892,7 +893,7 @@ if (!empty($arrayfields['a.fk_element']['checked'])) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1196,7 +1197,7 @@ while ($i < $imaxinloop) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 83ac43bc4e2..a190a675b77 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -6,6 +6,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2018-2019 Frédéric France + * 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 @@ -49,8 +50,8 @@ $action = GETPOST('action', 'aZ09'); $disabledefaultvalues = GETPOSTINT('disabledefaultvalues'); $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); -$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); +$filtert = GETPOSTINT("search_filtert", 3) ? GETPOSTINT("search_filtert", 3) : GETPOSTINT("filtert", 3); +$usergroup = GETPOSTINT("search_usergroup", 3) ? GETPOSTINT("search_usergroup", 3) : GETPOSTINT("usergroup", 3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; // $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; @@ -105,7 +106,7 @@ $year = GETPOSTINT("year") ? GETPOSTINT("year") : date("Y"); $month = GETPOSTINT("month") ? GETPOSTINT("month") : date("m"); $week = GETPOSTINT("week") ? GETPOSTINT("week") : date("W"); $day = GETPOSTINT("day") ? GETPOSTINT("day") : date("d"); -$pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); +$pid = GETPOSTISSET("search_projectid") ? GETPOSTINT("search_projectid", 3) : GETPOSTINT("projectid", 3); $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOSTINT("maxprint") != '') ? GETPOSTINT("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); @@ -463,7 +464,8 @@ $viewmode .= ''; // Add more views from hooks -$parameters = array(); $object = null; +$parameters = array(); +$object = null; $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); if (empty($reshook)) { $viewmode .= $hookmanager->resPrint; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 2201fe9d360..035a4687ea1 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -7,6 +7,7 @@ * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2023 Florian HENRY + * 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 @@ -50,8 +51,8 @@ $action = GETPOST('action', 'aZ09'); $disabledefaultvalues = GETPOSTINT('disabledefaultvalues'); $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); -$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); +$filtert = GETPOSTINT("search_filtert", 3) ? GETPOSTINT("search_filtert", 3) : GETPOSTINT("filtert", 3); +$usergroup = GETPOSTINT("search_usergroup", 3) ? GETPOSTINT("search_usergroup", 3) : GETPOSTINT("usergroup", 3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; $showbirthday = 0; @@ -102,12 +103,12 @@ $year = GETPOSTINT("year") ? GETPOSTINT("year") : date("Y"); $month = GETPOSTINT("month") ? GETPOSTINT("month") : date("m"); $week = GETPOSTINT("week") ? GETPOSTINT("week") : date("W"); $day = GETPOSTINT("day") ? GETPOSTINT("day") : date("d"); -$pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); +$pid = GETPOSTISSET("search_projectid") ? GETPOSTINT("search_projectid", 3) : GETPOSTINT("projectid", 3); $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo', 'na' or -1 $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOSTINT("maxprint") != '') ? GETPOSTINT("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$search_categ_cus = GETPOST("search_categ_cus", "int", 3) ? GETPOST("search_categ_cus", "int", 3) : 0; +$search_categ_cus = GETPOSTINT("search_categ_cus", 3) ? GETPOSTINT("search_categ_cus", 3) : 0; // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array:aZ09')) { $actioncode = GETPOST('search_actioncode', 'array:aZ09', 3); @@ -466,7 +467,8 @@ $viewmode .= ''; // Add more views from hooks -$parameters = array(); $object = null; +$parameters = array(); +$object = null; $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); if (empty($reshook)) { $viewmode .= $hookmanager->resPrint; @@ -938,7 +940,7 @@ while ($currentdaytoshow < $lastdaytoshow) { if ($filtert > 0) { $sql .= " AND u.rowid = ".((int) $filtert); } - if ($usergroup > 0) { + if ($usergroup > 0) { $sql .= " AND ug.fk_usergroup = ".((int) $usergroup); } if ($user->socid > 0) { diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index c474b6ce2e1..5b27d9ccd39 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -9,6 +9,7 @@ * Copyright (C) 2016 Marcos García * Copyright (C) 2018 Frédéric France * Copyright (C) 2021 Gauthier VERDOL + * 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 @@ -362,7 +363,7 @@ if ($result) { print dol_get_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($bankline, 'rowid', $linkback); diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index e8fa7ab7165..c1e9d0e34d4 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -1,6 +1,7 @@ * Copyright (C) 2017 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 @@ -66,7 +67,7 @@ print '