Commit 9685aa9d authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Accès à la liste 'personnel' pour les personnes nommées pour compéter les feuilles de temps

parent 4da4807c
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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é");
        }
@@ -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 ){
@@ -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);
        }


@@ -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");
                }
            }
+2 −1
Original line number Diff line number Diff line
@@ -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());
+14 −0
Original line number Diff line number Diff line
@@ -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