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);