Commit 9cab6297 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

adaptation admin aux multi-niveaux structures

parent 7b514191
Loading
Loading
Loading
Loading
+1 −1
Changes for module/Intervenant/config/module.config.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ return [
        Assertion\NoteAssertion::class        => \UnicaenPrivilege\Assertion\AssertionFactory::class,
        Service\MailService::class            => Service\MailServiceFactory::class,

        Assertion\StatutAssertion::class => Assertion\StatutAssertionFactory::class,
        Assertion\StatutAssertion::class => \UnicaenPrivilege\Assertion\AssertionFactory::class,
    ],


−x−32

File deleted.

+7
Changes for module/OffreFormation/config/module.config.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -598,6 +598,12 @@ return [
            'resources'  => ['ElementPedagogique'],
            'assertion'  => Assertion\OffreDeFormationAssertion::class,
        ],
        [
            'privileges' => Privileges::TYPE_INTERVENTION_EDITION,
            'resources'  => ['TypeInterventionStructure'],
            'assertion'  => Assertion\TypeInterventionAssertion::class,
        ],


    ],
    'controllers'  => [
@@ -624,6 +630,7 @@ return [
        Service\DomaineFonctionnelService::class        => Service\Factory\DomaineFonctionnelServiceFactory::class,
        Service\OffreFormationService::class            => Service\Factory\OffreFormationServiceFactory::class,
        Assertion\OffreDeFormationAssertion::class      => \UnicaenPrivilege\Assertion\AssertionFactory::class,
        Assertion\TypeInterventionAssertion::class      => \UnicaenPrivilege\Assertion\AssertionFactory::class,
        Service\VolumeHoraireEnsService::class          => Service\Factory\VolumeHoraireEnsServiceFactory::class,
        Processus\ReconductionProcessus::class          => Processus\Factory\ReconductionProcessusFactory::class,
        Service\TypeInterventionService::class          => Service\Factory\TypeInterventionServiceFactory::class,
+x+63
Changes for module/OffreFormation/src/Assertion/TypeInterventionAssertion.php: 63 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace OffreFormation\Assertion;

use Application\Acl\Role;
use Application\Provider\Privilege\Privileges;
use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\ParametresServiceAwareTrait;
use Laminas\Permissions\Acl\Resource\ResourceInterface;
use Lieu\Entity\Db\Structure;
use OffreFormation\Entity\Db\TypeInterventionStructure;
use UnicaenPrivilege\Assertion\AbstractAssertion;


/**
 * Description of OffreDeFormationAssertion
 *
 * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
 */
class TypeInterventionAssertion extends AbstractAssertion
{
    use ContextServiceAwareTrait;
    use ParametresServiceAwareTrait;

    protected function assertEntity(ResourceInterface $entity = null, $privilege = null)
    {
        $role = $this->getRole();
        // Si le rôle n'est pas renseigné alors on s'en va...
        if (!$role instanceof Role) return false;
        // pareil si le rôle ne possède pas le privilège adéquat
        if ($privilege && !$role->hasPrivilege($privilege)) return false;

        // Si c'est bon alors on affine...
        switch (true) {
            case $entity instanceof TypeInterventionStructure:
                switch ($privilege) {
                    case Privileges::TYPE_INTERVENTION_EDITION:
                        return $this->assertTypeInterventionStructureSaisie($role, $entity);
                }
            break;
        }

        return true;
    }



    protected function assertTypeInterventionStructureSaisie(Role $role, TypeInterventionStructure $tis)
    {
        return $this->assertStructureSaisie($role, $tis->getStructure());
    }



    protected function assertStructureSaisie(Role $role, Structure $structure)
    {
        if ($rs = $role->getStructure()) {
            return $structure->inStructure($rs);
        }

        return true;
    }
}
 No newline at end of file
+9 −1
Changes for module/OffreFormation/src/Entity/Db/TypeInterventionStructure.php: 9 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace OffreFormation\Entity\Db;

use Application\Entity\Db\Annee;
use Laminas\Permissions\Acl\Resource\ResourceInterface;
use OffreFormation\Entity\Db\Traits\TypeInterventionAwareTrait;
use Lieu\Entity\Db\StructureAwareTrait;
use UnicaenApp\Entity\HistoriqueAwareInterface;
@@ -11,7 +12,7 @@ use UnicaenApp\Entity\HistoriqueAwareTrait;
/**
 * TypeInterventionStructure
 */
class TypeInterventionStructure implements HistoriqueAwareInterface
class TypeInterventionStructure implements HistoriqueAwareInterface, ResourceInterface
{
    use HistoriqueAwareTrait;
    use TypeInterventionAwareTrait;
@@ -51,6 +52,13 @@ class TypeInterventionStructure implements HistoriqueAwareInterface



    public function getResourceId(): string
    {
        return 'TypeInterventionStructure';
    }



    /**
     * @return bool
     */
Loading