Commit dcf0fc3b authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Correction : seul certains justificatifs sont bloquants

parent 9978551e
Loading
Loading
Loading
Loading
+0 −18
Changes for module/Soutenance/config/others/proposition.config.php: 0 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -116,13 +116,6 @@ return [
                    ],
                    'privileges' => PropositionPrivileges::PROPOSITION_PRESIDENCE,
                ],
                [
                    'controller' => PropositionController::class,
                    'action' => [
                        'avancement',
                    ],
                    'privileges' => PropositionPrivileges::PROPOSITION_VISUALISER,
                ],
                [
                    'controller' => PropositionController::class,
                    'action' => [
@@ -141,17 +134,6 @@ return [
        'routes' => [
            'soutenance' => [
                'child_routes' => [
                    'avancement' => [
                        'type' => Segment::class,
                        'may_terminate' => true,
                        'options' => [
                            'route' => '/avancement',
                            'defaults' => [
                                'controller' => PropositionController::class,
                                'action' => 'avancement',
                            ],
                        ],
                    ],
                    'proposition' => [
                        'type' => Segment::class,
                        'may_terminate' => true,
+17 −29
Changes for module/Soutenance/src/Soutenance/Assertion/JustificatifAssertion.php: 17 added lines, 29 removed lines.
Original line number Diff line number Diff line
@@ -2,13 +2,12 @@

namespace Soutenance\Assertion;

use Application\Assertion\AbstractAssertion;
use Application\Entity\Db\Role;
use Application\Entity\Db\These;
use Application\Service\These\TheseServiceAwareTrait;
use Application\Service\UserContextServiceAwareTrait;
use DateInterval;
use DateTime;
use Soutenance\Entity\Etat;
use Soutenance\Provider\Privilege\JustificatifPrivileges;
use Soutenance\Service\Parametre\ParametreServiceAwareTrait;
use Soutenance\Service\Proposition\PropositionServiceAwareTrait;
@@ -17,10 +16,7 @@ use Zend\Permissions\Acl\Assertion\AssertionInterface;
use Zend\Permissions\Acl\Resource\ResourceInterface;
use Zend\Permissions\Acl\Role\RoleInterface;

class JustificatifAssertion
    implements AssertionInterface
    //extends AbstractAssertion
{
class JustificatifAssertion implements AssertionInterface {
    use UserContextServiceAwareTrait;
    use ParametreServiceAwareTrait;
    use PropositionServiceAwareTrait;
@@ -42,44 +38,36 @@ class JustificatifAssertion
    }

    public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
//    public function assertEntity(ResourceInterface $resource = null, $privilege = null)
    {
        /** @var These $these */
        $these = $resource;
        $proposition = $this->getPropositionService()->findByThese($these);

        $date_current = new DateTime();
        $date_soutenance = ($these->getDateSoutenance())?$these->getDateSoutenance():$proposition->getDate();
        $interval = $this->getParametreService()->getParametreByCode('PERIODE_INTERVENTION_DIRECTEUR')->getValeur();
        $maxi = (DateTime::createFromFormat('d/m/Y', $date_soutenance->format('d/m/Y')))->add(new DateInterval('P'.$interval.'D'));

        $depasse = (new DateTime() > $date_soutenance);
        $encours = ($proposition->getEtat()->getCode() === Etat::EN_COURS);

        $user = $this->userContextService->getIdentityDb();
        $role = $this->userContextService->getSelectedIdentityRole();
        if ($role->getCode() === Role::CODE_ADMIN_TECH) return true;

        switch ($privilege) {
            case JustificatifPrivileges::JUSTIFICATIF_AJOUTER:
                if ($role->getCode() === Role::CODE_BDD && $role->getStructure() === $these->getEtablissement()->getStructure()) return true;
                if ($date_current > $maxi) return false;
                if ($role->getCode() === Role::CODE_DIRECTEUR_THESE)return $this->getTheseService()->isDirecteur($these, $user->getIndividu());
                if ($role->getCode() === Role::CODE_DIRECTEUR_THESE)return $this->getTheseService()->isCoDirecteur($these, $user->getIndividu());
                if ($role->getCode() === Role::CODE_DOCTORANT)return $this->getTheseService()->isDoctorant($these, $user->getIndividu());
                return false;
            case JustificatifPrivileges::JUSTIFICATIF_RETIRER:
                if ($role->getCode() === Role::CODE_BDD && $role->getStructure() === $these->getEtablissement()->getStructure()) return true;
                if ($date_current > $maxi) return false;
                if ($role->getCode() === Role::CODE_DIRECTEUR_THESE)return $this->getTheseService()->isDirecteur($these, $user->getIndividu());
                if ($role->getCode() === Role::CODE_DIRECTEUR_THESE)return $this->getTheseService()->isCoDirecteur($these, $user->getIndividu());
                switch ($role->getCode()) {
                    case Role::CODE_ADMIN_TECH:
                        return true;
                    case Role::CODE_BDD:
                        return ($role->getStructure() === $these->getEtablissement()->getStructure());
                    case Role::CODE_DIRECTEUR_THESE :
                        return ($encours AND !$depasse and $this->getTheseService()->isDirecteur($these, $user->getIndividu()));
                    case Role::CODE_CODIRECTEUR_THESE :
                        return ($encours AND !$depasse and $this->getTheseService()->isCoDirecteur($these, $user->getIndividu()));
                    case Role::CODE_DOCTORANT :
                        return ($encours AND !$depasse and $this->getTheseService()->isDoctorant($these, $user->getIndividu()));
                }
                return false;
        }

        return false;
    }


//    public function assertController($controller, $action = null, $privilege = null)
//    {
//        return false;
//    }

}
 No newline at end of file
+0 −28
Changes for module/Soutenance/src/Soutenance/Controller/PropositionController.php: 0 added lines, 28 removed lines.
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ use Application\Controller\AbstractController;
use Application\Entity\Db\Acteur;
use Application\Entity\Db\Individu;
use Application\Entity\Db\Role;
use Application\Entity\Db\TypeValidation;
use Application\Entity\Db\Utilisateur;
use Application\Service\Acteur\ActeurServiceAwareTrait;
use Application\Service\UserContextServiceAwareTrait;
@@ -476,33 +475,6 @@ class PropositionController extends AbstractController
        exit;
    }

    public function avancementAction()
    {
        $these = $this->requestedThese();
        $proposition = $this->getPropositionService()->findByThese($these);

        $directeurs = $this->getActeurService()->getRepository()->findEncadrementThese($these);

        /** @var Membre[] $rapporteurs */
        $rapporteurs = ($proposition) ? $proposition->getRapporteurs() : [];

        /** Justificatifs attendus ---------------------------------------------------------------------------------- */
        $justificatifs = $this->getJustificatifService()->generateListeJustificatif($proposition);

        $validationPDC = $this->getValidationService()->getRepository()->findValidationByCodeAndThese(TypeValidation::CODE_PAGE_DE_COUVERTURE, $these);

        return new ViewModel([
            'these' => $these,
            'proposition' => $proposition,
            'jury' => $this->getPropositionService()->juryOk($proposition),
            'justificatif' => $this->getJustificatifService()->isJustificatifsOk($proposition, $justificatifs),
            'validations' => ($proposition) ? $this->getPropositionService()->getValidationSoutenance($these) : [],
            'directeurs' => $directeurs,
            'rapporteurs' => $rapporteurs,
            'validationPDC' => $validationPDC,
        ]);
    }

    public function toggleSursisAction()
    {
        $these = $this->requestedThese();
+8 −2
Changes for module/Soutenance/src/Soutenance/Service/Justificatif/JustificatifService.php: 8 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -281,10 +281,12 @@ class JustificatifService {
    /**
     * @param Proposition $proposition
     * @param array $justificatifs
     * @return boolean
     * @return boolean|null
     */
    public function isJustificatifsOk($proposition, $justificatifs = [])
    public function isJustificatifsOk(Proposition $proposition, array $justificatifs = []) : ?bool
    {
        $non_bloquant = ['DELEGUATION_SIGNATURE', 'DEMANDE_LABEL_EUROPEEN'];

        if ($justificatifs === []) {
            $justificatifs = $this->generateListeJustificatif($proposition);
        }
@@ -292,8 +294,12 @@ class JustificatifService {
        $justificatifsOk = true;
        foreach ($justificatifs as $justificatif) {
            if ($justificatif['justificatif'] === null) {
                if (array_search($justificatif['type'], $non_bloquant) === false) {
                    $justificatifsOk = false;
                    break;
                } else {
                    $justificatifsOk = null;
                }
            }
        }
        return $justificatifsOk;
+11 −11
Changes for module/Soutenance/view/soutenance/index/index-acteur.phtml: 11 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -86,17 +86,17 @@ $canVisualiser = $this->isAllowed(EngagementImpartialitePrivileges::getResourceI
                Voir les validations <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                <?php foreach($theses as $theseLink) : ?>
                    <li class="complete">
                        <a  <?php /** @see \Soutenance\Controller\PropositionController::avancementAction() */ ?>
                            href="<?php echo $this->url('soutenance/avancement', ['these' => $theseLink->getId()], [], true); ?>">
                            <span class="badge"><?php echo $theseLink->getDoctorant(); ?></span>
                            <?php
                            echo $this->partial('application/these/partial/titre', ['these' => $theseLink, 'useTitreThese' => true, 'length' => 120, 'description' => false])
                            ?>
                        </a>
                    </li>
                <?php endforeach; ?>
<!--                --><?php //foreach($theses as $theseLink) : ?>
<!--                    <li class="complete">-->
<!--                        <a  --><?php ///** @see \Soutenance\Controller\PropositionController::avancementAction() */ ?>
<!--                            href="--><?php //echo $this->url('soutenance/avancement', ['these' => $theseLink->getId()], [], true); ?><!--">-->
<!--                            <span class="badge">--><?php //echo $theseLink->getDoctorant(); ?><!--</span>-->
<!--                            --><?php
//                            echo $this->partial('application/these/partial/titre', ['these' => $theseLink, 'useTitreThese' => true, 'length' => 120, 'description' => false])
//                            ?>
<!--                        </a>-->
<!--                    </li>-->
<!--                --><?php //endforeach; ?>
            </ul>
        </div>
    <?php endif; ?>
Loading