diff --git a/ajax_inscr_mobile.php b/ajax_inscr_mobile.php index b69b126..6ed1e9f 100644 --- a/ajax_inscr_mobile.php +++ b/ajax_inscr_mobile.php @@ -31,7 +31,7 @@ switch ($strAction) { $strStatut = trim((string)($_REQUEST['par_statut_course'] ?? '')); $intEveId = fxEveAccesResolveEveIdFromParId($intParId); - if ($intEveId <= 0 || !fxInscrMobileCanDo($intComId, $intEveId, 'inscriptions_mobile.statut_edit')) { + if ($intEveId <= 0 || !fxInscrMobileCanDo($intComId, $intEveId, 'inscriptions_gestion.statut_edit')) { $tabRetour = array('state' => 'error', 'message' => 'unauthorized'); break; } diff --git a/php/inc_fx_eve_acces.php b/php/inc_fx_eve_acces.php index 71efcaa..2963227 100644 --- a/php/inc_fx_eve_acces.php +++ b/php/inc_fx_eve_acces.php @@ -161,10 +161,10 @@ function fxEveAccesGetEventIds($intComId) return $arrIds; } -/** Acces web mobile : vue API/page OU au moins une permission action inscriptions_mobile.* */ +/** Acces web gestion inscriptions : vue API/page OU au moins une permission action inscriptions_gestion.* */ function fxEveAccesHasInscrMobileWebAccess($intComId, $intEveId) { - if (fxEveAccesHasAnyPermission(intval($intComId), intval($intEveId), array('registrations.view', 'inscriptions_mobile.view'))) { + if (fxEveAccesHasAnyPermission(intval($intComId), intval($intEveId), array('registrations.view', 'inscriptions_gestion.view'))) { return true; } @@ -177,7 +177,7 @@ function fxEveAccesHasInscrMobileWebAccess($intComId, $intEveId) $sql = "SELECT COUNT(*) FROM " . fxEveAccesPermSql() . " WHERE com_id = " . intval($intComId) . " AND eve_id = " . intval($intEveId) . " - AND perm_key LIKE 'inscriptions_mobile.%'"; + AND perm_key LIKE 'inscriptions_gestion.%'"; $intNb = $objDatabase->fxGetVar($sql); return ($intNb != null && intval($intNb) > 0); @@ -194,8 +194,8 @@ function fxEveAccesGetEventIdsWithInscrMobileAccess($intComId) $sql = "SELECT DISTINCT eve_id FROM " . fxEveAccesPermSql() . " WHERE com_id = " . intval($intComId) . " AND ( - perm_key IN ('registrations.view', 'inscriptions_mobile.view') - OR perm_key LIKE 'inscriptions_mobile.%' + perm_key IN ('registrations.view', 'inscriptions_gestion.view') + OR perm_key LIKE 'inscriptions_gestion.%' ) ORDER BY eve_id ASC"; $tab = $objDatabase->fxGetResults($sql); diff --git a/php/inc_fx_inscriptions_mobile.php b/php/inc_fx_inscriptions_mobile.php index f69f66b..d72eea2 100644 --- a/php/inc_fx_inscriptions_mobile.php +++ b/php/inc_fx_inscriptions_mobile.php @@ -30,7 +30,7 @@ function fxInscrMobileUserHasPromoteurMenu($intComId) { /** Permissions v2 requises pour la fiche inscriptions mobile (web). */ function fxInscrMobilePermKeysView() { - return array('registrations.view', 'inscriptions_mobile.view'); + return array('registrations.view', 'inscriptions_gestion.view'); } function fxInscrMobilePermKeysScan() { @@ -55,7 +55,7 @@ function fxInscrMobileCanDo($intComId, $intEveId, $strActionPerm) { } /* dossards.manage autorise aussi la modification du no dossard sur fiche mobile. */ - if ($strActionPerm === 'inscriptions_mobile.bib_edit' + if ($strActionPerm === 'inscriptions_gestion.bib_edit' && fxEveAccesHasPermission(intval($intComId), intval($intEveId), 'dossards.manage')) { return true; } @@ -1179,12 +1179,12 @@ function fxInscrMobileRenderFiche($intEveId, $strLangue, $strBaseUrl, $arrReq, $ $intComId = intval($_SESSION['com_id'] ?? 0); $intRowEveId = intval($arrRow['eve_id']); - $blnCanStatut = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_mobile.statut_edit'); - $blnCanBib = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_mobile.bib_edit'); - $blnCanRemis = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_mobile.bib_remis'); - $blnCanEdit = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_mobile.edit'); - $blnCanCancel = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_mobile.cancel'); - $blnCanRestore = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_mobile.restore'); + $blnCanStatut = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_gestion.statut_edit'); + $blnCanBib = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_gestion.bib_edit'); + $blnCanRemis = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_gestion.bib_remis'); + $blnCanEdit = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_gestion.edit'); + $blnCanCancel = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_gestion.cancel'); + $blnCanRestore = fxInscrMobileCanDo($intComId, $intRowEveId, 'inscriptions_gestion.restore'); $blnHasEditable = ($blnCanStatut || $blnCanBib || $blnCanRemis); $blnHasGestion = ($blnCanEdit || $blnCanCancel || $blnCanRestore); diff --git a/sql/MSIN-eve-acces-v2-phase1-pilot-example.sql b/sql/MSIN-eve-acces-v2-phase1-pilot-example.sql index e06c8bc..37ba0ff 100644 --- a/sql/MSIN-eve-acces-v2-phase1-pilot-example.sql +++ b/sql/MSIN-eve-acces-v2-phase1-pilot-example.sql @@ -16,7 +16,7 @@ /* - Etape B - Acces pilote mobile 30 jours + Etape B - Acces pilote gestion inscriptions 30 jours INSERT INTO inscriptions_eve_acces (com_id, eve_id, role_id, ea_statut, ea_expires_at, ea_expire_days, ea_granted_by, ea_note) @@ -28,9 +28,9 @@ SELECT DATE_ADD(NOW(), INTERVAL 30 DAY), 30, 1, - 'Pilote prod - API mobile v2' + 'Pilote prod - gestion inscriptions v2' FROM inscriptions_eve_roles r -WHERE r.role_code = 'mobile_ops' +WHERE r.role_code = 'gestion_ops' LIMIT 1; */ diff --git a/sql/MSIN-eve-acces-v2-phase1-seed.sql b/sql/MSIN-eve-acces-v2-phase1-seed.sql index 04d79d4..38fcec8 100644 --- a/sql/MSIN-eve-acces-v2-phase1-seed.sql +++ b/sql/MSIN-eve-acces-v2-phase1-seed.sql @@ -21,8 +21,8 @@ VALUES 'Tableau inscriptions web promoteur', NULL, 2, 1, 110), ('inscriptions.edit', 'inscriptions', 'Inscriptions (modification)', 'Registrations (edit)', 'Modifier ou annuler inscriptions', NULL, 2, 1, 120), - ('inscriptions_mobile.view', 'inscriptions', 'Inscriptions mobile (web)', 'Mobile registrations (web)', - 'Interface web inscriptions mobile', NULL, 2, 1, 130), + ('inscriptions_gestion.view', 'inscriptions', 'Gestion inscription (web)', 'Registration management (web)', + 'Interface web de gestion des inscriptions', NULL, 2, 1, 130), ('dossards.view', 'dossards', 'Dossards (lecture)', 'Bibs (read)', NULL, NULL, 2, 1, 210), ('dossards.manage', 'dossards', 'Dossards (gestion)', 'Bibs (manage)', NULL, NULL, 2, 1, 220), ('epreuves.view', 'epreuves', 'Epreuves (lecture)', 'Races (read)', NULL, NULL, 2, 1, 310), @@ -60,13 +60,13 @@ VALUES 'Acces complet sur l evenement', 'Full access to the event', 'fa-crown', 1, 1, 10), - ('mobile_ops', 'Operations mobile', 'Mobile operations', - 'API mobile : evenements, inscriptions, scan QR', - 'Mobile API: events, registrations, QR scan', + ('gestion_ops', 'Operations gestion', 'Management operations', + 'Gestion des inscriptions : evenements, inscriptions, scan QR', + 'Registration management: events, registrations, QR scan', 'fa-mobile', 1, 1, 20), - ('mobile_readonly', 'Mobile lecture seule', 'Mobile read-only', - 'API mobile : consulter evenements et inscriptions', - 'Mobile API: view events and registrations only', + ('gestion_readonly', 'Gestion lecture seule', 'Management read-only', + 'Consulter evenements et inscriptions', + 'View events and registrations only', 'fa-eye', 1, 1, 30), ('reports_finance', 'Finances', 'Finance', 'Rapports finances et paiements uniquement', @@ -101,7 +101,7 @@ WHERE r.role_code = 'owner' DELETE erp FROM inscriptions_eve_role_permissions erp INNER JOIN inscriptions_eve_roles r ON r.role_id = erp.role_id -WHERE r.role_code = 'mobile_ops'; +WHERE r.role_code = 'gestion_ops'; INSERT INTO inscriptions_eve_role_permissions (role_id, perm_key) SELECT r.role_id, p.perm_key @@ -109,12 +109,12 @@ FROM inscriptions_eve_roles r INNER JOIN inscriptions_eve_permissions p ON p.perm_key IN ('events.list', 'events.view', 'registrations.view', 'registrations.scan') AND p.perm_actif = 1 -WHERE r.role_code = 'mobile_ops'; +WHERE r.role_code = 'gestion_ops'; DELETE erp FROM inscriptions_eve_role_permissions erp INNER JOIN inscriptions_eve_roles r ON r.role_id = erp.role_id -WHERE r.role_code = 'mobile_readonly'; +WHERE r.role_code = 'gestion_readonly'; INSERT INTO inscriptions_eve_role_permissions (role_id, perm_key) SELECT r.role_id, p.perm_key @@ -122,7 +122,7 @@ FROM inscriptions_eve_roles r INNER JOIN inscriptions_eve_permissions p ON p.perm_key IN ('events.list', 'events.view', 'registrations.view') AND p.perm_actif = 1 -WHERE r.role_code = 'mobile_readonly'; +WHERE r.role_code = 'gestion_readonly'; DELETE erp FROM inscriptions_eve_role_permissions erp @@ -152,7 +152,7 @@ FROM inscriptions_eve_roles r INNER JOIN inscriptions_eve_permissions p ON p.perm_key IN ( 'events.list', 'events.view', - 'registrations.view', 'inscriptions.view', 'inscriptions_mobile.view', + 'registrations.view', 'inscriptions.view', 'inscriptions_gestion.view', 'dossards.view', 'reports.chrono', 'reports.adhesions', 'reports.adhesions_sales', 'reports.custom' ) AND p.perm_actif = 1 diff --git a/sql/MSIN-eve-acces-v2-phase2-multi-granular.sql b/sql/MSIN-eve-acces-v2-phase2-multi-granular.sql index 198ceb0..b1a4968 100644 --- a/sql/MSIN-eve-acces-v2-phase2-multi-granular.sql +++ b/sql/MSIN-eve-acces-v2-phase2-multi-granular.sql @@ -39,7 +39,7 @@ UPDATE `inscriptions_eve_permissions` SET `perm_scope` = 'report' UPDATE `inscriptions_eve_permissions` SET `perm_scope` = 'page' WHERE `perm_key` IN ( - 'inscriptions.view', 'inscriptions_mobile.view', + 'inscriptions.view', 'inscriptions_gestion.view', 'dossards.view', 'epreuves.view', 'rabais.view', 'team.view' ); @@ -115,24 +115,27 @@ INSERT INTO `inscriptions_eve_permissions` (`perm_key`, `perm_group`, `perm_scope`, `perm_label_fr`, `perm_label_en`, `perm_description_fr`, `perm_description_en`, `perm_phase`, `perm_actif`, `perm_tri`) VALUES - ('inscriptions_mobile.statut_edit', 'inscriptions', 'action', - 'Mobile : statut course', 'Mobile: race status', - 'Modifier le statut course sur la fiche mobile', NULL, 2, 1, 131), - ('inscriptions_mobile.bib_edit', 'inscriptions', 'action', - 'Mobile : no dossard', 'Mobile: bib number', - 'Modifier le numero de dossard sur la fiche mobile', NULL, 2, 1, 132), - ('inscriptions_mobile.bib_remis', 'inscriptions', 'action', - 'Mobile : dossard remis', 'Mobile: bib handed out', - 'Marquer dossard remis sur la fiche mobile', NULL, 2, 1, 133), - ('inscriptions_mobile.edit', 'inscriptions', 'action', - 'Mobile : modifier fiche', 'Mobile: edit registration', - 'Bouton modifier inscription sur fiche mobile', NULL, 2, 1, 134), - ('inscriptions_mobile.cancel', 'inscriptions', 'action', - 'Mobile : annuler', 'Mobile: cancel', - 'Annuler une inscription depuis la fiche mobile', NULL, 2, 1, 135), - ('inscriptions_mobile.restore', 'inscriptions', 'action', - 'Mobile : retablir', 'Mobile: restore', - 'Retablir une inscription annulee depuis la fiche mobile', NULL, 2, 1, 136) + ('inscriptions_gestion.statut_edit', 'inscriptions', 'action', + 'Gestion inscription : statut', 'Registration mgmt: status', + 'Modifier le statut course sur la fiche', NULL, 2, 1, 131), + ('inscriptions_gestion.bib_edit', 'inscriptions', 'action', + 'Gestion inscription : no dossard', 'Registration mgmt: bib number', + 'Modifier le numero de dossard sur la fiche', NULL, 2, 1, 132), + ('inscriptions_gestion.bib_remis', 'inscriptions', 'action', + 'Gestion inscription : dossard remis', 'Registration mgmt: bib handed out', + 'Marquer dossard remis sur la fiche', NULL, 2, 1, 133), + ('inscriptions_gestion.edit', 'inscriptions', 'action', + 'Gestion inscription : modifier', 'Registration mgmt: edit', + 'Bouton modifier inscription sur la fiche', NULL, 2, 1, 134), + ('inscriptions_gestion.cancel', 'inscriptions', 'action', + 'Gestion inscription : annuler', 'Registration mgmt: cancel', + 'Annuler une inscription depuis la fiche', NULL, 2, 1, 135), + ('inscriptions_gestion.restore', 'inscriptions', 'action', + 'Gestion inscription : retablir', 'Registration mgmt: restore', + 'Retablir une inscription annulee depuis la fiche', NULL, 2, 1, 136), + ('inscriptions_gestion.refund', 'inscriptions', 'action', + 'Gestion inscription : remboursement', 'Registration mgmt: refund', + 'Effectuer un remboursement PayPal depuis la fiche de gestion', NULL, 2, 1, 137) ON DUPLICATE KEY UPDATE `perm_group` = VALUES(`perm_group`), `perm_scope` = VALUES(`perm_scope`), @@ -145,18 +148,18 @@ ON DUPLICATE KEY UPDATE UPDATE `inscriptions_eve_permissions` SET `perm_scope` = 'page' - WHERE `perm_key` = 'inscriptions_mobile.view'; + WHERE `perm_key` = 'inscriptions_gestion.view'; /* ------------------------------------------------------------------ - 5. Kits : mobile_ops complet, mobile_statut (exemple granulaire) + 5. Kits : gestion_ops complet, gestion_statut (exemple granulaire) ------------------------------------------------------------------ */ INSERT INTO `inscriptions_eve_roles` (`role_code`, `role_label_fr`, `role_label_en`, `role_description_fr`, `role_description_en`, `role_icone`, `role_systeme`, `role_actif`, `role_tri`) VALUES - ('mobile_statut', 'Mobile statuts seulement', 'Mobile status only', - 'Fiche mobile : consulter et modifier les statuts (pas le dossard)', - 'Mobile sheet: view and edit status only (not bib number)', + ('gestion_statut', 'Gestion statuts seulement', 'Management status only', + 'Fiche : consulter et modifier les statuts (pas le dossard)', + 'Sheet: view and edit status only (not bib number)', 'fa-flag-checkered', 1, 1, 25) ON DUPLICATE KEY UPDATE `role_label_fr` = VALUES(`role_label_fr`), @@ -182,7 +185,7 @@ WHERE r.role_code = 'owner' DELETE erp FROM inscriptions_eve_role_permissions erp INNER JOIN inscriptions_eve_roles r ON r.role_id = erp.role_id -WHERE r.role_code = 'mobile_ops'; +WHERE r.role_code = 'gestion_ops'; INSERT INTO inscriptions_eve_role_permissions (role_id, perm_key) SELECT r.role_id, p.perm_key @@ -190,44 +193,44 @@ FROM inscriptions_eve_roles r INNER JOIN inscriptions_eve_permissions p ON p.perm_key IN ( 'events.list', 'events.view', 'registrations.view', 'registrations.scan', - 'inscriptions_mobile.view', - 'inscriptions_mobile.statut_edit', 'inscriptions_mobile.bib_edit', - 'inscriptions_mobile.bib_remis', 'inscriptions_mobile.edit', - 'inscriptions_mobile.cancel', 'inscriptions_mobile.restore' + 'inscriptions_gestion.view', + 'inscriptions_gestion.statut_edit', 'inscriptions_gestion.bib_edit', + 'inscriptions_gestion.bib_remis', 'inscriptions_gestion.edit', + 'inscriptions_gestion.cancel', 'inscriptions_gestion.restore' ) AND p.perm_actif = 1 -WHERE r.role_code = 'mobile_ops'; +WHERE r.role_code = 'gestion_ops'; DELETE erp FROM inscriptions_eve_role_permissions erp INNER JOIN inscriptions_eve_roles r ON r.role_id = erp.role_id -WHERE r.role_code = 'mobile_readonly'; +WHERE r.role_code = 'gestion_readonly'; INSERT INTO inscriptions_eve_role_permissions (role_id, perm_key) SELECT r.role_id, p.perm_key FROM inscriptions_eve_roles r INNER JOIN inscriptions_eve_permissions p ON p.perm_key IN ( - 'events.list', 'events.view', 'registrations.view', 'inscriptions_mobile.view' + 'events.list', 'events.view', 'registrations.view', 'inscriptions_gestion.view' ) AND p.perm_actif = 1 -WHERE r.role_code = 'mobile_readonly'; +WHERE r.role_code = 'gestion_readonly'; DELETE erp FROM inscriptions_eve_role_permissions erp INNER JOIN inscriptions_eve_roles r ON r.role_id = erp.role_id -WHERE r.role_code = 'mobile_statut'; +WHERE r.role_code = 'gestion_statut'; INSERT INTO inscriptions_eve_role_permissions (role_id, perm_key) SELECT r.role_id, p.perm_key FROM inscriptions_eve_roles r INNER JOIN inscriptions_eve_permissions p ON p.perm_key IN ( - 'events.list', 'events.view', 'registrations.view', 'inscriptions_mobile.view', - 'inscriptions_mobile.statut_edit', 'inscriptions_mobile.bib_remis' + 'events.list', 'events.view', 'registrations.view', 'inscriptions_gestion.view', + 'inscriptions_gestion.statut_edit', 'inscriptions_gestion.bib_remis' ) AND p.perm_actif = 1 -WHERE r.role_code = 'mobile_statut'; +WHERE r.role_code = 'gestion_statut'; /* ------------------------------------------------------------------ diff --git a/sql/MSIN-eve-acces-v2-phase3-role-delegable.sql b/sql/MSIN-eve-acces-v2-phase3-role-delegable.sql index bfee573..2167fc5 100644 --- a/sql/MSIN-eve-acces-v2-phase3-role-delegable.sql +++ b/sql/MSIN-eve-acces-v2-phase3-role-delegable.sql @@ -5,16 +5,26 @@ SET NAMES utf8mb4; -ALTER TABLE `inscriptions_eve_roles` - ADD COLUMN `role_delegable` tinyint(1) unsigned NOT NULL DEFAULT 0 - COMMENT 'Proposable par le promoteur lors d invitations equipe' - AFTER `role_systeme`; +/* Ajout idempotent : n'ajoute la colonne que si elle n'existe pas deja + (evite l'erreur 1060 - Duplicate column name si le script est relance). */ +SET @col_exists := ( + SELECT COUNT(*) FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'inscriptions_eve_roles' + AND COLUMN_NAME = 'role_delegable' +); +SET @ddl := IF(@col_exists = 0, + 'ALTER TABLE `inscriptions_eve_roles` ADD COLUMN `role_delegable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT ''Proposable par le promoteur lors d invitations equipe'' AFTER `role_systeme`', + 'DO 0'); +PREPARE stmt FROM @ddl; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; UPDATE `inscriptions_eve_roles` SET `role_delegable` = 1 WHERE `role_code` IN ( - 'mobile_ops', - 'mobile_readonly', - 'mobile_statut', + 'gestion_ops', + 'gestion_readonly', + 'gestion_statut', 'bib_ops' ); diff --git a/sql/MSIN-eve-acces-v2-rename-mobile-to-gestion.sql b/sql/MSIN-eve-acces-v2-rename-mobile-to-gestion.sql new file mode 100644 index 0000000..9817b50 --- /dev/null +++ b/sql/MSIN-eve-acces-v2-rename-mobile-to-gestion.sql @@ -0,0 +1,210 @@ +/* + MSIN - Acces evenement v2 - Renommage / fusion "mobile" -> "gestion" + + Contexte : la fiche/ecran etait improprement nomme "mobile". Il s'agit en + realite de la GESTION DES INSCRIPTIONS (responsive). Comme ces droits ne + sont pas encore en production, on corrige le nommage proprement. + + IMPORTANT - approche FUSION (merge) idempotente : + On NE renomme PAS la cle parente (inscriptions_eve_permissions.perm_key / + inscriptions_eve_roles.role_code) par UPDATE, car si les nouvelles cles + existent deja (seeds mis a jour deja appliques), la cascade FK provoque + une collision de cle primaire (erreur 1761). + + A la place : + 1. on s'assure que les NOUVELLES cles existent (INSERT idempotent) ; + 2. on RE-AIGUILLE les enregistrements enfants (role_permissions, + acces_extra, acces, acces_log) des ANCIENNES vers les NOUVELLES, + en supprimant d'abord les doublons ; + 3. on SUPPRIME les anciennes cles (permissions + roles). + + Fonctionne que les seeds aient ete relances ou non. Rejouable sans effet. + + COUCHE 2 (NON traitee ici, menage ulterieur) : noms de fichiers, fonctions + fxInscrMobile*, routes /mobile et inc_tableau_inscriptions_mobile (URLs/QR). + + NOTE : 'inscriptions_mobile.' fait 20 caracteres -> SUBSTRING(x, 21). +*/ + +SET NAMES utf8mb4; + + +/* ================================================================== + PARTIE A - PERMISSIONS + ================================================================== */ + +/* --- A1. S'assurer que les nouvelles permissions existent (+ libelles) --- */ +INSERT INTO `inscriptions_eve_permissions` + (`perm_key`, `perm_group`, `perm_scope`, `perm_label_fr`, `perm_label_en`, + `perm_description_fr`, `perm_description_en`, `perm_phase`, `perm_actif`, `perm_tri`) +VALUES + ('inscriptions_gestion.view', 'inscriptions', 'page', + 'Gestion inscription (web)', 'Registration management (web)', + 'Interface web de gestion des inscriptions', NULL, 2, 1, 130), + ('inscriptions_gestion.statut_edit', 'inscriptions', 'action', + 'Gestion inscription : statut', 'Registration mgmt: status', + 'Modifier le statut course sur la fiche', NULL, 2, 1, 131), + ('inscriptions_gestion.bib_edit', 'inscriptions', 'action', + 'Gestion inscription : no dossard', 'Registration mgmt: bib number', + 'Modifier le numero de dossard sur la fiche', NULL, 2, 1, 132), + ('inscriptions_gestion.bib_remis', 'inscriptions', 'action', + 'Gestion inscription : dossard remis', 'Registration mgmt: bib handed out', + 'Marquer dossard remis sur la fiche', NULL, 2, 1, 133), + ('inscriptions_gestion.edit', 'inscriptions', 'action', + 'Gestion inscription : modifier', 'Registration mgmt: edit', + 'Bouton modifier inscription sur la fiche', NULL, 2, 1, 134), + ('inscriptions_gestion.cancel', 'inscriptions', 'action', + 'Gestion inscription : annuler', 'Registration mgmt: cancel', + 'Annuler une inscription depuis la fiche', NULL, 2, 1, 135), + ('inscriptions_gestion.restore', 'inscriptions', 'action', + 'Gestion inscription : retablir', 'Registration mgmt: restore', + 'Retablir une inscription annulee depuis la fiche', NULL, 2, 1, 136), + ('inscriptions_gestion.refund', 'inscriptions', 'action', + 'Gestion inscription : remboursement', 'Registration mgmt: refund', + 'Effectuer un remboursement PayPal depuis la fiche de gestion', NULL, 2, 1, 137) +ON DUPLICATE KEY UPDATE + `perm_group` = VALUES(`perm_group`), + `perm_scope` = VALUES(`perm_scope`), + `perm_label_fr` = VALUES(`perm_label_fr`), + `perm_label_en` = VALUES(`perm_label_en`), + `perm_description_fr` = VALUES(`perm_description_fr`), + `perm_phase` = VALUES(`perm_phase`), + `perm_actif` = VALUES(`perm_actif`), + `perm_tri` = VALUES(`perm_tri`); + + +/* --- A2. role_permissions : retirer les doublons puis re-aiguiller --- */ +DELETE rp FROM `inscriptions_eve_role_permissions` rp +JOIN `inscriptions_eve_role_permissions` rp2 + ON rp2.role_id = rp.role_id + AND rp2.perm_key = CONCAT('inscriptions_gestion.', SUBSTRING(rp.perm_key, 21)) +WHERE rp.perm_key LIKE 'inscriptions_mobile.%'; + +UPDATE `inscriptions_eve_role_permissions` +SET `perm_key` = CONCAT('inscriptions_gestion.', SUBSTRING(`perm_key`, 21)) +WHERE `perm_key` LIKE 'inscriptions_mobile.%'; + + +/* --- A3. acces_extra : retirer les doublons puis re-aiguiller --- */ +DELETE ae FROM `inscriptions_eve_acces_extra` ae +JOIN `inscriptions_eve_acces_extra` ae2 + ON ae2.com_id = ae.com_id + AND ae2.eve_id = ae.eve_id + AND ae2.perm_key = CONCAT('inscriptions_gestion.', SUBSTRING(ae.perm_key, 21)) +WHERE ae.perm_key LIKE 'inscriptions_mobile.%'; + +UPDATE `inscriptions_eve_acces_extra` +SET `perm_key` = CONCAT('inscriptions_gestion.', SUBSTRING(`perm_key`, 21)) +WHERE `perm_key` LIKE 'inscriptions_mobile.%'; + + +/* --- A4. Supprimer les anciennes permissions (catalogue) --- */ +DELETE FROM `inscriptions_eve_permissions` +WHERE `perm_key` LIKE 'inscriptions_mobile.%'; + + +/* --- A5. Attribuer la nouvelle permission refund au role "owner" --- */ +INSERT INTO `inscriptions_eve_role_permissions` (`role_id`, `perm_key`) +SELECT r.role_id, 'inscriptions_gestion.refund' +FROM `inscriptions_eve_roles` r +WHERE r.role_code = 'owner' +ON DUPLICATE KEY UPDATE `perm_key` = `inscriptions_eve_role_permissions`.`perm_key`; + + +/* ================================================================== + PARTIE B - ROLES (mobile_* -> gestion_*) par fusion + ================================================================== */ + +/* --- B1. S'assurer que les nouveaux roles existent (+ libelles) --- */ +INSERT INTO `inscriptions_eve_roles` + (`role_code`, `role_label_fr`, `role_label_en`, `role_description_fr`, `role_description_en`, `role_icone`, `role_systeme`, `role_actif`, `role_tri`) +VALUES + ('gestion_ops', 'Operations gestion', 'Management operations', + 'Gestion des inscriptions : evenements, inscriptions, scan QR', + 'Registration management: events, registrations, QR scan', + 'fa-mobile', 1, 1, 20), + ('gestion_readonly', 'Gestion lecture seule', 'Management read-only', + 'Consulter evenements et inscriptions', + 'View events and registrations only', + 'fa-eye', 1, 1, 30), + ('gestion_statut', 'Gestion statuts seulement', 'Management status only', + 'Fiche : consulter et modifier les statuts (pas le dossard)', + 'Sheet: view and edit status only (not bib number)', + 'fa-flag-checkered', 1, 1, 25) +ON DUPLICATE KEY UPDATE + `role_label_fr` = VALUES(`role_label_fr`), + `role_label_en` = VALUES(`role_label_en`), + `role_description_fr` = VALUES(`role_description_fr`), + `role_description_en` = VALUES(`role_description_en`), + `role_icone` = VALUES(`role_icone`), + `role_actif` = VALUES(`role_actif`), + `role_tri` = VALUES(`role_tri`); + + +/* --- B2. Fusion mobile_ops -> gestion_ops --- */ +SET @old := (SELECT role_id FROM `inscriptions_eve_roles` WHERE role_code = 'mobile_ops' LIMIT 1); +SET @new := (SELECT role_id FROM `inscriptions_eve_roles` WHERE role_code = 'gestion_ops' LIMIT 1); + +DELETE rp FROM `inscriptions_eve_role_permissions` rp +JOIN `inscriptions_eve_role_permissions` rp2 ON rp2.role_id = @new AND rp2.perm_key = rp.perm_key +WHERE rp.role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; +UPDATE `inscriptions_eve_role_permissions` SET role_id = @new +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + +DELETE a FROM `inscriptions_eve_acces` a +JOIN `inscriptions_eve_acces` a2 ON a2.com_id = a.com_id AND a2.eve_id = a.eve_id AND a2.role_id = @new +WHERE a.role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; +UPDATE `inscriptions_eve_acces` SET role_id = @new +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + +UPDATE `inscriptions_eve_acces_log` SET role_id = @new +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + +DELETE FROM `inscriptions_eve_roles` +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + + +/* --- B3. Fusion mobile_readonly -> gestion_readonly --- */ +SET @old := (SELECT role_id FROM `inscriptions_eve_roles` WHERE role_code = 'mobile_readonly' LIMIT 1); +SET @new := (SELECT role_id FROM `inscriptions_eve_roles` WHERE role_code = 'gestion_readonly' LIMIT 1); + +DELETE rp FROM `inscriptions_eve_role_permissions` rp +JOIN `inscriptions_eve_role_permissions` rp2 ON rp2.role_id = @new AND rp2.perm_key = rp.perm_key +WHERE rp.role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; +UPDATE `inscriptions_eve_role_permissions` SET role_id = @new +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + +DELETE a FROM `inscriptions_eve_acces` a +JOIN `inscriptions_eve_acces` a2 ON a2.com_id = a.com_id AND a2.eve_id = a.eve_id AND a2.role_id = @new +WHERE a.role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; +UPDATE `inscriptions_eve_acces` SET role_id = @new +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + +UPDATE `inscriptions_eve_acces_log` SET role_id = @new +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + +DELETE FROM `inscriptions_eve_roles` +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + + +/* --- B4. Fusion mobile_statut -> gestion_statut --- */ +SET @old := (SELECT role_id FROM `inscriptions_eve_roles` WHERE role_code = 'mobile_statut' LIMIT 1); +SET @new := (SELECT role_id FROM `inscriptions_eve_roles` WHERE role_code = 'gestion_statut' LIMIT 1); + +DELETE rp FROM `inscriptions_eve_role_permissions` rp +JOIN `inscriptions_eve_role_permissions` rp2 ON rp2.role_id = @new AND rp2.perm_key = rp.perm_key +WHERE rp.role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; +UPDATE `inscriptions_eve_role_permissions` SET role_id = @new +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + +DELETE a FROM `inscriptions_eve_acces` a +JOIN `inscriptions_eve_acces` a2 ON a2.com_id = a.com_id AND a2.eve_id = a.eve_id AND a2.role_id = @new +WHERE a.role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; +UPDATE `inscriptions_eve_acces` SET role_id = @new +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + +UPDATE `inscriptions_eve_acces_log` SET role_id = @new +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; + +DELETE FROM `inscriptions_eve_roles` +WHERE role_id = @old AND @old IS NOT NULL AND @new IS NOT NULL AND @old <> @new; diff --git a/superadm/php/inc_fx_eve_acces_admin.php b/superadm/php/inc_fx_eve_acces_admin.php index dfea58c..28af990 100644 --- a/superadm/php/inc_fx_eve_acces_admin.php +++ b/superadm/php/inc_fx_eve_acces_admin.php @@ -478,7 +478,7 @@ function fxEveAccesAdminRenderKitForm($intRoleId, $strError = '') - placeholder="ex. mobile_statut"> + placeholder="ex. gestion_statut"> Code verrouillé (kit système).