From 3aac23734fc74d90402d5df17170f107354767d2 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 9 Nov 2022 16:13:51 +0100 Subject: [PATCH 1/9] New : expand/collapse user permission module --- htdocs/langs/en_US/users.lang | 2 ++ htdocs/user/perms.php | 63 ++++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 3f2c7f5f53a..757e9f1dedf 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -127,3 +127,5 @@ DateLastLogin=Date last login DatePreviousLogin=Date previous login IPLastLogin=IP last login IPPreviousLogin=IP previous login +ShowAllPerms=Show all permission rows +HideAllPerms=Hide all permission rows diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 6dca3bdca83..a35baab0059 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -44,6 +44,7 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $module = GETPOST('module', 'alpha'); $rights = GETPOST('rights', 'int'); +$updatedmodulename = GETPOST('updatedmodulename', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userperms'; // To manage different context of search if (!isset($id) || empty($id)) { @@ -307,6 +308,13 @@ if ($reshook < 0) { } +print "\n"; +print '
'; +print ''.$langs->trans("ShowAllPerms").""; +print ' / '; +print ''.$langs->trans("HideAllPerms").""; +print '
'; + print "\n"; print '
'; print ''; @@ -469,17 +477,17 @@ if ($result) { $picto = ($objMod->picto ? $objMod->picto : 'generic'); // Show break line - print ''; + print ''; print ''; if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) { if ($caneditperms) { - print ''; } print ''; @@ -495,12 +503,14 @@ if ($result) { if ($user->admin) { print ''; } - + print ''; print ''."\n"; } print ''."\n"; - print ''; + print 'module && $module != "allmodules" ? ' style="display:none"' : '').'>'; // Picto and label of module print ''; } elseif (in_array($obj->id, $permsuser)) { // Permission granted by user if ($caneditperms) { - print ''; @@ -538,7 +548,7 @@ if ($result) { } else { // Do not own permission if ($caneditperms) { - print ''; @@ -548,7 +558,7 @@ if ($result) { } else { // Do not own permission if ($caneditperms) { - print ''; @@ -587,6 +597,41 @@ if ($result) { print '
'; print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); print ''; print ''; - print 'module.'&confirm=yes">'.$langs->trans("All").""; + print 'module && $module != "allmodules" ? ' style="display:none"' : '').'>'; + print 'module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("All").""; print ' / '; - print 'module.'&confirm=yes">'.$langs->trans("None").""; + print 'module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None").""; print ' module || $module == "allmodules" ? ' style="display:none"' : '').'>'; + print ' '; + print '
'; @@ -517,7 +527,7 @@ if ($result) { print 'id.'&confirm=yes">'; + print 'id.'&confirm=yes&updatedmodulename='.$obj->module.'">'; //print img_edit_remove($langs->trans("Remove")); print img_picto($langs->trans("Remove"), 'switch_on'); print 'id.'&confirm=yes&token='.newToken().'">'; + print 'id.'&confirm=yes&token='.newToken().'&updatedmodulename='.$obj->module.'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); print 'id.'&confirm=yes&token='.newToken().'">'; + print 'id.'&confirm=yes&token='.newToken().'&updatedmodulename='.$obj->module.'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); print '
'; print '
'; +print ''; + $parameters = array(); $reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { From 39774e4c87269e87d1ac7be893a5253172f2bc02 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 9 Nov 2022 21:03:38 +0100 Subject: [PATCH 2/9] Fix issue scrutinizer property default does not exist in /core/lib/functionsnumtoword.lib.php --- htdocs/core/lib/functionsnumtoword.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php index 6de1e69de1f..9295a6061c0 100644 --- a/htdocs/core/lib/functionsnumtoword.lib.php +++ b/htdocs/core/lib/functionsnumtoword.lib.php @@ -187,7 +187,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') /*In dolibarr 3.6.2 (my current version) doesn't have $langs->default and in case exist why ask $lang like a parameter?*/ - if (((is_object($langs) && $langs->default == 'es_MX') || (!is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency') { + if (((is_object($langs) && $langs->getDefaultLang(1) == 'es_MX') || (!is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency') { if ($numero >= 1 && $numero < 2) { return ("UN PESO ".$parte_decimal." / 100 M.N."); } elseif ($numero >= 0 && $numero < 1) { From cdcd54e6fe4b21c8257575f2650ebe371431a083 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 9 Nov 2022 22:40:53 +0100 Subject: [PATCH 3/9] Fix issue scrutinizer in htdocs/core/lib/project.lib.php --- htdocs/core/lib/project.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 062c3f711af..56079824f7c 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1124,9 +1124,9 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec $projectstatic->ref = $lines[$i]->project_ref; $projectstatic->title = $lines[$i]->project_label; $projectstatic->public = $lines[$i]->public; - $projectstatic->status = $lines[$i]->project_status; + $projectstatic->status = $lines[$i]->project->status; - $taskstatic->id = $lines[$i]->task_id; + $taskstatic->id = $lines[$i]->fk_statut; $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id); $taskstatic->label = $lines[$i]->task_label; $taskstatic->date_start = $lines[$i]->date_start; From 213c23275ce01cee6a3a837136065623d8d3edbb Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 10 Nov 2022 12:15:06 +0100 Subject: [PATCH 4/9] Fix issue scrutinizer change varible modepaimentid by modepaymentid and ->modepayement by --- htdocs/core/modules/dons/html_cerfafr.modules.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 792c8434ba4..83c2504be3d 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -120,18 +120,18 @@ class html_cerfafr extends ModeleDon // This is not the proper way to do it but $formclass->form_modes_reglement // prints the translation instead of returning it - if ($don->modepaiementid) { - $formclass->load_cache_types_paiements(); - $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label']; + $formclass->load_cache_types_paiements(); + if ($don->modepaymentid) { + $paymentmode = $formclass->cache_types_paiements[$don->modepaymentid]['label']; } else { $paymentmode = ''; } - - if ($don->modepaymentcode == 'CHQ') { + $modepaymentcode = $formclass->cache_types_paiements[$don->modepaymentid]['code']; + if ($modepaymentcode == 'CHQ') { $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; - } elseif ($don->modepaymentcode == 'LIQ') { + } elseif ($modepaymentcode == 'LIQ') { $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; - } elseif ($don->modepaymentcode == 'VIR' || $don->modepaymentcode == 'PRE' || $don->modepaymentcode == 'CB') { + } elseif ($modepaymentcode == 'VIR' || $modepaymentcode == 'PRE' || $modepaymentcode == 'CB') { $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; } else { $ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire'; From 4e439c76ed72e5faa7e06035f4a1f6401438a9d4 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 10 Nov 2022 13:36:28 +0100 Subject: [PATCH 5/9] Fix issue for variable total_vat to total_tva --- .../modules/product/doc/doc_generic_product_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 94d511367e2..821b6a24e10 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -334,7 +334,7 @@ class doc_generic_product_odt extends ModelePDFProduct '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook From e1ada1f39757eebbc4de0da7dfbb3ac030c1204a Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 10 Nov 2022 13:46:52 +0100 Subject: [PATCH 6/9] Fix issue scrutinizer in doc_generic_project_odt --- .../modules/project/doc/doc_generic_project_odt.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 8b1261f35f0..4e8be5f6389 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -134,8 +134,8 @@ class doc_generic_project_odt extends ModelePDFProjects // Get source company $this->emetteur = $mysoc; - if (!$this->emetteur->pays_code) { - $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini } } From 9a435a1f1bde3eb3e34c653ed813b54d8e9f09d3 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 10 Nov 2022 14:19:29 +0100 Subject: [PATCH 7/9] Update perms.php --- htdocs/user/perms.php | 88 +++++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index a35baab0059..8f7d152e73a 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -268,7 +268,7 @@ print '
'; print ''; // Login -print ''; +print ''; if (!empty($object->ldap_sid) && $object->statut == 0) { print '
'.$langs->trans("Login").'
'.$langs->trans("Login").''; print $langs->trans("LoginAccountDisableInDolibarr"); @@ -307,14 +307,6 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - -print "\n"; -print '
'; -print ''.$langs->trans("ShowAllPerms").""; -print ' / '; -print ''.$langs->trans("HideAllPerms").""; -print '
'; - print "\n"; print '
'; print ''; @@ -328,13 +320,22 @@ if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->ad print ' / '; print ''.$langs->trans("None").""; print ''; + } else { + print ''; } print ''; +} else { + print ''; + print ''; } + print ''; -if ($user->admin) { - print ''; -} +print ''; + print ''."\n"; @@ -477,7 +478,7 @@ if ($result) { $picto = ($objMod->picto ? $objMod->picto : 'generic'); // Show break line - print ''; + print ''; print ''; + print ''; + } else { + print ''; } print ''; } else { if ($caneditperms) { - print ''; + print ''; + print ''; + } else { + print ''; } print ''; } print ''; - // Permission id - if ($user->admin) { - print ''; - } - print ''; + print ''; //Add picto + / - when open en closed print ''."\n"; } @@ -521,6 +533,8 @@ if ($result) { if (!empty($object->admin) && !empty($objMod->rights_admin_allowed)) { // Permission granted because admin if ($caneditperms) { print ''; + } else { + print ''; } print ''; + } else { + print ''; } print ''; + } else { + print ''; } print ''; + } else { + print ''; } print ''; } @@ -562,13 +582,19 @@ if ($result) { //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); print ''; + } else { + print ''; } print ''; } // Description of permission $permlabel = (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); - print '
    '.$langs->trans("Permissions").''; +print ''.img_picto('', 'folder-open', 'class="paddingright"').''.$langs->trans("ExpandAll").''; +print ' | '; +print ''.img_picto('', 'folder', 'class="paddingright"').''.$langs->trans("UndoExpandAll").''; +print '
'; print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); print ''; @@ -489,23 +490,34 @@ if ($result) { print ' / '; print 'module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None").""; print 'module || $module == "allmodules" ? ' style="display:none"' : '').'>    module && $module != "allmodules" ? ' style="display:none"' : '').'>'; + print 'module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("All").""; + print ' / '; + print 'module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None").""; + print 'module || $module == "allmodules" ? ' style="display:none"' : '').'>   module || $module == "allmodules" ? ' style="display:none"' : '').'>'; - print ' '; - print ''; + print '
'; + print img_picto('', 'folder', 'class="marginright"'); + print '
'; + print ''; + print '
'.img_picto($langs->trans("Administrator"), 'star').' '; print img_picto($langs->trans("Active"), 'tick'); @@ -531,6 +545,8 @@ if ($result) { //print img_edit_remove($langs->trans("Remove")); print img_picto($langs->trans("Remove"), 'switch_on'); print ' '; print img_picto($langs->trans("Active"), 'tick'); @@ -541,6 +557,8 @@ if ($result) { print ''; print $form->textwithtooltip($langs->trans("Inherited"), $langs->trans("PermissionInheritedFromAGroup")); print ' '; print img_picto($langs->trans("Active"), 'tick'); @@ -552,6 +570,8 @@ if ($result) { //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); print '    '; + if (!$user->admin) { + print ''; + } else { + print ''; + } print $permlabel; if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { if (preg_match('/_advance$/', $obj->perms)) { @@ -598,15 +624,20 @@ print '
'; print '
'; print ''; +print ''; + $parameters = array(); $reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { From 7b106e43d7afc6f80eea4cba179bf4ec5117fd3e Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Sat, 12 Nov 2022 19:35:01 +0100 Subject: [PATCH 8/9] FIX - php 8 warning function lib --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 90ce1a5b821..74e3afaa141 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1934,7 +1934,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab $out .= '
'; if (!empty($links[$i][0])) { $titletoshow = preg_replace('/<.*$/', '', $links[$i][1]); - $out .= ''; + $out .= ''; } $out .= $links[$i][1]; if (!empty($links[$i][0])) { From bed11989fa954e1a8728eea217c00062995dd4f2 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 14 Nov 2022 10:09:10 +0100 Subject: [PATCH 9/9] fix params function getDefaultLang 1 to 0 --- htdocs/core/lib/functionsnumtoword.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php index 9295a6061c0..36475e5385f 100644 --- a/htdocs/core/lib/functionsnumtoword.lib.php +++ b/htdocs/core/lib/functionsnumtoword.lib.php @@ -187,7 +187,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') /*In dolibarr 3.6.2 (my current version) doesn't have $langs->default and in case exist why ask $lang like a parameter?*/ - if (((is_object($langs) && $langs->getDefaultLang(1) == 'es_MX') || (!is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency') { + if (((is_object($langs) && $langs->getDefaultLang(0) == 'es_MX') || (!is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency') { if ($numero >= 1 && $numero < 2) { return ("UN PESO ".$parte_decimal." / 100 M.N."); } elseif ($numero >= 0 && $numero < 1) {