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.
This commit is contained in:
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user