From 0e083bab20865a6d34f5dc2e688c8291cba522fc Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 22 Nov 2022 17:28:54 +0100 Subject: [PATCH 01/17] Fix(scrutinizer) https://scrutinizer-ci.com/g/Dolibarr/dolibarr/issues/develop/files/htdocs/don/class/paymentdonation.class.php?selectedLabels%5B0%5D=9&selectedSeverities%5B0%5D=10&orderField=lastFound&order=desc&honorSelectedPaths=0 --- htdocs/don/class/paymentdonation.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index e4928ac9363..a9ddcf62638 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -130,7 +130,7 @@ class PaymentDonation extends CommonObject $now = dol_now(); // Validate parameters - if (!$this->datepaid) { + if (!$this->datep) { $this->error = 'ErrorBadValueForParameterCreatePaymentDonation'; return -1; } @@ -587,7 +587,7 @@ class PaymentDonation extends CommonObject // Insert payment into llx_bank $bank_line_id = $acc->addline( - $this->datepaid, + $this->datep, $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") $label, $amount, From fadc50b152b41f5bdcac8798e44a01fb01cb76af Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 29 Nov 2022 11:29:03 +0100 Subject: [PATCH 02/17] Fix(scrutinizer) https://scrutinizer-ci.com/g/Dolibarr/dolibarr/issues/develop/files/htdocs/expensereport/class/paymentexpensereport.class.php?selectedLabels%5B0%5D=9&selectedSeverities%5B0%5D=10&orderField=lastFound&order=desc&honorSelectedPaths=0 --- htdocs/expensereport/class/paymentexpensereport.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index e871cba86b3..0a5ae80bb86 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -113,7 +113,7 @@ class PaymentExpenseReport extends CommonObject $now = dol_now(); // Validate parameters - if (!$this->datepaid) { + if (!$this->datep) { $this->error = 'ErrorBadValueForParameterCreatePaymentExpenseReport'; return -1; } @@ -531,7 +531,7 @@ class PaymentExpenseReport extends CommonObject // Insert payment into llx_bank $bank_line_id = $acc->addline( - $this->datepaid, + $this->datep, $this->fk_typepayment, // Payment mode id or code ("CHQ or VIR for example") $label, -$amount, From 721c7ed9298943472fd7ef37946e46fb071653e2 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 30 Nov 2022 22:43:07 +0100 Subject: [PATCH 03/17] Fix(Scrutinizer) --- htdocs/don/class/paymentdonation.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index a9ddcf62638..61c9086e10e 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -189,7 +189,7 @@ class PaymentDonation extends CommonObject $sql .= " fk_typepayment, num_payment, note, ext_payment_id, ext_payment_site,"; $sql .= " fk_user_creat, fk_bank)"; $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; - $sql .= " '".$this->db->idate($this->datepaid)."',"; + $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " ".price2num($totalamount).","; $sql .= " ".((int) $this->paymenttype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', "; $sql .= " ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").","; @@ -584,7 +584,6 @@ class PaymentDonation extends CommonObject if ($mode == 'payment_donation') { $amount = $total; } - // Insert payment into llx_bank $bank_line_id = $acc->addline( $this->datep, From dbe7f659cc3fd852da46242e8d9f4ef0a968a28d Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 31 Jan 2023 22:55:04 +0100 Subject: [PATCH 04/17] fix (scrutinizer) replace datepaid by datep and in payment replacement of the variable that receives the value --- htdocs/expensereport/class/paymentexpensereport.class.php | 3 +-- htdocs/expensereport/payment/payment.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 0a5ae80bb86..a566b4a2b00 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -111,7 +111,6 @@ class PaymentExpenseReport extends CommonObject $error = 0; $now = dol_now(); - // Validate parameters if (!$this->datep) { $this->error = 'ErrorBadValueForParameterCreatePaymentExpenseReport'; @@ -170,7 +169,7 @@ class PaymentExpenseReport extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,"; $sql .= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; $sql .= " VALUES ($this->fk_expensereport, '".$this->db->idate($now)."',"; - $sql .= " '".$this->db->idate($this->datepaid)."',"; + $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " ".price2num($totalamount).","; $sql .= " ".((int) $this->fk_typepayment).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ".((int) $user->id).","; $sql .= " 0)"; // fk_bank is ID of transaction into ll_bank diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 6456bf80d7f..20b49b1533c 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -107,8 +107,8 @@ if ($action == 'add_payment') { // Create a line of payments $payment = new PaymentExpenseReport($db); $payment->fk_expensereport = $expensereport->id; - $payment->datepaid = $datepaid; - $payment->amounts = $amounts; // Tableau de montant + $payment->datep = $datepaid; + $payment->amounts = $amounts; // Tableau de montant $payment->total = $total; $payment->fk_typepayment = GETPOST("fk_typepayment", 'int'); $payment->num_payment = GETPOST("num_payment", 'alphanothtml'); From 5ae8735f7e0e7e211b11729d5bc7d5808c7dc45e Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 31 Jan 2023 23:11:15 +0100 Subject: [PATCH 05/17] fix (scrutinizer) In payment don replacement of the variable that receives the value --- htdocs/don/payment/payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php index 6a2cc78f128..08084898f80 100644 --- a/htdocs/don/payment/payment.php +++ b/htdocs/don/payment/payment.php @@ -95,7 +95,7 @@ if ($action == 'add_payment') { // Create a line of payments $payment = new PaymentDonation($db); $payment->chid = $chid; - $payment->datepaid = $datepaid; + $payment->datep = $datepaid; $payment->amounts = $amounts; // Tableau de montant $payment->paymenttype = GETPOST("paymenttype", 'int'); $payment->num_payment = GETPOST("num_payment", 'alphanohtml'); From 8aab392369c2242e4d7b5b5d6dcbe2a5a6b44ce4 Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 29 Nov 2022 22:44:00 +0100 Subject: [PATCH 06/17] Fix(scrutinizer) https://scrutinizer-ci.com/g/Dolibarr/dolibarr/issues/develop/files/htdocs/societe/price.php?selectedLabels%5B0%5D=9&selectedSeverities%5B0%5D=10&orderField=lastFound&order=desc&honorSelectedPaths=0 --- htdocs/societe/class/societe.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index fa6d77ad485..fff6daf3ce6 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -504,6 +504,12 @@ class Societe extends CommonObject */ public $tva_intra; + public $tva_npr; + + public $tva_tx; + + public $price_base_type; + // Local taxes public $localtax1_assuj; public $localtax1_value; From abe8c56ace97fdbd2adec977c9d68d6c0f4d5a56 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 1 Feb 2023 12:46:49 +0100 Subject: [PATCH 07/17] fix (scrutinizer) remove my edit --- htdocs/societe/class/societe.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index fff6daf3ce6..8d09012ccec 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -504,8 +504,6 @@ class Societe extends CommonObject */ public $tva_intra; - public $tva_npr; - public $tva_tx; public $price_base_type; From 8dc4ed05cad3b6548cc8508fb17f5196d9545597 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 1 Feb 2023 12:54:26 +0100 Subject: [PATCH 08/17] fix (scrutinizer) remove my edit --- htdocs/societe/class/societe.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8d09012ccec..fff6daf3ce6 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -504,6 +504,8 @@ class Societe extends CommonObject */ public $tva_intra; + public $tva_npr; + public $tva_tx; public $price_base_type; From c19d259d46c11f068fe6e9489080c620a9834b37 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 1 Feb 2023 12:55:32 +0100 Subject: [PATCH 09/17] fix (scrutinizer) remove my edit --- htdocs/societe/class/societe.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index fff6daf3ce6..8d09012ccec 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -504,8 +504,6 @@ class Societe extends CommonObject */ public $tva_intra; - public $tva_npr; - public $tva_tx; public $price_base_type; From 465a88738e15d52386cd9743ddde4fb44ce1057d Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 15 Feb 2023 15:39:49 +0100 Subject: [PATCH 10/17] fix (scrutinizer) deletion of the variables add in company --- htdocs/societe/class/societe.class.php | 4 ---- htdocs/societe/price.php | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8d09012ccec..fa6d77ad485 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -504,10 +504,6 @@ class Societe extends CommonObject */ public $tva_intra; - public $tva_tx; - - public $price_base_type; - // Local taxes public $localtax1_assuj; public $localtax1_value; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index af2898a8556..dafe53a19d8 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -321,7 +321,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { // VAT print ''.$langs->trans("VATRate").''; - print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1); + print $form->load_tva("tva_tx", GETPOST("tva_tx", "alpha"), $mysoc, '', $object->id, 0, '', false, 1); print ''; // Price base @@ -329,7 +329,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print $langs->trans('PriceBase'); print ''; print ''; - print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); + print $form->selectPriceBaseType(GETPOST("price_base_type", "aZ09"), "price_base_type"); print ''; print ''; From 8fce0d6f5f716298e3e4f16188eb08e05bb2a5eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Mar 2023 15:29:13 +0100 Subject: [PATCH 11/17] Comment --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 8ccd4882ac7..3d54742b38d 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2016-2023 Laurent Destailleur * Copyright (C) 2020 Nicolas ZABOURI * * This program is free software; you can redistribute it and/or modify From 152bbeb90a9ad54509d0e9be90b0fadb7f8464b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Mar 2023 18:27:32 +0100 Subject: [PATCH 12/17] Securize and enhance objectonoff for external modules --- htdocs/core/ajax/objectonoff.php | 57 +++++++++++++++---- htdocs/core/class/commonobject.class.php | 3 +- htdocs/core/lib/ajax.lib.php | 5 +- htdocs/core/lib/security.lib.php | 10 ++-- .../template/class/myobject.class.php | 4 +- 5 files changed, 57 insertions(+), 22 deletions(-) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index 77cd3234cd8..54344da699e 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -18,7 +18,7 @@ /** * \file htdocs/core/ajax/objectonoff.php * \brief File to set status for an object - * This Ajax service is called when option MAIN_DIRECT_STATUS_UPDATE is set. + * This Ajax service is oftenly called when option MAIN_DIRECT_STATUS_UPDATE is set. */ if (!defined('NOTOKENRENEWAL')) { @@ -53,15 +53,34 @@ $format = 'int'; $object = new GenericObject($db); -$tablename = $element; -if ($tablename == 'websitepage') { - $tablename = 'website_page'; -} +$tmparray = explode('@', $element); +if (empty($tmparray[1])) { + $subelement = ''; -$object->table_element = $tablename; + $object->module = $element; + $object->element = $element; + $object->table_element = $element; + + // Special case for compatibility + if ($object->table_element == 'websitepage') { + $object->table_element = 'website_page'; + } +} else { + $element = $tmparray[0]; + $subelement = $tmparray[1]; + + $object->module = $element; + $object->element = $subelement; + $object->table_element = $object->module.'_'.$object->element; +} $object->id = $id; $object->fields[$field] = array('type' => $format, 'enabled' => 1); +$module = $object->module; +$element = $object->element; + +//var_dump($object->module); var_dump($object->element); var_dump($object->table_element); + // Security check if (!empty($user->socid)) { $socid = $user->socid; @@ -70,12 +89,20 @@ if (!empty($user->socid)) { //$user->hasRight('societe', 'lire') = 0;$user->rights->fournisseur->lire = 0; //restrictedArea($user, 'societe', $id); -if (in_array($field, array('status'))) { - restrictedArea($user, $element, $id); +// We check permission. +// Check is done on $user->rights->element->create or $user->rights->element->subelement->create (because $action = 'set') +if (preg_match('/status$/', $field)) { + $module = $object->module; + $element = $object->element; + $usesublevelpermission = ($module != $element ? $element : ''); + if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly + $usesublevelpermission = ''; + } + restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission); } elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) { // Special case for products - restrictedArea($user, 'produit|service', $id, 'product&product', '', '', 'rowid'); + restrictedArea($user, 'produit|service', $object, 'product&product', '', '', 'rowid'); } else { - httponly_accessforbidden("Bad value for combination of parameters element/field."); + httponly_accessforbidden("Bad value for combination of parameters element/field."); // This includes the exit. } @@ -89,7 +116,7 @@ print ''; print load_fiche_titre($langs->trans($title), $morehtmlright, '', 0, 0, 'showlinkedobjectblock'); @@ -8893,20 +8895,19 @@ class Form $res = @include dol_buildpath('core/tpl/objectlinked_lineimport.tpl.php'); } - print ''; - - return $nbofdifferenttypes; } + + return $nbofdifferenttypes; } /** * Show block with links to link to other objects. * - * @param CommonObject $object Object we want to show links to - * @param array $restrictlinksto Restrict links to some elements, for exemple array('order') or array('supplier_order'). null or array() if no restriction. - * @param array $excludelinksto Do not show links of this type, for exemple array('order') or array('supplier_order'). null or array() if no exclusion. - * @return string <0 if KO, >0 if OK + * @param CommonObject $object Object we want to show links to + * @param array $restrictlinksto Restrict links to some elements, for exemple array('order') or array('supplier_order'). null or array() if no restriction. + * @param array $excludelinksto Do not show links of this type, for exemple array('order') or array('supplier_order'). null or array() if no exclusion. + * @return string HTML block */ public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array()) { diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 1bf83410088..57cbb0188a5 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -30,7 +30,7 @@ * @param string $desc Description of export * @param array $events_array Array of events ("uid","startdate","duration","enddate","title","summary","category","email","url","desc","author") * @param string $outputfile Output file - * @return int < 0 if ko, Nb of events in file if ok + * @return int < 0 if KO, Nb of events in file if OK */ function build_calfile($format, $title, $desc, $events_array, $outputfile) { @@ -43,6 +43,8 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) return -1; } + $nbevents = 0; + // Note: A cal file is an UTF8 encoded file $calfileh = fopen($outputfile, "w"); @@ -144,6 +146,8 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) */ if ($type === "event") { + $nbevents++; + fwrite($calfileh, "BEGIN:VEVENT\n"); fwrite($calfileh, "UID:".$uid."\n"); @@ -247,6 +251,8 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) // Output the vCard/iCal VJOURNAL object if ($type === "journal") { + $nbevents++; + fwrite($calfileh, "BEGIN:VJOURNAL\n"); fwrite($calfileh, "UID:".$uid."\n"); @@ -289,6 +295,8 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing"); return -2; } + + return $nbevents; } /** @@ -303,7 +311,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) * @param string $filter (optional) Filter * @param string $url Url (If empty, forge URL for agenda RSS export) * @param string $langcode Language code to show in header - * @return int < 0 if ko, Nb of events in file if ok + * @return int < 0 if KO, Nb of events in file if OK */ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '', $langcode = '') { @@ -317,6 +325,8 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt return -1; } + $nbevents = 0; + $fichier = fopen($outputfile, "w"); if ($fichier) { @@ -362,6 +372,8 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt } if ($eventqualified) { + $nbevents++; + if (is_object($event) && get_class($event) == 'WebsitePage') { // Convert object into an array $tmpevent = array(); @@ -426,6 +438,8 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt fclose($fichier); dolChmod($outputfile); } + + return $nbevents; } /** @@ -437,8 +451,6 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt */ function format_cal($format, $string) { - global $conf; - $newstring = $string; if ($format === "vcal") { diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index 7bbe8d7c1a6..e83730c89e2 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -44,7 +44,7 @@ class DataPolicy /** * getAllContactNotInformed * - * @return number + * @return integer */ public function getAllContactNotInformed() { @@ -75,12 +75,14 @@ class DataPolicy $this->error = $this->db->error(); return -1; } + + return 1; } /** * getAllCompaniesNotInformed * - * @return number + * @return integer */ public function getAllCompaniesNotInformed() { @@ -110,12 +112,14 @@ class DataPolicy $this->error = $this->db->error(); return -1; } + + return 1; } /** * getAllAdherentsNotInformed * - * @return number + * @return integer */ public function getAllAdherentsNotInformed() { @@ -145,6 +149,8 @@ class DataPolicy $this->error = $this->db->error(); return -1; } + + return 1; } /** From 7b7413aadf3a5f31cec0846a9703833a3ff70b2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Mar 2023 01:52:07 +0100 Subject: [PATCH 17/17] Look and feel v18 --- htdocs/user/virtualcard.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/user/virtualcard.php b/htdocs/user/virtualcard.php index 55d63c3d40a..ee47afffc0e 100644 --- a/htdocs/user/virtualcard.php +++ b/htdocs/user/virtualcard.php @@ -129,7 +129,9 @@ print '
'; print '
'; -print ''.$langs->trans("UserPublicPageDesc").'

'; +if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { + print ''.$langs->trans("UserPublicPageDesc").'

'; +} $param = '&id='.((int) $object->id); $param .= '&dol_openinpopup=1';