src/Security/NoteVoter.php line 61

Open in your IDE?
  1. <?php
  2. //------------------------------------------------------------------------------
  3. // src/Security/NoteVoter.php
  4. //------------------------------------------------------------------------------
  5. namespace App\Security;
  6. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  7. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  8. use Doctrine\Persistence\ManagerRegistry;
  9. use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
  10. use App\Entity\Access;
  11. use App\Entity\Client\Client;
  12. use App\Entity\Config\Config;
  13. use App\Entity\Config\Module;
  14. use App\Entity\HR\AccessFunction;
  15. use App\Entity\Mission\Mission;
  16. use App\Entity\Platform\Note;
  17. use App\Entity\Security\Acl;
  18. use App\Entity\Security\AclPermission;
  19. use App\Services\AccessClient\AccessClientTools;
  20. use App\Services\Config\ModuleTools;
  21. class NoteVoter extends Voter
  22. {
  23.     const ADD "add_note";
  24.     const ADD_CLIENT_VISIBLE "add_note_client_visible";
  25.     const EDIT "edit_note";
  26.     const HIDE "hide_note";
  27.     const DELETE "delete_note";
  28.     const IS_GRANTED_CONSTANTS = array(
  29.         self::ADD,
  30.         self::ADD_CLIENT_VISIBLE,
  31.         self::EDIT,
  32.         self::HIDE,
  33.         self::DELETE,
  34.     );
  35.     //--------------------------------------------------------------------------------
  36.     // acl constants
  37.     const ACL_PERM_ADD "note_add";
  38.     const ACL_PERM_ADD_SOCIETY "note_add_society";
  39.     const ACL_PERM_ADD_MANAGER "note_add_manager";
  40.     const ACL_PERM_EDIT "note_edit";
  41.     const ACL_PERM_EDIT_SOCIETY "note_edit_society";
  42.     const ACL_PERM_EDIT_MANAGER "note_edit_manager";
  43.     const ACL_PERM_HIDE "note_hide";
  44.     const ACL_PERM_HIDE_SOCIETY "note_hide_society";
  45.     const ACL_PERM_HIDE_MANAGER "note_hide_manager";
  46.     const ACL_PERM_DELETE "note_delete";
  47.     const ACL_PERM_DELETE_SOCIETY "note_delete_society";
  48.     const ACL_PERM_DELETE_MANAGER "note_delete_manager";
  49.     public function __construct(AccessDecisionManagerInterface $accessDecisionManagerManagerRegistry $doctrineAccessClientTools $accessClientToolsModuleTools $moduleTools)
  50.     {
  51.         $this->accessDecisionManager $accessDecisionManager;
  52.         $this->em $doctrine->getManager();
  53.         $this->accessClientTools $accessClientTools;
  54.         $this->moduleTools $moduleTools;
  55.         $this->aclRepository $this->em->getRepository(Acl::class);
  56.         $this->aclPermissionRepository $this->em->getRepository(AclPermission::class);
  57.     }
  58.     // Plan.io Task #4453 [See AccessVoter for details]
  59.     public function supportsAttribute(string $attribute): bool
  60.     {
  61.         return in_array($attributeself::IS_GRANTED_CONSTANTStrue);
  62.     }
  63.     
  64.     protected function supports(string $attribute$subject): bool
  65.     {
  66.         // if the attribute isn't one we support, return false
  67.         if (!in_array($attributeself::IS_GRANTED_CONSTANTS))
  68.         {
  69.             return false;
  70.         }
  71.         // Only vote on Note objects or Client objects inside this voter
  72.         if ($subject !== null && !($subject instanceof Note || $subject instanceof Client || $subject instanceof Mission))
  73.         {
  74.             return false;
  75.         }
  76.         return true;
  77.     }
  78.     protected function voteOnAttribute(string $attribute$subjectTokenInterface $token): bool
  79.     {
  80.         $user $token->getUser();
  81.         if (!$user instanceof Access)
  82.         {
  83.             // the user must be logged in; if not, deny access
  84.             return false;
  85.         }
  86.         // The user must have a function; if not deny access
  87.         $function $user->getFunction();
  88.         if ($function === null)        return false;
  89.         // Plan.io Task #3710 : Get current group
  90.         $currentGroup $user->getSocietyGroup();
  91.         if ($currentGroup === null)
  92.             return false;
  93.         // For this voter, the subject cannot be null
  94.         if ($subject === null)
  95.             return false;
  96.         // Check current group affectation
  97.         // This also includes mission sharing
  98.         //        mission.society.group = currentGroup
  99.         //        OR
  100.         //        mission.getSocietyGroupOwner = currentGroup
  101.         $societyGroupOwner null;
  102.         if ($subject !== null)
  103.         {
  104.             $subjectGroup null;
  105.             if ($subject instanceof Note)
  106.             {
  107.                 $subjectGroup $subject->getSocietyGroup();
  108.                 // Try to fecth the societyGroupOwner from the mission
  109.                 if ($subject->getMission() !== null)
  110.                 {
  111.                     $societyGroupOwner $subject->getMission()->getSocietyGroupOwner();
  112.                 }
  113.             }
  114.             else
  115.             {
  116.                 if ($subject instanceof Mission)
  117.                 {
  118.                     $client $subject->getReceiver();
  119.                     if ($client === null)
  120.                         return false;
  121.                     $subjectGroup $client->getSocietyGroup();
  122.                     // Try to fecth the societyGroupOwner from the mission
  123.                     $societyGroupOwner $subject->getSocietyGroupOwner();
  124.                 }
  125.                 else
  126.                 {
  127.                     $client $subject;
  128.                     if ($client === null)
  129.                         return false;
  130.                     $subjectGroup $client->getSocietyGroup();
  131.                     // Try to fetch the societyGroupOwner from the client
  132.                     $societyGroupOwner null;
  133.                 }
  134.             }
  135.             if ($subjectGroup === null)
  136.             {
  137.                 return false;
  138.             }
  139.             if ($subjectGroup === null)
  140.                 return false;
  141.             // Checking ...
  142.             if ($societyGroupOwner !== null)
  143.             {
  144.                 if (!$currentGroup->equals($subjectGroup) && !$currentGroup->equals($societyGroupOwner))
  145.                 {
  146.                     return false;
  147.                 }
  148.             }
  149.             else
  150.             {
  151.                 if (!$currentGroup->equals($subjectGroup))
  152.                 {
  153.                     return false;
  154.                 }
  155.             }
  156.         }
  157.         switch ($attribute)
  158.         {
  159.             case self::ADD:
  160.             {
  161.                 // $subject should be instanceof Client or Mission
  162.                 return $this->canAdd($subject$user$function);
  163.             }
  164.             case self::ADD_CLIENT_VISIBLE:
  165.             {
  166.                 // $subject should be instanceof Mission
  167.                 if ($subject instanceof Mission)
  168.                 {
  169.                     return $this->canAddClientVisible($subject$user$function);
  170.                 }
  171.                 else
  172.                 {
  173.                     return false;
  174.                 }
  175.             }
  176.             case self::EDIT:
  177.             {
  178.                 // $subject should be instanceof Note
  179.                 $note $subject;
  180.                 return $this->canEdit($note$user$function);
  181.             }
  182.             case self::HIDE:
  183.             {
  184.                 // $subject should be instanceof Note
  185.                 $note $subject;
  186.                 return $this->canHide($note$user$function);
  187.             }
  188.             case self::DELETE:
  189.             {
  190.                 // $subject should be instanceof Note
  191.                 $note $subject;
  192.                 return $this->canDelete($note$user$function$token);
  193.             }
  194.         }
  195.         throw new \LogicException('This code should not be reached!');
  196.     }
  197.     // $access is the user trying to load the resource
  198.     // $client is the resource being loaded
  199.     // Check if the Society of the resource
  200.     // belongs to the societies of the $access
  201.     private function checkSociety(Client $clientAccess $access)
  202.     {
  203.         if ($client === null)
  204.             return false;
  205.         $individual $client->getIndividual();
  206.         if ($individual === null)
  207.             return false;
  208.         $clientSociety $individual->getSociety();
  209.         if ($clientSociety === null)
  210.             return false;
  211.         // Get all the societies of the access
  212.         $societies $access->getSocieties();
  213.         foreach ($societies as $society)
  214.         {
  215.             if ($society->equals($clientSociety))
  216.             {
  217.                 return true;
  218.             }
  219.         }
  220.         return false;
  221.     }
  222.     // $access is the user trying to load the resource
  223.     // $client is the resource being loaded
  224.     // Check if the Society of the resource
  225.     // belongs to the societies of the $access
  226.     private function checkManager(Client $clientAccess $access)
  227.     {
  228.         if ($client === null)
  229.             return false;
  230.         $individual $client->getIndividual();
  231.         if ($individual === null)
  232.             return false;
  233.         $clientManager $individual->getManager();
  234.         if ($clientManager === null)
  235.             return false;
  236.         if ($clientManager->equals($access))
  237.             return true;
  238.         return false;
  239.     }
  240.     private function canAdd($subjectAccess $accessAccessFunction $function)
  241.     {
  242.         if ($subject instanceof Mission)
  243.         {
  244.             // Deny edit on archivedRefused objects
  245.             if ($subject->isArchivedRefused())
  246.             {
  247.                 return false;
  248.             }
  249.         }
  250.         // Three AclPermission may exist
  251.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_ADD);
  252.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_ADD_SOCIETY);
  253.         $aclPermManager $this->aclPermissionRepository->findOneByName(self::ACL_PERM_ADD_MANAGER);
  254.         // If all are null, exit
  255.         if ($aclPerm === null && $aclPermSociety === null && $aclPermManager === null)
  256.             return false;
  257.         // Get First one
  258.         if ($aclPerm !== null)
  259.         {
  260.             $acl $this->aclRepository->findOneBy(array(
  261.                 'function'        =>    $function,
  262.                 'permission'    =>    $aclPerm
  263.             ));
  264.             if ($acl !== null)
  265.             {
  266.                 if ($acl->getValue())
  267.                 {
  268.                     // A single positive answer is enough
  269.                     return true;
  270.                 }
  271.             }
  272.         }
  273.         if ($subject instanceof Mission)
  274.             $client $subject->getReceiver();
  275.         else
  276.             if ($subject instanceof Client)
  277.                 $client $subject;
  278.             else
  279.                 return false;
  280.         // If we are here it means that nothing good has been found
  281.         // Load second permission
  282.         if ($aclPermSociety !== null)
  283.         {
  284.             $acl $this->aclRepository->findOneBy(array(
  285.                 'function'        =>    $function,
  286.                 'permission'    =>    $aclPermSociety
  287.             ));
  288.             if ($acl !== null)
  289.             {
  290.                 if ($acl->getValue())
  291.                 {
  292.                     // A single positive answer is enough
  293.                     // In this case the good answer will be provided by the checkSociety
  294.                     return $this->checkSociety($client$access);
  295.                 }
  296.             }
  297.         }
  298.         // If we are here it means that nothing good has been found
  299.         // Load third permission
  300.         if ($aclPermManager !== null)
  301.         {
  302.             $acl $this->aclRepository->findOneBy(array(
  303.                 'function'        =>    $function,
  304.                 'permission'    =>    $aclPermManager
  305.             ));
  306.             if ($acl !== null)
  307.             {
  308.                 if ($acl->getValue())
  309.                 {
  310.                     // A single positive answer is enough
  311.                     // In this case the good answer will be provided by the checkManager
  312.                     return $this->checkManager($client$access);
  313.                 }
  314.             }
  315.         }
  316.         // If we are here, all hope is lost
  317.         return false;
  318.     }
  319.     private function canAddClientVisible(Mission $missionAccess $accessAccessFunction $function)
  320.     {
  321.         // Deny edit on archivedRefused objects
  322.         if ($mission->isArchivedRefused())
  323.         {
  324.             return false;
  325.         }
  326.         $receiver $mission->getReceiver();
  327.         if ($receiver === null)
  328.         {
  329.             // This should not happen
  330.             return false;
  331.         }
  332.         // Deny if mission.receiver has not activated its account
  333.         // Plan.io Task #4327 : Add Client Account, and remove JCAF
  334.         // Does the Receiver have an AccessClientRecord ?
  335.         $accessClientIsActive $this->accessClientTools->accessClientIsActiveForClient($receiver);
  336.         if (!$accessClientIsActive)
  337.         {
  338.             return false;
  339.         }
  340.         // Three AclPermission may exist
  341.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_ADD);
  342.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_ADD_SOCIETY);
  343.         $aclPermManager $this->aclPermissionRepository->findOneByName(self::ACL_PERM_ADD_MANAGER);
  344.         // If all are null, exit
  345.         if ($aclPerm === null && $aclPermSociety === null && $aclPermManager === null)
  346.             return false;
  347.         // Get First one
  348.         if ($aclPerm !== null)
  349.         {
  350.             $acl $this->aclRepository->findOneBy(array(
  351.                 'function'        =>    $function,
  352.                 'permission'    =>    $aclPerm
  353.             ));
  354.             if ($acl !== null)
  355.             {
  356.                 if ($acl->getValue())
  357.                 {
  358.                     // A single positive answer is enough
  359.                     return true;
  360.                 }
  361.             }
  362.         }
  363.         $client $mission->getReceiver();
  364.         // If we are here it means that nothing good has been found
  365.         // Load second permission
  366.         if ($aclPermSociety !== null)
  367.         {
  368.             $acl $this->aclRepository->findOneBy(array(
  369.                 'function'        =>    $function,
  370.                 'permission'    =>    $aclPermSociety
  371.             ));
  372.             if ($acl !== null)
  373.             {
  374.                 if ($acl->getValue())
  375.                 {
  376.                     // A single positive answer is enough
  377.                     // In this case the good answer will be provided by the checkSociety
  378.                     return $this->checkSociety($client$access);
  379.                 }
  380.             }
  381.         }
  382.         // If we are here it means that nothing good has been found
  383.         // Load third permission
  384.         if ($aclPermManager !== null)
  385.         {
  386.             $acl $this->aclRepository->findOneBy(array(
  387.                 'function'        =>    $function,
  388.                 'permission'    =>    $aclPermManager
  389.             ));
  390.             if ($acl !== null)
  391.             {
  392.                 if ($acl->getValue())
  393.                 {
  394.                     // A single positive answer is enough
  395.                     // In this case the good answer will be provided by the checkManager
  396.                     return $this->checkManager($client$access);
  397.                 }
  398.             }
  399.         }
  400.         // If we are here, all hope is lost
  401.         return false;
  402.     }
  403.     private function canEdit(Note $noteAccess $accessAccessFunction $function)
  404.     {
  405.         // Deny edit on archivedRefused objects
  406.         if ($note->isArchivedRefused())
  407.         {
  408.             return false;
  409.         }
  410.         if ($note->isReadonly())
  411.         {
  412.             return false;
  413.         }
  414.         // Plan.io Task #4071 : Deny parent mission actions on child item
  415.         if ($note->getMission() !== null && $note->getMission()->getParent() !== null)
  416.         {
  417.             if ($note->belongsToChildOf($note->getMission()->getParent()))
  418.             {
  419.                 return false;
  420.             }
  421.         }
  422.         // Deny edit on notes that have been successfully sent to Jcaf
  423.         if (!empty($note->getRemoteJcafId()))
  424.         {
  425.             return false;
  426.         }
  427.         // Deny edit on notes that have been successfully sent to Rekto
  428.         if (!empty($note->getRemoteRektoId()))
  429.         {
  430.             return false;
  431.         }
  432.         // Allways allow authors to edit their own notes
  433.         if ($note->getAuthor() !== null && $note->getAuthor()->equals($access))
  434.             return true;
  435.         $client $note->getClient();
  436.         if ($client === null)
  437.         {
  438.             $mission $note->getMission();
  439.             if ($mission === null)
  440.                 return false;
  441.             $client $mission->getReceiver();
  442.             if ($client === null)
  443.                 return null;
  444.         }
  445.         // Three AclPermission may exist
  446.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_EDIT);
  447.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_EDIT_SOCIETY);
  448.         $aclPermManager $this->aclPermissionRepository->findOneByName(self::ACL_PERM_EDIT_MANAGER);
  449.         // If all are null, exit
  450.         if ($aclPerm === null && $aclPermSociety === null && $aclPermManager === null)
  451.             return false;
  452.         // Get First one
  453.         if ($aclPerm !== null)
  454.         {
  455.             $acl $this->aclRepository->findOneBy(array(
  456.                 'function'        =>    $function,
  457.                 'permission'    =>    $aclPerm
  458.             ));
  459.             if ($acl !== null)
  460.             {
  461.                 if ($acl->getValue())
  462.                 {
  463.                     // A single positive answer is enough
  464.                     return true;
  465.                 }
  466.             }
  467.         }
  468.         // If we are here it means that nothing good has been found
  469.         // Load second permission
  470.         if ($aclPermSociety !== null)
  471.         {
  472.             $acl $this->aclRepository->findOneBy(array(
  473.                 'function'        =>    $function,
  474.                 'permission'    =>    $aclPermSociety
  475.             ));
  476.             if ($acl !== null)
  477.             {
  478.                 if ($acl->getValue())
  479.                 {
  480.                     // A single positive answer is enough
  481.                     // In this case the good answer will be provided by the checkSociety
  482.                     return $this->checkSociety($client$access);
  483.                 }
  484.             }
  485.         }
  486.         // If we are here it means that nothing good has been found
  487.         // Load third permission
  488.         if ($aclPermManager !== null)
  489.         {
  490.             $acl $this->aclRepository->findOneBy(array(
  491.                 'function'        =>    $function,
  492.                 'permission'    =>    $aclPermManager
  493.             ));
  494.             if ($acl !== null)
  495.             {
  496.                 if ($acl->getValue())
  497.                 {
  498.                     // A single positive answer is enough
  499.                     // In this case the good answer will be provided by the checkManager
  500.                     return $this->checkManager($client$access);
  501.                 }
  502.             }
  503.         }
  504.         // If we are here, all hope is lost
  505.         return false;
  506.     }
  507.     private function canHide(Note $noteAccess $accessAccessFunction $function)
  508.     {
  509.         // Allways allow authors to edit their own notes
  510.         if ($note->getAuthor() !== null && $note->getAuthor()->equals($access))
  511.             return true;
  512.         $client $note->getClient();
  513.         if ($client === null)
  514.         {
  515.             $mission $note->getMission();
  516.             if ($mission === null)
  517.                 return false;
  518.             $client $mission->getReceiver();
  519.             if ($client === null)
  520.                 return null;
  521.         }
  522.         // Three AclPermission may exist
  523.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HIDE);
  524.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HIDE_SOCIETY);
  525.         $aclPermManager $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HIDE_MANAGER);
  526.         // If all are null, exit
  527.         if ($aclPerm === null && $aclPermSociety === null && $aclPermManager === null)
  528.             return false;
  529.         // Get First one
  530.         if ($aclPerm !== null)
  531.         {
  532.             $acl $this->aclRepository->findOneBy(array(
  533.                 'function'        =>    $function,
  534.                 'permission'    =>    $aclPerm
  535.             ));
  536.             if ($acl !== null)
  537.             {
  538.                 if ($acl->getValue())
  539.                 {
  540.                     // A single positive answer is enough
  541.                     return true;
  542.                 }
  543.             }
  544.         }
  545.         // If we are here it means that nothing good has been found
  546.         // Load second permission
  547.         if ($aclPermSociety !== null)
  548.         {
  549.             $acl $this->aclRepository->findOneBy(array(
  550.                 'function'        =>    $function,
  551.                 'permission'    =>    $aclPermSociety
  552.             ));
  553.             if ($acl !== null)
  554.             {
  555.                 if ($acl->getValue())
  556.                 {
  557.                     // A single positive answer is enough
  558.                     // In this case the good answer will be provided by the checkSociety
  559.                     return $this->checkSociety($client$access);
  560.                 }
  561.             }
  562.         }
  563.         // If we are here it means that nothing good has been found
  564.         // Load third permission
  565.         if ($aclPermManager !== null)
  566.         {
  567.             $acl $this->aclRepository->findOneBy(array(
  568.                 'function'        =>    $function,
  569.                 'permission'    =>    $aclPermManager
  570.             ));
  571.             if ($acl !== null)
  572.             {
  573.                 if ($acl->getValue())
  574.                 {
  575.                     // A single positive answer is enough
  576.                     // In this case the good answer will be provided by the checkManager
  577.                     return $this->checkManager($client$access);
  578.                 }
  579.             }
  580.         }
  581.         // If we are here, all hope is lost
  582.         return false;
  583.     }
  584.     private function canDelete(Note $noteAccess $accessAccessFunction $function$token)
  585.     {
  586.         // Plan.io Task #4383, modified by #4453
  587.         // Temporarly allow admins to delete any Note
  588.         // if ($this->security->isGranted('rekapp_admin'))
  589.         if ($this->accessDecisionManager->decide($token, ['rekapp_admin']))
  590.         {
  591.             return true;
  592.         }
  593.         // Deny edit on archivedRefused objects
  594.         if ($note->isArchivedRefused())
  595.         {
  596.             return false;
  597.         }
  598.         if ($note->isReadonly())
  599.         {
  600.             return false;
  601.         }
  602.         // Plan.io Task #4071 : Deny parent mission actions on child item
  603.         if ($note->getMission() !== null && $note->getMission()->getParent() !== null)
  604.         {
  605.             if ($note->belongsToChildOf($note->getMission()->getParent()))
  606.             {
  607.                 return false;
  608.             }
  609.         }
  610.         // Deny delete on notes that have been successfully sent to Jcaf
  611.         if (!empty($note->getRemoteJcafId()))
  612.         {
  613.             return false;
  614.         }
  615.         // Deny delete on notes that have been successfully sent to Rekto
  616.         if (!empty($note->getRemoteRektoId()))
  617.         {
  618.             return false;
  619.         }
  620.         // Allways allow authors to edit their own notes
  621.         if ($note->getAuthor() !== null && $note->getAuthor()->equals($access))
  622.             return true;
  623.         $client $note->getClient();
  624.         if ($client === null)
  625.         {
  626.             $mission $note->getMission();
  627.             if ($mission === null)
  628.                 return false;
  629.             $client $mission->getReceiver();
  630.             if ($client === null)
  631.                 return null;
  632.         }
  633.         // Three AclPermission may exist
  634.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_DELETE);
  635.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_DELETE_SOCIETY);
  636.         $aclPermManager $this->aclPermissionRepository->findOneByName(self::ACL_PERM_DELETE_MANAGER);
  637.         // If all are null, exit
  638.         if ($aclPerm === null && $aclPermSociety === null && $aclPermManager === null)
  639.             return false;
  640.         // Get First one
  641.         if ($aclPerm !== null)
  642.         {
  643.             $acl $this->aclRepository->findOneBy(array(
  644.                 'function'        =>    $function,
  645.                 'permission'    =>    $aclPerm
  646.             ));
  647.             if ($acl !== null)
  648.             {
  649.                 if ($acl->getValue())
  650.                 {
  651.                     // A single positive answer is enough
  652.                     return true;
  653.                 }
  654.             }
  655.         }
  656.         // If we are here it means that nothing good has been found
  657.         // Load second permission
  658.         if ($aclPermSociety !== null)
  659.         {
  660.             $acl $this->aclRepository->findOneBy(array(
  661.                 'function'        =>    $function,
  662.                 'permission'    =>    $aclPermSociety
  663.             ));
  664.             if ($acl !== null)
  665.             {
  666.                 if ($acl->getValue())
  667.                 {
  668.                     // A single positive answer is enough
  669.                     // In this case the good answer will be provided by the checkSociety
  670.                     return $this->checkSociety($client$access);
  671.                 }
  672.             }
  673.         }
  674.         // If we are here it means that nothing good has been found
  675.         // Load third permission
  676.         if ($aclPermManager !== null)
  677.         {
  678.             $acl $this->aclRepository->findOneBy(array(
  679.                 'function'        =>    $function,
  680.                 'permission'    =>    $aclPermManager
  681.             ));
  682.             if ($acl !== null)
  683.             {
  684.                 if ($acl->getValue())
  685.                 {
  686.                     // A single positive answer is enough
  687.                     // In this case the good answer will be provided by the checkManager
  688.                     return $this->checkManager($client$access);
  689.                 }
  690.             }
  691.         }
  692.         // If we are here, all hope is lost
  693.         return false;
  694.     }
  695. }