Skip to content
Snippets Groups Projects
Commit 8039b2de authored by lecluse's avatar lecluse
Browse files
parent deebd5c8
Branches
Tags
No related merge requests found
Showing
with 459 additions and 235 deletions
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "748ee1c993c5f0ae90ee21769545e4da", "hash": "748ee1c993c5f0ae90ee21769545e4da",
......
...@@ -102,15 +102,3 @@ select * from individu_fonct_struct@harpprod ifs where no_dossier_pers = 16956; ...@@ -102,15 +102,3 @@ select * from individu_fonct_struct@harpprod ifs where no_dossier_pers = 16956;
select * from individu@harpprod where nom_usuel = 'DENOYES'; select * from individu@harpprod where nom_usuel = 'DENOYES';
select
r.code categorie,
p.code privilege,
p.id p_id
from
privilege p
join categorie_privilege r on r.id = p.categorie_id
order by
categorie, privilege
\ No newline at end of file
-- paiements
select * from mise_en_paiement
--;delete from mise_en_paiement
--;update mise_en_paiement set histo_destructeur_id = 4, histo_destruction=sysdate
where formule_res_service_id IN (
select id from formule_resultat_service where service_id IN (
select id from service where intervenant_id IN (
select id from intervenant where source_code = '100733'
)
)
);
-- contrats
select * from contrat
--;delete from contrat
--;update contrat set histo_destructeur_id = 4, histo_destruction=sysdate
where intervenant_id IN (
select id from intervenant where source_code = '100733'
);
-- validations de volumes_horaires
select * from validation_vol_horaire
--;delete from validation_vol_horaire
where volume_horaire_id IN (
select id FROM volume_horaire WHERE service_id IN (
select id from service where intervenant_id IN (
select id from intervenant where source_code = '100733'
)
)
);
-- volumes horaires
select * from volume_horaire
--;delete from volume_horaire
--;update volume_horaire set histo_destructeur_id = 4, histo_destruction=sysdate
where service_id IN (
select id from service where intervenant_id IN (
select id from intervenant where source_code = '100733'
)
);
-- services
select * from service
--;delete from service
--;update service set histo_destructeur_id = 4, histo_destruction=sysdate
where intervenant_id IN (
select id from intervenant where source_code = '100733'
);
-- intervenant
select * from intervenant
--;delete from intervenant
--;update intervenant set histo_destructeur_id = 4, histo_destruction=sysdate
where source_code = '100733';
\ No newline at end of file
INSERT INTO CATEGORIE_PRIVILEGE (
ID,
CODE,
LIBELLE
) VALUES (
CATEGORIE_PRIVILEGE_ID_SEQ.nextval,
'modification-service-du',
'Modification de service dû'
);
INSERT INTO PRIVILEGE (
ID,
CATEGORIE_ID,
CODE,
LIBELLE
) VALUES (
privilege_id_seq.nextval,
(SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = 'modif-service-du' ),
'association',
'Association'
);
INSERT INTO PRIVILEGE (
ID,
CATEGORIE_ID,
CODE,
LIBELLE
) VALUES (
privilege_id_seq.nextval,
(SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = 'modif-service-du' ),
'visualisation',
'Visualisation'
);
INSERT INTO PRIVILEGE (
ID,
CATEGORIE_ID,
CODE,
LIBELLE
) VALUES (
privilege_id_seq.nextval,
(SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = 'modif-service-du' ),
'edition',
'Édition'
);
INSERT INTO PRIVILEGE (
ID,
CATEGORIE_ID,
CODE,
LIBELLE
) VALUES (
privilege_id_seq.nextval,
(SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = 'mise-en-paiement' ),
'export-paie',
'Export vers le logiciel de paie'
);
select
cp.code categorie,
p.code privilege
from
privilege p
join categorie_privilege cp on cp.id = p.categorie_id
order by
categorie, privilege
\ No newline at end of file
...@@ -113,14 +113,14 @@ return [ ...@@ -113,14 +113,14 @@ return [
'title' => "Gestion des rôles", 'title' => "Gestion des rôles",
'route' => 'gestion/droits/roles', 'route' => 'gestion/droits/roles',
'withtarget' => true, 'withtarget' => true,
'resource' => 'controller/Application\Controller\Gestion:roles', 'resource' => 'privilege/privilege-visualisation',
], ],
'privileges' => [ 'privileges' => [
'label' => "Privilèges", 'label' => "Privilèges",
'title' => "Gestion des privilèges", 'title' => "Gestion des privilèges",
'route' => 'gestion/droits/privileges', 'route' => 'gestion/droits/privileges',
'withtarget' => true, 'withtarget' => true,
'resource' => 'controller/Application\Controller\Gestion:privileges', 'resource' => 'privilege/privilege-visualisation',
], ],
], ],
], ],
...@@ -143,7 +143,7 @@ return [ ...@@ -143,7 +143,7 @@ return [
[ [
'controller' => 'Application\Controller\Gestion', 'controller' => 'Application\Controller\Gestion',
'action' => ['droits', 'roles', 'privileges'], 'action' => ['droits', 'roles', 'privileges'],
'privileges' => ['privilege-visualisation', 'privilege-edition'] 'privileges' => ['privilege-visualisation', 'privilege-edition'],
], ],
[ [
'controller' => 'Application\Controller\Gestion', 'controller' => 'Application\Controller\Gestion',
......
...@@ -179,6 +179,9 @@ $main = [ ...@@ -179,6 +179,9 @@ $main = [
'Application\\Acl\\IntervenantPermanentRole', 'Application\\Acl\\IntervenantPermanentRole',
], ],
], ],
'resource_providers' => [
'ApplicationPrivilege' => [],
],
], ],
'service_manager' => [ 'service_manager' => [
'invokables' => [ 'invokables' => [
...@@ -197,12 +200,16 @@ $main = [ ...@@ -197,12 +200,16 @@ $main = [
'ApplicationPays' => 'Application\\Service\\Pays', 'ApplicationPays' => 'Application\\Service\\Pays',
'ApplicationDepartement' => 'Application\\Service\\Departement', 'ApplicationDepartement' => 'Application\\Service\\Departement',
'IntervenantNavigationPageVisibility' => 'Application\\Service\\IntervenantNavigationPageVisibility', 'IntervenantNavigationPageVisibility' => 'Application\\Service\\IntervenantNavigationPageVisibility',
'ApplicationRuleProvider' => 'Application\Provider\Rule\RuleProvider', 'TestAssertion' => 'Application\\Assertion\\TestAssertion',
], ],
'aliases' => array(
'PrivilegeProvider' => 'ApplicationPrivilege'
),
'factories' => [ 'factories' => [
'navigation' => 'Application\Service\NavigationFactoryFactory', 'navigation' => 'Application\Service\NavigationFactoryFactory',
'ApplicationRoleProvider' => 'Application\Provider\Role\RoleProviderFactory', 'ApplicationRoleProvider' => 'Application\Provider\Role\RoleProviderFactory',
'ApplicationIdentityProvider' => 'Application\Provider\Identity\IdentityProviderFactory', 'ApplicationIdentityProvider' => 'Application\Provider\Identity\IdentityProviderFactory',
'BjyAuthorize\Service\Authorize' => 'Application\Service\AuthorizeFactory', // surcharge!!!
], ],
'abstract_factories' => [ 'abstract_factories' => [
], ],
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace Application; namespace Application;
use Application\Entity\Db\Privilege;
return [ return [
'router' => [ 'router' => [
'routes' => [ 'routes' => [
...@@ -110,47 +112,52 @@ return [ ...@@ -110,47 +112,52 @@ return [
], ],
'bjyauthorize' => [ 'bjyauthorize' => [
'guards' => [ 'guards' => [
'BjyAuthorize\Guard\Controller' => [ 'Application\Guard\PrivilegeController' => [
[ [
'controller' => 'Application\Controller\Paiement', 'controller' => 'Application\Controller\Paiement',
'action' => ['index','demandeMiseEnPaiement','etatPaiement','misesEnPaiementCsv'], 'action' => ['index','etatPaiement','misesEnPaiementCsv'],
'roles' => [R_COMPOSANTE, R_ADMINISTRATEUR, R_DRH], 'privileges' => [
Privilege::MISE_EN_PAIEMENT_DEMANDE,
Privilege::MISE_EN_PAIEMENT_VISUALISATION,
Privilege::MISE_EN_PAIEMENT_VALIDATION,
],
'assertion' => 'MiseEnPaiementAssertion',
], ],
[ [
'controller' => 'Application\Controller\Paiement', 'controller' => 'Application\Controller\Paiement',
'action' => ['miseEnPaiement','extractionWinpaie'], 'action' => ['demandeMiseEnPaiement'],
'roles' => [R_ADMINISTRATEUR, R_DRH], 'privileges' => [Privilege::MISE_EN_PAIEMENT_DEMANDE],
], 'assertion' => 'MiseEnPaiementAssertion',
],
], ],
'resource_providers' => [
'BjyAuthorize\Provider\Resource\Config' => [
'MiseEnPaiement' => [],
],
],
'rule_providers' => [
'BjyAuthorize\Provider\Rule\Config' => [
'allow' => [
[ [
[R_ROLE], 'controller' => 'Application\Controller\Paiement',
'MiseEnPaiement', 'action' => ['miseEnPaiement'],
[ 'privileges' => [Privilege::MISE_EN_PAIEMENT_MISE_EN_PAIEMENT]
Assertion\MiseEnPaiementAssertion::PRIVILEGE_VISUALISATION,
Assertion\MiseEnPaiementAssertion::PRIVILEGE_DEMANDE,
Assertion\MiseEnPaiementAssertion::PRIVILEGE_VALIDATION,
Assertion\MiseEnPaiementAssertion::PRIVILEGE_MISE_EN_PAIEMENT,
],
Assertion\MiseEnPaiementAssertion::getAssertionId(),
], ],
[ [
[R_ADMINISTRATEUR, R_DRH], 'controller' => 'Application\Controller\Paiement',
'MiseEnPaiement', 'action' => ['extractionWinpaie'],
['export-csv-winpaie'], 'privileges' => [Privilege::MISE_EN_PAIEMENT_EXPORT_PAIE]
],
], ],
], ],
], // 'rule_providers' => [
], // 'Application\Provider\Rule\RuleProvider' => [
// 'allow' => [
// [
// [
// 'mise-en-paiement-demande',
// 'mise-en-paiement-mise-en-paiement',
// 'mise-en-paiement-visualisation',
// 'mise-en-paiement-validation'
// ],
// 'MiseEnPaiement',
// [],
// 'MiseEnPaiementAssertion',
// ]
// ],
// ],
// ],
], ],
'service_manager' => [ 'service_manager' => [
'invokables' => [ 'invokables' => [
......
...@@ -236,7 +236,7 @@ return [ ...@@ -236,7 +236,7 @@ return [
'controller' => 'Application\Controller\ServiceReferentiel', 'controller' => 'Application\Controller\ServiceReferentiel',
'action' => ['index', 'saisie', 'suppression', 'rafraichir-ligne', 'constatation'], 'action' => ['index', 'saisie', 'suppression', 'rafraichir-ligne', 'constatation'],
'roles' => [R_ROLE], 'roles' => [R_ROLE],
], ]
], ],
], ],
'resource_providers' => [ 'resource_providers' => [
...@@ -248,8 +248,16 @@ return [ ...@@ -248,8 +248,16 @@ return [
], ],
], ],
'rule_providers' => [ 'rule_providers' => [
'BjyAuthorize\Provider\Rule\Config' => [ 'Application\Provider\Rule\RuleProvider' => [
'allow' => [ 'allow' => [
[
'mep-visualisation',
'Service',
['create', 'read', 'delete', 'update'],
'ServiceAssertion',
]
],
/*'allow' => [
[ [
[R_ROLE], [R_ROLE],
'Service', 'Service',
...@@ -274,7 +282,7 @@ return [ ...@@ -274,7 +282,7 @@ return [
['create', 'read', 'delete', 'update'], ['create', 'read', 'delete', 'update'],
'ServiceReferentielAssertion' 'ServiceReferentielAssertion'
] ]
], ],*/
], ],
], ],
], ],
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
namespace Application\Assertion; namespace Application\Assertion;
use DateTime;
use Application\Acl\IntervenantPermanentRole;
use Zend\Mvc\MvcEvent; use Zend\Mvc\MvcEvent;
use Zend\Permissions\Acl\Acl; use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Assertion\AssertionInterface; use Zend\Permissions\Acl\Assertion\AssertionInterface;
...@@ -11,7 +9,6 @@ use Zend\Permissions\Acl\Resource\ResourceInterface; ...@@ -11,7 +9,6 @@ use Zend\Permissions\Acl\Resource\ResourceInterface;
use Zend\Permissions\Acl\Role\RoleInterface; use Zend\Permissions\Acl\Role\RoleInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait; use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Application\Acl\Role;
/** /**
* Description of AbstractAssertion * Description of AbstractAssertion
...@@ -20,9 +17,7 @@ use Application\Acl\Role; ...@@ -20,9 +17,7 @@ use Application\Acl\Role;
*/ */
abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAwareInterface abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAwareInterface
{ {
use ServiceLocatorAwareTrait, use ServiceLocatorAwareTrait;
\Application\Service\Traits\ContextAwareTrait
;
const PRIVILEGE_CREATE = 'create'; const PRIVILEGE_CREATE = 'create';
...@@ -30,40 +25,6 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw ...@@ -30,40 +25,6 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
const PRIVILEGE_UPDATE = 'update'; const PRIVILEGE_UPDATE = 'update';
const PRIVILEGE_DELETE = 'delete'; const PRIVILEGE_DELETE = 'delete';
/**
* @var Acl
*/
protected $acl;
/**
* copntrôle par les privileges activés ou non
*
* @var boolean
*/
protected $assertPrivilegesEnabled = false;
/**
* contrôle par les ressources activés ou non
*
* @var boolean
*/
protected $assertResourcesEnabled = true;
/**
* @var string
*/
protected $privilege;
/**
* @var ResourceInterface|string
*/
protected $resource;
/**
* @var RoleInterface
*/
protected $role;
/** /**
* !!!! Pour éviter l'erreur "Serialization of 'Closure' is not allowed"... !!!! * !!!! Pour éviter l'erreur "Serialization of 'Closure' is not allowed"... !!!!
* *
...@@ -89,112 +50,167 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw ...@@ -89,112 +50,167 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
*/ */
public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null) public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
{ {
/** @deprecated */
$this->acl = $acl; $this->acl = $acl;
$this->resource = $resource; $this->resource = $resource;
$this->privilege = $privilege; $this->privilege = $privilege;
$this->role = $this->getSelectedIdentityRole(); $this->role = $role;
/* fin de deprecated */
if (! $this->assertPrivilege() ) return false; // gestion des privilèges
if (! $this->assertResource() ) return false; if ($this->detectPrivilege($resource)){
return true; if (! $this->assertPrivilege ($acl, $role, ltrim( strstr( $resource, '/' ), '/'), $privilege)) return false;
}
private function assertPrivilege() // gestion des contrôleurs
{ }else if($this->detectController($resource)){
if (! $this->assertPrivilegesEnabled) return true; // si pas activé alors on sort $spos = strpos($resource,'/')+1;
if ($this->role instanceof Role && ! empty($this->resource) && ! empty($this->privilege)){ $dpos = strrpos($resource, ':')+1;
return $this->role->hasPrivilege($this->privilege, $this->resource); $controller = substr( $resource, $spos, $dpos-$spos-1);
} $action = substr( $resource, $dpos );
return true; if (! $this->assertController ($acl, $role, $controller, $action, $privilege)) return false;
}
private function assertResource() // gestion des entités
{ }else if($this->detectEntity($resource)){
if (! $this->assertResourcesEnabled) return true; // si pas activé alors on sort if (! $this->assertEntity ($acl, $role, $resource, $privilege)) return false;
if (! $this->resource instanceof ResourceInterface) return true; // pas assez de précisions
$resourceId = $this->resource->getResourceId(); // gestion de tout le reste
}else{
if (! $this->assertOther ($acl, $role, $resource, $privilege)) return false;
if (method_exists( $this, 'assertResource'.$resourceId)){
return $this->{'assertResource'.$resourceId}( $this->resource );
} }
return true; return true;
} }
/** /**
* *
* @return MvcEvent * @param string $resource
* @return boolean
*/ */
protected function getMvcEvent() private function detectPrivilege( $resource=null )
{ {
return $this->getServiceLocator()->get('Application')->getMvcEvent(); return is_string($resource) && 0 === strpos($resource, 'privilege/');
} }
/** /**
*
* @param Acl $acl
* @param RoleInterface $role
* @param string $privilege
* @param string $subPrivilege
* @return boolean * @return boolean
*/ */
protected function assertCRUD() protected function assertPrivilege(Acl $acl, RoleInterface $role=null, $privilege=null, $subPrivilege=null)
{ {
if (!$this->privilege) {
return true; return true;
} }
switch ($this->privilege) {
case self::PRIVILEGE_CREATE:
return $this->_assertCreate();
case self::PRIVILEGE_READ:
return $this->_assertRead();
case self::PRIVILEGE_UPDATE:
return $this->_assertUpdate();
case self::PRIVILEGE_DELETE:
return $this->_assertDelete();
default:
return true;
}
}
private function _assertCreate() /**
*
* @param string $resource
* @return boolean
*/
private function detectController( $resource=null )
{ {
if (is_object($this->resource) && $this->resource->getId()) { return is_string($resource) && 0 === strpos($resource, 'controller/');
return false;
} }
/**
*
* @param Acl $acl
* @param RoleInterface $role
* @param string $controller
* @param string $action
* @param string $privilege
* @return boolean
*/
protected function assertController(Acl $acl, RoleInterface $role=null, $controller=null, $action=null, $privilege=null)
{
return true; return true;
} }
private function _assertRead()
/**
*
* @param string $resource
* @return boolean
*/
private function detectEntity( $resource=null )
{ {
if (is_object($this->resource) && !$this->resource->getId()) { return
return false; is_object($resource)
&& method_exists($resource, 'getId');
} }
/**
*
* @param Acl $acl
* @param RoleInterface $role
* @param ResourceInterface $entity
* @param string $privilege
* @return boolean
*/
protected function assertEntity(Acl $acl, RoleInterface $role=null, ResourceInterface $entity=null, $privilege=null)
{
return true; return true;
} }
private function _assertUpdate()
{
if (is_object($this->resource) && !$this->resource->getId()) {
return false;
}
/**
*
* @param Acl $acl
* @param RoleInterface $role
* @param ResourceInterface $entity
* @param string $privilege
* @return boolean
*/
protected function assertOther(Acl $acl, RoleInterface $role=null, ResourceInterface $entity=null, $privilege=null)
{
return true; return true;
} }
private function _assertDelete()
/**
* @deprecated ?
* @return boolean
*/
protected function assertCRUD()
{ {
if (is_object($this->resource) && !$this->resource->getId()) { if (!$this->privilege) {
return false; return true;
} }
switch ($this->privilege) {
case self::PRIVILEGE_CREATE:
return ! (is_object($this->resource) && $this->resource->getId());
case self::PRIVILEGE_READ:
return ! (is_object($this->resource) && !$this->resource->getId());
case self::PRIVILEGE_UPDATE:
return ! (is_object($this->resource) && !$this->resource->getId());
case self::PRIVILEGE_DELETE:
return ! (is_object($this->resource) && !$this->resource->getId());
default:
return true; return true;
} }
}
protected function getSelectedIdentityRole()
/**
*
* @return MvcEvent
*/
protected function getMvcEvent()
{ {
return $this->getServiceContext()->getSelectedIdentityRole(); $application = $this->getServiceLocator()->get('Application');
return $application->getMvcEvent();
} }
/** /**
* @deprecated
*
* Retourne un privilège "normalisé" en fonction du type de ressource spécifié. * Retourne un privilège "normalisé" en fonction du type de ressource spécifié.
* *
* - Si la ressource est un objet, le privilège est directement utilisable. * - Si la ressource est un objet, le privilège est directement utilisable.
...@@ -217,50 +233,4 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw ...@@ -217,50 +233,4 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
return $privilege; return $privilege;
} }
/**
* Teste si la date de fin de "privilège" du rôle courant est dépassée ou non.
*
* @return boolean
*/
protected function isDateFinPrivilegeDepassee()
{
$dateFin = null;
/**
* Rôle Intervenant Permanent
*/
if ($this->role instanceof IntervenantPermanentRole) {
// il existe une date de fin de saisie (i.e. ajout, modif, suppression) de service par les intervenants permanents eux-mêmes
if (in_array($this->privilege, [self::PRIVILEGE_CREATE, self::PRIVILEGE_UPDATE, self::PRIVILEGE_DELETE])) {
$dateFin = $this->getServiceContext()->getDateFinSaisiePermanents();
/**
* Vilaine verrue pour prolonger la période de saisie des permanents de l'ESPE
* @todo Virer cette verrue après le 27/03/2015 !!
*/
if ($this->role->getIntervenant()->getStructure()->getSourceCode() === 'E01') {
$dateFin = new \DateTime('2015-03-27');
}
}
}
if (null === $dateFin) {
return false;
}
$now = new DateTime();
$now->setTime(0, 0, 0);
$dateFin->setTime(0, 0, 0);
return $now > $dateFin;
}
public static function getAssertionId()
{
$getCalledClass = get_called_class();
$getCalledClass = substr( $getCalledClass, strrpos( $getCalledClass, '\\')+1 );
return $getCalledClass;
}
} }
\ No newline at end of file
...@@ -54,7 +54,7 @@ class AgrementAssertion extends AbstractAssertion implements AgrementServiceAwar ...@@ -54,7 +54,7 @@ class AgrementAssertion extends AbstractAssertion implements AgrementServiceAwar
* Cas N°1 : la ressource spécifiée est une entité ; un privilège est spécifié. * Cas N°1 : la ressource spécifiée est une entité ; un privilège est spécifié.
*/ */
if ($resource instanceof Agrement) { if ($resource instanceof Agrement) {
return $this->assertEntity(); return $this->assertEntityOld();
} }
/** /**
...@@ -107,7 +107,7 @@ class AgrementAssertion extends AbstractAssertion implements AgrementServiceAwar ...@@ -107,7 +107,7 @@ class AgrementAssertion extends AbstractAssertion implements AgrementServiceAwar
* *
* @return boolean * @return boolean
*/ */
protected function assertEntity() protected function assertEntityOld()
{ {
if (!parent::assertCRUD()) { if (!parent::assertCRUD()) {
return false; return false;
......
...@@ -50,7 +50,7 @@ class ContratAssertion extends AbstractAssertion implements WorkflowIntervenantA ...@@ -50,7 +50,7 @@ class ContratAssertion extends AbstractAssertion implements WorkflowIntervenantA
parent::assert($acl, $role, $resource, $privilege); parent::assert($acl, $role, $resource, $privilege);
if ($resource instanceof Contrat) { if ($resource instanceof Contrat) {
return $this->assertEntity(); return $this->assertEntityOld();
} }
return true; return true;
...@@ -60,7 +60,7 @@ class ContratAssertion extends AbstractAssertion implements WorkflowIntervenantA ...@@ -60,7 +60,7 @@ class ContratAssertion extends AbstractAssertion implements WorkflowIntervenantA
* *
* @return boolean * @return boolean
*/ */
protected function assertEntity() protected function assertEntityOld()
{ {
if (!parent::assertCRUD()) { if (!parent::assertCRUD()) {
return false; return false;
......
...@@ -48,7 +48,7 @@ class FichierAssertion extends AbstractAssertion implements /*FichierServiceAwar ...@@ -48,7 +48,7 @@ class FichierAssertion extends AbstractAssertion implements /*FichierServiceAwar
* Cas N°1 : la ressource spécifiée est une entité ; un privilège est spécifié. * Cas N°1 : la ressource spécifiée est une entité ; un privilège est spécifié.
*/ */
if ($resource instanceof Fichier) { if ($resource instanceof Fichier) {
return $this->assertEntity(); return $this->assertEntityOld();
} }
/** /**
...@@ -65,7 +65,7 @@ class FichierAssertion extends AbstractAssertion implements /*FichierServiceAwar ...@@ -65,7 +65,7 @@ class FichierAssertion extends AbstractAssertion implements /*FichierServiceAwar
* *
* @return boolean * @return boolean
*/ */
protected function assertEntity() protected function assertEntityOld()
{ {
if (!parent::assertCRUD()) { if (!parent::assertCRUD()) {
return false; return false;
......
...@@ -5,6 +5,7 @@ namespace Application\Assertion; ...@@ -5,6 +5,7 @@ namespace Application\Assertion;
use Application\Interfaces\StructureAwareInterface; use Application\Interfaces\StructureAwareInterface;
use Application\Entity\Db\ServiceAPayerInterface; use Application\Entity\Db\ServiceAPayerInterface;
use Application\Entity\Db\MiseEnPaiement; use Application\Entity\Db\MiseEnPaiement;
use Zend\Permissions\Acl;
/** /**
* Description of MiseEnPaiementAssertion * Description of MiseEnPaiementAssertion
...@@ -18,17 +19,20 @@ class MiseEnPaiementAssertion extends AbstractAssertion ...@@ -18,17 +19,20 @@ class MiseEnPaiementAssertion extends AbstractAssertion
const PRIVILEGE_VALIDATION = 'validation'; const PRIVILEGE_VALIDATION = 'validation';
const PRIVILEGE_MISE_EN_PAIEMENT = 'mise-en-paiement'; const PRIVILEGE_MISE_EN_PAIEMENT = 'mise-en-paiement';
protected $assertPrivilegesEnabled = true;
protected function assertEntity(Acl\Acl $acl, Acl\Role\RoleInterface $role = null, Acl\Resource\ResourceInterface $entity = null, $privilege = null)
{
if ($entity instanceof MiseEnPaiement)
return $this->assertEntityMiseEnPaiement($entity);
return true;
}
protected function assertResourceMiseEnPaiement( MiseEnPaiement $miseEnPaiement ) protected function assertEntityMiseEnPaiement( MiseEnPaiement $miseEnPaiement )
{ {
if ($miseEnPaiement->getValidation() && $this->privilege == self::PRIVILEGE_DEMANDE){ if ($miseEnPaiement->getValidation() && $this->privilege == self::PRIVILEGE_DEMANDE){
return false; // pas de nouvelle demande si la mise en paiement est déjà validée return false; // pas de nouvelle demande si la mise en paiement est déjà validée
} }
// if ($miseEnPaiement->getValidation() === null && $this->privilege == self::PRIVILEGE_MISE_EN_PAIEMENT){
// return false; // impossible de mettre en paiement une demande non validée
// }
if ($serviceAPayer = $miseEnPaiement->getServiceAPayer()){ if ($serviceAPayer = $miseEnPaiement->getServiceAPayer()){
return $this->assertResourceServiceAPayer($serviceAPayer); return $this->assertResourceServiceAPayer($serviceAPayer);
......
...@@ -40,7 +40,7 @@ class PieceJointeAssertion extends AbstractAssertion implements WorkflowInterven ...@@ -40,7 +40,7 @@ class PieceJointeAssertion extends AbstractAssertion implements WorkflowInterven
* Cas N°1 : la ressource spécifiée est une entité ; un privilège est spécifié. * Cas N°1 : la ressource spécifiée est une entité ; un privilège est spécifié.
*/ */
if ($resource instanceof PieceJointe) { if ($resource instanceof PieceJointe) {
return $this->assertEntity($acl, $role, $resource, $privilege); return $this->assertEntityOld($acl, $role, $resource, $privilege);
} }
/** /**
...@@ -57,7 +57,7 @@ class PieceJointeAssertion extends AbstractAssertion implements WorkflowInterven ...@@ -57,7 +57,7 @@ class PieceJointeAssertion extends AbstractAssertion implements WorkflowInterven
* *
* @return boolean * @return boolean
*/ */
protected function assertEntity() protected function assertEntityOld()
{ {
if (!parent::assertCRUD()) { if (!parent::assertCRUD()) {
return false; return false;
......
...@@ -13,6 +13,8 @@ use Zend\Permissions\Acl\Acl; ...@@ -13,6 +13,8 @@ use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Resource\ResourceInterface; use Zend\Permissions\Acl\Resource\ResourceInterface;
use Zend\Permissions\Acl\Role\RoleInterface; use Zend\Permissions\Acl\Role\RoleInterface;
use Application\Entity\Db\TypeVolumeHoraire; use Application\Entity\Db\TypeVolumeHoraire;
use DateTime;
use Application\Acl\IntervenantPermanentRole;
/** /**
* Description of Service * Description of Service
...@@ -44,7 +46,7 @@ class ServiceAssertion extends AbstractAssertion ...@@ -44,7 +46,7 @@ class ServiceAssertion extends AbstractAssertion
parent::assert($acl, $role, $resource, $privilege); parent::assert($acl, $role, $resource, $privilege);
if ($resource instanceof Service) { if ($resource instanceof Service) {
return $this->assertEntity(); return $this->assertEntityOld();
} }
return true; return true;
...@@ -56,7 +58,7 @@ class ServiceAssertion extends AbstractAssertion ...@@ -56,7 +58,7 @@ class ServiceAssertion extends AbstractAssertion
* *
* @return boolean * @return boolean
*/ */
protected function assertEntity() protected function assertEntityOld()
{ {
/********************************************************* /*********************************************************
* Rôle administrateur * Rôle administrateur
...@@ -166,4 +168,35 @@ class ServiceAssertion extends AbstractAssertion ...@@ -166,4 +168,35 @@ class ServiceAssertion extends AbstractAssertion
return false; return false;
} }
/**
* Teste si la date de fin de "privilège" du rôle courant est dépassée ou non.
*
* @return boolean
*/
protected function isDateFinPrivilegeDepassee()
{
$dateFin = null;
/**
* Rôle Intervenant Permanent
*/
if ($this->role instanceof IntervenantPermanentRole) {
// il existe une date de fin de saisie (i.e. ajout, modif, suppression) de service par les intervenants permanents eux-mêmes
if (in_array($this->privilege, [self::PRIVILEGE_CREATE, self::PRIVILEGE_UPDATE, self::PRIVILEGE_DELETE])) {
$dateFin = $this->getServiceContext()->getDateFinSaisiePermanents();
}
}
if (null === $dateFin) {
return false;
}
$now = new DateTime();
$now->setTime(0, 0, 0);
$dateFin->setTime(0, 0, 0);
return $now > $dateFin;
}
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ use Application\Entity\Db\ServiceReferentiel; ...@@ -13,6 +13,7 @@ use Application\Entity\Db\ServiceReferentiel;
use Zend\Permissions\Acl\Acl; use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Resource\ResourceInterface; use Zend\Permissions\Acl\Resource\ResourceInterface;
use Zend\Permissions\Acl\Role\RoleInterface; use Zend\Permissions\Acl\Role\RoleInterface;
use DateTime;
/** /**
* *
...@@ -38,7 +39,7 @@ class ServiceReferentielAssertion extends AbstractAssertion ...@@ -38,7 +39,7 @@ class ServiceReferentielAssertion extends AbstractAssertion
parent::assert($acl, $role, $resource, $privilege); parent::assert($acl, $role, $resource, $privilege);
if ($resource instanceof ServiceReferentiel) { if ($resource instanceof ServiceReferentiel) {
return $this->assertEntity(); return $this->assertEntityOld();
} }
return true; return true;
...@@ -50,7 +51,7 @@ class ServiceReferentielAssertion extends AbstractAssertion ...@@ -50,7 +51,7 @@ class ServiceReferentielAssertion extends AbstractAssertion
* *
* @return boolean * @return boolean
*/ */
protected function assertEntity() protected function assertEntityOld()
{ {
$intervenant = $this->resource->getIntervenant(); $intervenant = $this->resource->getIntervenant();
$serviceStructure = $this->resource->getStructure(); $serviceStructure = $this->resource->getStructure();
...@@ -132,4 +133,35 @@ class ServiceReferentielAssertion extends AbstractAssertion ...@@ -132,4 +133,35 @@ class ServiceReferentielAssertion extends AbstractAssertion
return true; return true;
} }
/**
* Teste si la date de fin de "privilège" du rôle courant est dépassée ou non.
*
* @return boolean
*/
protected function isDateFinPrivilegeDepassee()
{
$dateFin = null;
/**
* Rôle Intervenant Permanent
*/
if ($this->role instanceof IntervenantPermanentRole) {
// il existe une date de fin de saisie (i.e. ajout, modif, suppression) de service par les intervenants permanents eux-mêmes
if (in_array($this->privilege, [self::PRIVILEGE_CREATE, self::PRIVILEGE_UPDATE, self::PRIVILEGE_DELETE])) {
$dateFin = $this->getServiceContext()->getDateFinSaisiePermanents();
}
}
if (null === $dateFin) {
return false;
}
$now = new DateTime();
$now->setTime(0, 0, 0);
$dateFin->setTime(0, 0, 0);
return $now > $dateFin;
}
} }
\ No newline at end of file
<?php
namespace Application\Assertion;
use Application\Entity\Db\Service;
use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Resource\ResourceInterface;
use Zend\Permissions\Acl\Role\RoleInterface;
/**
* Description of TestAssertion
*
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/
class TestAssertion extends AbstractAssertion
{
/**
* @var Service
*/
protected $resource;
/**
* Returns true if and only if the assertion conditions are met
*
* This method is passed the ACL, Role, Resource, and privilege to which the authorization query applies. If the
* $role, $resource, or $privilege parameters are null, it means that the query applies to all Roles, Resources, or
* privileges, respectively.
*
* @param Acl $acl
* @param RoleInterface $role
* @param ResourceInterface $resource
* @param string $privilege
* @return bool
*/
public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
{
parent::assert($acl, $role, $resource, $privilege);
var_dump($acl->getRoles());
// var_dump($acl);
// var_dump($role);
// var_dump($resource);
// var_dump($privilege);
return true;
}
}
\ No newline at end of file
...@@ -37,7 +37,7 @@ abstract class ValidationEnsRefAbstractAssertion extends AbstractAssertion ...@@ -37,7 +37,7 @@ abstract class ValidationEnsRefAbstractAssertion extends AbstractAssertion
parent::assert($acl, $role, $resource, $privilege); parent::assert($acl, $role, $resource, $privilege);
if ($resource instanceof ValidationEntity) { if ($resource instanceof ValidationEntity) {
return $this->assertEntity(); return $this->assertEntityOld();
} }
return true; return true;
......
...@@ -79,7 +79,7 @@ class ValidationReferentielAssertion extends ValidationEnsRefAbstractAssertion ...@@ -79,7 +79,7 @@ class ValidationReferentielAssertion extends ValidationEnsRefAbstractAssertion
// //
// return false; // return false;
// } // }
protected function assertEntity() protected function assertEntityOld()
{ {
$rule = $this->getServiceLocator()->get('ValidationReferentielRule') $rule = $this->getServiceLocator()->get('ValidationReferentielRule')
->setIntervenant($this->resource->getIntervenant()) ->setIntervenant($this->resource->getIntervenant())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment