From d1e0efc4663906551c4e5da489a001826bfc552a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Sat, 4 Oct 2025 20:01:57 +0200 Subject: [PATCH 1/5] NEW Add getcontacts on api of interventional and proposal (#35589) * Add getContacts method to retrieve contact information * Implement getContacts method for proposals Added a method to retrieve contacts associated with a proposal, including access checks and data cleaning. * Implement getContacts method for invoices Added a method to retrieve contacts associated with a specific invoice, including access checks and error handling. * Update api_proposals.class.php * Update api_invoices.class.php * Update api_interventions.class.php * Update api_interventions.class.php * Add method to set invoice as draft * Return contacts directly instead of cleaned data * Return raw contacts instead of cleaned data * Combine external and internal contacts in order list Merge external and internal contacts for orders. * Change return type from Object to array in API doc Updated return type in API documentation for contact information. * Change return type in api_orders.class.php docblock Updated return type in docblock to reflect array return. * Change return type from Object to array in API doc * Update api_orders.class.php * Update api_interventions.class.php * Update api_proposals.class.php * Update api_orders.class.php * Update api_interventions.class.php * Update api_interventions.class.php * Update api_interventions.class.php --------- Co-authored-by: Laurent Destailleur --- .../comm/propal/class/api_proposals.class.php | 35 ++++++++++++++ htdocs/commande/class/api_orders.class.php | 3 ++ .../class/api_interventions.class.php | 48 ++++++++++++++++--- 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 5a6bd277618..ae53c83c61d 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -655,6 +655,41 @@ class Proposals extends DolibarrApi throw new RestException(405, $this->propal->error); } } + /** + * Get contacts of given proposal + * + * Return an array with contact information + * + * @param int $id ID of proposal + * @param string $type Type of the proposal + * @return array Array of contacts associated + * + * @url GET {id}/contacts + * + * @throws RestException + */ + public function getContacts($id, $type = '') + { + if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) { + throw new RestException(403); + } + + $result = $this->propal->fetch($id); + if (!$result) { + throw new RestException(404, 'Proposal not found'); + } + + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $contacts = $this->propal->liste_contact(-1, 'external', 0, $type); + $socpeoples = $this->propal->liste_contact(-1, 'internal', 0, $type); + + $contacts = array_merge($contacts, $socpeoples); + + return $contacts; + } /** * Add (link) a contact to a commercial proposal diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 5cba8258a8d..053d01a10e7 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -607,6 +607,9 @@ class Orders extends DolibarrApi } $contacts = $this->commande->liste_contact(-1, 'external', 0, $type); + $socpeoples = $this->commande->liste_contact(-1, 'internal', 0, $type); + + $contacts = array_merge($contacts, $socpeoples); return $contacts; } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index d9150a3620d..557e77e159a 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -732,13 +732,50 @@ class Interventions extends DolibarrApi return $this->_cleanObjectDatas($this->fichinter); } - /** + /** + * Get contacts of given interventional + * + * Return an array with contact information + * + * @param int $id ID of interventional + * @param string $type Type of the interventional + * @return array Object with cleaned properties + * + * @url GET {id}/contacts + * + * @throws RestException + */ + public function getContacts($id, $type = '') + { + if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'lire')) { + throw new RestException(403); + } + + $result = $this->fichinter->fetch($id); + if (!$result) { + throw new RestException(404, 'Interventional not found'); + } + + if (!DolibarrApi::_checkAccessToResource('ficheinter', $this->fichinter->id)) { + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $contacts = $this->fichinter->liste_contact(-1, 'external', 0, $type); + $socpeoples = $this->fichinter->liste_contact(-1, 'internal', 0, $type); + + $contacts = array_merge($contacts, $socpeoples); + + return $contacts; + } + + + /** * Delete a contact type of given interventional * - * @param int $id Id of interventional to update - * @param int $contactid Row key of the contact in the array contact_ids. - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). - * @return Object Object with cleaned properties + * @param int $id Id of interventional to update + * @param int $contactid Row key of the contact in the array contact_ids. + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @return Object Object deleted * * @url DELETE {id}/contact/{contactid}/{type} * @@ -792,7 +829,6 @@ class Interventions extends DolibarrApi */ public function updateInterventionalLine($id, $lineid, $request_data) { - $result = $this->fichinter->fetch($id); if (!$result) { throw new RestException(404, 'Interventional not found'); From a15c3a4ff22e62ef4c0b5ee065fb8ea4edd41245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 4 Oct 2025 20:02:49 +0200 Subject: [PATCH 2/5] fix members cards (#35639) * fix members cards * fix * fix members cards --- htdocs/adherents/cartes/carte.php | 28 +++++++++---------- .../class/commonstickergenerator.class.php | 17 +++++------ .../member/doc/pdf_standard_member.class.php | 14 ++++------ 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 0e2b6864c3c..191cccae92c 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -1,10 +1,10 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2006-2013 Laurent Destailleur - * Copyright (C) 2024 Alexandre Spangaro - * Copyright (C) 2024-2025 MDW - * Copyright (C) 2024 Frédéric France +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2024 Alexandre Spangaro + * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-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 @@ -26,22 +26,22 @@ * \brief Page to output members business cards */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php'; -require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php'; - /** * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager * @var Translate $langs * @var User $user - * - * @var array $_Avery_Labels */ +require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; +/** @var array $_Avery_Labels */ + +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php'; + $langs->loadLangs(array("members", "errors")); // Choice of printing year or current year. diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 7d99ff22eed..85d5cd6817c 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -1,11 +1,12 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2006-2013 Laurent Destailleur - * Copyright (C) 2015 Francis Appels - * Copyright (C) 2024-2025 MDW +/* Copyright (C) 2003 Steve Dillon + * Copyright (C) 2003 Laurent Passebecq + * Copyright (C) 2001-2003 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2015 Francis Appels + * Copyright (C) 2024-2025 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 @@ -112,7 +113,7 @@ abstract class CommonStickerGenerator extends CommonDocGenerator public $Tformat; /** - * @var array + * @var ?array */ public $_Avery_Labels; // phpcs:enable diff --git a/htdocs/core/modules/member/doc/pdf_standard_member.class.php b/htdocs/core/modules/member/doc/pdf_standard_member.class.php index 63c086e518a..6778397a697 100644 --- a/htdocs/core/modules/member/doc/pdf_standard_member.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard_member.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2015 Francis Appels - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 Frédéric France * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -49,7 +49,7 @@ class pdf_standard_member extends CommonStickerGenerator */ public function __construct($db) { - global $langs; + global $langs, $_Avery_Labels; // Translations $langs->loadLangs(array("main", "admin")); @@ -58,6 +58,7 @@ class pdf_standard_member extends CommonStickerGenerator $this->name = "standard"; $this->description = $langs->trans('TemplateforBusinessCards'); //$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + $this->_Avery_Labels = $_Avery_Labels; $this->type = 'pdf-various-sizes'; } @@ -165,7 +166,6 @@ class pdf_standard_member extends CommonStickerGenerator $pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C'); } - $ytop += (empty($header) ? 0 : (1 + $this->_Line_Height)); // Define widthtouse and heighttouse @@ -275,7 +275,7 @@ class pdf_standard_member extends CommonStickerGenerator public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = '', $filename = 'tmp_cards') { // phpcs:enable - global $user, $conf, $langs, $mysoc, $_Avery_Labels; + global $user, $conf, $langs, $mysoc; $this->code = $srctemplatepath; @@ -356,7 +356,7 @@ class pdf_standard_member extends CommonStickerGenerator $textfooter = make_substitutions(getDolGlobalString("ADHERENT_CARD_FOOTER_TEXT"), $substitutionarray); $textright = make_substitutions(getDolGlobalString("ADHERENT_CARD_TEXT_RIGHT"), $substitutionarray); - $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; + $nb = $this->_Avery_Labels[$this->code]['NX'] * $this->_Avery_Labels[$this->code]['NY']; if ($nb <= 0) { $nb = 1; // Protection to avoid empty page } @@ -380,7 +380,7 @@ class pdf_standard_member extends CommonStickerGenerator $arrayofrecords = $object; } - $this->Tformat = $_Avery_Labels[$this->code]; + $this->Tformat = $this->_Avery_Labels[$this->code]; if (empty($this->Tformat)) { dol_print_error(null, 'ErrorBadTypeForCard'.$this->code); exit; @@ -426,8 +426,6 @@ class pdf_standard_member extends CommonStickerGenerator $file = $dir.'/'.$filename; } - //var_dump($file);exit; - if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); From 234fa7690f9b2896551ab3c1aa70e90da727f7b6 Mon Sep 17 00:00:00 2001 From: MDW Date: Sat, 4 Oct 2025 20:03:38 +0200 Subject: [PATCH 3/5] Qual: Update phan baseline & minor fix (#35638) # Qual: Update phan baseline & minor fix Fix new phan notice using cast of potential null value. Remove unneeded exceptions from baseline. --- dev/tools/phan/baseline.txt | 4 +--- .../fourn/class/fournisseur.commande.class.php | 18 +++++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 142321ab70a..074c97342dc 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -20,8 +20,8 @@ return [ // PhanPossiblyUndeclaredGlobalVariable : 6 occurrences // PhanTypeArraySuspiciousNull : 6 occurrences // PhanTypeComparisonFromArray : 6 occurrences - // PhanTypeMismatchArgumentProbablyReal : 6 occurrences // PhanTypeExpectedObjectPropAccess : 5 occurrences + // PhanTypeMismatchArgumentProbablyReal : 5 occurrences // PhanPluginDuplicateArrayKey : 4 occurrences // PhanParamTooMany : 3 occurrences // PhanPluginUndeclaredVariableIsset : 3 occurrences @@ -41,7 +41,6 @@ return [ 'htdocs/comm/mailing/index.php' => ['PhanUndeclaredProperty'], 'htdocs/comm/mailing/targetemailing.php' => ['PhanUndeclaredProperty'], 'htdocs/comm/propal/list.php' => ['PhanUndeclaredProperty'], - 'htdocs/commande/class/api_orders.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/commande/class/commande.class.php' => ['PhanUndeclaredProperty'], 'htdocs/commande/list.php' => ['PhanUndeclaredProperty'], 'htdocs/commande/list_det.php' => ['PhanTypeInvalidDimOffset'], @@ -176,7 +175,6 @@ return [ 'htdocs/fichinter/class/api_interventions.class.php' => ['PhanUndeclaredProperty'], 'htdocs/fichinter/class/fichinterrec.class.php' => ['PhanUndeclaredProperty'], 'htdocs/filefunc.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/fourn/class/api_supplier_orders.class.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/fourn/class/fournisseur.commande.class.php' => ['PhanUndeclaredProperty'], 'htdocs/fourn/commande/card.php' => ['PhanUndeclaredProperty'], 'htdocs/fourn/facture/card-rec.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7fb3cbabd34..10a75f0be6a 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3160,7 +3160,7 @@ class CommandeFournisseur extends CommonOrder $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice = calcul_price_total($qty, (float) $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, (float) $pu_ht_devise); + $tabprice = calcul_price_total($qty, (float) $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, (float) $this->multicurrency_tx, (float) $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -3199,14 +3199,14 @@ class CommandeFournisseur extends CommonOrder } else { // Ensure packaging is numeric, positive, and use fmod instead of %, to prevent error with decimal packaging values (resulting in division by zero) if ( - !empty($this->line->packaging) - && is_numeric($this->line->packaging) - && (float) $this->line->packaging > 0 - && fmod((float) $qty, (float) $this->line->packaging) > 0 - ) { - $coeff = intval($qty / $this->line->packaging) + 1; - $qty = $this->line->packaging * $coeff; - setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); + !empty($this->line->packaging) + && is_numeric($this->line->packaging) + && (float) $this->line->packaging > 0 + && fmod((float) $qty, (float) $this->line->packaging) > 0 + ) { + $coeff = intval($qty / $this->line->packaging) + 1; + $qty = $this->line->packaging * $coeff; + setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); } } } From 76916ad1cf4385370cff133c8964d3ec8b6e4818 Mon Sep 17 00:00:00 2001 From: Jon Bendtsen Date: Sat, 4 Oct 2025 20:08:27 +0200 Subject: [PATCH 4/5] Add fk_project to Mass Emailings (#35635) * Add fk_project to Mass Emailings * Mass Mailing fk_project SQL definition dispre * mailing typecasting fk_project * mailing using correct variable name * more type casting to fix phpstan errors related to fk_project in mass mailing * mailing fk_project NULL better default in DB --------- Co-authored-by: Jon Bendtsen --- .../comm/mailing/class/api_mailings.class.php | 53 +++++++++++++++++-- htdocs/comm/mailing/class/mailing.class.php | 9 ++++ .../install/mysql/migration/22.0.0-23.0.0.sql | 2 + .../mysql/tables/llx_mailing-mailing.sql | 3 +- 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/mailing/class/api_mailings.class.php b/htdocs/comm/mailing/class/api_mailings.class.php index 10a8491c75e..46830e90e32 100644 --- a/htdocs/comm/mailing/class/api_mailings.class.php +++ b/htdocs/comm/mailing/class/api_mailings.class.php @@ -98,6 +98,10 @@ class Mailings extends DolibarrApi $this->mailing->fetchObjectLinked(); + if (!DolibarrApi::_checkAccessToResource('project', ((int) $this->mailing->fk_project))) { + throw new RestException(403, 'Access (project) not allowed for login '.DolibarrApiAccess::$user->login); + } + return $this->_cleanObjectDatas($this->mailing); } @@ -112,6 +116,7 @@ class Mailings extends DolibarrApi * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param string $fk_projects Project ids to filter mass mailings (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'2016-01-01')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* @@ -122,18 +127,27 @@ class Mailings extends DolibarrApi * * @throws RestException */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '', $pagination_data = false, $loadlinkedobjects = 0) + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $fk_projects = '', $sqlfilters = '', $properties = '', $pagination_data = false, $loadlinkedobjects = 0) { if (!DolibarrApiAccess::$user->hasRight('mailing', 'read')) { throw new RestException(403); } + $arrayProjects = explode(",", $fk_projects); + foreach ($arrayProjects as $project => $value) { + if (!DolibarrApi::_checkAccessToResource('project', ((int) $value))) { + throw new RestException(403, 'Access (project) not allowed for login '.DolibarrApiAccess::$user->login); + } + } + $obj_ret = array(); $sql = "SELECT t.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing AS t"; $sql .= ' WHERE t.entity IN ('.getEntity('mailing').')'; - // Add sql filters + if ($fk_projects) { + $sql .= " AND t.fk_project IN (".$this->db->sanitize($fk_projects).")"; + } // Add sql filters if ($sqlfilters) { $errormessage = ''; $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage); @@ -224,6 +238,10 @@ class Mailings extends DolibarrApi throw new RestException(404, 'Mass mailing to clone not found, id='.$id); } + if (!DolibarrApi::_checkAccessToResource('project', ((int) $this->mailing->fk_project))) { + throw new RestException(403, 'Access (project) not allowed for login '.DolibarrApiAccess::$user->login); + } + $cloningResult = $this->mailing->createFromClone(DolibarrApiAccess::$user, ((int) $id), ((int) $cloneContent), ((int) $cloneRecipients), ((int) $notrigger)); if ($cloningResult < 0) { throw new RestException(500, "Error cloning mass mailing", array_merge(array($this->mailing->error), $this->mailing->errors)); @@ -262,9 +280,15 @@ class Mailings extends DolibarrApi $this->mailing->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09'); continue; } + if ($field === 'fk_project') { + if (!DolibarrApi::_checkAccessToResource('project', ((int) $value))) { + throw new RestException(403, 'Access (project) not allowed for login '.DolibarrApiAccess::$user->login); + } + } $this->mailing->$field = $this->_checkValForAPI($field, $value, $this->mailing); } + if ($this->mailing->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating mass mailing", array_merge(array($this->mailing->error), $this->mailing->errors)); } @@ -296,6 +320,10 @@ class Mailings extends DolibarrApi throw new RestException(404, 'Mass mailing not found, id='.$id); } + if (!DolibarrApi::_checkAccessToResource('project', ((int) $this->mailing->fk_project))) { + throw new RestException(403, 'Access (project) not allowed for login '.DolibarrApiAccess::$user->login); + } + if (!DolibarrApi::_checkAccessToResource('mailing', $this->mailing->id)) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -349,6 +377,10 @@ class Mailings extends DolibarrApi throw new RestException(404, 'Mass mailing not found, id='.$id); } + if (!DolibarrApi::_checkAccessToResource('project', ((int) $this->mailing->fk_project))) { + throw new RestException(403, 'Access (project) not allowed for login '.DolibarrApiAccess::$user->login); + } + if (!DolibarrApi::_checkAccessToResource('mailing', $this->mailing->id)) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -391,6 +423,10 @@ class Mailings extends DolibarrApi throw new RestException(404, 'Mass mailing not found, id='.$id); } + if (!DolibarrApi::_checkAccessToResource('project', ((int) $this->mailing->fk_project))) { + throw new RestException(403, 'Access (project) not allowed for login '.DolibarrApiAccess::$user->login); + } + if (!DolibarrApi::_checkAccessToResource('mailing', $this->mailing->id)) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -434,6 +470,10 @@ class Mailings extends DolibarrApi throw new RestException(404, 'Mass mailing not found, id='.$id); } + if (!DolibarrApi::_checkAccessToResource('project', ((int) $this->mailing->fk_project))) { + throw new RestException(403, 'Access (project) not allowed for login '.DolibarrApiAccess::$user->login); + } + if (!DolibarrApi::_checkAccessToResource('mailing', $this->mailing->id)) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -476,6 +516,10 @@ class Mailings extends DolibarrApi throw new RestException(404, 'Mass mailing not found, id='.$id); } + if (!DolibarrApi::_checkAccessToResource('project', ((int) $this->mailing->fk_project))) { + throw new RestException(403, 'Access (project) not allowed for login '.DolibarrApiAccess::$user->login); + } + if (!DolibarrApi::_checkAccessToResource('mailing', $this->mailing->id)) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -524,6 +568,10 @@ class Mailings extends DolibarrApi throw new RestException(404, 'Mass mailing not found, id='.$id); } + if (!DolibarrApi::_checkAccessToResource('project', ((int) $this->mailing->fk_project))) { + throw new RestException(403, 'Access (project) not allowed for login '.DolibarrApiAccess::$user->login); + } + if (!DolibarrApi::_checkAccessToResource('mailing', $this->mailing->id)) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -614,7 +662,6 @@ class Mailings extends DolibarrApi unset($object->fk_delivery_address); unset($object->fk_element); unset($object->fk_multicurrency); - unset($object->fk_project); unset($object->fk_projet); unset($object->import_key); unset($object->isextrafieldmanaged); diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index b2b219205fd..e4eb696499d 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -174,6 +174,12 @@ class Mailing extends CommonObject */ public $substitutionarrayfortest; + /** + * @var ?int The related project ID + * @see setProject(), project + */ + public $fk_project; + const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; const STATUS_SENTPARTIALY = 2; @@ -318,6 +324,7 @@ class Mailing extends CommonObject $sql .= ", evenunsubscribe = ".((int) $this->evenunsubscribe); $sql .= ", note_public = '".$this->db->escape($this->note_public)."'"; $sql .= ", note_private = '".$this->db->escape($this->note_private)."'"; + $sql .= ", fk_project = '".((int) $this->fk_project)."'"; $sql .= " WHERE rowid = ".(int) $this->id; dol_syslog(__METHOD__, LOG_DEBUG); @@ -381,6 +388,7 @@ class Mailing extends CommonObject $sql .= ", m.joined_file2"; $sql .= ", m.joined_file3"; $sql .= ", m.joined_file4"; + $sql .= ", m.fk_project"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql .= " WHERE entity IN (".getEntity('mailing').")"; if ($ref) { @@ -443,6 +451,7 @@ class Mailing extends CommonObject $this->joined_file2 = $obj->joined_file2; $this->joined_file3 = $obj->joined_file3; $this->joined_file4 = $obj->joined_file4; + $this->fk_project = $obj->fk_project; if ($this->messtype == 'sms') { $this->picto = 'phone'; diff --git a/htdocs/install/mysql/migration/22.0.0-23.0.0.sql b/htdocs/install/mysql/migration/22.0.0-23.0.0.sql index 5747ba93504..50302975a80 100644 --- a/htdocs/install/mysql/migration/22.0.0-23.0.0.sql +++ b/htdocs/install/mysql/migration/22.0.0-23.0.0.sql @@ -200,4 +200,6 @@ create table llx_categorie_supplier_proposal import_key varchar(14) )ENGINE=innodb; +ALTER TABLE llx_mailing ADD COLUMN fk_project integer DEFAULT NULL; + -- end of migration diff --git a/htdocs/install/mysql/tables/llx_mailing-mailing.sql b/htdocs/install/mysql/tables/llx_mailing-mailing.sql index eb03b17853b..c0cbbbe0477 100644 --- a/htdocs/install/mysql/tables/llx_mailing-mailing.sql +++ b/htdocs/install/mysql/tables/llx_mailing-mailing.sql @@ -52,5 +52,6 @@ create table llx_mailing joined_file4 varchar(255), statut smallint DEFAULT 0, -- status (draft:0, valid: 1, approved: 2, sent: 3) note_private text, - note_public text + note_public text, + fk_project integer DEFAULT NULL )ENGINE=innodb; From 78ca88f4fc48f2d13828c09a78bb3c3f11884a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 5 Oct 2025 16:51:29 +0200 Subject: [PATCH 5/5] clean code (#35640) * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code --- dev/build/phpstan/phpstan-baseline.neon | 24 -------- htdocs/adherents/admin/member.php | 2 + htdocs/adherents/admin/website.php | 14 +++-- htdocs/adherents/type.php | 9 +-- htdocs/commande/card.php | 59 ++++++++++--------- htdocs/compta/bank/various_payment/card.php | 2 +- htdocs/core/lib/files.lib.php | 7 +-- .../member/doc/pdf_standard_member.class.php | 2 +- htdocs/ecm/index_medias.php | 49 ++++++++------- .../class/price_parser.class.php | 4 +- htdocs/public/members/new.php | 10 ++-- 11 files changed, 80 insertions(+), 102 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 4e09e7bae45..5e389231ffc 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -2358,30 +2358,12 @@ parameters: count: 1 path: ../../../htdocs/comm/propal/list.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: ../../../htdocs/commande/card.php - - - - message: '#^Right side of && is always true\.$#' - identifier: booleanAnd.rightAlwaysTrue - count: 2 - path: ../../../htdocs/commande/card.php - - message: '#^Variable \$classname might not be defined\.$#' identifier: variable.undefined count: 3 path: ../../../htdocs/commande/card.php - - - message: '#^Parameter \#1 \$object of method Orders\:\:_cleanObjectDatas\(\) expects object, array\\>\|int given\.$#' - identifier: argument.type - count: 1 - path: ../../../htdocs/commande/class/api_orders.class.php - - message: '#^Variable \$socid might not be defined\.$#' identifier: variable.undefined @@ -9846,12 +9828,6 @@ parameters: count: 1 path: ../../../htdocs/fourn/card.php - - - message: '#^Parameter \#1 \$object of method SupplierOrders\:\:_cleanObjectDatas\(\) expects object, array\ given\.$#' - identifier: argument.type - count: 1 - path: ../../../htdocs/fourn/class/api_supplier_orders.class.php - - message: '#^Variable \$contact might not be defined\.$#' identifier: variable.undefined diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 89b6c85f6e0..32a02575fe9 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -303,6 +303,7 @@ foreach ($dirModMember as $dirroot) { $arrayofmodules = dol_sort_array($arrayofmodules, 'position'); '@phan-var-force array $arrayofmodules'; +/** @var array $arrayofmodules */ foreach ($arrayofmodules as $file => $modCodeMember) { print ''."\n"; @@ -405,6 +406,7 @@ foreach ($dirmodels as $reldir) { require_once $dir.'/'.$file; $module = new $classname($db); '@phan-var-force doc_generic_member_odt|pdf_standard_member $module'; + /** @var doc_generic_member_odt|pdf_standard_member $module */ $modulequalified = 1; if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index c8a6a08218e..65be0b4c281 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -4,7 +4,7 @@ * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2024 Alexandre Spangaro - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 Frédéric France * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -237,14 +237,16 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { print "\n"; // Force nature of member (mor/phy) - $morphys = array(); - $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Moral"); + $morphys = [ + "" => $langs->trans("MorAndPhy"), // for empty choice + "phy" => $langs->trans("Physical"), + "mor" => $langs->trans("Moral"), + ]; print ''; print $langs->trans("ForceMemberNature"); print ''; - $forcenature = getDolGlobalInt('MEMBER_NEWFORM_FORCEMORPHY', 0); - print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, 1); + $forcenature = getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY'); + print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature); print "\n"; // Amount diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index b38f3ad48fb..6e35dc2a6c0 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -554,10 +554,11 @@ if ($action == 'create') { print ''; // Morphy - $morphys = array(); - $morphys[""] = $langs->trans("MorAndPhy"); - $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Moral"); + $morphys = [ + "" => $langs->trans("MorAndPhy"), // for empty choice + "phy" => $langs->trans("Physical"), + "mor" => $langs->trans("Moral"), + ]; print ''.$langs->trans("MembersNature").''; print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy'); print ""; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ab59815860c..39640c85552 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -391,11 +391,9 @@ if (empty($reshook)) { $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOSTFLOAT('originmulticurrency_tx'); // Fill array 'array_options' with data from add form - if (!$error) { - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) { - $error++; - } + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; } // If creation from another object of another module (Example: origin=propal, originid=1) @@ -440,6 +438,7 @@ if (empty($reshook)) { $classname = ucfirst($subelement); $srcobject = new $classname($db); '@phan-var-force Commande|Propal|Contrat $srcobject'; + /** @var Commande|Propal|Contrat $srcobject */ dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); $result = $srcobject->fetch($object->origin_id); @@ -2044,7 +2043,7 @@ if (empty($reshook)) { if (!$error && getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB') && $usercancreate) { - if ($action == 'addcontact' && $usercancreate) { + if ($action == 'addcontact') { // Test on permission already done if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); @@ -2062,14 +2061,14 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } - } elseif ($action == 'swapstatut' && $usercancreate) { + } elseif ($action == 'swapstatut') { // Test on permission already done // bascule du statut d'un contact if ($object->id > 0) { $result = $object->swapContactStatus(GETPOSTINT('ligne')); } else { dol_print_error($db); } - } elseif ($action == 'deletecontact' && $usercancreate) { + } elseif ($action == 'deletecontact') { // Test on permission already done // Efface un contact $result = $object->delete_contact($lineid); @@ -2186,10 +2185,10 @@ if ($action == 'create' && $usercancreate) { $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0); $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0)); - $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0)); + $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0)); $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0)); - //$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); - //$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + // $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); + // $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); $dateorder = !getDolGlobalString('MAIN_AUTOFILL_DATE_ORDER') ? -1 : ''; $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : ''); @@ -2218,9 +2217,9 @@ if ($action == 'create' && $usercancreate) { $shipping_method_id = $soc->shipping_method_id; $warehouse_id = $soc->fk_warehouse; $demand_reason_id = $soc->demand_reason_id; - //$remise_percent = $soc->remise_percent; - //$remise_absolue = 0; - $dateorder = !getDolGlobalString('MAIN_AUTOFILL_DATE_ORDER') ? -1 : ''; + // $remise_percent = $soc->remise_percent; + // $remise_absolue = 0; + $dateorder = !getDolGlobalString('MAIN_AUTOFILL_DATE_ORDER') ? -1 : ''; if (isModEnabled("multicurrency") && !empty($soc->multicurrency_code)) { $currency_code = $soc->multicurrency_code; @@ -2484,7 +2483,7 @@ if ($action == 'create' && $usercancreate) { } // Categories - if (!empty($conf->categorie->enabled)) { + if (isModEnabled('category')) { print '' . $langs->trans("Categories") . ''; print $form->selectCategories(Categorie::TYPE_ORDER, 'categories', $object); print ""; @@ -2521,13 +2520,12 @@ if ($action == 'create' && $usercancreate) { $objectsrc->update_price(1); } - print "\n"; - print "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print ''; - print ''; + print "\n\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print ''; + print ''; switch ($classname) { case 'Propal': @@ -2752,7 +2750,6 @@ if ($action == 'create' && $usercancreate) { ); } - $paymentTermsSelect = $form->getSelectConditionsPaiements(0, 'cond_reglement_id', -1, 0, 0, 'minwidth200'); $formquestion[] = array( @@ -2819,12 +2816,17 @@ if ($action == 'create' && $usercancreate) { if ($conf->browser->name == 'ie') { $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy } - $formquestion = array( + $formquestion = [ // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ? GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); + [ + 'type' => 'other', + 'name' => 'idwarehouse', + 'label' => $langs->trans("SelectWarehouseForStockIncrease"), + 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ? GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo) + ] + ]; } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220); @@ -2898,12 +2900,12 @@ if ($action == 'create' && $usercancreate) { $langs->load('subtotals'); $type = 'title'; $depth_array = $object->getPossibleLevels($langs); - require dol_buildpath('/core/tpl/subtotal_create.tpl.php'); + include DOL_DOCUMENT_ROOT . '/core/tpl/subtotal_create.tpl.php'; } elseif ($action == 'add_subtotal_line') { $langs->load('subtotals'); $type = 'subtotal'; $titles = $object->getPossibleTitles(); - require dol_buildpath('/core/tpl/subtotal_create.tpl.php'); + include DOL_DOCUMENT_ROOT . '/core/tpl/subtotal_create.tpl.php'; } // Call Hook formConfirm @@ -2956,7 +2958,6 @@ if ($action == 'create' && $usercancreate) { } $morehtmlref .= ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); // Call Hook tabContentViewOrder diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 634971a30ba..e5cd161c346 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -523,7 +523,7 @@ if ($action == 'create') { print $hookmanager->resPrint; // Category - if (is_array($options) && count($options) && $conf->categorie->enabled) { + if (is_array($options) && count($options) && isModEnabled('category')) { print ''.$langs->trans("RubriquesTransactions").''; print img_picto('', 'category').Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1, 0, 0, '', 0, 0, 0, '', 'minwidth300', 1); print ''; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 83a4436d569..c024fde45a4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -431,6 +431,8 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir, $object = if (is_null($object)) { $object = new stdClass(); + $object->id = null; + $object->element = null; } $filearrayindatabase = dol_dir_list_in_database(rtrim($relativedir, "/\\"), '', null, 'name', SORT_ASC, 0, '', $object); @@ -461,11 +463,6 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir, $object = } } - //var_dump($relativedir); - //var_dump($filearray); - //var_dump($filearrayindatabase); - //var_dump($object->entity); - // Complete filearray with properties found into $filearrayindatabase foreach ($filearray as $key => $val) { $tmpfilename = preg_replace('/\.noexe$/', '', $filearray[$key]['name']); diff --git a/htdocs/core/modules/member/doc/pdf_standard_member.class.php b/htdocs/core/modules/member/doc/pdf_standard_member.class.php index 6778397a697..6b70b637c9a 100644 --- a/htdocs/core/modules/member/doc/pdf_standard_member.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard_member.class.php @@ -272,7 +272,7 @@ class pdf_standard_member extends CommonStickerGenerator * @param string $filename Name of output file (without extension) * @return int<-1,1> 1=OK, <=0=KO */ - public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = '', $filename = 'tmp_cards') + public function write_file($object, $outputlangs, $srctemplatepath = '', $mode = 'member', $nooutput = '', $filename = 'tmp_cards') { // phpcs:enable global $user, $conf, $langs, $mysoc; diff --git a/htdocs/ecm/index_medias.php b/htdocs/ecm/index_medias.php index f68ea1b57ae..e93404b1aef 100644 --- a/htdocs/ecm/index_medias.php +++ b/htdocs/ecm/index_medias.php @@ -1,7 +1,7 @@ - * Copyright (C) 2008-2010 Regis Houssin - * Copyright (C) 2024 Frédéric France +/* Copyright (C) 2008-2017 Laurent Destailleur + * Copyright (C) 2008-2010 Regis Houssin + * Copyright (C) 2024-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 @@ -27,12 +27,6 @@ // Load Dolibarr environment require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; - /** * @var Conf $conf * @var DoliDB $db @@ -41,6 +35,12 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; * @var User $user */ +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; + // Load translation files required by the page $langs->loadLangs(array('ecm', 'companies', 'other', 'users', 'orders', 'propal', 'bills', 'contracts')); @@ -143,9 +143,9 @@ if ($action == 'renamefile') { // Test on permission not required here. Must be // Add directory if ($action == 'add' && $permissiontouploadfile) { - $ecmdir->ref = 'NOTUSEDYET'; - $ecmdir->label = GETPOST("label"); - $ecmdir->description = GETPOST("desc"); + $ecmdir->ref = 'NOTUSEDYET'; + $ecmdir->label = GETPOST("label"); + $ecmdir->description = GETPOST("desc"); $id = $ecmdir->create($user); if ($id > 0) { @@ -188,8 +188,6 @@ if ($action == 'refreshmanual' && $permissiontoread) { $adirwascreated = 0; // Now we compare both trees to complete missing trees into database - //var_dump($disktree); - //var_dump($sqltree); foreach ($disktree as $dirdesc) { // Loop on tree onto disk $dirisindatabase = 0; foreach ($sqltree as $dirsqldesc) { @@ -202,7 +200,6 @@ if ($action == 'refreshmanual' && $permissiontoread) { if (!$dirisindatabase) { $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; dol_syslog($txt); - //print $txt."
\n"; // We must first find the fk_parent of directory to create $dirdesc['fullname'] $fk_parent = -1; @@ -237,23 +234,24 @@ if ($action == 'refreshmanual' && $permissiontoread) { } if ($fk_parent >= 0) { - $ecmdirtmp->ref = 'NOTUSEDYET'; - $ecmdirtmp->label = dol_basename($dirdesc['fullname']); - $ecmdirtmp->description = ''; - $ecmdirtmp->fk_parent = $fk_parent; + $ecmdirtmp->ref = 'NOTUSEDYET'; + $ecmdirtmp->label = dol_basename($dirdesc['fullname']); + $ecmdirtmp->description = ''; + $ecmdirtmp->fk_parent = $fk_parent; $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; dol_syslog($txt); //print $ecmdirtmp->cachenbofdoc."
\n";exit; $id = $ecmdirtmp->create($user); if ($id > 0) { - $newdirsql = array('id' => $id, - 'id_mere' => $ecmdirtmp->fk_parent, - 'label' => $ecmdirtmp->label, - 'description' => $ecmdirtmp->description, - 'fullrelativename' => $relativepathmissing); + $newdirsql = [ + 'id' => $id, + 'id_mere' => $ecmdirtmp->fk_parent, + 'label' => $ecmdirtmp->label, + 'description' => $ecmdirtmp->description, + 'fullrelativename' => $relativepathmissing, + ]; $sqltree[] = $newdirsql; // We complete fulltree for following loops - //var_dump($sqltree); $adirwascreated = 1; } else { dol_syslog("Failed to create directory ".$ecmdirtmp->label, LOG_ERR); @@ -261,7 +259,6 @@ if ($action == 'refreshmanual' && $permissiontoread) { } else { $txt = "Parent of ".$dirdesc['fullname']." not found"; dol_syslog($txt); - //print $txt."
\n"; } } } diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index d5e714439f4..1acee47f315 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -118,13 +118,13 @@ class PriceParser if (in_array($code, array(9, 14, 19, 20))) { //Errors which have 0 arg return $langs->trans("ErrorPriceExpression".$code); } elseif (in_array($code, array(1, 2, 3, 4, 5, 8, 10, 11, 17, 21, 22))) { //Errors which have 1 arg - return $langs->trans("ErrorPriceExpression".$code, $info); + return $langs->trans("ErrorPriceExpression".$code, (string) $info); } elseif (in_array($code, array(6, 23))) { //Errors which have 2 args return $langs->trans("ErrorPriceExpression".$code, $info[0], $info[1]); } elseif (in_array($code, array(7, 12, 13, 15, 16, 18))) { //Internal errors return $langs->trans("ErrorPriceExpressionInternal", $code); } else { //Unknown errors - return $langs->trans("ErrorPriceExpressionUnknown", $code); + return $langs->trans("ErrorPriceExpressionUnknown", (string) $code); } } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index cbe7c36ddaf..055f0700971 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -4,7 +4,7 @@ * Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2012 J. Fernando Lagrange - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2021 Waël Almoman * Copyright (C) 2022 Udo Tamm @@ -609,9 +609,11 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR print ''."\n"; // Moral/Physic attribute - $morphys = array(); - $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Moral"); + $morphys = [ + // "" => $langs->trans("MorAndPhy"), + "phy" => $langs->trans("Physical"), + "mor" => $langs->trans("Moral"), + ]; $checkednature = GETPOST("morphy", 'alpha'); $listetype_natures = $adht->morphyByType(1); // Load the array of morphy per type $listetype_natures_json = json_encode($listetype_natures);