Loading module/Oscar/src/Oscar/Controller/PersonController.php +5 −3 Original line number Diff line number Diff line Loading @@ -172,6 +172,7 @@ class PersonController extends AbstractOscarController public function personnelAction(){ $access = $this->getConfiguration('oscar.listPersonnel'); if( $access == 0 ){ throw new BadRequest400Exception("Cette fonctionnalité n'est pas activé"); } Loading @@ -187,6 +188,7 @@ class PersonController extends AbstractOscarController $idCoWorkers = []; $idSubordinates = $this->getPersonService()->getSubordinateIds($this->getCurrentPerson()->getId()); $idTimesheet = $this->getPersonService()->getTimesheetDelegationIds($this->getCurrentPerson()->getId()); if( $access > 1 ){ Loading @@ -197,7 +199,7 @@ class PersonController extends AbstractOscarController if( !$this->getOscarUserContext()->hasPrivileges(Privileges::PERSON_INDEX) ){ $params['ids'] = array_merge($idCoWorkers, $idSubordinates); $params['ids'] = array_merge($idCoWorkers, $idSubordinates, $idTimesheet); } Loading Loading @@ -741,9 +743,9 @@ class PersonController extends AbstractOscarController /** @var OrganizationRepository $organizationRepository */ $organizationRepository = $this->getEntityManager()->getRepository(Organization::class); $organizationIds = $organizationRepository->getOrganizationsIdsForPerson($this->getCurrentPerson()->getId(), true); $coworkerIds = $this->getPersonService()->getCoWorkerIds($this->getCurrentPerson()->getId()); if( ! in_array($id, $coworkerIds) ){ if( ! (in_array($id, $coworkerIds) || $this->getCurrentPerson()->getTimesheetsFor()->contains($person)) ){ throw new Unauthorized401Exception("Vous n'avez pas accès à la fiche de cette personne"); } } Loading module/Oscar/src/Oscar/Service/OscarUserContext.php +2 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,8 @@ class OscarUserContext extends UserContext // Accès niveau 1 : N+1 $subodinates = $personRepository->getSubordinatesIds($this->getCurrentPerson()->getId()); if( $access > 0 && count($subodinates) > 0 ) return true; if( $access > 0 && (count($subodinates) > 0 || count($this->getCurrentPerson()->getTimesheetsFor()) > 0)) return true; // Accès niveau 2 : Membre de l'organisation $idsOrga = $organisationRepository->getOrganizationsIdsForPerson($this->getCurrentPerson()->getId()); Loading module/Oscar/src/Oscar/Service/PersonService.php +14 −0 Original line number Diff line number Diff line Loading @@ -567,6 +567,20 @@ class PersonService implements ServiceLocatorAwareInterface, EntityManagerAwareI return array_map('current', $nm1); } /** * Retourne la liste des IDS des personnes qui ont autorisé la délégation du remplissage des feuilles de temps. * @param $idPerson */ public function getTimesheetDelegationIds( $idPerson ){ /** @var Person $person */ $person = $this->getPersonRepository()->find($idPerson); $ids = []; foreach ($person->getTimesheetsFor() as $p) { $ids[] = $p->getId(); } return $ids; } /** * @param int $currentPage * @param int $resultByPage Loading Loading
module/Oscar/src/Oscar/Controller/PersonController.php +5 −3 Original line number Diff line number Diff line Loading @@ -172,6 +172,7 @@ class PersonController extends AbstractOscarController public function personnelAction(){ $access = $this->getConfiguration('oscar.listPersonnel'); if( $access == 0 ){ throw new BadRequest400Exception("Cette fonctionnalité n'est pas activé"); } Loading @@ -187,6 +188,7 @@ class PersonController extends AbstractOscarController $idCoWorkers = []; $idSubordinates = $this->getPersonService()->getSubordinateIds($this->getCurrentPerson()->getId()); $idTimesheet = $this->getPersonService()->getTimesheetDelegationIds($this->getCurrentPerson()->getId()); if( $access > 1 ){ Loading @@ -197,7 +199,7 @@ class PersonController extends AbstractOscarController if( !$this->getOscarUserContext()->hasPrivileges(Privileges::PERSON_INDEX) ){ $params['ids'] = array_merge($idCoWorkers, $idSubordinates); $params['ids'] = array_merge($idCoWorkers, $idSubordinates, $idTimesheet); } Loading Loading @@ -741,9 +743,9 @@ class PersonController extends AbstractOscarController /** @var OrganizationRepository $organizationRepository */ $organizationRepository = $this->getEntityManager()->getRepository(Organization::class); $organizationIds = $organizationRepository->getOrganizationsIdsForPerson($this->getCurrentPerson()->getId(), true); $coworkerIds = $this->getPersonService()->getCoWorkerIds($this->getCurrentPerson()->getId()); if( ! in_array($id, $coworkerIds) ){ if( ! (in_array($id, $coworkerIds) || $this->getCurrentPerson()->getTimesheetsFor()->contains($person)) ){ throw new Unauthorized401Exception("Vous n'avez pas accès à la fiche de cette personne"); } } Loading
module/Oscar/src/Oscar/Service/OscarUserContext.php +2 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,8 @@ class OscarUserContext extends UserContext // Accès niveau 1 : N+1 $subodinates = $personRepository->getSubordinatesIds($this->getCurrentPerson()->getId()); if( $access > 0 && count($subodinates) > 0 ) return true; if( $access > 0 && (count($subodinates) > 0 || count($this->getCurrentPerson()->getTimesheetsFor()) > 0)) return true; // Accès niveau 2 : Membre de l'organisation $idsOrga = $organisationRepository->getOrganizationsIdsForPerson($this->getCurrentPerson()->getId()); Loading
module/Oscar/src/Oscar/Service/PersonService.php +14 −0 Original line number Diff line number Diff line Loading @@ -567,6 +567,20 @@ class PersonService implements ServiceLocatorAwareInterface, EntityManagerAwareI return array_map('current', $nm1); } /** * Retourne la liste des IDS des personnes qui ont autorisé la délégation du remplissage des feuilles de temps. * @param $idPerson */ public function getTimesheetDelegationIds( $idPerson ){ /** @var Person $person */ $person = $this->getPersonRepository()->find($idPerson); $ids = []; foreach ($person->getTimesheetsFor() as $p) { $ids[] = $p->getId(); } return $ids; } /** * @param int $currentPage * @param int $resultByPage Loading