Files
ms1inscription-v5/sql/MSIN-4401-inscr-gestion-actions-perm.sql

79 lines
3.2 KiB
SQL

-- MSIN-4401 — Droits granulaires fiche Gestion : facture, transaction, renvoi
-- Prérequis : MSIN-eve-acces-v2-phase2-multi-granular.sql (perms base)
-- Idempotent. Safe pilote.
--
-- Note : kit propriétaire (role_grants_all) n'a PAS besoin de ces lignes.
SET NAMES utf8mb4;
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.invoice', 'inscriptions', 'action',
'Gestion inscription : facture', 'Registration mgmt: invoice',
'Afficher la facture (numero de commande) depuis la fiche',
'Show invoice (order number) from the sheet',
2, 1, 138),
('inscriptions_gestion.transaction', 'inscriptions', 'action',
'Gestion inscription : transaction', 'Registration mgmt: transaction',
'Afficher le resume de transaction depuis la fiche',
'Show transaction summary from the sheet',
2, 1, 139),
('inscriptions_gestion.renvoi', 'inscriptions', 'action',
'Gestion inscription : renvoyer confirmation', 'Registration mgmt: resend confirmation',
'Renvoyer la confirmation au participant depuis la fiche',
'Resend confirmation to the participant from the sheet',
2, 1, 140)
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_description_en` = VALUES(`perm_description_en`),
`perm_phase` = VALUES(`perm_phase`),
`perm_actif` = 1,
`perm_tri` = VALUES(`perm_tri`);
/* Kits terrain :
- gestion_ops = facture + transaction + renvoi
- gestion_readonly = facture + transaction (consultation)
- gestion_statut = aucun de ces 3 (kit trop étroit) */
INSERT INTO inscriptions_eve_role_permissions (role_id, perm_key)
SELECT r.role_id, p.perm_key
FROM inscriptions_eve_roles r
CROSS JOIN (
SELECT 'inscriptions_gestion.invoice' AS perm_key
UNION ALL SELECT 'inscriptions_gestion.transaction'
UNION ALL SELECT 'inscriptions_gestion.renvoi'
) p
WHERE r.role_code = 'gestion_ops'
ON DUPLICATE KEY UPDATE perm_key = VALUES(perm_key);
INSERT INTO inscriptions_eve_role_permissions (role_id, perm_key)
SELECT r.role_id, p.perm_key
FROM inscriptions_eve_roles r
CROSS JOIN (
SELECT 'inscriptions_gestion.invoice' AS perm_key
UNION ALL SELECT 'inscriptions_gestion.transaction'
) p
WHERE r.role_code = 'gestion_readonly'
ON DUPLICATE KEY UPDATE perm_key = VALUES(perm_key);
/* Retire si une version précédente du script les avait collés sur gestion_statut */
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 = 'gestion_statut'
AND erp.perm_key IN (
'inscriptions_gestion.invoice',
'inscriptions_gestion.transaction',
'inscriptions_gestion.renvoi'
);
/* Retire le refund des kits terrain (droit explicite ou grants_all seulement). */
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 IN ('gestion_ops', 'gestion_readonly', 'gestion_statut')
AND erp.perm_key = 'inscriptions_gestion.refund';