Commit a3d5d6d5 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Fichiers divers liés à une thèse : déplacement des privilèges dans la catégorie 'these'.

parent 2ffb33fc
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
--
-- Déplacement des privilèges de la catégorie 'fichier-divers' vers la catégorie 'these'
-- car ils concernent des fichiers liés à une thèse (ex: PV de soutenance).
--
-- La catégorie 'fichier-divers' désigne désormais les privilèges concernant des fichiers non liés
-- aux thèses (ex: fichiers déposés pour les pages d'informations).
--
update PRIVILEGE p
    set CATEGORIE_ID = (select id from CATEGORIE_PRIVILEGE where CODE = 'these'),
        CODE = 'fichier-divers-'||CODE
    where CATEGORIE_ID = (select id from CATEGORIE_PRIVILEGE where CODE = 'fichier-divers')
/

--
-- 2 nouveaux privilèges pour les opérations sur des fichiers divers, *non liées aux thèses* :
--   - fichier-divers/televerser
--   - fichier-divers/telecharger
--
insert into PRIVILEGE (ID, CATEGORIE_ID, CODE, LIBELLE, ORDRE)
    select PRIVILEGE_ID_SEQ.nextval, cp.id, 'televerser', 'Téléverser ou supprimer un fichier divers, non lié à une thèse', 100
    from CATEGORIE_PRIVILEGE cp
    where cp.CODE = 'fichier-divers'
/
insert into PRIVILEGE (ID, CATEGORIE_ID, CODE, LIBELLE, ORDRE)
    select PRIVILEGE_ID_SEQ.nextval, cp.id, 'telecharger', 'Télécharger un fichier divers, non lié à une thèse', 200
    from CATEGORIE_PRIVILEGE cp
    where cp.CODE = 'fichier-divers'
/

--
-- Supression du privilège faq/modifier-fichier, utilisé pour les fichiers des pages d'informations.
-- Il est remplacé par le privilège fichier-divers/televerser.
--
delete from PRIVILEGE
    where CATEGORIE_ID = (select id from CATEGORIE_PRIVILEGE where CODE = 'faq')
      and CODE = 'modifier-fichier'
/
-- Ajout des privilèges fichier-divers/* au profil 'ADMIN_TECH'
insert into PROFIL_PRIVILEGE (PRIVILEGE_ID, PROFIL_ID)
    with data(categ, priv) as (
        select 'fichier-divers',  'televerser'  from dual union
        select 'fichier-divers',  'telecharger' from dual
    )
    select p.id as PRIVILEGE_ID, profil.id as PROFIL_ID
    from data
    join PROFIL on profil.ROLE_ID in (/*'ADMIN_TECH',*/ 'BU', 'BDD')
    join CATEGORIE_PRIVILEGE cp on cp.CODE = data.categ
    join PRIVILEGE p on p.CATEGORIE_ID = cp.id and p.code = data.priv
/
-- Attribution (si pas déjà fait) des privilèges fichier-divers/* au rôle 'ADMIN_TECH' (grâce au profil 'ADMIN_TECH').
insert into ROLE_PRIVILEGE (ROLE_ID, PRIVILEGE_ID)
    SELECT r.id as ROLE_ID, p.ID as PRIVILEGE_ID
    from PROFIL_PRIVILEGE pp
             join profil on PROFIL.ID = pp.PROFIL_ID and profil.ROLE_ID in (/*'ADMIN_TECH',*/ 'BU', 'BDD')
             join PRIVILEGE p on p.id = pp.PRIVILEGE_ID
             join CATEGORIE_PRIVILEGE cp on cp.id = p.CATEGORIE_ID and cp.CODE = 'fichier-divers'
             join role r on r.CODE = PROFIL.ROLE_ID
    where not exists (
        select * from ROLE_PRIVILEGE rp where rp.ROLE_ID = r.id and rp.PRIVILEGE_ID = p.id
    );
