From 4bcc7a8f6322e316f45c6595f4325422bc665d8f Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 13 Mar 2023 16:24:19 +0100 Subject: [PATCH 01/15] fix : Fatal error: Uncaught TypeError: strlen(): Argument #1 () must be of type string, array given in /home/httpd/vhosts/aflac.fr/domains/dev.aflac.fr/httpdocs/core/class/extrafields.class.php on line 728 --- htdocs/core/class/extrafields.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5d91febc65d..2e2c91d16fc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -725,6 +725,8 @@ class ExtraFields if (is_array($param) && count($param) > 0) { $params = serialize($param); + } elseif (is_array($param)) { + $params = ''; } elseif (strlen($param) > 0) { $params = trim($param); } else { From 59af4d3dceddeb9e23aec0b10809eec65d5f4d48 Mon Sep 17 00:00:00 2001 From: hystepik Date: Tue, 14 Mar 2023 15:27:55 +0100 Subject: [PATCH 02/15] New : add convertion of images for single image --- htdocs/core/class/html.formfile.class.php | 20 +++++++++++++++++++- htdocs/core/tpl/filemanager.tpl.php | 21 +++++++++++++++++---- htdocs/langs/en_US/ecm.lang | 4 ++++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index f04914ad85b..215e729a278 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1445,7 +1445,25 @@ class FormFile if (in_array($modulepart, array('product', 'produit', 'service'))) { $newmodulepart = 'produit|service'; } - + if (image_format_supported($file['name']) > 0) { + if ($permtoeditline) { + $moreparaminurl = ''; + if (!empty($object->id) && $object->id > 0) { + $moreparaminurl .= '&id='.$object->id; + } elseif (GETPOST('website', 'alpha')) { + $moreparaminurl .= '&website='.GETPOST('website', 'alpha'); + } + // Set the backtourl + if ($modulepart == 'medias' && !GETPOST('website')) { + $moreparaminurl .= '&backtourl='.urlencode(DOL_URL_ROOT.'/ecm/index_medias.php?file_manager=1&modulepart='.$modulepart.'§ion_dir='.$relativepath); + } + if ($modulepart == 'medias' && !GETPOST('website')) { + print ''.img_picto('', 'images', 'class="flip marginrightonly"').''; + } elseif ($modulepart == 'medias' && GETPOST('website')) { + print ''.img_picto('', 'images', 'class="flip marginrightonly"').''; + } + } + } if (!$disablecrop && image_format_supported($file['name']) > 0) { if ($permtoeditline) { // Link to resize diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index b3edcb7984f..da73f5cd4b6 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -197,18 +197,22 @@ if ($action == 'confirmconvertimgwebp') { $section_dir=GETPOST('section_dir', 'alpha'); $section=GETPOST('section', 'alpha'); + $file=GETPOST('filetoregenerate', 'alpha'); $form = new Form($db); $formquestion['section_dir']=array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir'); $formquestion['section']=array('type'=>'hidden', 'value'=>$section, 'name'=>'section'); + $formquestion['filetoregenerate']=array('type'=>'hidden', 'value'=>$file, 'name'=>'filetoregenerate'); if ($module == 'medias') { $formquestion['website']=array('type'=>'hidden', 'value'=>$website->ref, 'name'=>'website'); } - print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('ConfirmImgWebpCreation'), $langs->trans('ConfirmGenerateImgWebp', $object->ref), 'convertimgwebp', $formquestion, "yes", 1); + print $form->formconfirm($_SERVER["PHP_SELF"], empty($file) ? $langs->trans('ConfirmImgWebpCreation') : $langs->trans('ConfirmChosenImgWebpCreation'), empty($file) ? $langs->trans('ConfirmGenerateImgWebp') : $langs->trans('ConfirmGenerateChosenImgWebp'), 'convertimgwebp', $formquestion, "yes", 1); $action = 'file_manager'; } // Duplicate images into .webp if ($action == 'convertimgwebp' && $permtoadd) { + $file = GETPOST('filetoregenerate', 'alpha'); + if ($module == 'medias') { $imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/'.dol_sanitizePathName(GETPOST('section_dir', 'alpha')); } else { @@ -217,9 +221,14 @@ if ($action == 'convertimgwebp' && $permtoadd) { include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $regeximgext = getListOfPossibleImageExt(); + if (!empty($file)) { + $filelist = array(); + $filelist[]["fullname"] = dol_osencode($imagefolder.'/'.$file); // get $imagefolder.'/'.$file infos + } else { + $regeximgext = getListOfPossibleImageExt(); - $filelist = dol_dir_list($imagefolder, "files", 0, $regeximgext); + $filelist = dol_dir_list($imagefolder, "files", 0, $regeximgext); + } $nbconverted = 0; @@ -245,7 +254,11 @@ if ($action == 'convertimgwebp' && $permtoadd) { } } if (!$error) { - setEventMessages($langs->trans('SucessConvertImgWebp'), null); + if (!empty($file)) { + setEventMessages($langs->trans('SucessConvertChosenImgWebp'), null); + } else { + setEventMessages($langs->trans('SucessConvertImgWebp'), null); + } } $action = 'file_manager'; } diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index 724e5aa59d7..2e88812681d 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -47,6 +47,10 @@ ECMSetup=ECM Setup GenerateImgWebp=Duplicate all images with another version with .webp format ConfirmGenerateImgWebp=If you confirm, you will generate an image in .webp format for all images currently into this folder (subfolders are not included)... ConfirmImgWebpCreation=Confirm all images duplication +GenerateChosenImgWebp=Duplicate chosen image with another version with .webp format +ConfirmGenerateChosenImgWebp=If you confirm, you will generate an image in .webp format for chosen image +ConfirmChosenImgWebpCreation=Confirm chosen images duplication SucessConvertImgWebp=Images successfully duplicated +SucessConvertChosenImgWebp=Chosen image successfully duplicated ECMDirName=Dir name ECMParentDirectory=Parent directory From 948155e96f77307a2763cd72bfbb1934b00cc8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Tue, 14 Mar 2023 23:01:54 +0100 Subject: [PATCH 03/15] NEW No overwrite of optionals during put() When making a PUT request, only the sent fields should be changed. This should apply for optionals too. However up until now the array_options field gets changed as whole and therefore overwritten if only one optional fields gets send. --- htdocs/societe/class/api_contacts.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 88e9398f5fa..9d6ed42ddb1 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -326,8 +326,13 @@ class Contacts extends DolibarrApi foreach ($request_data as $field => $value) { if ($field == 'id') { continue; + } elseif ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->contact->array_options[$index] = $val; + } + } else { + $this->contact->$field = $value; } - $this->contact->$field = $value; } if (isModEnabled('mailing') && !empty($this->contact->email) && isset($this->contact->no_email)) { From 525f2704a3b14b1dc1b4d72fd964107e213689d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 14 Mar 2023 23:18:24 +0100 Subject: [PATCH 04/15] uncomment code to have user feedback --- .../modules/mrp/doc/doc_generic_mo_odt.modules.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 340530d8504..2f0c11d0649 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -4,7 +4,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2021 Philippe Grand - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2023 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 @@ -342,10 +342,10 @@ class doc_generic_mo_odt extends ModelePDFMo $odfHandler = new odf( $srctemplatepath, array( - 'PATH_TO_TMP' => $conf->mrp->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. - 'DELIMITER_LEFT' => '{', - 'DELIMITER_RIGHT' => '}' + 'PATH_TO_TMP' => $conf->mrp->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' ) ); } catch (Exception $e) { @@ -359,8 +359,6 @@ class doc_generic_mo_odt extends ModelePDFMo // [!-- BEGIN lines --]*[!-- END lines --] //print html_entity_decode($odfHandler->__toString()); //print exit; - /* - // Make substitutions into odt of freetext try { @@ -461,7 +459,7 @@ class doc_generic_mo_odt extends ModelePDFMo $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - */ + // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { From 340ede36b68b1e12d8eeb603531c2013ec7a0148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 15 Mar 2023 08:59:08 +0100 Subject: [PATCH 05/15] fix warnings --- htdocs/compta/prelevement/create.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 598b86fcda3..85f0be90125 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2010-2012 Juanjo Menent * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2019 Markus Welters * * This program is free software; you can redistribute it and/or modify @@ -126,8 +126,8 @@ if (empty($reshook)) { $bprev = new BonPrelevement($db); if (!$error) { - // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) - $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); + // getDolGlobalString('PRELEVEMENT_CODE_BANQUE') and getDolGlobalString('PRELEVEMENT_CODE_GUICHET') should be empty (we don't use them anymore) + $result = $bprev->create(getDolGlobalString('PRELEVEMENT_CODE_BANQUE'), getDolGlobalString('PRELEVEMENT_CODE_GUICHET'), $mode, $format, $executiondate, 0, $type); if ($result < 0) { setEventMessages($bprev->error, $bprev->errors, 'errors'); } elseif ($result == 0) { From f1ba6a361180fe115a137e1a192c3cacb3ab169c Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 15 Mar 2023 10:33:42 +0100 Subject: [PATCH 06/15] add function in modulebuilder for rewriting all permissions --- htdocs/core/lib/modulebuilder.lib.php | 68 +++++++++++++++++++++++++++ htdocs/modulebuilder/index.php | 22 ++++----- 2 files changed, 76 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index a60e9a3a78a..5f5dd041ccb 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -416,3 +416,71 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' return $error ? -1 : 1; } + +/** + * Rewriting all permissions after updating file + * @param string $file file with path + * @param string $objectname name of the permission object + * @param string $right permission of object + * @param string $rightUpdated permission of object updated + * @param int $action 0 for delete, 1 for add, 2 fo update + * @return void + */ +function rewritingAllPermissions($file, $objectname, $right, $rightUpdated, $action) +{ + global $langs; + $start = "/* BEGIN MODULEBUILDER PERMISSIONS */"; + $end = "/* END MODULEBUILDER PERMISSIONS */"; + $perms_after_action = ''; + $error = 0; + if (empty($right)) { + $error++; + } + if ($action == 2 && empty($rightUpdated)) { + $error++; + } + if (!$error) { + // Open the file and read line by line + $handle = fopen($file, "r"); + $i = 1; + $lines = array(); + + while (($line = fgets($handle)) !== false) { + //search line begin + if (strpos($line, $start) !== false) { + $start_line = $i; + + // Copy lines until the end on array + while (($line = fgets($handle)) !== false) { + if (strpos($line, $end) !== false) { + $end_line = $i; + break; + } + $lines[] = $line; + $i++; + } + break; + } + $i++; + } + $allContent = implode("", $lines); + if (str_contains($allContent, $right)) { + if ($action == 0) { + $perms_after_action = str_replace($right, "\n\t\t", $allContent); + if (!str_contains($perms_after_action, $objectname)) { + $perms_after_action = str_replace(['/*'.strtoupper($objectname).'*/','/*END '.strtoupper($objectname).'*/'], "", $perms_after_action); + } + } + if ($action == 2) { + $perms_after_action = str_replace($right, $rightUpdated."\n\t\t", $allContent); + } + if ($action == 1 && !empty($right)) { + $perms_after_action = str_replace("", $right, $allContent); + var_dump($perms_after_action);exit; + } + dolReplaceInFile($file, array($allContent => '')); + dolReplaceInFile($file, array('/* BEGIN MODULEBUILDER PERMISSIONS */' => '/* BEGIN MODULEBUILDER PERMISSIONS */'."\n".$perms_after_action)); + } + fclose($handle); + } +} diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 04d0f290732..9a5aff0e8d6 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2235,6 +2235,8 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { setEventMessages($langs->trans('FailedToAddCodeIntoDescriptor', 'END MODULEBUILDER PERMISSIONS'), null, 'warnings'); } } + + rewritingAllPermissions($moduledescriptorfile, $objectForPerms, $right, '', 1); } clearstatcache(true); @@ -2355,7 +2357,8 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e } $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; - $check = dolReplaceInFile($moduledescriptorfile, array($right => $rightUpdated)); + + rewritingAllPermissions($moduledescriptorfile, $x2, $right, $rightUpdated, 2); setEventMessages($langs->trans('PermissionUpdatedSuccesfuly'), null); @@ -2400,21 +2403,12 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p "; $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + //reriting all permissions + rewritingAllPermissions($moduledescriptorfile, $x2, $rightTodelete, '', 0); + + - // TODO ALI The delete must be done by rewriting all content between /* BEGIN MODULEBUILDER PERMISSIONS */ and /* END MODULEBUILDER PERMISSIONS */ - $check = dolReplaceInFile($moduledescriptorfile, array($rightTodelete => "\n\t\t")); - if ($check > 0) { - //check if all permissions of object was deleted - $permsForObj = array(); - foreach ($permissions as $perms) { - $permsForObj[] = $perms[4]; - } - $permsForObj = array_count_values($permsForObj); - if ($permsForObj[$permissions[$key][4]] == 1) { - $delObjStart = dolReplaceInFile($moduledescriptorfile, array('/*'.strtoupper($permissions[$key][4].'*/') => '','/*END '.strtoupper($permissions[$key][4].'*/') => '')); - } - } if (!$error) { // check if module is enabled if (isModEnabled(strtolower($module))) { From c1aecd2bfe8d6ce2d104bba1049e6794e63003fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 15 Mar 2023 10:39:28 +0100 Subject: [PATCH 07/15] fix warning --- htdocs/societe/paymentmodes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 2cc9094176a..b8663dfe40f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1023,7 +1023,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // Get list of remote payment modes $listofsources = array(); - if (is_object($stripe)) { + if (isset($stripe) && is_object($stripe)) { try { $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (!empty($customerstripe->id)) { From aec3e151ab10abf27444a2ed21ed5b3aec7e5de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 15 Mar 2023 10:47:15 +0100 Subject: [PATCH 08/15] fix warnings --- htdocs/societe/paymentmodes.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index b8663dfe40f..93ec01e0524 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -155,7 +155,7 @@ if (empty($reshook)) { } if (!$error) { - $companybankaccount->old = dol_clone($companybankaccount); + $companybankaccount->oldcopy = dol_clone($companybankaccount); $companybankaccount->socid = $object->id; @@ -196,8 +196,8 @@ if (empty($reshook)) { $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib } - if ($companypaymentmode->old->stripe_card_ref != $companypaymentmode->stripe_card_ref) { - if ($companybankaccount->old->iban != $companybankaccount->iban) { + if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) { + if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) { // TODO If we modified the iban, we must also update the pm_ on Stripe side, or break the link completely ? } } @@ -229,7 +229,7 @@ if (empty($reshook)) { $companypaymentmode->fetch($id); if (!$error) { - $companybankaccount->old = dol_clone($companybankaccount); + $companybankaccount->oldcopy = dol_clone($companybankaccount); $companypaymentmode->fk_soc = $object->id; @@ -258,8 +258,8 @@ if (empty($reshook)) { $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib } - if ($companypaymentmode->old->stripe_card_ref != $companypaymentmode->stripe_card_ref) { - if ($companybankaccount->old->number != $companybankaccount->number) { + if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) { + if ($companybankaccount->oldcopy->number != $companybankaccount->number) { // TODO If we modified the card, we must also update the pm_ on Stripe side, or break the link completely ? } } @@ -306,7 +306,7 @@ if (empty($reshook)) { $companybankaccount->rum = GETPOST('rum', 'alpha'); $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth', 'int'), GETPOST('date_rumday', 'int'), GETPOST('date_rumyear', 'int')); $companybankaccount->datec = dol_now(); - $companybankaccount->status = 1; + $companybankaccount->status = 1; $companybankaccount->bank = trim($companybankaccount->bank); if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) { From 2a7583ca1494880ea0ea1a25a5adfffc050281dd Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 15 Mar 2023 10:48:13 +0100 Subject: [PATCH 09/15] fix a problem in function --- htdocs/core/lib/modulebuilder.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 5f5dd041ccb..d94f2071134 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -476,7 +476,6 @@ function rewritingAllPermissions($file, $objectname, $right, $rightUpdated, $act } if ($action == 1 && !empty($right)) { $perms_after_action = str_replace("", $right, $allContent); - var_dump($perms_after_action);exit; } dolReplaceInFile($file, array($allContent => '')); dolReplaceInFile($file, array('/* BEGIN MODULEBUILDER PERMISSIONS */' => '/* BEGIN MODULEBUILDER PERMISSIONS */'."\n".$perms_after_action)); From 009395443778102b1e159619e21f7e0a99f1bc9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Wed, 15 Mar 2023 16:00:20 +0100 Subject: [PATCH 10/15] NEW Support contact in post() document API When uploading a document via the API, add the modulepart "contact". By this, documents linked to a contact can be uploaded. --- htdocs/api/class/api_documents.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 78442622c7e..5ab7de3f384 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -666,13 +666,22 @@ class Documents extends DolibarrApi $modulepart = 'propale'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $object = new Propal($this->db); + } elseif ($modulepart == 'contact' || $modulepart == 'socpeople') { + $modulepart = 'contact'; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + $object = new Contact($this->db); + $fetchbyid = true; } else { // TODO Implement additional moduleparts throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } if (is_object($object)) { - $result = $object->fetch('', $ref); + if ($fetchbyid) { + $result = $object->fetch($ref); + } else { + $result = $object->fetch('', $ref); + } if ($result == 0) { throw new RestException(404, "Object with ref '".$ref."' was not found."); From 451a0e8469bc0086472afc6239eb819ca0a6760a Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Thu, 16 Mar 2023 01:29:29 +0100 Subject: [PATCH 11/15] Allow users to show or hide the "vote allowed" column in UI --- htdocs/adherents/admin/website.php | 10 ++++++++++ htdocs/langs/en_US/members.lang | 1 + htdocs/public/members/new.php | 5 +++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 705d7cf426f..522f2b7afa0 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -60,6 +60,7 @@ if ($action == 'update') { $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2); $minamount = GETPOST('MEMBER_MIN_AMOUNT'); $publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC'); + $showvoteallowed = GETPOST('MEMBER_SHOW_VOTE_ALLOWED'); $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE'); $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int'); $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09'); @@ -68,6 +69,7 @@ if ($action == 'update') { $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", !$showvoteallowed, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show" $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); if ($forcetype < 0) { $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); @@ -246,6 +248,14 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", (!empty($conf->global->MEMBER_COUNTERS_ARE_PUBLIC) ? $conf->global->MEMBER_COUNTERS_ARE_PUBLIC : 0), 1); print "\n"; + // Show "vote allowed" setting for membership types + $hidevoteallowed = (!empty($conf->global->MEMBER_HIDE_VOTE_ALLOWED) ? $conf->global->MEMBER_HIDE_VOTE_ALLOWED : 0); + print ''; + print $langs->trans("MembersShowVotesAllowed"); + print ''; + print $form->selectyesno("MEMBER_SHOW_VOTE_ALLOWED", !$hidevoteallowed, 1); // Reverse the logic "hide -> show" for retrocompatibility + print "\n"; + // Jump to an online payment page print ''; print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 1597f9f2719..880f66cea4e 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -27,6 +27,7 @@ MembersListNotUpToDate=List of valid members with out-of-date contribution MembersListExcluded=List of excluded members MembersListResiliated=List of terminated members MembersListQualified=List of qualified members +MembersShowVotesAllowed=Show whether votes are allowed, in the table of membership types MenuMembersToValidate=Draft members MenuMembersValidated=Validated members MenuMembersExcluded=Excluded members diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index c0d5c927564..253da6cfaaf 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -802,6 +802,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW $units[$lines->short_label] = $langs->trans(ucfirst($lines->label)); $publiccounters = getDolGlobalString("MEMBER_COUNTERS_ARE_PUBLIC"); + $hidevoteallowed = getDolGlobalString("MEMBER_HIDE_VOTE_ALLOWED"); $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut as status, d.morphy,"; $sql .= " COUNT(a.rowid) AS membercount"; @@ -825,7 +826,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW print ''.$langs->trans("MembershipDuration").''; print ''.$langs->trans("Amount").''; print ''.$langs->trans("MembersNature").''; - print ''.$langs->trans("VoteAllowed").''; + if (empty($hidevoteallowed)) print ''.$langs->trans("VoteAllowed").''; if ($publiccounters) print ''.$langs->trans("Members").''; print ''.$langs->trans("NewSubscription").''; print "\n"; @@ -865,7 +866,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW print $langs->trans("MorAndPhy"); } print ''; - print ''.yn($objp->vote).''; + if (empty($hidevoteallowed)) print ''.yn($objp->vote).''; $membercount = $objp->membercount>0? $objp->membercount: "–"; if ($publiccounters) print ''.$membercount.''; print ''; From 3d826061deefa078fc7c8f052fbdf0a6b675298c Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Thu, 16 Mar 2023 01:31:09 +0100 Subject: [PATCH 12/15] Allow users to show or hide the table of membership types in UI If the table is not shown, the form is shown directly as it was for Dolibarr <= 16.0 --- htdocs/adherents/admin/website.php | 10 ++++++++++ htdocs/langs/en_US/members.lang | 1 + 2 files changed, 11 insertions(+) diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 522f2b7afa0..e663b91ba28 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -60,6 +60,7 @@ if ($action == 'update') { $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2); $minamount = GETPOST('MEMBER_MIN_AMOUNT'); $publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC'); + $showtable = GETPOST('MEMBER_SHOW_TABLE');; $showvoteallowed = GETPOST('MEMBER_SHOW_VOTE_ALLOWED'); $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE'); $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int'); @@ -69,6 +70,7 @@ if ($action == 'update') { $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "MEMBER_SKIP_TABLE", !$showtable, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "skip -> show" $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", !$showvoteallowed, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show" $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); if ($forcetype < 0) { @@ -248,6 +250,14 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", (!empty($conf->global->MEMBER_COUNTERS_ARE_PUBLIC) ? $conf->global->MEMBER_COUNTERS_ARE_PUBLIC : 0), 1); print "\n"; + // Show the table of all available membership types. If not, show a form (as the default was for Dolibarr <=16.0) + $skiptable = (!empty($conf->global->MEMBER_SKIP_TABLE) ? $conf->global->MEMBER_SKIP_TABLE : 0); + print ''; + print $langs->trans("MembersShowMembershipTypesTable"); + print ''; + print $form->selectyesno("MEMBER_SHOW_TABLE", !$skiptable, 1); // Reverse the logic "hide -> show" for retrocompatibility + print "\n"; + // Show "vote allowed" setting for membership types $hidevoteallowed = (!empty($conf->global->MEMBER_HIDE_VOTE_ALLOWED) ? $conf->global->MEMBER_HIDE_VOTE_ALLOWED : 0); print ''; diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 880f66cea4e..b6abe5034b1 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -27,6 +27,7 @@ MembersListNotUpToDate=List of valid members with out-of-date contribution MembersListExcluded=List of excluded members MembersListResiliated=List of terminated members MembersListQualified=List of qualified members +MembersShowMembershipTypesTable=Show a table of all available membership types (if no, show directly the registration form) MembersShowVotesAllowed=Show whether votes are allowed, in the table of membership types MenuMembersToValidate=Draft members MenuMembersValidated=Validated members From 6fa3e7417dae1033a6dbd49d917c5753ea0ac21c Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 16 Mar 2023 10:40:18 +0100 Subject: [PATCH 13/15] update function for rewrite permissions --- htdocs/core/lib/modulebuilder.lib.php | 117 +++++++++++++++----------- htdocs/modulebuilder/index.php | 111 ++++++------------------ 2 files changed, 94 insertions(+), 134 deletions(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index d94f2071134..5f8b34442db 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -418,68 +418,83 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' } /** - * Rewriting all permissions after updating file + * delete all permissions * @param string $file file with path - * @param string $objectname name of the permission object - * @param string $right permission of object - * @param string $rightUpdated permission of object updated - * @param int $action 0 for delete, 1 for add, 2 fo update * @return void */ -function rewritingAllPermissions($file, $objectname, $right, $rightUpdated, $action) +function deletePerms($file) { - global $langs; $start = "/* BEGIN MODULEBUILDER PERMISSIONS */"; $end = "/* END MODULEBUILDER PERMISSIONS */"; - $perms_after_action = ''; - $error = 0; - if (empty($right)) { - $error++; + $i = 1; + $array = array(); + $lines = file($file); + // Search for start and end lines + foreach ($lines as $i => $line) { + if (strpos($line, $start) !== false) { + $start_line = $i + 1; + + // Copy lines until the end on array + while (($line = $lines[++$i]) !== false) { + if (strpos($line, $end) !== false) { + $end_line = $i + 1; + break; + } + $array[] = $line; + } + break; + } } - if ($action == 2 && empty($rightUpdated)) { + $allContent = implode("", $array); + dolReplaceInFile($file, array($allContent => '')); +} + +/** + * Rewriting all permissions after any actions + * @param string $file filename or path + * @param array $permissions permissions existing in file + * @param int|null $key key for permission needed + * @param array|null $right $right to update or add + * @param int $action 0 for delete, 1 for add, 2 for update + * @return int 1 if OK,-1 if KO + */ +function reWriteAllPermissions($file, $permissions, $key, $right, $action) +{ + $error = 0; + $rights = array(); + if ($action == 0) { + // delete right from permissions array + array_splice($permissions, array_search($permissions[$key], $permissions), 1); + } elseif ($action == 1) { + array_push($permissions, $right); + } elseif ($action == 2 && !empty($right)) { + // update right from permissions array + array_splice($permissions, array_search($permissions[$key], $permissions), 1, $right); + } else { $error++; } if (!$error) { - // Open the file and read line by line - $handle = fopen($file, "r"); - $i = 1; - $lines = array(); - - while (($line = fgets($handle)) !== false) { - //search line begin - if (strpos($line, $start) !== false) { - $start_line = $i; - - // Copy lines until the end on array - while (($line = fgets($handle)) !== false) { - if (strpos($line, $end) !== false) { - $end_line = $i; - break; - } - $lines[] = $line; - $i++; - } - break; - } - $i++; + // prepare permissions array + $count_perms = count($permissions); + for ($i = 0;$i<$count_perms;$i++) { + $permissions[$i][0] = "\$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1)"; + $permissions[$i][1] = "\$this->rights[\$r][1] = '".$permissions[$i][1]."'"; + $permissions[$i][4] = "\$this->rights[\$r][4] = '".$permissions[$i][4]."'"; + $permissions[$i][5] = "\$this->rights[\$r][5] = '".$permissions[$i][5]."';\n\t\t"; } - $allContent = implode("", $lines); - if (str_contains($allContent, $right)) { - if ($action == 0) { - $perms_after_action = str_replace($right, "\n\t\t", $allContent); - if (!str_contains($perms_after_action, $objectname)) { - $perms_after_action = str_replace(['/*'.strtoupper($objectname).'*/','/*END '.strtoupper($objectname).'*/'], "", $perms_after_action); - } - } - if ($action == 2) { - $perms_after_action = str_replace($right, $rightUpdated."\n\t\t", $allContent); - } - if ($action == 1 && !empty($right)) { - $perms_after_action = str_replace("", $right, $allContent); - } - dolReplaceInFile($file, array($allContent => '')); - dolReplaceInFile($file, array('/* BEGIN MODULEBUILDER PERMISSIONS */' => '/* BEGIN MODULEBUILDER PERMISSIONS */'."\n".$perms_after_action)); + + //convert to string + foreach ($permissions as $perms) { + $rights[] = implode(";\n\t\t", $perms); + $rights[] = "\$r++;\n\t\t"; } - fclose($handle); + $rights_str = implode("", $rights); + // delete all permission from file + deletePerms($file); + // rewrite all permission again + dolReplaceInFile($file, array('/* BEGIN MODULEBUILDER PERMISSIONS */' => '/* BEGIN MODULEBUILDER PERMISSIONS */'."\n\t\t".$rights_str)); + return 1; + } else { + return -1; } } diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 9a5aff0e8d6..0ede69fae56 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2146,6 +2146,7 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rights")), null, 'errors'); } + $id = GETPOST('id', 'alpha'); $label = GETPOST('label', 'alpha'); $objectForPerms = strtolower(GETPOST('permissionObj', 'alpha')); $crud = GETPOST('crud', 'alpha'); @@ -2168,8 +2169,6 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { $counter = 0; $permsForObject =array(); $permissions = $moduleobj->rights; - $firstRight = 0; - $existRight = 0; $allObject = array(); $countPerms = count($permissions); @@ -2188,55 +2187,34 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { $countPermsObj = count($permsForObject); for ($j = 0; $j<$countPermsObj; $j++) { if (in_array($label, $permsForObject[$j])) { - $existRight++; + $error++; setEventMessages($langs->trans("ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)), null, 'errors'); } } - // if not found permission for the object - if (!in_array($objectForPerms, array_unique($allObject))) { - $firstRight++; - $existRight++; - } + if (!$error) { + $key = $countPerms + 1; + //prepare right to add + $rightToAdd = [ + 0=> $id, + 1=>$label, + 4=>$objectForPerms, + 5=>$crud + ]; + + $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + //rewriting all permissions after add a right + reWriteAllPermissions($moduledescriptorfile, $permissions, $key, $rightToAdd, 1); + setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null); + if (isModEnabled(strtolower($module))) { $result = unActivateModule(strtolower($module)); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); if ($result) { setEventMessages($result, null, 'errors'); } - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings'); } - //prepare stirng to add - $rightToAdd = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$label'; - \$this->rights[\$r][4] = '$objectForPerms'; - \$this->rights[\$r][5] = '$crud'; - \$r++; - "; - $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; - - //var_dump($existRight.' '.$firstRight);exit; - if (!$existRight) { - dolReplaceInFile($moduledescriptorfile, array('/*END '.strtoupper($objectForPerms).'*/' => $rightToAdd.'/*END '.strtoupper($objectForPerms).'*/')); - setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null); - } - if ($firstRight > 0) { - $filecontentbefore = file_get_contents($moduledescriptorfile); - - $result = dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectForPerms).'*/'.$rightToAdd."/*END ".strtoupper($objectForPerms).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */')); - - $filecontentafter = file_get_contents($moduledescriptorfile); - - if ($filecontentbefore != $filecontentafter) { - setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null); - } else { - setEventMessages($langs->trans('FailedToAddCodeIntoDescriptor', 'END MODULEBUILDER PERMISSIONS'), null, 'warnings'); - } - } - - rewritingAllPermissions($moduledescriptorfile, $objectForPerms, $right, '', 1); } clearstatcache(true); @@ -2293,11 +2271,11 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e } $permissions = $moduleobj->rights; - $r =(int) GETPOST('counter'); + $key =(int) GETPOST('counter')-1; //get permission want to delete from permissions array - $x1 = $permissions[$r-1][1]; - $x2 = $permissions[$r-1][4]; - $x3 = $permissions[$r-1][5]; + $x1 = $permissions[$key][1]; + $x2 = $permissions[$key][4]; + $x3 = $permissions[$key][5]; //check existing object permission $counter = 0; $permsForObject =array(); @@ -2327,24 +2305,6 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e } } - // TODO ALI Update of permission must be done by rewriting completely the permission section - //prepare right want to delete - $right = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$x1'; - \$this->rights[\$r][4] = '$x2'; - \$this->rights[\$r][5] = '$x3'; - \$r++; - "; - // right after editing - $rightUpdated = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$label'; - \$this->rights[\$r][4] = '$objectForPerms'; - \$this->rights[\$r][5] = '$crud'; - \$r++; - "; - if (!$error) { if (isModEnabled(strtolower($module))) { $result = unActivateModule(strtolower($module)); @@ -2352,13 +2312,12 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e if ($result) { setEventMessages($result, null, 'errors'); } - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings'); } $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; - - rewritingAllPermissions($moduledescriptorfile, $x2, $right, $rightUpdated, 2); + // rewriting all permissions after update permission needed + reWriteAllPermissions($moduledescriptorfile, $permissions, $key, $rightUpdated, 2); setEventMessages($langs->trans('PermissionUpdatedSuccesfuly'), null); @@ -2389,27 +2348,13 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p $permissions = $moduleobj->rights; $key = (int) GETPOST('permskey', 'int')-1; - //get permission want to delete from permissions array - $x1 = $permissions[$key][1]; - $x2 = $permissions[$key][4]; - $x3 = $permissions[$key][5]; - //prepare right want to delete - $rightTodelete = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$x1'; - \$this->rights[\$r][4] = '$x2'; - \$this->rights[\$r][5] = '$x3'; - \$r++; - "; - - $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; - //reriting all permissions - rewritingAllPermissions($moduledescriptorfile, $x2, $rightTodelete, '', 0); - - - if (!$error) { + $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + + // rewriting all permissions + reWriteAllPermissions($moduledescriptorfile, $permissions, $key, '', 0); + // check if module is enabled if (isModEnabled(strtolower($module))) { $result = unActivateModule(strtolower($module)); From 33324cae685a6beda4832570781faa4fc314c775 Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 16 Mar 2023 12:59:32 +0100 Subject: [PATCH 14/15] Add missing printFieldListFrom hook in movements list --- htdocs/product/stock/movement_list.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index c0b055352c0..c54af0df426 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -630,6 +630,12 @@ if (!empty($extrafields->attributes[$object->table_element]['label']) && is_arra } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; + +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= " WHERE m.fk_product = p.rowid"; if ($msid > 0) { $sql .= " AND m.rowid = ".((int) $msid); From 932f561fd044ba1b3280a3edd80dd2dab232fe25 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Mar 2023 21:07:30 +0100 Subject: [PATCH 15/15] Update api_documents.class.php --- htdocs/api/class/api_documents.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 5ab7de3f384..7cd84d656da 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -607,7 +607,8 @@ class Documents extends DolibarrApi if ($ref) { $tmpreldir = ''; - + $fetchbyid = false; + if ($modulepart == 'facture' || $modulepart == 'invoice') { $modulepart = 'facture';