From 5936cdb61cdf6a5c56a74342b77558b01881c698 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 1 Jul 2026 14:14:25 -0400 Subject: [PATCH] Add legacy promoteur functionality and migration enhancements This commit introduces several enhancements related to the legacy promoteur system. It adds a new function to check if the legacy promoteur site is enabled and updates various functions to utilize this check, ensuring that legacy features are only accessible when appropriate. Additionally, it refines the migration process for legacy accounts, including improved handling of migration statistics and event access. The admin interface is updated to reflect these changes, enhancing the overall management of legacy promoteur accounts. The version code is updated to reflect these changes. --- php/inc_fonctions.php | 29 ++ php/inc_fx_compte.php | 26 +- php/inc_fx_eve_acces.php | 283 ++++++++---------- php/inc_fx_inscriptions_gestion.php | 37 ++- php/inc_fx_promoteur_hub.php | 8 + ...N-eve-acces-v2-promoteur-legacy-toggle.sql | 14 + superadm/enregistrer.php | 15 +- superadm/inc_droite.php | 29 ++ superadm/index.php | 44 ++- superadm/php/inc_functions.php | 22 ++ superadm/php/inc_fx_eve_acces_admin.php | 107 ++----- v3_ci4/app/Libraries/EventAccess.php | 10 + 12 files changed, 348 insertions(+), 276 deletions(-) create mode 100644 sql/MSIN-eve-acces-v2-promoteur-legacy-toggle.sql diff --git a/php/inc_fonctions.php b/php/inc_fonctions.php index 60a636c..16ebed2 100644 --- a/php/inc_fonctions.php +++ b/php/inc_fonctions.php @@ -1574,6 +1574,10 @@ function fxIsPromoteur($intComId, $intEveId) { global $objDatabase; + if (!fxPromoteurLegacySiteEnabled()) { + return false; + } + $sql = "select * from inscriptions_comptes where FIND_IN_SET('" . intval($intEveId) . "',com_eve_promoteur) AND com_id = " . intval($intComId); $tab = $objDatabase->fxGetResults($sql); @@ -2041,6 +2045,31 @@ function fxGetVariable($strVarNom) return $strVarValeur; } +/** + * Interrupteur site : promoteur legacy (com_eve_promoteur / fxIsPromoteur) actif ? + * Defaut : oui (1). Super admin : bouton dans inc_droite (variables.promoteur_legacy_actif). + */ +function fxPromoteurLegacySiteEnabled() +{ + static $blnEnabled = null; + + if ($blnEnabled !== null) { + return $blnEnabled; + } + + global $objDatabase; + + if (!isset($objDatabase)) { + $blnEnabled = true; + return $blnEnabled; + } + + $strVal = fxGetVariable('promoteur_legacy_actif'); + $blnEnabled = ($strVal === null || $strVal === '' || intval($strVal) === 1); + + return $blnEnabled; +} + function fxGetMailHeader($blnTransaction = false, $strLangue = 'fr') { if ($blnTransaction) { diff --git a/php/inc_fx_compte.php b/php/inc_fx_compte.php index ecf9988..92d195c 100644 --- a/php/inc_fx_compte.php +++ b/php/inc_fx_compte.php @@ -1505,13 +1505,23 @@ function fxShowMenuCompte($arrCompteClient, $strLangue) $strRetour .= fxShowPromoteurHubMenuLink($arrCompteClient, $strLangue); // menu promoteur legacy + if (!function_exists('fxInscrGestionUserHasLegacyPromoteurMenu')) { + require_once dirname(__FILE__) . '/inc_fx_inscriptions_gestion.php'; + } - if (trim($arrCompteClient['com_eve_promoteur']) != '' || trim($arrCompteClient['com_rapports']) != '') { // si le compte client a des événements dont il est le promoteur - $arrEvePromoteur = explode(',', $arrCompteClient['com_eve_promoteur']); - $intNbEvePromoteur = fxcount($arrEvePromoteur); - $strNbEvenements = '(' . $intNbEvePromoteur . ' '; - $strNbEvenements .= ($intNbEvePromoteur > 1) ? afficheTexte('compte_evenement_pluriel', 0) : afficheTexte('compte_evenement_singulier', 0); - $strNbEvenements .= ')'; + $blnLegacyPromoteurMenu = fxInscrGestionUserHasLegacyPromoteurMenu($arrCompteClient['com_id']); + $blnHasRapports = trim($arrCompteClient['com_rapports']) != ''; + + if ($blnLegacyPromoteurMenu || $blnHasRapports) { + if ($blnLegacyPromoteurMenu) { + $arrEvePromoteur = explode(',', $arrCompteClient['com_eve_promoteur']); + $intNbEvePromoteur = fxcount($arrEvePromoteur); + $strNbEvenements = '(' . $intNbEvePromoteur . ' '; + $strNbEvenements .= ($intNbEvePromoteur > 1) ? afficheTexte('compte_evenement_pluriel', 0) : afficheTexte('compte_evenement_singulier', 0); + $strNbEvenements .= ')'; + } else { + $strNbEvenements = ''; + } $strRetour .= '