72 lines
2.1 KiB
PHP
72 lines
2.1 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'])) {
|
|
// MSIN-4401 — Le JS doit renvoyer au login, pas afficher un message mort.
|
|
echo json_encode(array(
|
|
'ok' => false,
|
|
'code' => 'session',
|
|
'msg' => fxPromoteurHubTexte('promoteur_hub_ajax_session', 0),
|
|
));
|
|
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' => fxPromoteurHubTexte('promoteur_hub_ajax_invalid', 0)));
|
|
exit;
|
|
}
|
|
|
|
if (!fxPromoteurHubComHasEvent($intComId, $intEveId)) {
|
|
echo json_encode(array('ok' => false, 'msg' => fxPromoteurHubTexte('promoteur_hub_ajax_denied', 0)));
|
|
exit;
|
|
}
|
|
|
|
if ($strAction === 'event_stats') {
|
|
if (!fxPromoteurHubCanViewDashboard($intComId, $intEveId)) {
|
|
echo json_encode(array('ok' => false, 'msg' => fxPromoteurHubTexte('promoteur_hub_ajax_denied', 0)));
|
|
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' => fxPromoteurHubTexte('promoteur_hub_ajax_not_found', 0)));
|
|
exit;
|
|
}
|
|
|
|
echo json_encode(array(
|
|
'ok' => true,
|
|
'html' => fxPromoteurHubRenderEventPanelContent($arrItem, $strLangue),
|
|
));
|