From dd4a83043ab078d81c3fd67a13a4ea1ea4e6961a Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 7 Jul 2026 16:09:11 -0400 Subject: [PATCH] 4436 Add payment session handling and mode checks in inc_fonctions.php and inc_fx_panier_js.php This commit introduces new functions for managing payment session data, including `fxPaiementSessionComId`, `fxPaiementCanUseModesPromoteur`, and `fxPaiementCanUseModesAdmin`. These functions enhance the payment processing logic by determining the appropriate payment modes based on user roles (promoteur or admin). The existing payment display functions in `inc_fx_panier_js.php` are updated to utilize these new functions, improving the clarity and maintainability of the payment handling process. These changes aim to enhance user experience and ensure proper access control for payment options. --- php/inc_fonctions.php | 43 ++++++++++++++++++++++++++++++++++++++++ php/inc_fx_panier_js.php | 22 ++++++++++---------- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/php/inc_fonctions.php b/php/inc_fonctions.php index 4a5593c..e3b2d46 100644 --- a/php/inc_fonctions.php +++ b/php/inc_fonctions.php @@ -871,6 +871,49 @@ function fxGetPaiements($blnAdmin = false, $blnIsPromoteur = false, $strLangue = return false; } +/** Compte connecté au panier (com_info ou com_id en session). */ +function fxPaiementSessionComId() +{ + if (!empty($_SESSION['com_info']['com_id'])) { + return intval($_SESSION['com_info']['com_id']); + } + + if (!empty($_SESSION['com_id'])) { + return intval($_SESSION['com_id']); + } + + return 0; +} + +/** Modes paiement réservés promoteur (chèque, etc.) — aligné hub v2 + legacy. */ +function fxPaiementCanUseModesPromoteur($intComId, $intEveId) +{ + $intComId = intval($intComId); + $intEveId = intval($intEveId); + + if ($intComId <= 0 || $intEveId <= 0) { + return false; + } + + if (!function_exists('fxPromoteurHubCanAccessPromoteurWeb')) { + require_once __DIR__ . '/inc_fx_promoteur_hub.php'; + } + + $arrLegacyFlip = array(); + + if (function_exists('fxPromoteurHubGetLegacyEventIds')) { + $arrLegacyFlip = array_flip(array_map('intval', fxPromoteurHubGetLegacyEventIds($intComId))); + } + + return fxPromoteurHubCanAccessPromoteurWeb($intComId, $intEveId, $arrLegacyFlip); +} + +/** Modes paiement réservés admin (canal superadm / usa_id). */ +function fxPaiementCanUseModesAdmin() +{ + return !empty($_SESSION['usa_id']); +} + // fonction qui retire/transforme le HTML présent dans les termes et conditions à accepter // param : texteà transformer // créé : 2013-04-26 diff --git a/php/inc_fx_panier_js.php b/php/inc_fx_panier_js.php index 539b101..d1ee4ef 100644 --- a/php/inc_fx_panier_js.php +++ b/php/inc_fx_panier_js.php @@ -736,14 +736,13 @@ function fxShowBlocPaiement($tabEvenement, $fltMontant, $strLangue) '; if (floatval($fltMontant) > 0) { - if (isset($_SESSION['com_info']) && $_SESSION['com_info'] != '') { - $blnIsPromoteur = fxIsPromoteur($_SESSION['com_info']['com_id'], $tabEvenement['general']['eve_id']); + $intComId = fxPaiementSessionComId(); + + if ($intComId > 0) { + $blnIsPromoteur = fxPaiementCanUseModesPromoteur($intComId, $tabEvenement['general']['eve_id']); } - // si en mode admin, récupérer les mode de paiement réservés aux admin - if (isset($_SESSION['usa_id'])) { - $blnAdmin = true; - } + $blnAdmin = fxPaiementCanUseModesAdmin(); $tabPaiements = fxGetPaiements($blnAdmin, $blnIsPromoteur, $strLangue); @@ -916,14 +915,13 @@ function fxShowBlocPaiementpaypaladvance($tabEvenement, $fltMontant, $strLangue) '; if (floatval($fltMontant) > 0) { - if (isset($_SESSION['com_info']) && $_SESSION['com_info'] != '') { - $blnIsPromoteur = fxIsPromoteur($_SESSION['com_info']['com_id'], $tabEvenement['general']['eve_id']); + $intComId = fxPaiementSessionComId(); + + if ($intComId > 0) { + $blnIsPromoteur = fxPaiementCanUseModesPromoteur($intComId, $tabEvenement['general']['eve_id']); } - // si en mode admin, récupérer les mode de paiement réservés aux admin - if (isset($_SESSION['usa_id'])) { - $blnAdmin = true; - } + $blnAdmin = fxPaiementCanUseModesAdmin(); $tabPaiements = fxGetPaiements($blnAdmin, $blnIsPromoteur, $strLangue);