Update mobile registration access functions and enhance event permission checks
This commit modifies the mobile registration access logic to utilize the new `fxEveAccesHasInscrMobileWebAccess` function, improving permission handling for mobile event registrations. Additionally, it updates the `fxInscrMobileGetPromoteurEveIds` and `fxInscrMobileCanAccess` functions to streamline access checks. New functions for retrieving event IDs with mobile access permissions are introduced, enhancing overall access control and user experience.
This commit is contained in:
@ -1225,7 +1225,7 @@ if ($strLangue == 'fr') {
|
||||
$preloader_text.html('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
|
||||
$preloader.show();
|
||||
|
||||
pendingStatutXhr = $.post('<?php echo $vDomaine; ?>/ajax_promoteur.php', {
|
||||
pendingStatutXhr = $.post('<?php echo $vDomaine; ?>/ajax_inscr_mobile.php', {
|
||||
a: 'par_statut_course',
|
||||
par_id: intParId,
|
||||
par_statut_course: strCode,
|
||||
|
||||
@ -119,6 +119,55 @@ function fxEveAccesGetEventIds($intComId)
|
||||
return $arrIds;
|
||||
}
|
||||
|
||||
/** Acces web mobile : vue API/page OU au moins une permission action inscriptions_mobile.* */
|
||||
function fxEveAccesHasInscrMobileWebAccess($intComId, $intEveId)
|
||||
{
|
||||
if (fxEveAccesHasAnyPermission(intval($intComId), intval($intEveId), array('registrations.view', 'inscriptions_mobile.view'))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
global $objDatabase;
|
||||
|
||||
if (!fxEveAccesIsEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM v_eve_acces_permissions
|
||||
WHERE com_id = " . intval($intComId) . "
|
||||
AND eve_id = " . intval($intEveId) . "
|
||||
AND perm_key LIKE 'inscriptions_mobile.%'";
|
||||
$intNb = $objDatabase->fxGetVar($sql);
|
||||
|
||||
return ($intNb != null && intval($intNb) > 0);
|
||||
}
|
||||
|
||||
function fxEveAccesGetEventIdsWithInscrMobileAccess($intComId)
|
||||
{
|
||||
global $objDatabase;
|
||||
|
||||
if (!fxEveAccesIsEnabled()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT eve_id FROM v_eve_acces_permissions
|
||||
WHERE com_id = " . intval($intComId) . "
|
||||
AND (
|
||||
perm_key IN ('registrations.view', 'inscriptions_mobile.view')
|
||||
OR perm_key LIKE 'inscriptions_mobile.%'
|
||||
)
|
||||
ORDER BY eve_id ASC";
|
||||
$tab = $objDatabase->fxGetResults($sql);
|
||||
$arrIds = array();
|
||||
|
||||
if ($tab != null) {
|
||||
foreach ($tab as $row) {
|
||||
$arrIds[] = intval($row['eve_id']);
|
||||
}
|
||||
}
|
||||
|
||||
return $arrIds;
|
||||
}
|
||||
|
||||
function fxEveAccesHasPermission($intComId, $intEveId, $strPermKey)
|
||||
{
|
||||
global $objDatabase;
|
||||
@ -596,10 +645,8 @@ function fxEveAccesShowCompteForm($intComId)
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ($arrAcces == null || count($arrAcces) === 0) {
|
||||
echo '<tr><td colspan="6" class="text-muted">Aucun acces v2 pour ce compte.</td></tr>';
|
||||
} else {
|
||||
$arrPermsByEve = array();
|
||||
$arrPermsByEve = array();
|
||||
if ($arrAcces != null && count($arrAcces) > 0) {
|
||||
foreach ($arrAcces as $row) {
|
||||
$blnActif = ($row['ea_statut'] === 'actif'
|
||||
&& (empty($row['ea_expires_at']) || strtotime($row['ea_expires_at']) > time()));
|
||||
@ -636,19 +683,33 @@ function fxEveAccesShowCompteForm($intComId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($arrPermsByEve as $intEveKey => $arrEveMeta) {
|
||||
$arrPerms = fxEveAccesGetPermissionsForComEvent($intComId, $intEveKey);
|
||||
if ($arrPerms != null && count($arrPerms) > 0) {
|
||||
$arrKeys = array();
|
||||
foreach ($arrPerms as $p) {
|
||||
$arrKeys[] = $p['perm_key'];
|
||||
}
|
||||
echo '<tr class="table-info"><td colspan="6"><small><strong>Droits effectifs — '
|
||||
. htmlspecialchars($arrEveMeta['label']) . ' #' . $intEveKey . ' :</strong> '
|
||||
. htmlspecialchars(implode(', ', $arrKeys)) . '</small></td></tr>';
|
||||
$arrEveIdsEffectifs = fxEveAccesGetEventIdsWithInscrMobileAccess($intComId);
|
||||
foreach ($arrEveIdsEffectifs as $intEveKey) {
|
||||
$arrPerms = fxEveAccesGetPermissionsForComEvent($intComId, $intEveKey);
|
||||
if ($arrPerms == null || count($arrPerms) === 0) {
|
||||
continue;
|
||||
}
|
||||
$arrKeys = array();
|
||||
foreach ($arrPerms as $p) {
|
||||
$arrKeys[] = $p['perm_key'];
|
||||
}
|
||||
$strEveLbl = isset($arrPermsByEve[$intEveKey]['label'])
|
||||
? $arrPermsByEve[$intEveKey]['label']
|
||||
: ('eve_id ' . $intEveKey);
|
||||
if (!isset($arrPermsByEve[$intEveKey])) {
|
||||
$tabEveNom = $objDatabase->fxGetVar('SELECT eve_nom_fr FROM inscriptions_evenements WHERE eve_id = ' . intval($intEveKey) . ' LIMIT 1');
|
||||
if ($tabEveNom !== null && trim((string)$tabEveNom) !== '') {
|
||||
$strEveLbl = $tabEveNom;
|
||||
}
|
||||
}
|
||||
echo '<tr class="table-info"><td colspan="6"><small><strong>Droits effectifs — '
|
||||
. htmlspecialchars($strEveLbl) . ' #' . intval($intEveKey) . ' :</strong> '
|
||||
. htmlspecialchars(implode(', ', $arrKeys)) . '</small></td></tr>';
|
||||
}
|
||||
if (($arrAcces == null || count($arrAcces) === 0) && empty($arrEveIdsEffectifs)) {
|
||||
echo '<tr><td colspan="6" class="text-muted">Aucun acces v2 pour ce compte.</td></tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
|
||||
@ -72,12 +72,12 @@ function fxInscrMobileLoadEveAcces() {
|
||||
*/
|
||||
function fxInscrMobileGetPromoteurEveIds($intComId) {
|
||||
fxInscrMobileLoadEveAcces();
|
||||
return fxEveAccesGetEventIdsWithAnyPermission(intval($intComId), fxInscrMobilePermKeysView());
|
||||
return fxEveAccesGetEventIdsWithInscrMobileAccess(intval($intComId));
|
||||
}
|
||||
|
||||
function fxInscrMobileCanAccess($intComId, $intEveId) {
|
||||
fxInscrMobileLoadEveAcces();
|
||||
return fxEveAccesHasAnyPermission(intval($intComId), intval($intEveId), fxInscrMobilePermKeysView());
|
||||
return fxEveAccesHasInscrMobileWebAccess(intval($intComId), intval($intEveId));
|
||||
}
|
||||
|
||||
function fxInscrMobileCanScan($intComId, $intEveId) {
|
||||
|
||||
Reference in New Issue
Block a user