Commit 4c5c4006 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- UP : Suppression de l'action person/grant, non utilisée et en doublon avec...

- UP : Suppression de l'action person/grant, non utilisée et en doublon avec la vue accès plus complète
parent f1a4ced0
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -225,10 +225,6 @@ return array(
                    'action' => ['edit', 'new', 'merge', 'organizationRole', 'notificationPerson', 'notificationPersonGenerate'],
                    'privileges' => \Oscar\Provider\Privileges::PERSON_EDIT
                ],
                [ 'controller' =>   'Person',
                    'action' => ['grant'],
                    'privileges' => \Oscar\Provider\Privileges::DROIT_PRIVILEGE_VISUALISATION
                ],

                // Membre
                [ 'controller' =>   'Enroll',
+0 −7
Original line number Diff line number Diff line
@@ -562,13 +562,6 @@ person:
                defaults:
                    action: access

        grant:
            type: segment
            options:
                route: '/grant/:id'
                defaults:
                    action: grant

        notification:
            type: segment
            options:
+27 −58
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
 *
 * @copyright Certic (c) 2015
 */

namespace Oscar\Controller;

use BjyAuthorize\Exception\UnAuthorizedException;
@@ -82,8 +83,6 @@ class PersonController extends AbstractOscarController implements UsePersonServi
        $this->activityRequestService = $activityRequestService;
    }



    /**
     * Liste des personnes issue de Ldap.
     *
@@ -96,7 +95,8 @@ class PersonController extends AbstractOscarController implements UsePersonServi
        $this->getResponseDeprecated();
    }

    public function deleteAction(){
    public function deleteAction()
    {
        $method = $this->getHttpXMethod();
        $this->getOscarUserContextService()->check(Privileges::PERSON_EDIT);
        try {
@@ -105,6 +105,9 @@ class PersonController extends AbstractOscarController implements UsePersonServi
            }
            $person = $this->getPersonService()->getPersonById($this->params()->fromRoute('id'), true);

            // Test de déclaration
            // TODO Tester si la personne est déclarante, et lever une exception

            $del = $this->getEntityManager()->createQueryBuilder()->delete(NotificationPerson::class, 'n')
                ->where('n.person = :person')
                ->setParameter('person', $person);
@@ -136,23 +139,18 @@ class PersonController extends AbstractOscarController implements UsePersonServi
            }
            $this->redirect()->toRoute('home');

        }
        catch (ForeignKeyConstraintViolationException $e) {
        } catch (ForeignKeyConstraintViolationException $e) {
            $this->getLoggerService()->error($e->getMessage());
            throw new OscarException("Impossible de supprimer $person, elle est utilisée.");
        }
        catch (\Exception $e) {
        } catch (\Exception $e) {
            throw new OscarException("PAS POSSIBLE : " . $e->getMessage());
        }
    }

    public function accessAction(){


    public function accessAction()
    {
        $this->getOscarUserContextService()->check(Privileges::DROIT_PRIVILEGE_VISUALISATION);

        $person = $this->getPersonService()->getPerson($this->params()->fromRoute('id'));

        $privilegesDT = $this->getEntityManager()->getRepository(Privilege::class)->findBy([], ['root' => 'DESC']);

        $privileges = [];
@@ -176,7 +174,8 @@ class PersonController extends AbstractOscarController implements UsePersonServi
                $rolesApplication[] = $role->getId();
            }

        } catch (\Exception $e ){}
        } catch (\Exception $e) {
        }

        $rolesOrganisation = [];

@@ -206,7 +205,8 @@ class PersonController extends AbstractOscarController implements UsePersonServi
        ];
    }

    public function personnelAction(){
    public function personnelAction()
    {

        $access = $this->getOscarConfigurationService()->getConfiguration('listPersonnel');

@@ -233,8 +233,6 @@ class PersonController extends AbstractOscarController implements UsePersonServi
        }




        if (!$this->getOscarUserContextService()->hasPrivileges(Privileges::PERSON_INDEX)) {
            $params['ids'] = array_merge($idCoWorkers, $idSubordinates, $idTimesheet);
        }
@@ -260,8 +258,6 @@ class PersonController extends AbstractOscarController implements UsePersonServi
            'subordinates' => [],
        ];



        /** @var Person $person */
        foreach ($datas as $person) {
            $datasPerson = $person->toArrayList();
@@ -288,30 +284,6 @@ class PersonController extends AbstractOscarController implements UsePersonServi
        return ['result' => $output];
    }
    
    public function grantAction()
    {
        $this->getOscarUserContextService()->check(Privileges::DROIT_PRIVILEGE_VISUALISATION);
        $person = $this->getPersonService()->getPerson($this->params()->fromRoute('id'));

        $organizations = [];

        /** @var OrganizationPerson $personOrganization */
        foreach( $person->getOrganizations() as $personOrganization ){
            $organizations[$personOrganization->getOrganization()->getId()] = [
                'rôles' => $this->getOscarUserContextService()->getRolesPersonInOrganization($person, $personOrganization->getOrganization()),
                'privileges' => $this->getOscarUserContextService()->getPersonPrivilegesInOrganization($person, $personOrganization->getOrganization())
            ];

        }

        var_dump($organizations);

        //$userCOntext = $this->$this->getOscarUserContextService()->getPri
        return [
            'person' => $person
        ];
    }

    public function viewsAction()
    {
        $view = $this->params()->fromQuery('view', 'almoststart');
@@ -331,7 +303,8 @@ class PersonController extends AbstractOscarController implements UsePersonServi
        ];
    }

    public function notificationPersonAction(){
    public function notificationPersonAction()
    {
        $id = $this->params()->fromRoute('id');
        $person = $this->getPersonService()->getPerson($id);
        return [
@@ -340,7 +313,8 @@ class PersonController extends AbstractOscarController implements UsePersonServi
        ];
    }

    public function notificationPersonGenerateAction(){
    public function notificationPersonGenerateAction()
    {
        $id = $this->params()->fromRoute('id');
        $person = $this->getPersonService()->getPerson($id);
        $this->getNotificationService()->generateNotificationsPerson($person);
@@ -348,7 +322,6 @@ class PersonController extends AbstractOscarController implements UsePersonServi
    }



    /**
     * Affiche la liste des personnes.
     *
@@ -585,7 +558,8 @@ class PersonController extends AbstractOscarController implements UsePersonServi

    private $_cacheGetOrgaByCode = [];

    private function extractArrayKeyValue( $array, $key ){
    private function extractArrayKeyValue($array, $key)
    {
        if (array_key_exists($key, $array)) {
            return $array[$key];
        } else {
@@ -599,8 +573,7 @@ class PersonController extends AbstractOscarController implements UsePersonServi
        $persons = $this->getEntityManager()->getRepository(Person::class)->createQueryBuilder('p')
            ->innerJoin('p.organizations', 'o')
            ->innerJoin('o.roleObj', 'r')
            ->where('r.principal = true')
            ;
            ->where('r.principal = true');

        $dbroles = $this->getPersonService()->getRolesByAuthentification();

@@ -629,7 +602,8 @@ class PersonController extends AbstractOscarController implements UsePersonServi
     * @return array|Response|JsonModel
     * @throws OscarException
     */
    public function declarersAction(){
    public function declarersAction()
    {

        $format = $this->params()->fromQuery('f', null);
        $period = $this->params()->fromQuery('period', date('Y-m'));
@@ -642,8 +616,7 @@ class PersonController extends AbstractOscarController implements UsePersonServi
                    if ($declarerId) {
                        // Détails pour le déclarant
                        return $this->getResponseNotImplemented("Fonctionnalité à venir");
                    }
                    else {
                    } else {
                        $output = $this->baseJsonResponse();
                        $period = DateTimeUtils::extractPeriodDatasFromString($this->params()->fromQuery('period', date('Y-m')));
                        $output['period'] = $period;
@@ -751,12 +724,10 @@ class PersonController extends AbstractOscarController implements UsePersonServi
                                $person->setCustomSettingsObj($custom);
                                $this->getEntityManager()->flush($person);
                                $this->getLoggerService()->info(print_r($custom, true));
                            }
                            elseif ($daysLength != null) {
                            } elseif ($daysLength != null) {
                                $this->getUserParametersService()->performChangeSchedule($daysLength, $person);
                                return $this->getResponseOk("Heures enregistrées");
                            }
                            else {
                            } else {
                                if (!array_key_exists($model, $models)) {
                                    return $this->getResponseBadRequest("Modèle inconnu");
                                }
@@ -801,7 +772,6 @@ class PersonController extends AbstractOscarController implements UsePersonServi
        }



        if ($method == "POST") {
            $action = $this->params()->fromPost('action', null);
            if (in_array($action, ['addusurpation', 'removeusurpation'])) {
@@ -863,8 +833,7 @@ class PersonController extends AbstractOscarController implements UsePersonServi
                        $this->getPersonService()->refererentReplaceBy($newReferent, $referent);
                        return $this->redirect()->toRoute('person/show', ['id' => $newReferent->getId()]);

                    }
                    else {
                    } else {
                        $this->getPersonService()->refererentAddFromReferent($newReferent, $referent);
                        return $this->redirect()->toRoute('person/show', ['id' => $newReferent->getId()]);
                    }