MSIN-4465 — Refactor report access functions to support V2 permissions and enhance legacy menu handling. Update SQL queries for better data retrieval and add comments for clarity. Increment version code.

This commit is contained in:
2026-07-20 14:54:24 -04:00
parent f0bdefd805
commit f9d304484e
3 changed files with 115 additions and 26 deletions

View File

@ -767,8 +767,14 @@ function fxPromoteurHubGetEventLinks($arrItem, $strLangue)
);
}
/*
* MSIN-4465 — Menus hub legacy masqués (pages PHP toujours là).
* Pour réactiver : décommenter le bloc ci-dessous.
* - Dossards → inc_tableau_dossards
* - Quantités → inc_tableau_epreuves (si qte_modifiable)
* - Inscriptions V1 → inc_tableau_inscriptions
*
if (!$blnDon) {
// Menus legacy (dossards / quantités classiques) : promoteur legacy seul (sans kit V2)
if ($blnLegacyMenus || $blnSuper || $blnGrantsAll) {
$arrGestion[] = array('label' => fxPromoteurHubTexte('tableau_promoteur_menudossard', 0), 'url' => $strCompte . 'inc_tableau_dossards?promoteur_eve_id=' . $strE . '&lng=' . $strLangue, 'icon' => 'fa-id-card-o');
@ -781,6 +787,7 @@ function fxPromoteurHubGetEventLinks($arrItem, $strLangue)
if ($blnLegacyMenus || $blnSuper || $blnGrantsAll) {
$arrGestion[] = array('label' => fxPromoteurHubTexte('tableau_promoteur_menueinscription', 0), 'url' => $strCompte . 'inc_tableau_inscriptions?promoteur_eve_id=' . $strE . '&lng=' . $strLangue, 'icon' => 'fa-users');
}
*/
if ($fnCan(array('rabais.view', 'rabais.manage'))) {
$arrGestion[] = array('label' => fxPromoteurHubTexte('tableau_promoteur_rabais', 0), 'url' => $strCompte . 'inc_tableau_rabais?promoteur_eve_id=' . $strE . '&lng=' . $strLangue, 'icon' => 'fa-money');

View File

@ -1417,65 +1417,146 @@ function fxSuperadmConsumeRedirectAfterLogin($strDefault = 'index.php') {
}
/**
* Accès rapports superadm — super admin = tout ; sinon promoteur legacy (com_eve_promoteur / com_rapports).
* MSIN-4465 — Clés V2 pour un type de rapport (?r=…).
*/
function fxSuperadmReportsAllowed($intEvenement = 0) {
function fxSuperadmReportsPermKeysForReport($strReport)
{
switch ((string)$strReport) {
case 'chrono':
return array('reports.chrono');
case 'finances':
case 'finances-membership':
return array('reports.finances', 'reports.finances_membership', 'reports.finances_events');
case 'finances-membership-tq':
return array('reports.finances_membership');
case 'finances-membership-autre':
return array('reports.finances_events');
case 'adhesions':
return array('reports.adhesions');
case 'adhesions-ventes':
return array('reports.adhesions_sales');
case 'finances-pnq':
return array('reports.finances_captains');
case 'remboursements':
case 'remboursements-bilan':
return array('reports.payments');
case 'custom':
return array('reports.custom');
default:
return array(
'reports.chrono',
'reports.finances',
'reports.finances_membership',
'reports.finances_events',
'reports.payments',
'reports.adhesions',
'reports.adhesions_sales',
'reports.finances_captains',
'reports.custom',
);
}
}
/** MSIN-4465 — Accès rapport via kit V2 (grants_all ou reports.*). */
function fxSuperadmReportsAllowedV2($intComId, $intEveId, $strReport = '')
{
if (!function_exists('fxEveAccesHasAnyPermission')) {
require_once dirname(__FILE__) . '/../../php/inc_fx_eve_acces.php';
}
return fxEveAccesHasAnyPermission(
intval($intComId),
intval($intEveId),
fxSuperadmReportsPermKeysForReport($strReport)
);
}
/**
* Accès rapports superadm — super admin, promoteur legacy (com_eve_promoteur), ou droits V2.
* MSIN-4465 — branche V2 (kits / reports.*) en plus du legacy.
*/
function fxSuperadmReportsAllowed($intEvenement = 0, $strReport = '')
{
if (fxSuperadmIsLoggedIn()) {
return true;
}
if (intval($intEvenement) <= 0 || empty($_SESSION['com_info']['com_id'])) {
$intEvenement = intval($intEvenement);
if ($intEvenement <= 0 || empty($_SESSION['com_info']['com_id'])) {
return false;
}
$intComId = intval($_SESSION['com_info']['com_id']);
global $db;
$recPromoteur = $db->fxGetRow(
'SELECT com_eve_promoteur, com_rapports FROM inscriptions_comptes WHERE com_id = '
. intval($_SESSION['com_info']['com_id'])
'SELECT com_eve_promoteur, com_rapports FROM inscriptions_comptes WHERE com_id = ' . $intComId
);
if ($recPromoteur == null || trim((string)$recPromoteur['com_eve_promoteur']) === '') {
return false;
if ($recPromoteur != null && trim((string)$recPromoteur['com_eve_promoteur']) !== '') {
$tabEve = array_map('trim', explode(',', (string)$recPromoteur['com_eve_promoteur']));
if (in_array((string)$intEvenement, $tabEve, true)) {
return true;
}
}
$tabEve = array_map('trim', explode(',', (string)$recPromoteur['com_eve_promoteur']));
return in_array((string)intval($intEvenement), $tabEve, true);
return fxSuperadmReportsAllowedV2($intComId, $intEvenement, $strReport);
}
/** Rapports Excel/liste ADM (index.php?a=report&t=…) — super admin ou com_rapports / men_ref promoteur. */
function fxSuperadmReportMenuAllowed($intMenuId) {
/**
* Rapports Excel/liste ADM (index.php?a=report&t=…)
* super admin, com_rapports / men_ref promoteur legacy, ou V2 reports.custom.
* MSIN-4465
*/
function fxSuperadmReportMenuAllowed($intMenuId)
{
if (fxSuperadmIsLoggedIn()) {
return true;
}
if (intval($intMenuId) <= 0 || empty($_SESSION['com_info']['com_id'])) {
$intMenuId = intval($intMenuId);
if ($intMenuId <= 0 || empty($_SESSION['com_info']['com_id'])) {
return false;
}
$intComId = intval($_SESSION['com_info']['com_id']);
global $objDatabase;
$recRapport = $objDatabase->fxGetRow(
'SELECT men_ref FROM adm_menus WHERE men_id = ' . intval($intMenuId)
'SELECT men_ref FROM adm_menus WHERE men_id = ' . $intMenuId
);
$recPromoteur = $objDatabase->fxGetRow(
'SELECT com_eve_promoteur, com_rapports FROM inscriptions_comptes WHERE com_id = '
. intval($_SESSION['com_info']['com_id'])
'SELECT com_eve_promoteur, com_rapports FROM inscriptions_comptes WHERE com_id = ' . $intComId
);
if ($recPromoteur == null || $recRapport == null) {
if ($recRapport == null) {
return false;
}
$tabEve = array_map('trim', explode(',', (string)$recPromoteur['com_eve_promoteur']));
$tabRapports = array_map('trim', explode(',', (string)$recPromoteur['com_rapports']));
$strMenRef = trim((string)$recRapport['men_ref']);
if (trim((string)$recRapport['men_ref']) !== '0'
&& trim((string)$recRapport['men_ref']) !== ''
&& in_array(trim((string)$recRapport['men_ref']), $tabEve, true)) {
return true;
if ($recPromoteur != null) {
$tabEve = array_map('trim', explode(',', (string)$recPromoteur['com_eve_promoteur']));
$tabRapports = array_map('trim', explode(',', (string)$recPromoteur['com_rapports']));
if ($strMenRef !== '0' && $strMenRef !== '' && in_array($strMenRef, $tabEve, true)) {
return true;
}
if (in_array((string)$intMenuId, $tabRapports, true)) {
return true;
}
}
return in_array((string)intval($intMenuId), $tabRapports, true);
// MSIN-4465 — men_ref = eve_id → droit V2 reports.custom (ou grants_all)
if ($strMenRef !== '0' && $strMenRef !== '') {
$intEveId = intval($strMenRef);
if ($intEveId > 0) {
return fxSuperadmReportsAllowedV2($intComId, $intEveId, 'custom');
}
}
return false;
}
/** Sync tables statiques — superadm, préprod dev seulement (aligné sur sync_static_db.php). */

View File

@ -23,7 +23,8 @@ require_once('../php/inc_fx_memberships.php');
global $db, $objDatabasePreProd,$objDatabasecrm,$objDatabaseProd ;
fxSuperadmRedirectToLoginIfNeeded(true);
$blnLogged = fxSuperadmReportsAllowed(intval($intEvenement));
// MSIN-4465 — passer le type de rapport pour les droits V2 reports.*
$blnLogged = fxSuperadmReportsAllowed(intval($intEvenement), $strReport);
$strWhere = fxSetWhere($strReport, $_GET);
if (isset($_POST['btn_paiement'])) {