From 20786103288cf7d0daa3f578847579ad956ec9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 6 Oct 2025 18:17:02 +0200 Subject: [PATCH] add dolBuildUrl with examples of use (#35549) * add dol_buildurl with examples of use * add dol_buildurl with examples of use * add dol_buildurl with examples of use * add dol_buildurl with examples of use * wip * wip * add more example * add more example * add more example * add more example * add more example * add more example * add more example * add example * add example * add example * add example * add example * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * stay in the same area even we are on other area in other tab * clean code * clean code * clean code * clean code * clean code * clean code * clean code * add example * add example * add example * add example * add example * add example add example add example add example add example * add example * add example add example add example add example * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * fix * wip * wip * clean code --- htdocs/accountancy/admin/accountmodel.php | 27 +- htdocs/accountancy/admin/fiscalyear.php | 2 +- htdocs/adherents/card.php | 11 +- htdocs/adherents/class/adherent.class.php | 8 +- .../adherents/class/adherent_type.class.php | 6 +- htdocs/adherents/class/subscription.class.php | 8 +- htdocs/adherents/type.php | 35 +-- htdocs/ai/admin/setup.php | 6 +- htdocs/comm/propal/class/propal.class.php | 16 +- htdocs/commande/card.php | 6 +- htdocs/commande/class/commande.class.php | 9 +- htdocs/commande/note.php | 16 +- htdocs/contact/class/contact.class.php | 7 +- htdocs/contrat/card.php | 8 +- htdocs/contrat/class/contrat.class.php | 6 +- htdocs/core/lib/agenda.lib.php | 46 +-- htdocs/core/lib/asset.lib.php | 14 +- htdocs/core/lib/contact.lib.php | 18 +- htdocs/core/lib/contract.lib.php | 18 +- htdocs/core/lib/cron.lib.php | 18 +- htdocs/core/lib/functions.lib.php | 75 ++++- htdocs/core/lib/holiday.lib.php | 10 +- htdocs/core/lib/hrm.lib.php | 9 +- htdocs/core/lib/member.lib.php | 56 ++-- htdocs/core/lib/order.lib.php | 21 +- htdocs/core/lib/ticket.lib.php | 8 +- htdocs/core/lib/usergroups.lib.php | 52 ++-- htdocs/core/menus/standard/eldy.lib.php | 278 +++++++++--------- .../user/doc/doc_generic_user_odt.modules.php | 116 ++++---- .../class/emailcollector.class.php | 41 +-- htdocs/main.inc.php | 42 ++- .../template/class/myobject.class.php | 9 +- .../template/lib/mymodule.lib.php | 9 +- .../template/lib/mymodule_myobject.lib.php | 10 +- .../class/productfournisseurprice.class.php | 2 - .../class/recruitmentcandidature.class.php | 2 - htdocs/user/class/user.class.php | 9 +- htdocs/user/class/usergroup.class.php | 8 +- 38 files changed, 558 insertions(+), 484 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 3ef8a3873c7..a3fc3777c8a 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -329,7 +329,7 @@ print load_fiche_titre($titre, $linkback, 'title_accountancy'); // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.urlencode((string) ($page)).'&' : '').'sortfield='.urlencode((string) ($sortfield)).'&sortorder='.urlencode((string) ($sortorder)).'&rowid='.urlencode((string) ($rowid)).'&code='.urlencode((string) ($code)).'&id='.urlencode((string) ($id)), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm(dolBuildUrl($_SERVER["PHP_SELF"], ['page'=> $page, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'rowid' => $rowid, 'code' => $code, 'id' => $id]), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } @@ -577,19 +577,34 @@ if ($resql) { } } - $url = $_SERVER["PHP_SELF"].'?token='.newToken().($page ? '&page='.$page : '').'&sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ? urlencode($obj->code) : ''); - $url .= '&'.$param.'&'; + // $url = $_SERVER["PHP_SELF"].'?token='.newToken().($page ? '&page='.$page : '').'&sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ? urlencode($obj->code) : ''); + // $url .= '&'.$param.'&'; + + $query = []; + // decode and add param to query + parse_str($param, $query); + $query = array_merge($query, [ + 'action' => '', + 'page' => $page, + 'sortfield' => $sortfield, + 'sortorder' => $sortorder, + 'rowid' => (!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')), + 'code' => $obj->code, + ]); // Active print ''; - print ''.$actl[$obj->active].''; + $query['action'] = $acts[$obj->active]; + print ''.$actl[$obj->active].''; print ""; // Modify link - print ''.img_edit().''; + $query['action'] = 'edit'; + print ''.img_edit().''; // Delete link - print ''.img_delete().''; + $query['action'] = 'delete'; + print ''.img_delete().''; print "\n"; } diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 8eef6549850..5a0a2e4d778 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -202,7 +202,7 @@ if ($result) { if (getDolGlobalString('ACCOUNTANCY_FISCALYEAR_DEFAULT') == (int) $fiscalyearstatic->ref) { print img_picto($langs->trans("Default"), 'on'); } else { - print 'ref).'&label='.urlencode($fiscalyearstatic->label).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').''; + print ' 'setdefault', 'value' => $fiscalyearstatic->ref, 'label'=>$fiscalyearstatic->label], true).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').''; } print ''; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index f69788b0d17..f6a9ec4a95a 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1071,14 +1071,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("NoTypeDefinedGoToSetup").''; } if ($user->hasRight('member', 'configurer')) { - print ' '; + print ' 'create', 'typeid' => '--IDFORBACKTOPAGE--'])]).'">'; } print "\n"; - // Morphy - $morphys = array(); - $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Moral"); + // Legal entity or natural person + $morphys = [ + "phy" => $langs->trans("Physical"), + "mor" => $langs->trans("Moral"), + ]; $checkednature = GETPOST("morphy", 'alpha'); $listetype_natures = $adht->morphyByType(1); $listetype_natures_json = json_encode($listetype_natures); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ea06f221008..4d1a1404018 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2546,10 +2546,11 @@ class Adherent extends CommonObject $label = implode($this->getTooltipContentArray($params)); } - $url = DOL_URL_ROOT.'/adherents/card.php?rowid='.((int) $this->id); + $baseurl = DOL_URL_ROOT . '/adherents/card.php'; if ($option == 'subscription') { - $url = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.((int) $this->id); + $baseurl = DOL_URL_ROOT . '/adherents/subscription.php'; } + $query = ['rowid' => $this->id]; if ($option != 'nolink') { // Add param to save lastsearch_values or not @@ -2558,9 +2559,10 @@ class Adherent extends CommonObject $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } } + $url = dolBuildUrl($baseurl, $query); $linkstart .= 'getTooltipContentArray($params)); } - $url = DOL_URL_ROOT.'/adherents/type.php?rowid='.((int) $this->id); + $baseurl = DOL_URL_ROOT . '/adherents/type.php'; + $query = ['rowid' => $this->id]; // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } + $url = dolBuildUrl($baseurl, $query); $linkstart = 'datef)) { $label .= '
'.$langs->trans('DateEnd').': '.dol_print_date($this->datef, 'day'); } - - $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.((int) $this->id); - + $baseurl = DOL_URL_ROOT . '/adherents/subscription/card.php'; + $query = ['rowid' => $this->id]; if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); @@ -453,9 +452,10 @@ class Subscription extends CommonObject $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } } + $url = dolBuildUrl($baseurl, $query); $linkstart = '
'; $linkend = ''; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 6e35dc2a6c0..b7bad18911e 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -697,7 +697,7 @@ if ($rowid > 0) { // Edit if ($user->hasRight('adherent', 'configurer')) { - print '
'.$langs->trans("Modify").'
'; + print '
'.$langs->trans("Modify").'
'; } // Add @@ -710,14 +710,14 @@ if ($rowid > 0) { } if ($user->hasRight('adherent', 'configurer') && !empty($object->status)) { - print '
'.$langs->trans("AddMember").'
'; + print '
$object->id])], true).'">'.$langs->trans("AddMember").'
'; } else { print '
'.$langs->trans("AddMember").'
'; } // Delete if ($user->hasRight('adherent', 'configurer')) { - print '
'.$langs->trans("DeleteType").'
'; + print '
'.$langs->trans("DeleteType").'
'; } print ""; @@ -829,34 +829,35 @@ if ($rowid > 0) { $titre .= " (".$membertype->label.")"; } - $param = "&rowid=".urlencode((string) ($object->id)); + $query = ['rowid' => $object->id]; if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); + $query+= ['mode' => $mode]; } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); + $query += ['contextpage' => $contextpage]; } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); + $query += ['limit' => $limit]; } if (!empty($status)) { - $param .= "&status=".urlencode($status); + $query += ['status' => $status]; } if (!empty($search_ref)) { - $param .= "&search_ref=".urlencode($search_ref); + $query += ['search_ref' => $search_ref]; } if (!empty($search_lastname)) { - $param .= "&search_lastname=".urlencode($search_lastname); + $query += ['search_lastname' => $search_lastname]; } if (!empty($search_login)) { - $param .= "&search_login=".urlencode($search_login); + $query += ['search_login' => $search_login]; } if (!empty($search_email)) { - $param .= "&search_email=".urlencode($search_email); + $query += ['search_email' => $search_email]; } if (!empty($filter)) { - $param .= "&filter=".urlencode($filter); + $query += ['filter' => $filter]; } + $param = '&' . http_build_query($query); if ($sall) { print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; @@ -954,10 +955,10 @@ if ($rowid > 0) { if ($conf->main_checkbox_left_column) { print ''; if ($user->hasRight('adherent', 'creer')) { - print ''.img_edit().''; + print ' $object->id])], true).'">'.img_edit().''; } if ($user->hasRight('adherent', 'supprimer')) { - print ''.img_picto($langs->trans("Resiliate"), 'disable.png').''; + print ''.img_picto($langs->trans("Resiliate"), 'unlink').''; } print ""; } @@ -1022,10 +1023,10 @@ if ($rowid > 0) { if (!$conf->main_checkbox_left_column) { print ''; if ($user->hasRight('adherent', 'creer')) { - print ''.img_edit().''; + print ' $object->id])], true).'">'.img_edit().''; } if ($user->hasRight('adherent', 'supprimer')) { - print ''.img_picto($langs->trans("Resiliate"), 'disable.png').''; + print ''.img_picto($langs->trans("Resiliate"), 'unlink').''; } print ""; } diff --git a/htdocs/ai/admin/setup.php b/htdocs/ai/admin/setup.php index 95ab338352d..60e4347d82b 100644 --- a/htdocs/ai/admin/setup.php +++ b/htdocs/ai/admin/setup.php @@ -1,8 +1,8 @@ - * Copyright (C) 2022 Alice Adminson + * Copyright (C) 2022 Lamrani Abdel * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 Frédéric France * Coryright (C) 2024 Alexandre Spangaro * * This program is free software: you can redistribute it and/or modify @@ -134,7 +134,7 @@ $title = "AiSetup"; llxHeader('', $langs->trans($title), $help_url, '', 0, 0, '', '', '', 'mod-ai page-admin'); // Subheader -$linkback = ''.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').''.$langs->trans("BackToModuleList").''; +$linkback = ''.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($title), $linkback, 'title_setup'); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0d24b6cd3a7..05a6ed2c135 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3873,16 +3873,19 @@ class Propal extends CommonObject $label = implode($this->getTooltipContentArray($params)); } - $url = ''; + $baseurl = ''; + $query = []; if ($user->hasRight('propal', 'lire')) { + parse_str($get_params, $query); + $query = array_merge($query, ['id' => $this->id]); if ($option == '') { - $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id.$get_params; + $baseurl = DOL_URL_ROOT . '/comm/propal/card.php'; } elseif ($option == 'compta') { // deprecated - $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id.$get_params; + $baseurl = DOL_URL_ROOT . '/comm/propal/card.php'; } elseif ($option == 'expedition') { - $url = DOL_URL_ROOT.'/expedition/propal.php?id='.$this->id.$get_params; + $baseurl = DOL_URL_ROOT . '/expedition/propal.php'; } elseif ($option == 'document') { - $url = DOL_URL_ROOT.'/comm/propal/document.php?id='.$this->id.$get_params; + $baseurl = DOL_URL_ROOT . '/comm/propal/document.php'; } if ($option != 'nolink') { @@ -3892,10 +3895,11 @@ class Propal extends CommonObject $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } } } + $url = dolBuildUrl($baseurl, $query); $linkclose = ''; if (empty($notooltip) && $user->hasRight('propal', 'lire')) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 39640c85552..4d7ce2ba6b6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -3638,7 +3638,7 @@ if ($action == 'create' && $usercancreate) { $objref = dol_sanitizeFileName($object->ref); $relativepath = $objref . '/' . $objref . '.pdf'; $filedir = $conf->commande->multidir_output[$object->entity ?? $conf->entity] . '/' . $objref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $urlsource = dolBuildUrl($_SERVER["PHP_SELF"], ["id" => $object->id]); $genallowed = $usercanread; $delallowed = $usercancreate; print $formfile->showdocuments('commande', $objref, $filedir, $urlsource, $genallowed, (int) $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); @@ -3679,8 +3679,8 @@ if ($action == 'create' && $usercancreate) { $MAXEVENT = 10; //button to go to messaging from the events box - $morehtmlcenter = dolGetButtonTitle($langs->trans('FullConversation'), '', 'fa fa-comments imgforviewmode', DOL_URL_ROOT . '/commande/messaging.php?id=' . $object->id); - $morehtmlcenter .= dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT . '/commande/agenda.php?id=' . $object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('FullConversation'), '', 'fa fa-comments imgforviewmode', dolBuildUrl(DOL_URL_ROOT . '/commande/messaging.php', ['id' => $object->id])); + $morehtmlcenter .= dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dolBuildUrl(DOL_URL_ROOT . '/commande/agenda.php', ['id' => $object->id])); // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 1ce6598265f..405f7b32c59 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3890,11 +3890,11 @@ class Commande extends CommonOrder $result = ''; if (isModEnabled("shipping") && ($option == '1' || $option == '2')) { - $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id; + $baseurl = DOL_URL_ROOT . '/expedition/shipment.php'; } else { - $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id; + $baseurl = DOL_URL_ROOT . '/commande/card.php'; } - + $query = ['id' => $this->id]; if (!$user->hasRight('commande', 'lire')) { $option = 'nolink'; } @@ -3906,9 +3906,10 @@ class Commande extends CommonOrder $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } } + $url = dolBuildUrl($baseurl, $query); if ($short) { return $url; diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 88abba45e0b..03f085f76af 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2024 Frédéric France +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2024-2025 Frédéric France * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -106,7 +106,7 @@ if ($id > 0 || !empty($ref)) { // Order card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; @@ -122,7 +122,7 @@ if ($id > 0 || !empty($ref)) { if (0) { // @phpstan-ignore-line $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 44f12551acd..482aa9a60c4 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1564,8 +1564,8 @@ class Contact extends CommonObject $label = implode($this->getTooltipContentArray($params)); } - $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; - + $baseurl = DOL_URL_ROOT . '/contact/card.php'; + $query = ['id' => $this->id]; if ($option !== 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); @@ -1573,9 +1573,10 @@ class Contact extends CommonObject $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } } + $url = dolBuildUrl($baseurl, $query); $url .= $moreparam; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 8772aac8573..c3511441b77 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -157,14 +157,14 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } if (empty($reshook)) { - $backurlforlist = DOL_URL_ROOT.'/contrat/list.php'; + $backurlforlist = dolBuildUrl(DOL_URL_ROOT . '/contrat/list.php'); if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { - $backtopage = DOL_URL_ROOT.'/contrat/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); + $backtopage = dolBuildUrl(DOL_URL_ROOT . '/contrat/card.php', ['id'=> ((!empty($id) && $id > 0) ? $id : '__ID__')]); } } } @@ -1262,7 +1262,7 @@ if ($action == 'create') { print ''; print img_picto('', 'company', 'class="pictofixedwidth"'); print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); - print ' '; + print ' 'create'])]).'">'; print ''; } print ''."\n"; @@ -1310,7 +1310,7 @@ if ($action == 'create') { print ''.$langs->trans("Project").''; print img_picto('', 'project', 'class="pictofixedwidth"'); $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, "projectid", 0, 0, 1, 1); - print '   id).'">'; + print '   'create', 'socid' => $soc->id])]) . '">'; print ""; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 35804a19ba3..dd45159cdf0 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2073,7 +2073,8 @@ class Contrat extends CommonObject $result = ''; - $url = DOL_URL_ROOT.'/contrat/card.php?id='.$this->id; + $baseurl = DOL_URL_ROOT . '/contrat/card.php'; + $query = ['id' => $this->id]; //if ($option !== 'nolink') //{ @@ -2083,9 +2084,10 @@ class Contrat extends CommonObject $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } //} + $url = dolBuildUrl($baseurl, $query); $params = [ 'id' => $this->id, 'objecttype' => $this->element, diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 3d3ea0f90d1..72be646d81c 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -215,7 +215,7 @@ function show_array_actions_to_do($max = 5) print '
'; print ''; print ''; - print ''; + print ''; print ''; $i = 0; @@ -332,7 +332,7 @@ function show_array_last_actions_done($max = 5) print '
'; print '
'.$langs->trans("LastActionsToDo", $max).''.$langs->trans("FullList").''.$langs->trans("FullList").'
'; print ''; - print ''; + print ''; print ''; $i = 0; @@ -405,34 +405,34 @@ function agenda_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT."/admin/agenda_other.php"; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda_other.php"); $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'other'; $h++; - $head[$h][0] = DOL_URL_ROOT."/admin/agenda.php"; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda.php"); $head[$h][1] = $langs->trans("AutoActions"); $head[$h][2] = 'autoactions'; $h++; - $head[$h][0] = DOL_URL_ROOT."/admin/agenda_reminder.php"; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda_reminder.php"); $head[$h][1] = $langs->trans("Reminders"); $head[$h][2] = 'reminders'; $h++; - $head[$h][0] = DOL_URL_ROOT."/admin/agenda_xcal.php"; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda_xcal.php"); $head[$h][1] = $langs->trans("ExportCal"); $head[$h][2] = 'xcal'; $h++; - $head[$h][0] = DOL_URL_ROOT."/admin/agenda_extsites.php"; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda_extsites.php"); $head[$h][1] = $langs->trans("ExtSites"); $head[$h][2] = 'extsites'; $h++; complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda_admin'); - $head[$h][0] = DOL_URL_ROOT."/admin/agenda_extrafields.php"; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/agenda_extrafields.php"); $head[$h][1] = $langs->trans("ExtraFields"); $nbExtrafields = $extrafields->attributes['actioncomm']['count']; if ($nbExtrafields > 0) { @@ -460,7 +460,7 @@ function actions_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/comm/action/card.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/comm/action/card.php', ['id'=> $object->id]); $head[$h][1] = $langs->trans("CardAction"); $head[$h][2] = 'card'; $h++; @@ -470,7 +470,7 @@ function actions_prepare_head($object) include_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; $resource = new Dolresource($db); - $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=action&element_id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/resource/element_resource.php', ['element' => 'action', 'element_id'=> $object->id]); $listofresourcelinked = $resource->getElementResources($object->element, $object->id); $nbResources = (is_array($listofresourcelinked) ? count($listofresourcelinked) : 0); $head[$h][1] = $langs->trans("Resources"); @@ -487,7 +487,7 @@ function actions_prepare_head($object) $upload_dir = $conf->agenda->dir_output."/".$object->id; $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/comm/action/document.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Documents"); if (($nbFiles + $nbLinks) > 0) { $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? ''.($nbFiles + $nbLinks).'' : ''); @@ -495,7 +495,7 @@ function actions_prepare_head($object) $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/action/info.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/comm/action/info.php', ['id' => $object->id]); $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++; @@ -520,29 +520,36 @@ function calendars_prepare_head($param) $h = 0; $head = array(); + $query = []; + parse_str($param, $query); - $head[$h][0] = DOL_URL_ROOT.'/comm/action/list.php?mode=show_list'.($param ? '&'.$param : ''); + $query = array_merge($query, ['mode' => 'show_list']); + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/comm/action/list.php', $query); $head[$h][1] = $langs->trans("ViewList"); $head[$h][2] = 'cardlist'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?mode=show_month'.($param ? '&'.$param : ''); + $query['mode'] = 'show_month'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/comm/action/index.php', $query); $head[$h][1] = $langs->trans("ViewCal"); $head[$h][2] = 'cardmonth'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?mode=show_week'.($param ? '&'.$param : ''); + $query['mode'] = 'show_week'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/comm/action/index.php', $query); $head[$h][1] = $langs->trans("ViewWeek"); $head[$h][2] = 'cardweek'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?mode=show_day'.($param ? '&'.$param : ''); + $query['mode'] = 'show_day'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/comm/action/index.php', $query); $head[$h][1] = $langs->trans("ViewDay"); $head[$h][2] = 'cardday'; $h++; + unset($query['mode']); if (getDolGlobalString('AGENDA_SHOW_PERTYPE')) { - $head[$h][0] = DOL_URL_ROOT.'/comm/action/pertype.php'.($param ? '?'.$param : ''); + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/comm/action/pertype.php', $query); $head[$h][1] = $langs->trans("ViewPerType"); $head[$h][2] = 'cardpertype'; $h++; @@ -550,7 +557,10 @@ function calendars_prepare_head($param) $newparam = $param; $newparam = preg_replace('/&?search_filtert=\d+/', '', $newparam); - $head[$h][0] = DOL_URL_ROOT.'/comm/action/peruser.php'.($newparam ? '?'.$newparam : ''); + $query = []; + parse_str($newparam, $query); + + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/comm/action/peruser.php', $query); $head[$h][1] = $langs->trans("ViewPerUser"); $head[$h][2] = 'cardperuser'; $h++; diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index ff763e2419b..7b0de11829b 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2022-2024 Frédéric France + * Copyright (C) 2022-2025 Frédéric France * Copyright (C) 2024 MDW * Copyright (C) 2025 Alexandre Spangaro * @@ -42,7 +42,7 @@ function assetAdminPrepareHead() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/asset/admin/setup.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/asset/admin/setup.php'); $head[$h][1] = $langs->trans("Settings"); $head[$h][2] = 'settings'; $h++; @@ -57,7 +57,7 @@ function assetAdminPrepareHead() //); // to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'asset_admin'); - $head[$h][0] = DOL_URL_ROOT.'/asset/admin/asset_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/asset/admin/asset_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFields"); $nbExtrafields = $extrafields->attributes['asset']['count']; if ($nbExtrafields > 0) { @@ -66,7 +66,7 @@ function assetAdminPrepareHead() $head[$h][2] = 'asset_extrafields'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/asset/admin/assetmodel_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/asset/admin/assetmodel_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFieldsAssetModel"); $nbExtrafields = $extrafields->attributes['asset_model']['count']; if ($nbExtrafields > 0) { @@ -191,7 +191,7 @@ function assetModelPrepareHead($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/asset/model/card.php?id=' . $object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/asset/model/card.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -204,7 +204,7 @@ function assetModelPrepareHead($object) if (!empty($object->note_public)) { $nbNote++; } - $head[$h][0] = DOL_URL_ROOT . '/asset/model/note.php?id=' . $object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/asset/model/note.php', ['id' => $object->id]); $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) { $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '' . $nbNote . '' : ''); @@ -213,7 +213,7 @@ function assetModelPrepareHead($object) $h++; } - $head[$h][0] = DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/asset/model/agenda.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Events"); $head[$h][2] = 'agenda'; $h++; diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index e77ed84da68..65eae9c59b2 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -38,7 +38,7 @@ function contact_prepare_head(Contact $object) $tab = 0; $head = array(); - $head[$tab][0] = DOL_URL_ROOT.'/contact/card.php?id='.$object->id; + $head[$tab][0] = dolBuildUrl(DOL_URL_ROOT.'/contact/card.php', ['id' => $object->id]); $head[$tab][1] = $langs->trans("Contact"); $head[$tab][2] = 'card'; $tab++; @@ -47,13 +47,13 @@ function contact_prepare_head(Contact $object) && (!getDolGlobalString('MAIN_DISABLE_LDAP_TAB') || !empty($user->admin))) { $langs->load("ldap"); - $head[$tab][0] = DOL_URL_ROOT.'/contact/ldap.php?id='.$object->id; + $head[$tab][0] = dolBuildUrl(DOL_URL_ROOT.'/contact/ldap.php', ['id' => $object->id]); $head[$tab][1] = $langs->trans("LDAPCard"); $head[$tab][2] = 'ldap'; $tab++; } - $head[$tab][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$object->id; + $head[$tab][0] = dolBuildUrl(DOL_URL_ROOT.'/contact/perso.php', ['id' => $object->id]); $head[$tab][1] = $langs->trans("PersonalInformations"); $head[$tab][2] = 'perso'; $tab++; @@ -84,7 +84,7 @@ function contact_prepare_head(Contact $object) } dol_setcache($cachekey, $nbProject, 120); // If setting cache fails, this is not a problem, so we do not test result. } - $head[$tab][0] = DOL_URL_ROOT.'/contact/project.php?id='.$object->id; + $head[$tab][0] = dolBuildUrl(DOL_URL_ROOT.'/contact/project.php', ['id' => $object->id]); $head[$tab][1] = $langs->trans("Projects"); if ($nbProject > 0) { $head[$tab][1] .= ''.$nbProject.''; @@ -95,7 +95,7 @@ function contact_prepare_head(Contact $object) // Related items if (isModEnabled('order') || isModEnabled("propal") || isModEnabled('invoice') || isModEnabled('intervention') || isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { - $head[$tab][0] = DOL_URL_ROOT.'/contact/consumption.php?id='.$object->id; + $head[$tab][0] = dolBuildUrl(DOL_URL_ROOT.'/contact/consumption.php', ['id' => $object->id]); $head[$tab][1] = $langs->trans("Referers"); $head[$tab][2] = 'consumption'; $tab++; @@ -110,7 +110,7 @@ function contact_prepare_head(Contact $object) // Notes if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) { $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1); - $head[$tab][0] = DOL_URL_ROOT.'/contact/note.php?id='.$object->id; + $head[$tab][0] = dolBuildUrl(DOL_URL_ROOT.'/contact/note.php', ['id' => $object->id]); $head[$tab][1] = $langs->trans("Note"); if ($nbNote > 0) { $head[$tab][1] .= ''.$nbNote.''; @@ -124,7 +124,7 @@ function contact_prepare_head(Contact $object) $upload_dir = $conf->societe->dir_output."/contact/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); - $head[$tab][0] = DOL_URL_ROOT.'/contact/document.php?id='.$object->id; + $head[$tab][0] = dolBuildUrl(DOL_URL_ROOT.'/contact/document.php', ['id' => $object->id]); $head[$tab][1] = $langs->trans("Documents"); if (($nbFiles + $nbLinks) > 0) { $head[$tab][1] .= ''.($nbFiles + $nbLinks).''; @@ -133,7 +133,7 @@ function contact_prepare_head(Contact $object) $tab++; // Agenda / Events - $head[$tab][0] = DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id; + $head[$tab][0] = dolBuildUrl(DOL_URL_ROOT.'/contact/agenda.php', ['id' => $object->id]); $head[$tab][1] = $langs->trans("Events"); if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $head[$tab][1] .= '/'; @@ -144,7 +144,7 @@ function contact_prepare_head(Contact $object) // Log /* - $head[$tab][0] = DOL_URL_ROOT.'/contact/info.php?id='.$object->id; + $head[$tab][0] = dolBuildUrl(DOL_URL_ROOT.'/contact/info.php', ['id' => $object->id]); $head[$tab][1] = $langs->trans("Info"); $head[$tab][2] = 'info'; $tab++;*/ diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index 7a64a9bd7e1..b84a1c9f1fd 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -38,14 +38,14 @@ function contract_prepare_head(Contrat $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/contrat/card.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/contrat/card.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("ContractCard"); $head[$h][2] = 'card'; $h++; if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) { $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); - $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/contrat/contact.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("ContactsAddresses"); if ($nbContact > 0) { $head[$h][1] .= ''.$nbContact.''; @@ -56,7 +56,7 @@ function contract_prepare_head(Contrat $object) /* deprecated. Contracts and tickets are already linked with the generic "Link to" feature */ if (isModEnabled('ticket') && getDolGlobalString('TICKET_LINK_TO_CONTRACT_WITH_HARDLINK')) { - $head[$h][0] = DOL_URL_ROOT.'/contrat/ticket.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/contrat/ticket.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Tickets"); $head[$h][2] = 'ticket'; $h++; @@ -76,7 +76,7 @@ function contract_prepare_head(Contrat $object) if (!empty($object->note_public)) { $nbNote++; } - $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/contrat/note.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Notes"); if ($nbNote > 0) { $head[$h][1] .= ''.$nbNote.''; @@ -90,7 +90,7 @@ function contract_prepare_head(Contrat $object) $upload_dir = $conf->contrat->multidir_output[$object->entity ?? $conf->entity]."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/contrat/document.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Documents"); if (($nbFiles + $nbLinks) > 0) { $head[$h][1] .= ''.($nbFiles + $nbLinks).''; @@ -99,7 +99,7 @@ function contract_prepare_head(Contrat $object) $h++; - $head[$h][0] = DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/contrat/agenda.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Events"); if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $nbEvent = 0; @@ -156,7 +156,7 @@ function contract_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT."/admin/contract.php"; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/contract.php"); $head[$h][1] = $langs->trans("Contracts"); $head[$h][2] = 'contract'; $h++; @@ -167,7 +167,7 @@ function contract_admin_prepare_head() // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'contract_admin', 'add', 'core'); - $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFields"); $nbExtrafields = $extrafields->attributes['contrat']['count']; if ($nbExtrafields > 0) { @@ -176,7 +176,7 @@ function contract_admin_prepare_head() $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contractdet_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/contrat/admin/contractdet_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFieldsLines"); $nbExtrafields = $extrafields->attributes['contratdet']['count']; if ($nbExtrafields > 0) { diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php index c39f5b3719d..b45039c990b 100644 --- a/htdocs/core/lib/cron.lib.php +++ b/htdocs/core/lib/cron.lib.php @@ -2,6 +2,7 @@ /* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr * Copyright (C) 2013 Florian Henry * Copyright (C) 2024 MDW + * Copyright (C) 2025 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 @@ -35,12 +36,12 @@ function cronadmin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/cron/admin/cron.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/cron/admin/cron.php'); $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'setup'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/cron/list.php?mode=modulesetup'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/cron/list.php', ['mode' => 'modulesetup']); $head[$h][1] = $langs->trans("Module2300Name"); $head[$h][2] = 'jobs'; $h++; @@ -65,12 +66,12 @@ function cron_prepare_head(Cronjob $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/cron/card.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/cron/card.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("CronTask"); $head[$h][2] = 'card'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/cron/info.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/cron/info.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; @@ -100,13 +101,18 @@ function dol_print_cron_urls() // Cron launch print '
'; print $langs->trans("URLToLaunchCronJobs").':
'; - $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(!getDolGlobalString('CRON_KEY') ? '' : 'securitykey=' . getDolGlobalString('CRON_KEY').'&').'userlogin='.$user->login; + $query = [ + 'securitykey' => getDolGlobalString('CRON_KEY'), + 'userlogin' => $user->login, + ]; + $url = dolBuildUrl($urlwithroot.'/public/cron/cron_run_jobs_by_url.php', $query); print ''; print '
'.$langs->trans("OrToLaunchASpecificJob").'
'; - $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(!getDolGlobalString('CRON_KEY') ? '' : 'securitykey=' . getDolGlobalString('CRON_KEY').'&').'userlogin='.$user->login.'&id=cronjobid'; + $query += ['id' => 'cronjobid']; + $url = dolBuildUrl($urlwithroot.'/public/cron/cron_run_jobs_by_url.php', $query); print '
'; print ''; - print '
'.$langs->trans("LastDoneTasks", $max).''.$langs->trans("FullList").''.$langs->trans("FullList").'
'; print ''; + $query = []; + parse_str($options, $query); if ($sortfield) { - $options .= "&sortfield=" . urlencode($sortfield); + $query += ['sortfield' => $sortfield]; } if ($sortorder) { - $options .= "&sortorder=" . urlencode($sortorder); + $query += ['sortorder' => $sortorder]; + } + + $options = '&'.http_build_query($query); + if ($page) { + $query = array_merge($query, ['page' => $page]); } // Show navigation bar $pagelist = ''; @@ -7439,11 +7486,13 @@ function print_barre_liste($title, $page, $file, $options = '', $sortfield = '', if ($cpt >= 1) { if (empty($pagenavastextinput)) { - $pagelist .= ''; + $query['page'] = 0; + $pagelist .= ''; if ($cpt > 2) { $pagelist .= ''; } elseif ($cpt == 2) { - $pagelist .= ''; + $query['page'] = 0; + $pagelist .= ''; } } } @@ -7458,7 +7507,8 @@ function print_barre_liste($title, $page, $file, $options = '', $sortfield = '', if ($cpt == $page) { $pagelist .= ''; } else { - $pagelist .= ''; + $query['page'] = $cpt; + $pagelist .= ''; } } $cpt++; @@ -7469,13 +7519,16 @@ function print_barre_liste($title, $page, $file, $options = '', $sortfield = '', if ($cpt < $nbpages - 2) { $pagelist .= ''; } elseif ($cpt == $nbpages - 2) { - $pagelist .= ''; + $query['page'] = ($nbpages - 2); + $pagelist .= ''; } - $pagelist .= ''; + $query['page'] = ($nbpages - 1); + $pagelist .= ''; } } else { //var_dump($page.' '.$cpt.' '.$nbpages); - $pagelist .= ''; + $query['page'] = ($nbpages - 1); + $pagelist .= ''; } } else { $pagelist .= '"; @@ -7494,7 +7547,7 @@ function print_barre_liste($title, $page, $file, $options = '', $sortfield = '', print '
' . "\n"; + print "\n"; // Center if ($morehtmlcenter && !empty($conf->dol_optimize_smallscreen)) { @@ -7585,10 +7638,10 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be print ' '; diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index 10bfba25044..f8728403025 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -36,7 +36,7 @@ function holiday_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/holiday/card.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/holiday/card.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Leave"); $head[$h][2] = 'card'; $h++; @@ -47,7 +47,7 @@ function holiday_prepare_head($object) $upload_dir = $conf->holiday->multidir_output[$object->entity ?? $conf->entity].'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT.'/holiday/document.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/holiday/document.php', ['id' => $object->id]); $head[$h][1] = $langs->trans('Documents'); if (($nbFiles + $nbLinks) > 0) { $head[$h][1] .= ''.($nbFiles + $nbLinks).''; @@ -57,7 +57,7 @@ function holiday_prepare_head($object) complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'add', 'core'); - $head[$h][0] = DOL_URL_ROOT.'/holiday/info.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/holiday/info.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; @@ -89,7 +89,7 @@ function holiday_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/admin/holiday.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/holiday.php'); $head[$h][1] = $langs->trans("Setup"); $head[$h][2] = 'holiday'; $h++; @@ -100,7 +100,7 @@ function holiday_admin_prepare_head() // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin'); - $head[$h][0] = DOL_URL_ROOT.'/admin/holiday_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/holiday_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFields"); $nbExtrafields = $extrafields->attributes['holiday']['count']; if ($nbExtrafields > 0) { diff --git a/htdocs/core/lib/hrm.lib.php b/htdocs/core/lib/hrm.lib.php index 88176b3cff2..f3d19d63614 100644 --- a/htdocs/core/lib/hrm.lib.php +++ b/htdocs/core/lib/hrm.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 MDW + * Copyright (C) 2025 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 @@ -37,7 +38,7 @@ function establishment_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/card.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/hrm/establishment/card.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Establishment"); $head[$h][2] = 'card'; $h++; @@ -48,7 +49,7 @@ function establishment_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment'); - $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/hrm/establishment/info.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; @@ -74,12 +75,12 @@ function hrm_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_hrm.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/hrm/admin/admin_hrm.php'); $head[$h][1] = $langs->trans("Parameters"); $head[$h][2] = 'parameters'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_establishment.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/hrm/admin/admin_establishment.php'); $head[$h][1] = $langs->trans("Establishments"); $head[$h][2] = 'establishments'; $h++; diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index f0843bb2a07..ba01f38a2b2 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -1,9 +1,9 @@ - * Copyright (C) 2015-2016 Alexandre Spangaro - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2017 Regis Houssin - * Copyright (C) 2024 MDW +/* Copyright (C) 2006-2015 Laurent Destailleur + * Copyright (C) 2015-2016 Alexandre Spangaro + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2017 Regis Houssin + * Copyright (C) 2024 MDW * Copyright (C) 2025 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -39,7 +39,7 @@ function member_prepare_head(Adherent $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/adherents/card.php?rowid='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/card.php', ['rowid' => $object->id]); $head[$h][1] = $langs->trans("Member"); $head[$h][2] = 'general'; $h++; @@ -48,7 +48,7 @@ function member_prepare_head(Adherent $object) && (!getDolGlobalString('MAIN_DISABLE_LDAP_TAB') || !empty($user->admin))) { $langs->load("ldap"); - $head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/ldap.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("LDAPCard"); $head[$h][2] = 'ldap'; $h++; @@ -56,7 +56,7 @@ function member_prepare_head(Adherent $object) if ($user->hasRight('adherent', 'cotisation', 'lire')) { $nbSubscription = is_array($object->subscriptions) ? count($object->subscriptions) : 0; - $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/subscription.php', ['rowid' => $object->id]); $head[$h][1] = $langs->trans("Subscriptions"); $head[$h][2] = 'subscription'; if ($nbSubscription > 0) { @@ -68,7 +68,7 @@ function member_prepare_head(Adherent $object) if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { if ($user->hasRight('partnership', 'read')) { $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0; - $head[$h][0] = DOL_URL_ROOT.'/partnership/partnership_list.php?rowid='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/partnership/partnership_list.php', ['rowid' => $object->id]); $head[$h][1] = $langs->trans("Partnerships"); $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; @@ -105,7 +105,7 @@ function member_prepare_head(Adherent $object) if (!empty($object->note_public)) { $nbNote++; } - $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/note.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; if ($nbNote > 0) { @@ -119,7 +119,7 @@ function member_prepare_head(Adherent $object) $upload_dir = $conf->adherent->multidir_output[$object->entity ?? $conf->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member'); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/document.php', ['id' => $object->id]); $head[$h][1] = $langs->trans('Documents'); if (($nbFiles + $nbLinks) > 0) { $head[$h][1] .= ''.($nbFiles + $nbLinks).''; @@ -128,7 +128,7 @@ function member_prepare_head(Adherent $object) $h++; // Show agenda tab - $head[$h][0] = DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/agenda.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Events"); if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $nbEvent = 0; @@ -181,14 +181,14 @@ function member_type_prepare_head(AdherentType $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/type.php', ['rowid' => $object->id]); $head[$h][1] = $langs->trans("MemberType"); $head[$h][2] = 'card'; $h++; // Multilangs if (getDolGlobalInt('MAIN_MULTILANGS')) { - $head[$h][0] = DOL_URL_ROOT."/adherents/type_translation.php?rowid=".$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/type_translation.php', ['rowid' => $object->id]); $head[$h][1] = $langs->trans("Translation"); $head[$h][2] = 'translation'; $h++; @@ -198,7 +198,7 @@ function member_type_prepare_head(AdherentType $object) && (!getDolGlobalString('MAIN_DISABLE_LDAP_TAB') || !empty($user->admin))) { $langs->load("ldap"); - $head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/type_ldap.php', ['rowid' => $object->id]); $head[$h][1] = $langs->trans("LDAPCard"); $head[$h][2] = 'ldap'; $h++; @@ -231,12 +231,12 @@ function member_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/admin/member.php'); $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'general'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_emails.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/admin/member_emails.php'); $head[$h][1] = $langs->trans("EMails"); $head[$h][2] = 'emails'; $h++; @@ -247,7 +247,7 @@ function member_admin_prepare_head() // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin'); - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/admin/member_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFieldsMember"); $nbExtrafields = $extrafields->attributes['adherent']['count']; if ($nbExtrafields > 0) { @@ -256,7 +256,7 @@ function member_admin_prepare_head() $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_type_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/admin/member_type_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFieldsMemberType"); $nbExtrafields = $extrafields->attributes['adherent_type']['count']; if ($nbExtrafields > 0) { @@ -265,7 +265,7 @@ function member_admin_prepare_head() $head[$h][2] = 'attributes_type'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/admin/website.php'); $head[$h][1] = $langs->trans("BlankSubscriptionForm"); $head[$h][2] = 'website'; $h++; @@ -289,32 +289,32 @@ function member_stats_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/index.php'); $head[$h][1] = $langs->trans("Subscriptions"); $head[$h][2] = 'statssubscription'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/geo.php', ['mode' => 'memberbycountry']); $head[$h][1] = $langs->trans("Country"); $head[$h][2] = 'statscountry'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/geo.php', ['mode' => 'memberbyregion']); $head[$h][1] = $langs->trans("Region"); $head[$h][2] = 'statsregion'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/geo.php', ['mode' => 'memberbystate']); $head[$h][1] = $langs->trans("State"); $head[$h][2] = 'statsstate'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/geo.php', ['mode' => 'memberbytown']); $head[$h][1] = $langs->trans('Town'); $head[$h][2] = 'statstown'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/stats/byproperties.php'); $head[$h][1] = $langs->trans('ByProperties'); $head[$h][2] = 'statsbyproperties'; $h++; @@ -343,12 +343,12 @@ function subscription_prepare_head(Subscription $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/subscription/card.php', ['rowid' => $object->id]); $head[$h][1] = $langs->trans("Subscription"); $head[$h][2] = 'general'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/info.php?rowid='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/adherents/subscription/info.php', ['rowid' => $object->id]); $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 22002aef664..cb471726884 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -36,6 +36,7 @@ function commande_prepare_head(Commande $object) { global $db, $langs, $conf, $user; + if (isModEnabled("shipping")) { $langs->load("sendings"); } @@ -45,7 +46,7 @@ function commande_prepare_head(Commande $object) $head = array(); if (isModEnabled('order') && $user->hasRight('commande', 'lire')) { - $head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/commande/card.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("CustomerOrder"); $head[$h][2] = 'order'; $h++; @@ -53,7 +54,7 @@ function commande_prepare_head(Commande $object) if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) { $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); - $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/commande/contact.php', ['id' => $object->id]); $head[$h][1] = $langs->trans('ContactsAddresses'); if ($nbContact > 0) { $head[$h][1] .= ''.$nbContact.''; @@ -66,7 +67,7 @@ function commande_prepare_head(Commande $object) || (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->hasRight('expedition', 'delivery', 'lire'))) { $nbShipments = $object->getNbOfShipments(); $nbReceiption = 0; - $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/expedition/shipment.php', ['id' => $object->id]); $text = ''; if (getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION')) { $text .= $langs->trans("Shipments"); @@ -108,7 +109,7 @@ function commande_prepare_head(Commande $object) if (!empty($object->note_public)) { $nbNote++; } - $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/commande/note.php', ['id' => $object->id]); $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) { $head[$h][1] .= ''.$nbNote.''; @@ -122,7 +123,7 @@ function commande_prepare_head(Commande $object) $upload_dir = $conf->commande->multidir_output[$object->entity ?? $conf->entity]."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/commande/document.php', ['id' => $object->id]); $head[$h][1] = $langs->trans('Documents'); if (($nbFiles + $nbLinks) > 0) { $head[$h][1] .= ''.($nbFiles + $nbLinks).''; @@ -131,7 +132,7 @@ function commande_prepare_head(Commande $object) $h++; - $head[$h][0] = DOL_URL_ROOT.'/commande/agenda.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/commande/agenda.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Events"); if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $nbEvent = 0; @@ -188,19 +189,19 @@ function order_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/admin/order.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/admin/order.php'); $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'general'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/admin/order_pdf.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/admin/order_pdf.php'); $head[$h][1] = $langs->trans("PDF"); $head[$h][2] = 'pdf'; $h++; complete_head_from_modules($conf, $langs, null, $head, $h, 'order_admin'); - $head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/admin/order_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFields"); $nbExtrafields = $extrafields->attributes['commande']['count']; if ($nbExtrafields > 0) { @@ -209,7 +210,7 @@ function order_admin_prepare_head() $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/admin/orderdet_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFieldsLines"); $nbExtrafields = $extrafields->attributes['commandedet']['count']; if ($nbExtrafields > 0) { diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 04d0c4b9304..1a1d7e57846 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2019-2025 Frédéric France * Copyright (C) 2024 MDW * * This program is free software: you can redistribute it and/or modify @@ -41,12 +41,12 @@ function ticketAdminPrepareHead() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/admin/ticket.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/ticket.php'); $head[$h][1] = $langs->trans("TicketSettings"); $head[$h][2] = 'settings'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/admin/ticket_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/ticket_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFieldsTicket"); $nbExtrafields = $extrafields->attributes['ticket']['count']; if ($nbExtrafields > 0) { @@ -55,7 +55,7 @@ function ticketAdminPrepareHead() $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/admin/ticket_public.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/ticket_public.php'); $head[$h][1] = $langs->trans("PublicInterface"); $head[$h][2] = 'public'; $h++; diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 26d9561c948..b2a0e446785 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -1,11 +1,11 @@ - * Copyright (C) 2010-2017 Regis Houssin - * Copyright (C) 2015 Alexandre Spangaro - * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2021-2023 Anthony Berton - * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW +/* Copyright (C) 2006-2012 Laurent Destailleur + * Copyright (C) 2010-2017 Regis Houssin + * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2021-2023 Anthony Berton + * Copyright (C) 2024-2025 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 @@ -48,7 +48,7 @@ function user_prepare_head(User $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/user/card.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/card.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("User"); $head[$h][2] = 'user'; $h++; @@ -56,20 +56,20 @@ function user_prepare_head(User $object) if ((isModEnabled('ldap') && getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) && (!getDolGlobalString('MAIN_DISABLE_LDAP_TAB') || !empty($user->admin))) { $langs->load("ldap"); - $head[$h][0] = DOL_URL_ROOT.'/user/ldap.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/ldap.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("LDAPCard"); $head[$h][2] = 'ldap'; $h++; } if ($canreadperms) { - $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/perms.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Rights").(!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? ''.($object->nb_rights).'' : ''); $head[$h][2] = 'rights'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/param_ihm.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("UserGUISetup"); $head[$h][2] = 'guisetup'; $h++; @@ -95,14 +95,14 @@ function user_prepare_head(User $object) } } - $head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/agenda_extsites.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("ExtSites").($nbagenda ? ''.$nbagenda.'' : ''); $head[$h][2] = 'extsites'; $h++; } if (isModEnabled('clicktodial')) { - $head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/clicktodial.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("ClickToDial"); $head[$h][2] = 'clicktodial'; $h++; @@ -132,7 +132,7 @@ function user_prepare_head(User $object) } $langs->load("mails"); - $head[$h][0] = DOL_URL_ROOT.'/user/notify/card.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/notify/card.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("NotificationsAuto"); if ($nbNote > 0) { $head[$h][1] .= ''.$nbNote.''; @@ -153,7 +153,7 @@ function user_prepare_head(User $object) || (isModEnabled('holiday') && $user->hasRight('holiday', 'read') && ($user->id == $object->id || $user->hasRight('holiday', 'readall'))) ) { // Bank - $head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/bank.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("HRAndBank"); $head[$h][2] = 'bank'; $h++; @@ -169,7 +169,7 @@ function user_prepare_head(User $object) if (!empty($object->note_private)) { $nbNote++; } - $head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/note.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Note"); if ($nbNote > 0) { $head[$h][1] .= ''.$nbNote.''; @@ -183,7 +183,7 @@ function user_prepare_head(User $object) $upload_dir = $conf->user->dir_output."/".$object->id; $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT.'/user/document.php?userid='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/document.php', ['userid' => $object->id]); $head[$h][1] = $langs->trans("Documents"); if (($nbFiles + $nbLinks) > 0) { $head[$h][1] .= ''.($nbFiles + $nbLinks).''; @@ -191,7 +191,7 @@ function user_prepare_head(User $object) $head[$h][2] = 'document'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/user/agenda.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/agenda.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Events"); if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $nbEvent = 0; @@ -249,7 +249,7 @@ function group_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/user/group/card.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/group/card.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'group'; $h++; @@ -257,14 +257,14 @@ function group_prepare_head($object) if ((isModEnabled('ldap') && getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) && (!getDolGlobalString('MAIN_DISABLE_LDAP_TAB') || !empty($user->admin))) { $langs->load("ldap"); - $head[$h][0] = DOL_URL_ROOT.'/user/group/ldap.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/group/ldap.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("LDAPCard"); $head[$h][2] = 'ldap'; $h++; } if ($canreadperms) { - $head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$object->id; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/group/perms.php', ['id' => $object->id]); $head[$h][1] = $langs->trans("GroupRights").''.($object->nb_rights).''; $head[$h][2] = 'rights'; $h++; @@ -298,17 +298,17 @@ function user_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/admin/user.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/admin/user.php'); $head[$h][1] = $langs->trans("Parameters"); $head[$h][2] = 'card'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/admin/usergroup.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/admin/usergroup.php'); $head[$h][1] = $langs->trans("Group"); $head[$h][2] = 'usergroupcard'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/user/admin/user_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/admin/user_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("Users").")"; $nbExtrafields = $extrafields->attributes['user']['count']; if ($nbExtrafields > 0) { @@ -317,7 +317,7 @@ function user_admin_prepare_head() $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/user/admin/group_extrafields.php'; + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT . '/user/admin/group_extrafields.php'); $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("Groups").")"; $nbExtrafields = $extrafields->attributes['usergroup']['count']; if ($nbExtrafields > 0) { @@ -455,7 +455,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) $file = $dirtheme."/".$subdir."/thumb.png"; $url = $urltheme."/".$subdir."/thumb.png"; if (!file_exists($file)) { - $url = DOL_URL_ROOT.'/public/theme/common/nophoto.png'; + $url = dolBuildUrl(DOL_URL_ROOT . '/public/theme/common/nophoto.png'); } print ''; if ($subdir == getDolGlobalString('MAIN_THEME')) { diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index cb073c64b67..830f8470498 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -77,7 +77,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = if (!empty($landingpage)) { $landingpage = dol_buildpath($landingpage, 1); } else { - $landingpage = '/index.php?mainmenu=home&leftmenu=home'; + $landingpage = dolBuildUrl('/index.php', ['mainmenu'=>'home', 'leftmenu'=>'home']); } $menu_arr[] = array( 'name' => 'Home', @@ -106,7 +106,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); $menu_arr[] = array( 'name' => 'Members', - 'link' => '/adherents/index.php?mainmenu=members&leftmenu=', + 'link' => dolBuildUrl('/adherents/index.php', ['mainmenu'=>'members', 'leftmenu'=> '']), 'title' => "MenuMembers", 'level' => 0, 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)), @@ -138,7 +138,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu_arr[] = array( 'name' => 'Companies', - 'link' => '/societe/index.php?mainmenu=companies&leftmenu=', + 'link' => dolBuildUrl('/societe/index.php', ['mainmenu'=>'companies', 'leftmenu'=>'']), 'title' => "ThirdParties", 'level' => 0, 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)), @@ -163,7 +163,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); $menu_arr[] = array( 'name' => 'Products', - 'link' => '/product/index.php?mainmenu=products&leftmenu=', + 'link' => dolBuildUrl('/product/index.php', ['mainmenu' => 'products', 'leftmenu' => '']), 'title' => (isModEnabled('product') && isModEnabled('service')) ? (array("TMenuProducts", " | ", "TMenuServices")) : (isModEnabled('product') ? "TMenuProducts" : "TMenuServices"), @@ -190,7 +190,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); $menu_arr[] = array( 'name' => 'TMenuMRP', - 'link' => '/mrp/index.php?mainmenu=mrp&leftmenu=', + 'link' => dolBuildUrl('/mrp/index.php', ['mainmenu' => 'mrp', 'leftmenu' => '']), 'title' => "TMenuMRP", 'level' => 0, 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)), @@ -228,7 +228,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu_arr[] = array( 'name' => 'Project', - 'link' => '/projet/index.php?mainmenu=project&leftmenu=', + 'link' => dolBuildUrl('/projet/index.php', ['mainmenu' => 'project', 'leftmenu' => '']), 'title' => $titleboth, 'level' => 0, 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)), @@ -278,7 +278,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu_arr[] = array( 'name' => 'Commercial', - 'link' => ($onlysupplierorder ? '/fourn/commande/index.php?mainmenu=commercial&leftmenu=' : '/comm/index.php?mainmenu=commercial&leftmenu='), + 'link' => dolBuildUrl(($onlysupplierorder ? '/fourn/commande/index.php' : '/comm/index.php'), ['mainmenu' => 'commercial', 'leftmenu' => '']), 'title' => "Commercial", 'level' => 0, 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)), @@ -313,7 +313,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); $menu_arr[] = array( 'name' => 'Compta', - 'link' => '/compta/index.php?mainmenu=billing&leftmenu=', + 'link' => dolBuildUrl('/compta/index.php', ['mainmenu' => 'billing', 'leftmenu' => '']), 'title' => "MenuFinancial", 'level' => 0, 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)), @@ -338,7 +338,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); $menu_arr[] = array( 'name' => 'Bank', - 'link' => '/compta/bank/list.php?mainmenu=bank&leftmenu=&search_status=opened', + 'link' => dolBuildUrl('/compta/bank/list.php', ['mainmenu' => 'bank', 'leftmenu' => '', 'search_status' => 'opened']), 'title' => "MenuBankCash", 'level' => 0, 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)), @@ -363,7 +363,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); $menu_arr[] = array( 'name' => 'Accounting', - 'link' => '/accountancy/index.php?mainmenu=accountancy&leftmenu=', + 'link' => dolBuildUrl('/accountancy/index.php', ['mainmenu' => 'accountancy', 'leftmenu' => '']), 'title' => "MenuAccountancy", 'level' => 0, 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)), @@ -389,7 +389,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu_arr[] = array( 'name' => 'HRM', - 'link' => '/hrm/index.php?mainmenu=hrm&leftmenu=', + 'link' => dolBuildUrl('/hrm/index.php', ['mainmenu' => 'hrm', 'leftmenu' => '']), 'title' => "HRM", 'level' => 0, 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)), @@ -414,9 +414,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); $link = ''; if (isModEnabled('ticket')) { - $link = '/ticket/index.php?mainmenu=ticket&leftmenu='; + $link = dolBuildUrl('/ticket/index.php', ['mainmenu' => 'ticket', 'leftmenu' => '']); } else { - $link = '/knowledgemanagement/knowledgerecord_list.php?mainmenu=ticket&leftmenu='; + $link = dolBuildUrl('/knowledgemanagement/knowledgerecord_list.php', ['mainmenu' => 'ticket', 'leftmenu' => '']); } $menu_arr[] = array( 'name' => 'Ticket', @@ -445,7 +445,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); $menu_arr[] = array( 'name' => 'Tools', - 'link' => '/core/tools.php?mainmenu=tools&leftmenu=', + 'link' => dolBuildUrl('/core/tools.php', ['mainmenu' => 'tools', 'leftmenu' => '']), 'title' => "Tools", 'level' => 0, 'enabled' => (int) ($showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal)), @@ -577,7 +577,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Show logo company if (!getDolGlobalString('MAIN_MENU_INVERT') && getDolGlobalString('MAIN_SHOW_LOGO') && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { //$mysoc->logo_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI); - $mysoc->logo_squarred_mini = (!getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI') ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI); + $mysoc->logo_squarred_mini = getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI'); $logoContainerAdditionalClass = 'backgroundforcompanylogo'; if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND')) { @@ -585,13 +585,13 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = } if (!empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) { - $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); + $urllogo = dolBuildUrl(DOL_URL_ROOT.'/viewimage.php', ['cache' => 1, 'modulepart' => 'mycompany', 'file' => 'logos/thumbs/'.$mysoc->logo_squarred_mini]); /*} elseif (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) { $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); }*/ } else { - $urllogo = DOL_URL_ROOT.'/theme/dolibarr_512x512_white.png'; + $urllogo = dolBuildUrl(DOL_URL_ROOT.'/theme/dolibarr_512x512_white.png'); $logoContainerAdditionalClass = ''; } $title = $langs->trans("GoIntoSetupToChangeLogo"); @@ -1156,12 +1156,12 @@ function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = if (!empty($landingpage)) { $landingpage = dol_buildpath($landingpage, 1); } else { - $landingpage = '/index.php?mainmenu=home&leftmenu=home'; + $landingpage = dolBuildUrl('/index.php', ['mainmenu' => 'home', 'leftmenu' => 'home']); } $newmenu->add($landingpage, $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', ''); // Setup - $newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup', 0, '', '', '', ''); + $newmenu->add(dolBuildUrl("/admin/index.php", ['mainmenu' => 'home', 'leftmenu' => 'setup']), $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup', 0, '', '', '', ''); if ($usemenuhider || empty($leftmenu) || $leftmenu == "setup") { // Define $nbmodulesnotautoenabled - TODO This code is at different places @@ -1180,23 +1180,23 @@ function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); } - $newmenu->add("/admin/company.php?mainmenu=home", $langs->trans("MenuCompanySetup").$warnpicto, 1); + $newmenu->add(dolBuildUrl("/admin/company.php", ['mainmenu' => 'home']), $langs->trans("MenuCompanySetup").$warnpicto, 1); $warnpicto = ''; if ($nbmodulesnotautoenabled <= getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only user module enabled $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); } - $newmenu->add("/admin/modules.php?mainmenu=home", $langs->trans("Modules").$warnpicto, 1); - $newmenu->add("/admin/ihm.php?mainmenu=home", $langs->trans("GUISetup"), 1); - $newmenu->add("/admin/menus.php?mainmenu=home", $langs->trans("Menus"), 1); + $newmenu->add(dolBuildUrl("/admin/modules.php", ['mainmenu' => 'home']), $langs->trans("Modules").$warnpicto, 1); + $newmenu->add(dolBuildUrl("/admin/ihm.php", ['mainmenu' => 'home']), $langs->trans("GUISetup"), 1); + $newmenu->add(dolBuildUrl("/admin/menus.php", ['mainmenu' => 'home']), $langs->trans("Menus"), 1); - $newmenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"), 1); - $newmenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"), 1); - $newmenu->add("/admin/boxes.php?mainmenu=home", $langs->trans("Boxes"), 1); - $newmenu->add("/admin/delais.php?mainmenu=home", $langs->trans("MenuWarnings"), 1); - $newmenu->add("/admin/security_other.php?mainmenu=home", $langs->trans("Security"), 1); - $newmenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"), 1); - $newmenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"), 1); + $newmenu->add(dolBuildUrl("/admin/translation.php", ['mainmenu' => 'home']), $langs->trans("Translation"), 1); + $newmenu->add(dolBuildUrl("/admin/defaultvalues.php", ['mainmenu' => 'home']), $langs->trans("DefaultValues"), 1); + $newmenu->add(dolBuildUrl("/admin/boxes.php", ['mainmenu' => 'home']), $langs->trans("Boxes"), 1); + $newmenu->add(dolBuildUrl("/admin/delais.php", ['mainmenu' => 'home']), $langs->trans("MenuWarnings"), 1); + $newmenu->add(dolBuildUrl("/admin/security_other.php", ['mainmenu' => 'home']), $langs->trans("Security"), 1); + $newmenu->add(dolBuildUrl("/admin/limits.php", ['mainmenu' => 'home']), $langs->trans("MenuLimits"), 1); + $newmenu->add(dolBuildUrl("/admin/pdf.php", ['mainmenu' => 'home']), $langs->trans("PDF"), 1); $warnpicto = ''; /* No warning into menu entry, the message in Email setup page is enough @@ -1211,66 +1211,66 @@ function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = $warnpicto = img_warning($langs->trans("ErrorSetupOfEmailsNotComplete")); } - $newmenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails").$warnpicto, 1); - $newmenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"), 1); - $newmenu->add("/admin/dict.php?mainmenu=home", $langs->trans("Dictionary"), 1); - $newmenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"), 1); + $newmenu->add(dolBuildUrl("/admin/mails.php", ['mainmenu' => 'home']), $langs->trans("Emails").$warnpicto, 1); + $newmenu->add(dolBuildUrl("/admin/sms.php", ['mainmenu' => 'home']), $langs->trans("SMS"), 1); + $newmenu->add(dolBuildUrl("/admin/dict.php", ['mainmenu' => 'home']), $langs->trans("Dictionary"), 1); + $newmenu->add(dolBuildUrl("/admin/const.php", ['mainmenu' => 'home']), $langs->trans("OtherSetup"), 1); } // System tools - $newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=admintools", $langs->trans("AdminTools"), 0, $user->admin, '', $mainmenu, 'admintools', 0, '', '', '', ''); + $newmenu->add(dolBuildUrl('/admin/tools/index.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("AdminTools"), 0, $user->admin, '', $mainmenu, 'admintools', 0, '', '', '', ''); if ($usemenuhider || empty($leftmenu) || preg_match('/^admintools/', $leftmenu)) { // Load translation files required by the page $langs->loadLangs(array('admin', 'help')); - $newmenu->add('/admin/system/dolibarr.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('InfoDolibarr'), 1); + $newmenu->add(dolBuildUrl('/admin/system/dolibarr.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools_info']), $langs->trans('InfoDolibarr'), 1); if ($usemenuhider || empty($leftmenu) || $leftmenu == 'admintools_info') { - $newmenu->add('/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('Modules'), 2); - $newmenu->add('/admin/triggers.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('Triggers'), 2); - $newmenu->add('/admin/system/filecheck.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('FileCheck'), 2); - $newmenu->add('/admin/system/about.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('ExternalResources'), 2); + $newmenu->add(dolBuildUrl('/admin/system/modules.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools_info']), $langs->trans('Modules'), 2); + $newmenu->add(dolBuildUrl('/admin/triggers.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools_info']), $langs->trans('Triggers'), 2); + $newmenu->add(dolBuildUrl('/admin/system/filecheck.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools_info']), $langs->trans('FileCheck'), 2); + $newmenu->add(dolBuildUrl('/admin/system/about.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools_info']), $langs->trans('ExternalResources'), 2); } - $newmenu->add('/admin/system/browser.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoBrowser'), 1); - $newmenu->add('/admin/system/os.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoOS'), 1); - $newmenu->add('/admin/system/web.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoWebServer'), 1); - $newmenu->add('/admin/system/phpinfo.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoPHP'), 1); - $newmenu->add('/admin/system/database.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoDatabase'), 1); - $newmenu->add("/admin/system/perf.php?mainmenu=home&leftmenu=admintools", $langs->trans("InfoPerf"), 1); - $newmenu->add("/admin/system/security.php?mainmenu=home&leftmenu=admintools", $langs->trans("InfoSecurity"), 1); - $newmenu->add("/admin/tools/listevents.php?mainmenu=home&leftmenu=admintools", $langs->trans("Audit"), 1); - $newmenu->add("/admin/tools/listsessions.php?mainmenu=home&leftmenu=admintools", $langs->trans("Sessions"), 1); - $newmenu->add("/admin/tools/dolibarr_export.php?mainmenu=home&leftmenu=admintools", $langs->trans("Backup"), 1); - $newmenu->add("/admin/tools/dolibarr_import.php?mainmenu=home&leftmenu=admintools", $langs->trans("Restore"), 1); - $newmenu->add("/admin/tools/update.php?mainmenu=home&leftmenu=admintools", $langs->trans("MenuUpgrade"), 1); - $newmenu->add("/admin/tools/purge.php?mainmenu=home&leftmenu=admintools", $langs->trans("Purge"), 1); + $newmenu->add(dolBuildUrl('/admin/system/browser.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans('InfoBrowser'), 1); + $newmenu->add(dolBuildUrl('/admin/system/os.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans('InfoOS'), 1); + $newmenu->add(dolBuildUrl('/admin/system/web.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans('InfoWebServer'), 1); + $newmenu->add(dolBuildUrl('/admin/system/phpinfo.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans('InfoPHP'), 1); + $newmenu->add(dolBuildUrl('/admin/system/database.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans('InfoDatabase'), 1); + $newmenu->add(dolBuildUrl('/admin/system/perf.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("InfoPerf"), 1); + $newmenu->add(dolBuildUrl('/admin/system/security.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("InfoSecurity"), 1); + $newmenu->add(dolBuildUrl('/admin/tools/listevents.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("Audit"), 1); + $newmenu->add(dolBuildUrl('/admin/tools/listsessions.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("Sessions"), 1); + $newmenu->add(dolBuildUrl('/admin/tools/dolibarr_export.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("Backup"), 1); + $newmenu->add(dolBuildUrl('/admin/tools/dolibarr_import.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("Restore"), 1); + $newmenu->add(dolBuildUrl('/admin/tools/update.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("MenuUpgrade"), 1); + $newmenu->add(dolBuildUrl('/admin/tools/purge.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("Purge"), 1); /* Already into menu Tools if (isModEnabled('blockedlog')) { $langs->load("blockedlog"); - $newmenu->add("/blockedlog/admin/blockedlog_list.php?mainmenu=home&leftmenu=admintools", $langs->trans("BrowseBlockedLog"), 1, $user->admin); + $newmenu->add(dolBuildUrl('/blockedlog/admin/blockedlog_list.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("BrowseBlockedLog"), 1, $user->admin); } */ if (isModEnabled('product') || isModEnabled('service')) { $langs->load("products"); - $newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools", $langs->trans("ProductVatMassChange"), 1, $user->admin); + $newmenu->add(dolBuildUrl('/product/admin/product_tools.php', ['mainmenu' => 'home', 'leftmenu' => 'admintools']), $langs->trans("ProductVatMassChange"), 1, $user->admin); } } - $newmenu->add("/user/home.php?leftmenu=users", $langs->trans("MenuUsersAndGroups"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'users', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/user/home.php', ['leftmenu' => 'users']), $langs->trans("MenuUsersAndGroups"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'users', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"')); if ($user->hasRight('user', 'user', 'read')) { if ($usemenuhider || empty($leftmenu) || $leftmenu == "users") { $newmenu->add("", $langs->trans("Users"), 1, (int) ($user->hasRight('user', 'user', 'read') || $user->admin)); - $newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"), 2, (int) (($user->hasRight("user", "user", "write") || $user->admin) && !(isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE'))), '', 'home'); - $newmenu->add("/user/list.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, (int) ($user->hasRight('user', 'user', 'read') || $user->admin)); - $newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, (int) ($user->hasRight('user', 'user', 'read') || $user->admin)); + $newmenu->add(dolBuildUrl('/user/card.php', ['leftmenu' => 'users', 'action' => 'create']), $langs->trans("NewUser"), 2, (int) (($user->hasRight("user", "user", "write") || $user->admin) && !(isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE'))), '', 'home'); + $newmenu->add(dolBuildUrl('/user/list.php', ['leftmenu' => 'users']), $langs->trans("ListOfUsers"), 2, (int) ($user->hasRight('user', 'user', 'read') || $user->admin)); + $newmenu->add(dolBuildUrl('/user/hierarchy.php', ['leftmenu' => 'users']), $langs->trans("HierarchicView"), 2, (int) ($user->hasRight('user', 'user', 'read') || $user->admin)); if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) { $langs->load("categories"); - $newmenu->add("/categories/categorie_list.php?leftmenu=users&type=7", $langs->trans("UsersCategoriesShort"), 2, $user->hasRight('categorie', 'read'), '', $mainmenu, 'cat'); + $newmenu->add(dolBuildUrl('/categories/categorie_list.php', ['leftmenu' => 'users', 'type' => 7]), $langs->trans("UsersCategoriesShort"), 2, $user->hasRight('categorie', 'read'), '', $mainmenu, 'cat'); } $newmenu->add("", $langs->trans("Groups"), 1, (int) (($user->hasRight('user', 'user', 'read') || $user->admin) && !(isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')))); - $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, (int) (((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight("user", "group_advance", "write") : $user->hasRight("user", "user", "write")) || $user->admin) && !(isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')))); - $newmenu->add("/user/group/list.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, (int) ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('user', 'group_advance', 'read') : $user->hasRight('user', 'user', 'read')) || $user->admin)); + $newmenu->add(dolBuildUrl('/user/group/card.php', ['leftmenu' => 'users', 'action' => 'create']), $langs->trans("NewGroup"), 2, (int) (((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight("user", "group_advance", "write") : $user->hasRight("user", "user", "write")) || $user->admin) && !(isModEnabled('multicompany') && !empty($user->entity) && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')))); + $newmenu->add(dolBuildUrl('/user/group/list.php', ['leftmenu' => 'users']), $langs->trans("ListOfGroups"), 2, (int) ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('user', 'group_advance', 'read') : $user->hasRight('user', 'user', 'read')) || $user->admin)); } } } @@ -1294,17 +1294,17 @@ function get_left_menu_thridparties($mainmenu, &$newmenu, $usemenuhider = 1, $le // Societes if (isModEnabled('societe')) { $langs->load("companies"); - $newmenu->add("/societe/index.php?leftmenu=thirdparties", $langs->trans("ThirdParty"), 0, $user->hasRight('societe', 'lire'), '', $mainmenu, 'thirdparties', 0, '', '', '', img_picto('', 'company', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/societe/index.php', ['leftmenu' => 'thirdparties']), $langs->trans("ThirdParty"), 0, $user->hasRight('societe', 'lire'), '', $mainmenu, 'thirdparties', 0, '', '', '', img_picto('', 'company', 'class="paddingright pictofixedwidth"')); if ($user->hasRight('societe', 'creer')) { - $newmenu->add("/societe/card.php?action=create", $langs->trans("MenuNewThirdParty"), 1); + $newmenu->add(dolBuildUrl('/societe/card.php', ['action' => 'create']), $langs->trans("MenuNewThirdParty"), 1); if (!$conf->use_javascript_ajax) { - $newmenu->add("/societe/card.php?action=create&private=1", $langs->trans("MenuNewPrivateIndividual"), 1); + $newmenu->add(dolBuildUrl('/societe/card.php', ['action' => 'create', 'private' => 1]), $langs->trans("MenuNewPrivateIndividual"), 1); } } } - $newmenu->add("/societe/list.php?leftmenu=thirdparties", $langs->trans("List"), 1, $user->hasRight('societe', 'lire'), '', $mainmenu, 'thirdparties_list', 2); + $newmenu->add(dolBuildUrl('/societe/list.php', ['leftmenu' => 'thirdparties']), $langs->trans("List"), 1, $user->hasRight('societe', 'lire'), '', $mainmenu, 'thirdparties_list', 2); // Prospects if (isModEnabled('societe') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) { @@ -2391,8 +2391,8 @@ function get_left_menu_projects($mainmenu, &$newmenu, $usemenuhider = 1, $leftme } // Project assigned to user - $newmenu->add("/projet/index.php?leftmenu=projects".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titleboth, 0, $user->hasRight('projet', 'lire'), '', $mainmenu, 'projects', 0, '', '', '', img_picto('', 'project', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/projet/card.php?leftmenu=projects&action=create".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titlenew, 1, $user->hasRight('projet', 'creer')); + $newmenu->add(dolBuildUrl('/projet/index.php', ['leftmenu' => 'projects', 'search_project_user' => ($search_project_user ? $search_project_user : '')]), $titleboth, 0, $user->hasRight('projet', 'lire'), '', $mainmenu, 'projects', 0, '', '', '', img_picto('', 'project', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/projet/card.php', ['leftmenu' => 'projects', 'action' => 'create', 'search_project_user' => ($search_project_user ? $search_project_user : '')]), $titlenew, 1, $user->hasRight('projet', 'creer')); if (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { $newmenu->add("/projet/list.php?leftmenu=projects".($search_project_user ? '&search_project_user='.$search_project_user : '').'&search_status=99', $langs->trans("List"), 1, $showmode, '', 'project', 'list'); @@ -2401,15 +2401,15 @@ function get_left_menu_projects($mainmenu, &$newmenu, $usemenuhider = 1, $leftme $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99&search_opp_status=openedopp&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode); $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode); } elseif (getDolGlobalInt('PROJECT_USE_OPPORTUNITIES') == 2) { // 2 = leads only - $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99', $langs->trans("List"), 2, $showmode); + $newmenu->add(dolBuildUrl('/projet/list.php', ['mainmenu' => 'project', 'leftmenu' => 'list', 'search_usage_opportunity' => 1, 'search_status' => 99]), $langs->trans("List"), 2, $showmode); } - $newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->hasRight('projet', 'lire')); + $newmenu->add(dolBuildUrl('/projet/stats/index.php', ['leftmenu' => 'projects']), $langs->trans("Statistics"), 1, $user->hasRight('projet', 'lire')); // Categories if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) { $langs->load("categories"); - $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=6", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); + $newmenu->add(dolBuildUrl('/categories/categorie_list.php', ['leftmenu' => 'cat', 'type' => 6]), $langs->trans("Categories"), 1, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); } if (!getDolGlobalString('PROJECT_HIDE_TASKS')) { @@ -2445,32 +2445,32 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = if (isModEnabled('hrm')) { $langs->load("hrm"); - $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("Employees"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->hasRight('user', 'user', 'write')); - $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read')); + $newmenu->add(dolBuildUrl('/user/list.php', ['mainmenu' => 'hrm', 'leftmenu' => 'hrm', 'contextpage' => 'employeelist']), $langs->trans("Employees"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/user/card.php', ['mainmenu' => 'hrm', 'leftmenu' => 'hrm', 'action' => 'create', 'employee' => 1]), $langs->trans("NewEmployee"), 1, $user->hasRight('user', 'user', 'write')); + $newmenu->add(dolBuildUrl('/user/list.php', ['mainmenu' => 'hrm', 'leftmenu' => 'hrm', 'contextpage' => 'employeelist']), $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read')); - $newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillsManagement"), 0, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/hrm/skill_list.php', ['mainmenu' => 'hrm', 'leftmenu' => 'hrm_sm']), $langs->trans("SkillsManagement"), 0, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="paddingright pictofixedwidth"')); // Skills - $newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("Skills"), 1, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/hrm/skill_list.php', ['mainmenu' => 'hrm', 'leftmenu' => 'hrm_sm']), $langs->trans("Skills"), 1, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="paddingright pictofixedwidth"')); //$newmenu->add("/hrm/skill_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewSkill"), 1, $user->hasRight('hrm', 'all', 'write')); //$newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read')); // Job (Description of work to do and skills required) - $newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("JobsProfiles"), 1, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/hrm/job_list.php', ['mainmenu' => 'hrm', 'leftmenu' => 'hrm_sm']), $langs->trans("JobsProfiles"), 1, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"')); //$newmenu->add("/hrm/job_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->transnoentities("NewObject", $langs->trans("Job")), 1, $user->hasRight('hrm', 'all', 'write')); //$newmenu->add("/hrm/job_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read')); // Position = Link job - user - $newmenu->add("/hrm/position_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("EmployeePositions"), 1, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user-cog', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/hrm/position_list.php', ['mainmenu' => 'hrm', 'leftmenu' => 'hrm_sm']), $langs->trans("EmployeePositions"), 1, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user-cog', 'class="paddingright pictofixedwidth"')); //$newmenu->add("/hrm/position.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->transnoentities("NewObject", $langs->trans("Position")), 1, $user->hasRight('hrm', 'all', 'write')); //$newmenu->add("/hrm/position_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'all', 'read')); // Evaluation - $newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("Evals"), 1, $user->hasRight('hrm', 'evaluation', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/hrm/evaluation_list.php', ['mainmenu' => 'hrm', 'leftmenu' => 'hrm_sm']), $langs->trans("Evals"), 1, $user->hasRight('hrm', 'evaluation', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"')); //$newmenu->add("/hrm/evaluation_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewEval"), 1, $user->hasRight('hrm', 'evaluation', 'write')); //$newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->hasRight('hrm', 'evaluation', 'read')); - $newmenu->add("/hrm/compare.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillComparison"), 1, (int) ($user->hasRight('hrm', 'evaluation', 'read') || $user->hasRight('hrm', 'compare_advance', 'read'))); + $newmenu->add(dolBuildUrl('/hrm/compare.php', ['mainmenu' => 'hrm', 'leftmenu' => 'hrm_sm']), $langs->trans("SkillComparison"), 1, (int) ($user->hasRight('hrm', 'evaluation', 'read') || $user->hasRight('hrm', 'compare_advance', 'read'))); } // Leave/Holiday/Vacation module @@ -2478,47 +2478,47 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = // Load translation files required by the page $langs->loadLangs(array("holiday", "trips")); - $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("CPTitreMenu"), 0, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday', 0, '', '', '', img_picto('', 'holiday', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->hasRight('holiday', 'write'), '', $mainmenu); - $newmenu->add("/holiday/card_group.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("NewHolidayForGroup"), 1, (int) ($user->hasRight('holiday', 'writeall') && $user->hasRight('holiday', 'readall')), '', $mainmenu, 'holiday_sm'); - $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("List"), 1, $user->hasRight('holiday', 'read'), '', $mainmenu); + $newmenu->add(dolBuildUrl('/holiday/list.php', ['mainmenu' => 'hrm', 'leftmenu' => 'holiday']), $langs->trans("CPTitreMenu"), 0, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday', 0, '', '', '', img_picto('', 'holiday', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/holiday/card.php', ['mainmenu' => 'hrm', 'leftmenu' => 'holiday', 'action' => 'create']), $langs->trans("New"), 1, $user->hasRight('holiday', 'write'), '', $mainmenu); + $newmenu->add(dolBuildUrl('/holiday/card_group.php', ['mainmenu' => 'hrm', 'leftmenu' => 'holiday', 'action' => 'create']), $langs->trans("NewHolidayForGroup"), 1, (int) ($user->hasRight('holiday', 'writeall') && $user->hasRight('holiday', 'readall')), '', $mainmenu, 'holiday_sm'); + $newmenu->add(dolBuildUrl('/holiday/list.php', ['mainmenu' => 'hrm', 'leftmenu' => 'holiday']), $langs->trans("List"), 1, $user->hasRight('holiday', 'read'), '', $mainmenu); if ($usemenuhider || empty($leftmenu) || $leftmenu == "holiday") { - $newmenu->add("/holiday/list.php?search_status=1&mainmenu=hrm&leftmenu=holiday", $langs->trans("DraftCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); - $newmenu->add("/holiday/list.php?search_status=2&mainmenu=hrm&leftmenu=holiday", $langs->trans("ToReviewCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); - $newmenu->add("/holiday/list.php?search_status=3&mainmenu=hrm&leftmenu=holiday", $langs->trans("ApprovedCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); - $newmenu->add("/holiday/list.php?search_status=4&mainmenu=hrm&leftmenu=holiday", $langs->trans("CancelCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); - $newmenu->add("/holiday/list.php?search_status=5&mainmenu=hrm&leftmenu=holiday", $langs->trans("RefuseCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); + $newmenu->add(dolBuildUrl('/holiday/list.php', ['search_status' => 1, 'mainmenu' => 'hrm', 'leftmenu' => 'holiday']), $langs->trans("DraftCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); + $newmenu->add(dolBuildUrl('/holiday/list.php', ['search_status' => 2, 'mainmenu' => 'hrm', 'leftmenu' => 'holiday']), $langs->trans("ToReviewCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); + $newmenu->add(dolBuildUrl('/holiday/list.php', ['search_status' => 3, 'mainmenu' => 'hrm', 'leftmenu' => 'holiday']), $langs->trans("ApprovedCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); + $newmenu->add(dolBuildUrl('/holiday/list.php', ['search_status' => 4, 'mainmenu' => 'hrm', 'leftmenu' => 'holiday']), $langs->trans("CancelCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); + $newmenu->add(dolBuildUrl('/holiday/list.php', ['search_status' => 5, 'mainmenu' => 'hrm', 'leftmenu' => 'holiday']), $langs->trans("RefuseCP"), 2, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); } - $newmenu->add("/holiday/define_holiday.php?mainmenu=hrm", $langs->trans("MenuConfCP"), 1, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); - $newmenu->add("/holiday/month_report.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuReportMonth"), 1, $user->hasRight('holiday', 'readall'), '', $mainmenu, 'holiday_sm'); - $newmenu->add("/holiday/view_log.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuLogCP"), 1, $user->hasRight('holiday', 'define_holiday'), '', $mainmenu, 'holiday_sm'); + $newmenu->add(dolBuildUrl('/holiday/define_holiday.php', ['mainmenu' => 'hrm']), $langs->trans("MenuConfCP"), 1, $user->hasRight('holiday', 'read'), '', $mainmenu, 'holiday_sm'); + $newmenu->add(dolBuildUrl('/holiday/month_report.php', ['mainmenu' => 'hrm', 'leftmenu' => 'holiday']), $langs->trans("MenuReportMonth"), 1, $user->hasRight('holiday', 'readall'), '', $mainmenu, 'holiday_sm'); + $newmenu->add(dolBuildUrl('/holiday/view_log.php', ['mainmenu' => 'hrm', 'leftmenu' => 'holiday']), $langs->trans("MenuLogCP"), 1, $user->hasRight('holiday', 'define_holiday'), '', $mainmenu, 'holiday_sm'); } // Trips and expenses (old module) if (isModEnabled('deplacement')) { $langs->load("trips"); - $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->hasRight('deplacement', 'lire'), '', $mainmenu, 'tripsandexpenses', 0, '', '', '', img_picto('', 'trip', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/compta/deplacement/card.php?action=create&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("New"), 1, $user->hasRight('deplacement', 'creer')); - $newmenu->add("/compta/deplacement/list.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("List"), 1, $user->hasRight('deplacement', 'lire')); - $newmenu->add("/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->hasRight('deplacement', 'lire')); + $newmenu->add(dolBuildUrl('/compta/deplacement/index.php', ['leftmenu' => 'tripsandexpenses', 'mainmenu' => 'hrm']), $langs->trans("TripsAndExpenses"), 0, $user->hasRight('deplacement', 'lire'), '', $mainmenu, 'tripsandexpenses', 0, '', '', '', img_picto('', 'trip', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/compta/deplacement/card.php', ['action' => 'create', 'leftmenu' => 'tripsandexpenses', 'mainmenu' => 'hrm']), $langs->trans("New"), 1, $user->hasRight('deplacement', 'creer')); + $newmenu->add(dolBuildUrl('/compta/deplacement/list.php', ['leftmenu' => 'tripsandexpenses', 'mainmenu' => 'hrm']), $langs->trans("List"), 1, $user->hasRight('deplacement', 'lire')); + $newmenu->add(dolBuildUrl('/compta/deplacement/stats/index.php', ['leftmenu' => 'tripsandexpenses', 'mainmenu' => 'hrm']), $langs->trans("Statistics"), 1, $user->hasRight('deplacement', 'lire')); } // Expense report if (isModEnabled('expensereport')) { $langs->loadLangs(array("trips", "bills")); - $newmenu->add("/expensereport/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->hasRight('expensereport', 'lire'), '', $mainmenu, 'expensereport', 0, '', '', '', img_picto('', 'expensereport', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/expensereport/card.php?action=create&leftmenu=expensereport&mainmenu=hrm", $langs->trans("New"), 1, $user->hasRight('expensereport', 'creer')); - $newmenu->add("/expensereport/list.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("List"), 1, $user->hasRight('expensereport', 'lire')); + $newmenu->add(dolBuildUrl('/expensereport/index.php', ['leftmenu' => 'expensereport', 'mainmenu' => 'hrm']), $langs->trans("TripsAndExpenses"), 0, $user->hasRight('expensereport', 'lire'), '', $mainmenu, 'expensereport', 0, '', '', '', img_picto('', 'expensereport', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/expensereport/card.php', ['action' => 'create', 'leftmenu' => 'expensereport', 'mainmenu' => 'hrm']), $langs->trans("New"), 1, $user->hasRight('expensereport', 'creer')); + $newmenu->add(dolBuildUrl('/expensereport/list.php', ['leftmenu' => 'expensereport', 'mainmenu' => 'hrm']), $langs->trans("List"), 1, $user->hasRight('expensereport', 'lire')); if ($usemenuhider || empty($leftmenu) || $leftmenu == "expensereport") { - $newmenu->add("/expensereport/list.php?search_status=0&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Draft"), 2, $user->hasRight('expensereport', 'lire')); - $newmenu->add("/expensereport/list.php?search_status=2&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Validated"), 2, $user->hasRight('expensereport', 'lire')); - $newmenu->add("/expensereport/list.php?search_status=5&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Approved"), 2, $user->hasRight('expensereport', 'lire')); - $newmenu->add("/expensereport/list.php?search_status=6&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Paid"), 2, $user->hasRight('expensereport', 'lire')); - $newmenu->add("/expensereport/list.php?search_status=4&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Canceled"), 2, $user->hasRight('expensereport', 'lire')); - $newmenu->add("/expensereport/list.php?search_status=99&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Refused"), 2, $user->hasRight('expensereport', 'lire')); + $newmenu->add(dolBuildUrl('/expensereport/list.php', ['search_status' => 0, 'leftmenu' => 'expensereport', 'mainmenu' => 'hrm']), $langs->trans("Draft"), 2, $user->hasRight('expensereport', 'lire')); + $newmenu->add(dolBuildUrl('/expensereport/list.php', ['search_status' => 2, 'leftmenu' => 'expensereport', 'mainmenu' => 'hrm']), $langs->trans("Validated"), 2, $user->hasRight('expensereport', 'lire')); + $newmenu->add(dolBuildUrl('/expensereport/list.php', ['search_status' => 5, 'leftmenu' => 'expensereport', 'mainmenu' => 'hrm']), $langs->trans("Approved"), 2, $user->hasRight('expensereport', 'lire')); + $newmenu->add(dolBuildUrl('/expensereport/list.php', ['search_status' => 6, 'leftmenu' => 'expensereport', 'mainmenu' => 'hrm']), $langs->trans("Paid"), 2, $user->hasRight('expensereport', 'lire')); + $newmenu->add(dolBuildUrl('/expensereport/list.php', ['search_status' => 4, 'leftmenu' => 'expensereport', 'mainmenu' => 'hrm']), $langs->trans("Canceled"), 2, $user->hasRight('expensereport', 'lire')); + $newmenu->add(dolBuildUrl('/expensereport/list.php', ['search_status' => 99, 'leftmenu' => 'expensereport', 'mainmenu' => 'hrm']), $langs->trans("Refused"), 2, $user->hasRight('expensereport', 'lire')); } - $newmenu->add("/expensereport/payment/list.php?leftmenu=expensereport_payments&mainmenu=hrm", $langs->trans("Payments"), 1, (int) (int) ($user->hasRight('expensereport', 'lire') && isModEnabled('bank'))); - $newmenu->add("/expensereport/stats/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->hasRight('expensereport', 'lire')); + $newmenu->add(dolBuildUrl('/expensereport/payment/list.php', ['leftmenu' => 'expensereport_payments', 'mainmenu' => 'hrm']), $langs->trans("Payments"), 1, (int) (int) ($user->hasRight('expensereport', 'lire') && isModEnabled('bank'))); + $newmenu->add(dolBuildUrl('/expensereport/stats/index.php', ['leftmenu' => 'expensereport', 'mainmenu' => 'hrm']), $langs->trans("Statistics"), 1, $user->hasRight('expensereport', 'lire')); } if (isModEnabled('project')) { @@ -2527,7 +2527,7 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = $search_project_user = GETPOSTINT('search_project_user'); - $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("TimeEntry"), 0, $user->hasRight('projet', 'lire'), '', $mainmenu, 'timespent', 0, '', '', '', img_picto('', 'timespent', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/projet/activity/perweek.php', ['leftmenu' => 'tasks', 'search_project_user' => ($search_project_user ? $search_project_user : '')]), $langs->trans("TimeEntry"), 0, $user->hasRight('projet', 'lire'), '', $mainmenu, 'timespent', 0, '', '', '', img_picto('', 'timespent', 'class="paddingright pictofixedwidth"')); } } } @@ -2551,12 +2551,12 @@ function get_left_menu_tools($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu if ($mainmenu == 'tools') { if (isModEnabled('category')) { $titleindex = $langs->trans("Categories"); - $newmenu->add("/categories/index.php?leftmenu=category", $titleindex, 0, $user->hasRight('category', 'read'), '', $mainmenu, 'category', 5, '', '', '', img_picto('', 'category', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/categories/index.php', ['leftmenu' => 'category']), $titleindex, 0, $user->hasRight('category', 'read'), '', $mainmenu, 'category', 5, '', '', '', img_picto('', 'category', 'class="paddingright pictofixedwidth"')); } if (empty($user->socid)) { // limit to internal users $langs->load("mails"); - $newmenu->add("/admin/mails_templates.php?leftmenu=email_templates", $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates', 10, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/admin/mails_templates.php', ['leftmenu' => 'email_templates']), $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates', 10, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"')); } if (isModEnabled('mailing')) { @@ -2567,9 +2567,9 @@ function get_left_menu_tools($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu $titleindex .= ' | '.$langs->trans("SMSings"); $titlenew .= ' | '.$langs->trans("NewSMSing"); } - $newmenu->add("/comm/mailing/index.php?leftmenu=mailing", $titleindex, 0, $user->hasRight('mailing', 'lire'), '', $mainmenu, 'mailing', 15, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/comm/mailing/card.php?leftmenu=mailing&action=create", $titlenew, 1, $user->hasRight('mailing', 'creer')); - $newmenu->add("/comm/mailing/list.php?leftmenu=mailing", $titlelist, 1, $user->hasRight('mailing', 'lire')); + $newmenu->add(dolBuildUrl('/comm/mailing/index.php', ['leftmenu' => 'mailing']), $titleindex, 0, $user->hasRight('mailing', 'lire'), '', $mainmenu, 'mailing', 15, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/comm/mailing/card.php', ['leftmenu' => 'mailing', 'action' => 'create']), $titlenew, 1, $user->hasRight('mailing', 'creer')); + $newmenu->add(dolBuildUrl('/comm/mailing/list.php', ['leftmenu' => 'mailing']), $titlelist, 1, $user->hasRight('mailing', 'lire')); } $title = "ImportExportArea"; @@ -2581,9 +2581,9 @@ function get_left_menu_tools($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu } if (isModEnabled('import') || isModEnabled('export')) { $langs->load("exports"); - $newmenu->add("/imports/index.php?leftmenu=import", $langs->trans($title), 0, (int) ($user->hasRight('import', 'run') || $user->hasRight('export', 'lire')), '', $mainmenu, 'import', 20, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/imports/import.php?leftmenu=import", $langs->trans("NewImport"), 1, $user->hasRight('import', 'run')); - $newmenu->add("/exports/export.php?leftmenu=export", $langs->trans("NewExport"), 1, $user->hasRight('export', 'lire')); + $newmenu->add(dolBuildUrl('/imports/index.php', ['leftmenu' => 'import']), $langs->trans($title), 0, (int) ($user->hasRight('import', 'run') || $user->hasRight('export', 'lire')), '', $mainmenu, 'import', 20, '', '', '', img_picto('', 'technic', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/imports/import.php', ['leftmenu' => 'import']), $langs->trans("NewImport"), 1, $user->hasRight('import', 'run')); + $newmenu->add(dolBuildUrl('/exports/export.php', ['leftmenu' => 'export']), $langs->trans("NewExport"), 1, $user->hasRight('export', 'lire')); } /* if (isModEnabled('export')) { @@ -2592,7 +2592,7 @@ function get_left_menu_tools($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu $newmenu->add("/exports/export.php?leftmenu=export", $langs->trans("NewExport"), 1, $user->hasRight('export', 'lire')); } */ - $newmenu->add("/core/customreports.php?leftmenu=customreports", $langs->trans("BICustomReports"), 0, 1, '', $mainmenu, 'customreports', 100, '', '', '', img_picto('', 'graph', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/core/customreports.php', ['leftmenu' => 'customreports']), $langs->trans("BICustomReports"), 0, 1, '', $mainmenu, 'customreports', 100, '', '', '', img_picto('', 'graph', 'class="paddingright pictofixedwidth"')); } } @@ -2615,37 +2615,37 @@ function get_left_menu_members($mainmenu, &$newmenu, $usemenuhider = 1, $leftmen // Load translation files required by the page $langs->loadLangs(array("members", "compta")); - $newmenu->add("/adherents/index.php?leftmenu=members&mainmenu=members", $langs->trans("Members"), 0, $user->hasRight('adherent', 'read'), '', $mainmenu, 'members', 0, '', '', '', img_picto('', 'member', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/adherents/card.php?leftmenu=members&action=create", $langs->trans("NewMember"), 1, $user->hasRight('adherent', 'write')); - $newmenu->add("/adherents/list.php?leftmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'read')); - $newmenu->add("/adherents/list.php?leftmenu=members&statut=-1", $langs->trans("MenuMembersToValidate"), 2, $user->hasRight('adherent', 'read')); - $newmenu->add("/adherents/list.php?leftmenu=members&statut=1", $langs->trans("MenuMembersValidated"), 2, $user->hasRight('adherent', 'read')); - $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=waitingsubscription", $langs->trans("WaitingSubscription"), 3, $user->hasRight('adherent', 'read')); - $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=uptodate", $langs->trans("UpToDate"), 3, $user->hasRight('adherent', 'read')); - $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=outofdate", $langs->trans("OutOfDate"), 3, $user->hasRight('adherent', 'read')); - $newmenu->add("/adherents/list.php?leftmenu=members&statut=0", $langs->trans("MenuMembersResiliated"), 2, $user->hasRight('adherent', 'read')); - $newmenu->add("/adherents/list.php?leftmenu=members&statut=-2", $langs->trans("MenuMembersExcluded"), 2, $user->hasRight('adherent', 'read')); - $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->hasRight('adherent', 'read')); + $newmenu->add(dolBuildUrl('/adherents/index.php', ['leftmenu' => 'members', 'mainmenu' => 'members']), $langs->trans("Members"), 0, $user->hasRight('adherent', 'read'), '', $mainmenu, 'members', 0, '', '', '', img_picto('', 'member', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/adherents/card.php', ['leftmenu' => 'members', 'action' => 'create']), $langs->trans("NewMember"), 1, $user->hasRight('adherent', 'write')); + $newmenu->add(dolBuildUrl('/adherents/list.php', ['leftmenu' => 'members']), $langs->trans("List"), 1, $user->hasRight('adherent', 'read')); + $newmenu->add(dolBuildUrl('/adherents/list.php', ['leftmenu' => 'members', 'statut' => -1]), $langs->trans("MenuMembersToValidate"), 2, $user->hasRight('adherent', 'read')); + $newmenu->add(dolBuildUrl('/adherents/list.php', ['leftmenu' => 'members', 'statut' => 1]), $langs->trans("MenuMembersValidated"), 2, $user->hasRight('adherent', 'read')); + $newmenu->add(dolBuildUrl('/adherents/list.php', ['leftmenu' => 'members', 'statut' => 1, 'filter' => 'waitingsubscription']), $langs->trans("WaitingSubscription"), 3, $user->hasRight('adherent', 'read')); + $newmenu->add(dolBuildUrl('/adherents/list.php', ['leftmenu' => 'members', 'statut' => 1, 'filter' => 'uptodate']), $langs->trans("UpToDate"), 3, $user->hasRight('adherent', 'read')); + $newmenu->add(dolBuildUrl('/adherents/list.php', ['leftmenu' => 'members', 'statut' => 1, 'filter' => 'outofdate']), $langs->trans("OutOfDate"), 3, $user->hasRight('adherent', 'read')); + $newmenu->add(dolBuildUrl('/adherents/list.php', ['leftmenu' => 'members', 'statut' => 0]), $langs->trans("MenuMembersResiliated"), 2, $user->hasRight('adherent', 'read')); + $newmenu->add(dolBuildUrl('/adherents/list.php', ['leftmenu' => 'members', 'statut' => -2]), $langs->trans("MenuMembersExcluded"), 2, $user->hasRight('adherent', 'read')); + $newmenu->add(dolBuildUrl('/adherents/stats/index.php', ['leftmenu' => 'members']), $langs->trans("MenuMembersStats"), 1, $user->hasRight('adherent', 'read')); - $newmenu->add("/adherents/cartes/carte.php?leftmenu=export", $langs->trans("MembersCards"), 1, $user->hasRight('adherent', 'export')); + $newmenu->add(dolBuildUrl('/adherents/cartes/carte.php', ['leftmenu' => 'export']), $langs->trans("MembersCards"), 1, $user->hasRight('adherent', 'export')); if (isModEnabled('category') && getDolGlobalString('CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP')) { $langs->load("categories"); - $newmenu->add("/categories/categorie_list.php?leftmenu=cat&type=3", $langs->trans("Categories"), 1, $user->hasRight('categorie', 'read'), '', $mainmenu, 'cat'); + $newmenu->add(dolBuildUrl('/categories/categorie_list.php', ['leftmenu'=> 'cat', 'type' => 3]), $langs->trans("Categories"), 1, $user->hasRight('categorie', 'read'), '', $mainmenu, 'cat'); } - $newmenu->add("/adherents/index.php?leftmenu=members&mainmenu=members", $langs->trans("Subscriptions"), 0, $user->hasRight('adherent', 'cotisation', 'read'), '', $mainmenu, 'members', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/adherents/list.php?leftmenu=members&statut=-1,1&mainmenu=members", $langs->trans("NewMembership"), 1, $user->hasRight('adherent', 'cotisation', 'write')); - $newmenu->add("/adherents/subscription/list.php?leftmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'cotisation', 'read')); - $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->hasRight('adherent', 'read')); + $newmenu->add(dolBuildUrl('/adherents/index.php', ['leftmenu' => 'members', 'mainmenu'=> 'members']), $langs->trans("Subscriptions"), 0, $user->hasRight('adherent', 'cotisation', 'read'), '', $mainmenu, 'members', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/adherents/list.php', ['leftmenu' => 'members', 'statut' => '-1,1', 'mainmenu' => 'members']), $langs->trans("NewMembership"), 1, $user->hasRight('adherent', 'cotisation', 'write')); + $newmenu->add(dolBuildUrl('/adherents/subscription/list.php', ['leftmenu' => 'members']), $langs->trans("List"), 1, $user->hasRight('adherent', 'cotisation', 'read')); + $newmenu->add(dolBuildUrl('/adherents/stats/index.php', ['leftmenu' => 'members']), $langs->trans("MenuMembersStats"), 1, $user->hasRight('adherent', 'read')); - //$newmenu->add("/adherents/index.php?leftmenu=export&mainmenu=members",$langs->trans("Tools"),0,$user->hasRight('adherent', 'export'), '', $mainmenu, 'export'); - //if (isModEnabled('export') && ($usemenuhider || empty($leftmenu) || $leftmenu=="export")) $newmenu->add("/exports/index.php?leftmenu=export",$langs->trans("Datas"),1,$user->hasRight('adherent', 'export')); + // $newmenu->add(dolBuildUrl('/adherents/index.php', ['leftmenu' => 'export', 'mainmenu'=>'members']),$langs->trans("Tools"),0,$user->hasRight('adherent', 'export'), '', $mainmenu, 'export'); + // if (isModEnabled('export') && ($usemenuhider || empty($leftmenu) || $leftmenu=="export")) $newmenu->add(dolBuildUrl('/exports/index.php', ['leftmenu' => 'export']),$langs->trans("Datas"),1,$user->hasRight('adherent', 'export')); // Type - $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members", $langs->trans("MembersTypes"), 0, $user->hasRight('adherent', 'configurer'), '', $mainmenu, 'setup', 0, '', '', '', img_picto('', 'members', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members&action=create", $langs->trans("New"), 1, $user->hasRight('adherent', 'configurer')); - $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members", $langs->trans("List"), 1, $user->hasRight('adherent', 'configurer')); + $newmenu->add(dolBuildUrl('/adherents/type.php', ['leftmenu' => 'setup', 'mainmenu' => 'members']), $langs->trans("MembersTypes"), 0, $user->hasRight('adherent', 'configurer'), '', $mainmenu, 'setup', 0, '', '', '', img_picto('', 'members', 'class="paddingright pictofixedwidth"')); + $newmenu->add(dolBuildUrl('/adherents/type.php', ['leftmenu' => 'setup', 'mainmenu' => 'members', 'action' => 'create']), $langs->trans("New"), 1, $user->hasRight('adherent', 'configurer')); + $newmenu->add(dolBuildUrl('/adherents/type.php', ['leftmenu' => 'setup', 'mainmenu' => 'members']), $langs->trans("List"), 1, $user->hasRight('adherent', 'configurer')); } } } diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 51e9c738bf6..b8545bae395 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -1,9 +1,9 @@ - * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024-2025 MDW +/* Copyright (C) 2010-2012 Laurent Destailleur + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2018-2025 Frédéric France + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -113,21 +113,21 @@ class doc_generic_user_odt extends ModelePDFUser $odtChosen = getDolGlobalInt('MAIN_PROPAL_CHOOSE_ODT_DOCUMENT') > 0; $odtPath = trim(getDolGlobalString('USER_ADDON_PDF_ODT_PATH')); - $texte = $this->description.".
\n"; - $texte .= '
'; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; + $out = $this->description.".
\n"; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; if ($odtChosen) { - $texte .= ''; - $texte .= ''; - $texte .= ''; + $out .= ''; + $out .= ''; + $out .= ''; } - $texte .= ''; + $out .= '
'; // List of directories area - $texte .= ''; + $out .= '"; + $out .= '
'; + $out .= '
'; $texttitle = $langs->trans("ListOfDirectories"); $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath)); $listoffiles = array(); @@ -155,71 +155,71 @@ class doc_generic_user_odt extends ModelePDFUser // Scan directories if (count($listofdir)) { - $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + $out .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; if ($odtChosen) { // Model for creation $list = ModelePDFUser::liste_modeles($this->db); - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= '"; + $out .= '
'.$langs->trans("DefaultModelPropalCreate").''; - $texte .= $form->selectarray('value2', $list, getDolGlobalString('USER_ADDON_PDF_ODT_DEFAULT')); - $texte .= "
'; + $out .= ''; + $out .= ''; + $out .= '"; - $texte .= ''; - $texte .= ''; - $texte .= '"; - $texte .= ''; + $out .= ''; + $out .= ''; + $out .= '"; + $out .= ''; - $texte .= ''; - $texte .= '"; - $texte .= '
'.$langs->trans("DefaultModelPropalCreate").''; + $out .= $form->selectarray('value2', $list, getDolGlobalString('USER_ADDON_PDF_ODT_DEFAULT')); + $out .= "
'.$langs->trans("DefaultModelPropalToBill").''; - $texte .= $form->selectarray('value3', $list, getDolGlobalString('USER_ADDON_PDF_ODT_TOBILL')); - $texte .= "
'.$langs->trans("DefaultModelPropalToBill").''; + $out .= $form->selectarray('value3', $list, getDolGlobalString('USER_ADDON_PDF_ODT_TOBILL')); + $out .= "
'.$langs->trans("DefaultModelPropalClosed").''; - $texte .= $form->selectarray('value4', $list, getDolGlobalString('USER_ADDON_PDF_ODT_CLOSED')); - $texte .= "
'; + $out .= '
'.$langs->trans("DefaultModelPropalClosed").''; + $out .= $form->selectarray('value4', $list, getDolGlobalString('USER_ADDON_PDF_ODT_CLOSED')); + $out .= "
'; } - $texte .= '
'; } - $texte .= '
'; - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); - $texte .= '
'; - $texte .= ''; - $texte .= '
'; - $texte .= ''; - $texte .= '
'; + $out .= '
'; + $out .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); + $out .= '
'; + $out .= ''; + $out .= '
'; + $out .= ''; + $out .= '
'; // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate"); + $out .= '
'.$langs->trans("UploadNewTemplate"); $maxfilesizearray = getMaxFileSizeArray(); $maxmin = $maxfilesizearray['maxmin']; if ($maxmin > 0) { - $texte .= ''; // MAX_FILE_SIZE must precede the field type=file + $out .= ''; // MAX_FILE_SIZE must precede the field type=file } - $texte .= ' '; - $texte .= ''; - $texte .= ''; - $texte .= '
'; + $out .= ' '; + $out .= ''; + $out .= ''; + $out .= '
'; - $texte .= ''; + $out .= ''; - $texte .= ''; + $out .= ''; - $texte .= ''; - $texte .= '
'; + $out .= ''; + $out .= ''; - return $texte; + return $out; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index ed0aeadd769..201f049e891 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -434,7 +434,6 @@ class EmailCollector extends CommonObject foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { - //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } } @@ -1002,7 +1001,6 @@ class EmailCollector extends CommonObject $regexoptions = 'm'; // The m means ^ and $ char is valid at each new line. } - //var_dump($tmpproperty.' - '.$regexstring.' - '.$regexoptions.' - '.$sourcestring); if (preg_match('/'.$regexstring.'/'.$regexoptions, $sourcestring, $regforval)) { // Overwrite param $tmpproperty $valueextracted = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; @@ -1073,7 +1071,6 @@ class EmailCollector extends CommonObject complete_substitutions_array($substitutionarray, $outputlangs, $object); $matcharray = array(); preg_match_all('/__([a-z0-9]+(?:_[a-z0-9]+)?)__/i', $valuetouse, $matcharray); - //var_dump($tmpproperty.' - '.$object->$tmpproperty.' - '.$valuetouse); var_dump($matcharray); if (is_array($matcharray[1])) { // $matcharray[1] is an array with the list of substitution key found without the __X__ syntax into the SET entry foreach ($matcharray[1] as $keytoreplace) { if ($keytoreplace) { @@ -1090,8 +1087,7 @@ class EmailCollector extends CommonObject } } } - //var_dump($substitutionarray); - //dol_syslog('substitutionarray='.var_export($substitutionarray, true)); + // dol_syslog('substitutionarray='.var_export($substitutionarray, true)); $valuetouse = make_substitutions($valuetouse, $substitutionarray); if (preg_match('/^options_/', $tmpproperty)) { @@ -1634,7 +1630,6 @@ class EmailCollector extends CommonObject } dol_syslog("IMAP search string = ".$search); - //var_dump($search); } $nbemailprocessed = 0; @@ -1686,13 +1681,11 @@ class EmailCollector extends CommonObject '@phan-var-force Webklex\PHPIMAP\Query\Query $Query'; try { - //var_dump($Query->count()); if ($mode > 0) { $Query->leaveUnread(); } $arrayofemail = $Query->limit($this->maxemailpercollect)->setFetchOrder("asc")->get(); dol_syslog("EmailCollector::doCollectOneCollector nb arrayofemail ".(is_array($arrayofemail) ? count($arrayofemail) : 'Not array')); // @phpstan-ignore-line - //var_dump($arrayofemail); } catch (Exception $e) { $this->error = $e->getMessage(); $this->errors[] = $this->error; @@ -1797,8 +1790,6 @@ class EmailCollector extends CommonObject } else { $emailto = $this->decodeSMTPSubject($overview[0]->to); } - //var_dump($headers); - //var_dump($overview);exit; $operationslog .= '
** Process email #'.dol_escape_htmltag((string) $iforemailloop); @@ -1979,9 +1970,7 @@ class EmailCollector extends CommonObject $this->getmsg($connection, $imapemail); // This set global var $charset, $htmlmsg, $plainmsg, $attachments } '@phan-var-force Webklex\PHPIMAP\Attachment[] $attachments'; - - //print $plainmsg; - //var_dump($plainmsg); exit; + /** @var Webklex\PHPIMAP\Attachment[] $attachments */ //$htmlmsg,$plainmsg,$charset,$attachments $messagetext = $plainmsg ? $plainmsg : dol_string_nohtmltag((string) $htmlmsg, 0); @@ -2006,13 +1995,6 @@ class EmailCollector extends CommonObject } } - //var_dump($plainmsg); - //var_dump($htmlmsg); - //var_dump($messagetext); - //var_dump($charset); - //var_dump($attachments); - //exit; - // Parse IMAP email structure /* $structure = imap_fetchstructure($connection, $imapemail, FT_UID); @@ -2044,23 +2026,10 @@ class EmailCollector extends CommonObject } } } - //var_dump($result); - //var_dump($partplain); - //var_dump($parthtml); - - //var_dump($structure); - //var_dump($parthtml); - //var_dump($partplain); $messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK|FTP_UID); */ - //var_dump($messagetext); - //var_dump($structure->parts[0]->parts); - //print $header; - //print $messagetext; - //exit; - $fromstring = ''; $replytostring = ''; @@ -2098,7 +2067,6 @@ class EmailCollector extends CommonObject $sendtobcc = !empty($overview[0]->bcc) ? $overview[0]->bcc : ''; $dateemail = dol_stringtotime((string) $overview[0]->udate, 'gmt'); $subject = $overview[0]->subject; - //var_dump($msgid);exit; } if (!empty($searchfilterexcludesubjectarray)) { @@ -2155,8 +2123,6 @@ class EmailCollector extends CommonObject if (!in_array('<'.$msgid.'>', $arrayofreferences)) { $arrayofreferences = array_merge($arrayofreferences, array('<'.$msgid.'>')); } - // var_dump($headers['References']); - // var_dump($arrayofreferences); // We loop on References, but as soon as we found one that allow us to find an existing object, // we do a break (See line with comment "Exit loop of references"). @@ -2583,9 +2549,7 @@ class EmailCollector extends CommonObject if ($sourcestring) { $regforval = array(); - //var_dump($regexstring);var_dump($sourcestring); if (preg_match('/'.$regexstring.'/ms', $sourcestring, $regforval)) { - //var_dump($regforval[count($regforval)-1]);exit; // Overwrite param $tmpproperty if ($propertytooverwrite == 'id') { $idtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; @@ -2619,7 +2583,6 @@ class EmailCollector extends CommonObject $operationslog .= '
propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Not found'; } } - //var_dump($object->$tmpproperty);exit; } else { // Nothing can be done for this param $errorforactions++; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c7392377d89..4f0a22138b4 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -175,11 +175,11 @@ if (getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')) { if (session_id() && isset($_SESSION["dol_login"]) && !in_array($_SESSION["dol_login"], explode(';', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')))) { print 'Sorry, your application is offline.'."\n"; print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator users (' . str_replace(';', ', ', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')).') is allowed to connect for the moment.'."\n"; - $nexturl = DOL_URL_ROOT.'/user/logout.php?token='.newToken(); + $nexturl = dolBuildUrl(DOL_URL_ROOT . '/user/logout.php', [], true); print 'Please try later or click here to disconnect and change login user...'."\n"; } else { print 'Sorry, your application is offline. Only administrator users (' . str_replace(';', ', ', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')).') is allowed to connect for the moment.'."\n"; - $nexturl = DOL_URL_ROOT.'/'; + $nexturl = dolBuildUrl(DOL_URL_ROOT . '/'); print 'Please try later or click here to change login user...'."\n"; } exit; @@ -536,13 +536,23 @@ if (!defined('NOLOGIN')) { if (!empty($dolibarr_main_demo) && $_SERVER['PHP_SELF'] == DOL_URL_ROOT.'/index.php') { // We ask index page if (empty($_SERVER['HTTP_REFERER']) || !preg_match('/public/', $_SERVER['HTTP_REFERER'])) { dol_syslog("Call index page from another url than demo page (call is done from page ".(empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']).")"); - $url = ($dol_hide_topmenu ? 'dol_hide_topmenu='.$dol_hide_topmenu : ''); - $url .= ($url ? '&' : '').($dol_hide_leftmenu ? 'dol_hide_leftmenu='.$dol_hide_leftmenu : ''); - $url .= ($url ? '&' : '').($dol_optimize_smallscreen ? 'dol_optimize_smallscreen='.$dol_optimize_smallscreen : ''); - $url .= ($url ? '&' : '').($dol_no_mouse_hover ? 'dol_no_mouse_hover='.$dol_no_mouse_hover : ''); - $url .= ($url ? '&' : '').($dol_use_jmobile ? 'dol_use_jmobile='.$dol_use_jmobile : ''); - $url = DOL_URL_ROOT.'/public/demo/index.php'.($url ? '?'.$url : ''); - header("Location: ".$url); + $query = []; + if ($dol_hide_topmenu) { + $query += ['dol_hide_topmenu' => $dol_hide_topmenu]; + } + if ($dol_hide_leftmenu) { + $query += ['dol_hide_leftmenu' => $dol_hide_leftmenu]; + } + if ($dol_optimize_smallscreen) { + $query += ['dol_optimize_smallscreen' => $dol_optimize_smallscreen]; + } + if ($dol_no_mouse_hover) { + $query += ['dol_no_mouse_hover='.$dol_no_mouse_hover]; + } + if ($dol_use_jmobile) { + $query += ['dol_use_jmobile='.$dol_use_jmobile]; + } + header("Location: " . dolBuildUrl(DOL_URL_ROOT . '/public/demo/index.php', $query)); exit; } } @@ -839,17 +849,17 @@ if (!defined('NOLOGIN')) { $error++; } - $paramsurl = array(); + $paramsurl = []; if (GETPOSTINT('textbrowser')) { - $paramsurl[] = 'textbrowser='.GETPOSTINT('textbrowser'); + $paramsurl += ['textbrowser' => GETPOSTINT('textbrowser')]; } if (GETPOSTINT('nojs')) { - $paramsurl[] = 'nojs='.GETPOSTINT('nojs'); + $paramsurl += ['nojs' => GETPOSTINT('nojs')]; } if (GETPOST('lang', 'aZ09')) { - $paramsurl[] = 'lang='.GETPOST('lang', 'aZ09'); + $paramsurl += ['lang' => (string) GETPOST('lang', 'aZ09')]; } - header('Location: '.DOL_URL_ROOT.'/index.php'.(count($paramsurl) ? '?'.implode('&', $paramsurl) : '')); + header('Location: '.dolBuildUrl(DOL_URL_ROOT . '/index.php', $paramsurl)); exit; } else { // User is loaded, we may need to change language for him according to its choice @@ -2176,7 +2186,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead // Link to module builder if (isModEnabled('modulebuilder')) { - $text = ''; + $text = ''; //$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"'); $text .= ''; $text .= ''; @@ -2456,7 +2466,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') } if (empty($urllogout)) { - $urllogout = DOL_URL_ROOT.'/user/logout.php?token='.newToken(); + $urllogout = dolBuildUrl(DOL_URL_ROOT . '/user/logout.php', [], true); } // accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 24ad4c37b86..9ee15befbb3 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -189,7 +189,7 @@ class MyObject extends CommonObject public $fk_user_creat; /** - * @var int ID + * @var ?int ID */ public $fk_user_modif; @@ -835,8 +835,8 @@ class MyObject extends CommonObject $label = implode($this->getTooltipContentArray($params)); } - $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id; - + $baseurl = dol_buildpath('/mymodule/myobject_card.php', 1); + $query = ['id' => $this->id]; if ($option !== 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); @@ -844,9 +844,10 @@ class MyObject extends CommonObject $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } } + $url = dolBuildUrl($baseurl, $query); $linkclose = ''; if (empty($notooltip)) { diff --git a/htdocs/modulebuilder/template/lib/mymodule.lib.php b/htdocs/modulebuilder/template/lib/mymodule.lib.php index 8e1b911fd66..11aa36a4d76 100644 --- a/htdocs/modulebuilder/template/lib/mymodule.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule.lib.php @@ -1,5 +1,6 @@ * * 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 @@ -39,13 +40,13 @@ function mymoduleAdminPrepareHead() $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/mymodule/admin/setup.php", 1); + $head[$h][0] = dolBuildUrl(dol_buildpath("/mymodule/admin/setup.php", 1)); $head[$h][1] = $langs->trans("Settings"); $head[$h][2] = 'settings'; $h++; /* - $head[$h][0] = dol_buildpath("/mymodule/admin/myobject_extrafields.php", 1); + $head[$h][0] = dolBuildUrl(dol_buildpath("/mymodule/admin/myobject_extrafields.php", 1)); $head[$h][1] = $langs->trans("ExtraFields"); $nbExtrafields = (isset($extrafields->attributes['myobject']['label']) && is_countable($extrafields->attributes['myobject']['label'])) ? count($extrafields->attributes['myobject']['label']) : 0; if ($nbExtrafields > 0) { @@ -54,7 +55,7 @@ function mymoduleAdminPrepareHead() $head[$h][2] = 'myobject_extrafields'; $h++; - $head[$h][0] = dol_buildpath("/mymodule/admin/myobjectline_extrafields.php", 1); + $head[$h][0] = dolBuildUrl(dol_buildpath("/mymodule/admin/myobjectline_extrafields.php", 1)); $head[$h][1] = $langs->trans("ExtraFieldsLines"); $nbExtrafields = (isset($extrafields->attributes['myobjectline']['label']) && is_countable($extrafields->attributes['myobjectline']['label'])) ? count($extrafields->attributes['myobject']['label']) : 0; if ($nbExtrafields > 0) { @@ -64,7 +65,7 @@ function mymoduleAdminPrepareHead() $h++; */ - $head[$h][0] = dol_buildpath("/mymodule/admin/about.php", 1); + $head[$h][0] = dolBuildUrl(dol_buildpath("/mymodule/admin/about.php", 1)); $head[$h][1] = $langs->trans("About"); $head[$h][2] = 'about'; $h++; diff --git a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php index 7c1976ddf29..62178c3f0c3 100644 --- a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php @@ -42,13 +42,13 @@ function myobjectPrepareHead($object) $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/mymodule/myobject_card.php", 1).'?id='.$object->id; + $head[$h][0] = dolBuildUrl(dol_buildpath("/mymodule/myobject_card.php", 1), ['id' => $object->id]); $head[$h][1] = $langs->trans("MyObject"); $head[$h][2] = 'card'; $h++; if ($showtabofpagecontact) { - $head[$h][0] = dol_buildpath("/mymodule/myobject_contact.php", 1).'?id='.$object->id; + $head[$h][0] = dolBuildUrl(dol_buildpath("/mymodule/myobject_contact.php", 1), ['id' => $object->id]); $head[$h][1] = $langs->trans("Contacts"); $head[$h][2] = 'contact'; $h++; @@ -63,7 +63,7 @@ function myobjectPrepareHead($object) if (!empty($object->note_public)) { $nbNote++; } - $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id; + $head[$h][0] = dolBuildUrl(dol_buildpath('/mymodule/myobject_note.php', 1), ['id' => $object->id]); $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) { $head[$h][1] .= (!getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') ? ''.$nbNote.'' : ''); @@ -79,7 +79,7 @@ function myobjectPrepareHead($object) $upload_dir = $conf->mymodule->dir_output."/myobject/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id; + $head[$h][0] = dolBuildUrl(dol_buildpath("/mymodule/myobject_document.php", 1), ['id' => $object->id]); $head[$h][1] = $langs->trans('Documents'); if (($nbFiles + $nbLinks) > 0) { $head[$h][1] .= ''.($nbFiles + $nbLinks).''; @@ -89,7 +89,7 @@ function myobjectPrepareHead($object) } if ($showtabofpageagenda) { - $head[$h][0] = dol_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id; + $head[$h][0] = dolBuildUrl(dol_buildpath("/mymodule/myobject_agenda.php", 1), ['id' => $object->id]); $head[$h][1] = $langs->trans("Events"); $head[$h][2] = 'agenda'; $h++; diff --git a/htdocs/product/class/productfournisseurprice.class.php b/htdocs/product/class/productfournisseurprice.class.php index db5cc124807..87c1816af2c 100644 --- a/htdocs/product/class/productfournisseurprice.class.php +++ b/htdocs/product/class/productfournisseurprice.class.php @@ -354,8 +354,6 @@ class ProductFournisseurPrice extends CommonObject foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { - //var_dump($key); - //var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } } diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 3e3782b5517..f75e327b3e6 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -322,8 +322,6 @@ class RecruitmentCandidature extends CommonObject foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { - //var_dump($key); - //var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 100d8262bb8..b53f66ed67f 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3161,11 +3161,11 @@ class User extends CommonObject $label = ''; } - $url = DOL_URL_ROOT.'/user/card.php?id='.$this->id; + $baseurl = DOL_URL_ROOT . '/user/card.php'; if ($option == 'leave') { - $url = DOL_URL_ROOT.'/holiday/list.php?id='.$this->id; + $baseurl = DOL_URL_ROOT . '/holiday/list.php'; } - + $query = ['id' => $this->id]; if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); @@ -3173,9 +3173,10 @@ class User extends CommonObject $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } } + $url = dolBuildUrl($baseurl, $query); $linkstart = 'id; + $baseurl = DOL_URL_ROOT.'/user/group/perms.php'; } else { - $url = DOL_URL_ROOT.'/user/group/card.php?id='.$this->id; + $baseurl = DOL_URL_ROOT.'/user/group/card.php'; } + $query = ['id' => $this->id]; if ($option != 'nolink') { // Add param to save lastsearch_values or not @@ -859,9 +860,10 @@ class UserGroup extends CommonObject $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } } + $url = dolBuildUrl($baseurl, $query); $linkclose = ""; if (empty($notooltip)) {