This commit introduces significant updates to the promoteur hub, including the addition of a new JavaScript file for AJAX handling of event statistics and links. The PHP file `ajax_promoteur_hub.php` is modified to support new actions for fetching event statistics and links, improving the user experience with better error handling and loading indicators. Additionally, a new batch access control function is implemented in `inc_fx_promoteur_hub.php` to streamline permission checks for events. The version code is incremented to reflect these enhancements, aiming to improve functionality and maintainability across the promoteur hub.
97 lines
3.7 KiB
PHP
97 lines
3.7 KiB
PHP
<?php
|
|
/**
|
|
* MSIN-4435 — Assets JS modules v2 (hors inc_footer_scripts.php legacy).
|
|
* Bib v4, gestion inscriptions v2 : chargés uniquement sur leurs pages.
|
|
*/
|
|
|
|
if (!function_exists('fxV2RegisterScript')) {
|
|
|
|
/** @param string $strName bib-assignments | inscr-gestion | promoteur-hub */
|
|
function fxV2RegisterScript($strName) {
|
|
global $MS1_V2_SCRIPTS;
|
|
if (!isset($MS1_V2_SCRIPTS) || !is_array($MS1_V2_SCRIPTS)) {
|
|
$MS1_V2_SCRIPTS = [];
|
|
}
|
|
if (!in_array($strName, $MS1_V2_SCRIPTS, true)) {
|
|
$MS1_V2_SCRIPTS[] = $strName;
|
|
}
|
|
}
|
|
|
|
/** Config injectée dans window.MS1_V2_PROMOTEUR_HUB avant promoteur-hub.js */
|
|
function fxV2PromoteurHubConfig($strLangue) {
|
|
global $vDomaine;
|
|
|
|
$strLangue = ($strLangue === 'en') ? 'en' : 'fr';
|
|
$strWait = afficheTexte('preloader_wait', 0, 0, 1);
|
|
if (trim((string)$strWait) === '' || $strWait === 'preloader_wait') {
|
|
$strWait = ($strLangue === 'en') ? 'Loading…' : 'Chargement…';
|
|
}
|
|
|
|
return [
|
|
'ajaxUrl' => $vDomaine . '/ajax_promoteur_hub.php',
|
|
'preloaderWait' => $strWait,
|
|
];
|
|
}
|
|
|
|
/** Config injectée dans window.MS1_V2_INSCR_GESTION avant inscr-gestion.js */
|
|
function fxV2InscrGestionConfig($strLangue) {
|
|
global $vDomaine;
|
|
|
|
$strLangue = ($strLangue === 'en') ? 'en' : 'fr';
|
|
|
|
return [
|
|
'domain' => $vDomaine,
|
|
'lang' => $strLangue,
|
|
'preloaderWait' => afficheTexte('preloader_wait', 0, 0, 1),
|
|
'refundCancelHint' => ($strLangue === 'en')
|
|
? 'Your transaction has been refunded. If you also want to cancel it in the registration system:'
|
|
: "Votre transaction a été remboursée. Si vous voulez aussi l'annuler dans le système d'inscription :",
|
|
'loginMessages' => [
|
|
'txt_login' => ($strLangue === 'fr')
|
|
? "Veuillez entrer votre nom d'usager"
|
|
: 'Please enter your username',
|
|
'txt_password' => ($strLangue === 'fr')
|
|
? 'Veuillez entrer votre mot de passe'
|
|
: 'Please enter your password',
|
|
],
|
|
];
|
|
}
|
|
|
|
/** À appeler dans inc_footer.php après inc_footer_scripts.php */
|
|
function fxV2RenderFooterScripts() {
|
|
global $MS1_V2_SCRIPTS, $vDomaine, $strLangue;
|
|
|
|
if (empty($MS1_V2_SCRIPTS) || !is_array($MS1_V2_SCRIPTS)) {
|
|
return;
|
|
}
|
|
|
|
$mapFiles = [
|
|
'bib-assignments' => '/js/v2/bib-assignments.js',
|
|
'inscr-gestion' => '/js/v2/inscr-gestion.js',
|
|
'promoteur-hub' => '/js/v2/promoteur-hub.js',
|
|
];
|
|
|
|
if (in_array('promoteur-hub', $MS1_V2_SCRIPTS, true)) {
|
|
$cfg = fxV2PromoteurHubConfig($strLangue ?? 'fr');
|
|
echo '<script>window.MS1_V2_PROMOTEUR_HUB='
|
|
. json_encode($cfg, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP)
|
|
. ';</script>' . "\n";
|
|
}
|
|
|
|
if (in_array('inscr-gestion', $MS1_V2_SCRIPTS, true)) {
|
|
$cfg = fxV2InscrGestionConfig($strLangue ?? 'fr');
|
|
echo '<script>window.MS1_V2_INSCR_GESTION='
|
|
. json_encode($cfg, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP)
|
|
. ';</script>' . "\n";
|
|
}
|
|
|
|
foreach ($MS1_V2_SCRIPTS as $strName) {
|
|
if (!isset($mapFiles[$strName])) {
|
|
continue;
|
|
}
|
|
$strSrc = htmlspecialchars($vDomaine . $mapFiles[$strName], ENT_QUOTES, 'UTF-8');
|
|
echo '<script src="' . $strSrc . '?v=' . htmlspecialchars(_VERSION_CODE, ENT_QUOTES, 'UTF-8') . '"></script>' . "\n";
|
|
}
|
|
}
|
|
}
|