+2 −2
Original line number Diff line number Diff line
@@ -9,8 +9,8 @@ line;enabled;privilege;isRoleDoctorantSelected;;isStructureDuRoleRespectee;;isTh
7;1;\Application\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Le dépôt d'une version initiale n'est plus possible dès lors qu'une version corrigée est attendue.
8;1;\Application\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la BU a validé.
9;1;\Application\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;
10;1;\Application\Provider\Privilege\ThesePrivileges::FICHIER_DIVERS_TELEVERSER;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;
11;1;\Application\Provider\Privilege\ThesePrivileges::FICHIER_DIVERS_CONSULTER;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;
10;1;\Application\Provider\Privilege\ThesePrivileges::THESE_FICHIER_DIVERS_TELEVERSER;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;
11;1;\Application\Provider\Privilege\ThesePrivileges::THESE_FICHIER_DIVERS_CONSULTER;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;
12;1;\Application\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération.
13;1;\Application\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue.
14;1;\Application\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la BU a validé.
+41 −6
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ use Application\Controller\Factory\TheseControllerFactory;
use Application\Controller\Factory\TheseObserverControllerFactory;
use Application\Controller\Plugin\Url\UrlThesePluginFactory;
use Application\Controller\TheseConsoleController;
use Application\Controller\TheseController;
use Application\Entity\Db\Diffusion;
use Application\Entity\Db\WfEtape;
use Application\Form\Factory\AttestationHydratorFactory;
@@ -57,8 +58,8 @@ return [
                            ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE,
                            ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_CORRIGEE,
                            ThesePrivileges::THESE_SAISIE_RDV_BU,
                            ThesePrivileges::FICHIER_DIVERS_TELEVERSER,
                            ThesePrivileges::FICHIER_DIVERS_CONSULTER,
                            ThesePrivileges::THESE_FICHIER_DIVERS_TELEVERSER,
                            ThesePrivileges::THESE_FICHIER_DIVERS_CONSULTER,
                            ThesePrivileges::THESE_CONSULTATION_TOUTES_THESES,
                            ThesePrivileges::THESE_CONSULTATION_SES_THESES,
                            ThesePrivileges::THESE_MODIFICATION_TOUTES_THESES,
@@ -83,6 +84,14 @@ return [
                    ],
                    'roles' => 'user',
                ],
                [
                    'controller' => 'Application\Controller\These',
                    'action'     => [
                        'detail-depot-divers',
                        /* @see TheseController::detailDepotDiversAction() */
                    ],
                    'privileges' => ThesePrivileges::THESE_FICHIER_DIVERS_CONSULTER,
                ],
                [
                    'controller' => 'Application\Controller\These',
                    'action'     => [
@@ -149,7 +158,7 @@ return [
                        'depot-conv-mise-en-ligne',
                        'depot-avenant-conv-mise-en-ligne',
                    ],
                    'privileges' => ThesePrivileges::FICHIER_DIVERS_CONSULTER,
                    'privileges' => ThesePrivileges::THESE_FICHIER_DIVERS_CONSULTER,
                    'assertion'  => 'Assertion\\These',
                ],
                [
@@ -513,6 +522,19 @@ return [
                            ],
                        ],
                    ],
                    'depot-divers' => [
                        'type'          => 'Segment',
                        'options'       => [
                            'route'       => '/depot-divers/:these',
                            'constraints' => [
                                'these' => '\d+',
                            ],
                            'defaults'    => [
                                'action' => 'detail-depot-divers',
                                /* @see TheseController::detailDepotDiversAction() */
                            ],
                        ],
                    ],
                    'attestation' => [
                        'type'          => 'Segment',
                        'options'       => [
@@ -810,11 +832,24 @@ return [
                                'paramsInject' => [
                                    'these',
                                ],
                                'icon' => 'glyphicon glyphicon-exclamation-sign',
                                'icon' => 'glyphicon glyphicon-warning-sign',
                                'resource' => PrivilegeController::getResourceId('Application\Controller\These', 'modifier-rdv-bu'),
                                'etape' => null,
                                'visible' => 'Assertion\\These',
                            ],
                            'depot-divers' => [
                                'id'       => 'depot-divers',
                                'label'    => 'Dépôt fichiers divers',
                                'route'    => 'these/depot-divers',
                                'withtarget' => true,
                                'paramsInject' => [
                                    'these',
                                ],
                                'icon' => 'glyphicon glyphicon-duplicate',
                                'resource' => PrivilegeController::getResourceId('Application\Controller\These', 'detail-fichiers'),
                                'etape' => WfEtape::CODE_DEPOT_VERSION_ORIGINALE,
                                'visible' => 'Assertion\\These',
                            ],

                            'divider-these' => [
                                'label'    => null,
@@ -835,7 +870,7 @@ return [
                                    'these',
                                ],
                                'class' => 'version-initiale correction-attendue-{correctionAutorisee}',
                                'icon' => 'glyphicon glyphicon-file',
                                'icon' => 'glyphicon glyphicon-picture',
                                'resource' => PrivilegeController::getResourceId('Application\Controller\These', 'validation-page-de-couverture'),
//                                'etape' => WfEtape::CODE_DEPOT_VERSION_ORIGINALE,
//                                'visible' => 'Assertion\\These',
@@ -849,7 +884,7 @@ return [
                                    'these',
                                ],
                                'class' => 'version-initiale correction-attendue-{correctionAutorisee}',
                                'icon' => 'glyphicon glyphicon-duplicate',
                                'icon' => 'glyphicon glyphicon-file',
                                'resource' => PrivilegeController::getResourceId('Application\Controller\These', 'detail-fichiers'),
                                'etape' => WfEtape::CODE_DEPOT_VERSION_ORIGINALE,
                                'visible' => 'Assertion\\These',
+5 −5
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ namespace Application\Assertion\These;
 * /home/gauthierb/workspace/sygal/data/assertions/TheseEntityAssertion.csv.
 *
 * @author Application\Assertion\Generator\AssertionGenerator
 * @date 29/11/2018 12:25:42
 * @date 15/07/2019 09:35:53
 */
abstract class GeneratedTheseEntityAssertion
{
@@ -91,14 +91,14 @@ abstract class GeneratedTheseEntityAssertion
            return true;
        }

        if ($privilege === \Application\Provider\Privilege\ThesePrivileges::FICHIER_DIVERS_TELEVERSER) {
        if ($privilege === \Application\Provider\Privilege\ThesePrivileges::THESE_FICHIER_DIVERS_TELEVERSER) {
        //--------------------------------------------------------------------------------------
            /* line 10 */
            $this->linesTrace[] = '/* line 10 */';
            return true;
        }

        if ($privilege === \Application\Provider\Privilege\ThesePrivileges::FICHIER_DIVERS_CONSULTER) {
        if ($privilege === \Application\Provider\Privilege\ThesePrivileges::THESE_FICHIER_DIVERS_CONSULTER) {
        //--------------------------------------------------------------------------------------
            /* line 11 */
            $this->linesTrace[] = '/* line 11 */';
@@ -622,8 +622,8 @@ line;enabled;privilege;isRoleDoctorantSelected;;isStructureDuRoleRespectee;;isTh
7;1;\Application\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Le dépôt d'une version initiale n'est plus possible dès lors qu'une version corrigée est attendue.
8;1;\Application\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la BU a validé.
9;1;\Application\Provider\Privilege\ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;
10;1;\Application\Provider\Privilege\ThesePrivileges::FICHIER_DIVERS_TELEVERSER;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;
11;1;\Application\Provider\Privilege\ThesePrivileges::FICHIER_DIVERS_CONSULTER;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;
10;1;\Application\Provider\Privilege\ThesePrivileges::THESE_FICHIER_DIVERS_TELEVERSER;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;
11;1;\Application\Provider\Privilege\ThesePrivileges::THESE_FICHIER_DIVERS_CONSULTER;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;
12;1;\Application\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;1:0;;;;;;;;;;;;;;;;;;;;;;;0;L’état de la thèse ne permet pas cette opération.
13;1;\Application\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;1:1;;;;;;;;;;;;;;;;;;;;;0;Opération impossible dès lors qu’une version corrigée est attendue.
14;1;\Application\Provider\Privilege\ThesePrivileges::THESE_SAISIE_CONFORMITE_VERSION_ARCHIVAGE_INITIALE;;;;;;;;;;;;;;;1:1;;;;;;;;;;;;;0;Opération impossible dès lors que la BU a validé.
+112 −0
Original line number Diff line number Diff line
<?php

namespace Application\Provider\Privilege;

use Application\Entity\Db\NatureFichier;
use Application\Entity\Db\VersionFichier;
use UnicaenApp\Exception\RuntimeException;
use UnicaenAuth\Provider\Privilege\Privileges;

/**
 * Privilèges pour les opérations sur les fichiers *NE CONCERNANT PAS UNE THÈSE*.
 *
 * @see ThesePrivileges Pour ce qui concerne les thèses.
 */
class FichierPrivileges extends Privileges
{
    /**
     * Dépôt de fichiers dits "divers" (ex: fichiers pour les pages d'informations).
     */
    const FICHIER_DIVERS_TELEVERSER = 'fichier-divers-televerser';
    const FICHIER_DIVERS_TELECHARGER = 'fichier-divers-telecharger';

    /**
     * Dépôt de fichiers "communs" (ex: modèle d'avenant à la convention de MEL).
     */
    const FICHIER_COMMUN_TELEVERSER = 'fichier-commun-televerser';
    const FICHIER_COMMUN_TELECHARGER = 'fichier-commun-telecharger';

    /**
     * Retourne le privilège correspondant au téléversement/suppression de fichier
     * en fonction de la nature et de la version de fichier.
     *
     * @param NatureFichier       $nature
     * @param VersionFichier|null $versionFichier
     * @return string
     */
    public static function privilegeTeleverserFor(NatureFichier $nature, VersionFichier $versionFichier = null)
    {
        switch ($nature->getCode()) {
            case NatureFichier::CODE_PV_SOUTENANCE:
            case NatureFichier::CODE_RAPPORT_SOUTENANCE:
            case NatureFichier::CODE_PRE_RAPPORT_SOUTENANCE:
            case NatureFichier::CODE_DEMANDE_CONFIDENT:
            case NatureFichier::CODE_PROLONG_CONFIDENT:
            case NatureFichier::CODE_CONV_MISE_EN_LIGNE:
            case NatureFichier::CODE_AVENANT_CONV_MISE_EN_LIGNE:
                //
                return ThesePrivileges::THESE_FICHIER_DIVERS_TELEVERSER;

            case NatureFichier::CODE_THESE_PDF:
            case NatureFichier::CODE_FICHIER_NON_PDF:
                //
                return $versionFichier !== null && $versionFichier->estVersionCorrigee() ?
                    ThesePrivileges::THESE_DEPOT_VERSION_CORRIGEE :
                    ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;

            case NatureFichier::CODE_DIVERS:
                //
                return self::FICHIER_DIVERS_TELEVERSER;

            case NatureFichier::CODE_COMMUNS:
                //
                return self::FICHIER_COMMUN_TELEVERSER;

            default:
                //
                throw new RuntimeException("Cas non implémenté");
        }
    }

    /**
     * Retourne le privilège correspondant à l'opération de téléchargement de fichier
     * en fonction de la nature de fichier.
     *
     * @param NatureFichier       $nature
     * @param VersionFichier|null $versionFichier
     * @return string
     */
    public static function privilegeTelechargerFor(NatureFichier $nature, VersionFichier $versionFichier = null)
    {
        switch ($nature->getCode()) {
            case NatureFichier::CODE_PV_SOUTENANCE:
            case NatureFichier::CODE_RAPPORT_SOUTENANCE:
            case NatureFichier::CODE_PRE_RAPPORT_SOUTENANCE:
            case NatureFichier::CODE_DEMANDE_CONFIDENT:
            case NatureFichier::CODE_PROLONG_CONFIDENT:
            case NatureFichier::CODE_CONV_MISE_EN_LIGNE:
            case NatureFichier::CODE_AVENANT_CONV_MISE_EN_LIGNE:
                //
                return ThesePrivileges::THESE_FICHIER_DIVERS_CONSULTER;

            case NatureFichier::CODE_THESE_PDF:
            case NatureFichier::CODE_FICHIER_NON_PDF:
                //
                return $versionFichier !== null && $versionFichier->estVersionCorrigee() ?
                    ThesePrivileges::THESE_DEPOT_VERSION_CORRIGEE :
                    ThesePrivileges::THESE_DEPOT_VERSION_INITIALE;

            case NatureFichier::CODE_DIVERS:
                //
                return self::FICHIER_DIVERS_TELECHARGER;

            case NatureFichier::CODE_COMMUNS:
                //
                return self::FICHIER_COMMUN_TELECHARGER;

            default:
                //
                throw new RuntimeException("Cas non implémenté");
        }
    }
}
 No newline at end of file
Loading