Files
ms1inscription-v5/ajax_promoteur_hub.php

67 lines
1.9 KiB
PHP

<?php
session_start();
// Traductions toujours au nom de compte.php (jamais ajax_promoteur_hub.php).
define('MS1_PROMOTEUR_HUB_AJAX', true);
$_SERVER['PHP_SELF'] = '/compte.php';
$_SERVER['SCRIPT_NAME'] = '/compte.php';
require_once __DIR__ . '/php/inc_fonctions.php';
require_once __DIR__ . '/php/inc_fx_promoteur_hub.php';
header('Content-Type: application/json; charset=UTF-8');
$strAction = $_REQUEST['a'] ?? '';
$strLangue = $_REQUEST['lang'] ?? ($_SESSION['lang'] ?? 'fr');
if (!in_array($strLangue, array('fr', 'en'), true)) {
$strLangue = 'fr';
}
$vPage = 'compte.php';
$vtexte_page = obtenirTextepage($vPage, $strLangue, 2);
$intEveId = intval($_REQUEST['eve_id'] ?? 0);
if (empty($_SESSION['com_id'])) {
echo json_encode(array('ok' => false, 'msg' => 'Non connecté'));
exit;
}
$intComId = intval($_SESSION['com_id']);
if (!in_array($strAction, array('event_stats', 'event_links'), true) || $intEveId <= 0) {
echo json_encode(array('ok' => false, 'msg' => 'Requête invalide'));
exit;
}
if (!fxPromoteurHubComHasEvent($intComId, $intEveId)) {
echo json_encode(array('ok' => false, 'msg' => 'Accès refusé'));
exit;
}
if ($strAction === 'event_stats') {
if (!fxPromoteurHubCanViewDashboard($intComId, $intEveId)) {
echo json_encode(array('ok' => false, 'msg' => 'Accès refusé'));
exit;
}
$arrBundle = fxPromoteurHubRenderEventStatsBundle($intEveId, $strLangue);
echo json_encode(array(
'ok' => true,
'flash' => $arrBundle['flash'],
'html' => $arrBundle['html'],
));
exit;
}
$arrItem = fxPromoteurHubGetEventItemForLinks($intComId, $intEveId);
if ($arrItem === null) {
echo json_encode(array('ok' => false, 'msg' => 'Événement introuvable'));
exit;
}
echo json_encode(array(
'ok' => true,
'html' => fxPromoteurHubRenderEventPanelContent($arrItem, $strLangue),
));