src/Security/HRVarsVoter.php line 95

Open in your IDE?
  1. <?php
  2. //------------------------------------------------------------------------------
  3. // src/Security/HRVarsVoter.php
  4. //------------------------------------------------------------------------------
  5. namespace App\Security;
  6. use Doctrine\Persistence\ManagerRegistry;
  7. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  8. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  9. use App\Entity\Access;
  10. use App\Entity\Config\Module;
  11. use App\Entity\HR\AccessFunction;
  12. use App\Entity\HR\HumanResource;
  13. use App\Entity\Security\Acl;
  14. use App\Entity\Security\AclPermission;
  15. use App\Services\Config\ModuleTools;
  16. use App\Services\Config\OptionConfigTools;
  17. class HRVarsVoter extends Voter
  18. {
  19.     //--------------------------------------------------------------------------------
  20.     // is_granted constants
  21.     const IS_ACTIVE 'hr_vars_is_active';
  22.     const ADD_HR_VARIABLE                 'add_hr_variable';
  23.     const VIEW_HR_VARIABLE                 'view_hr_variable';
  24.     const EDIT_HR_VARIABLE                 'edit_hr_variable';
  25.     const EDIT_HR_VARIABLE_STATUS         'edit_hr_variable_status';
  26.     const DELETE_HR_VARIABLE             'delete_hr_variable';
  27.     const ADD_OP_VARIABLE                'add_op_variable';
  28.     const VIEW_OP_VARIABLE                'view_op_variable';
  29.     const EDIT_OP_VARIABLE                'edit_op_variable';
  30.     const EDIT_OP_VARIABLE_STATUS        'edit_op_variable_status';
  31.     const DELETE_OP_VARIABLE            'delete_op_variable';
  32.     const IS_GRANTED_CONSTANTS = array(
  33.         self::IS_ACTIVE,
  34.         self::ADD_HR_VARIABLE,
  35.         self::VIEW_HR_VARIABLE,
  36.         self::EDIT_HR_VARIABLE,
  37.         self::EDIT_HR_VARIABLE_STATUS,
  38.         self::DELETE_HR_VARIABLE,
  39.         self::ADD_OP_VARIABLE,
  40.         self::VIEW_OP_VARIABLE,
  41.         self::EDIT_OP_VARIABLE,
  42.         self::EDIT_OP_VARIABLE_STATUS,
  43.         self::DELETE_OP_VARIABLE,
  44.     );
  45.     //--------------------------------------------------------------------------------
  46.     //--------------------------------------------------------------------------------
  47.     // acl constants
  48.     // HRVariable
  49.     const ACL_PERM_HR_VARIABLE_ADD 'hr_variable_add';
  50.     const ACL_PERM_HR_VARIABLE_ADD_SOCIETY 'hr_variable_add_society';
  51.     const ACL_PERM_HR_VARIABLE_VIEW    'hr_variable_view';
  52.     const ACL_PERM_HR_VARIABLE_VIEW_SOCIETY    'hr_variable_view_society';
  53.     const ACL_PERM_HR_VARIABLE_EDIT    'hr_variable_edit';
  54.     const ACL_PERM_HR_VARIABLE_EDIT_SOCIETY    'hr_variable_edit_society';
  55.     const ACL_PERM_HR_VARIABLE_EDIT_STATUS 'hr_variable_edit_status';
  56.     const ACL_PERM_HR_VARIABLE_EDIT_STATUS_SOCIETY 'hr_variable_edit_status_society';
  57.     const ACL_PERM_HR_VARIABLE_DELETE 'hr_variable_delete';
  58.     const ACL_PERM_HR_VARIABLE_DELETE_SOCIETY 'hr_variable_delete_society';
  59.     // OPVariable
  60.     const ACL_PERM_OP_VARIABLE_ADD 'op_variable_add';
  61.     const ACL_PERM_OP_VARIABLE_ADD_SOCIETY 'op_variable_add_society';
  62.     const ACL_PERM_OP_VARIABLE_VIEW    'op_variable_view';
  63.     const ACL_PERM_OP_VARIABLE_VIEW_SOCIETY    'op_variable_view_society';
  64.     const ACL_PERM_OP_VARIABLE_EDIT    'op_variable_edit';
  65.     const ACL_PERM_OP_VARIABLE_EDIT_SOCIETY    'op_variable_edit_society';
  66.     const ACL_PERM_OP_VARIABLE_EDIT_STATUS 'op_variable_edit_status';
  67.     const ACL_PERM_OP_VARIABLE_EDIT_STATUS_SOCIETY 'op_variable_edit_status_society';
  68.     const ACL_PERM_OP_VARIABLE_DELETE 'op_variable_delete';
  69.     const ACL_PERM_OP_VARIABLE_DELETE_SOCIETY 'op_variable_delete_society';
  70.     //--------------------------------------------------------------------------------
  71.     public function __construct(ManagerRegistry $doctrineModuleTools $moduleToolsOptionConfigTools $optionConfigTools)
  72.     {
  73.         $this->em $doctrine->getManager();
  74.         $this->moduleTools $moduleTools;
  75.         $this->optionConfigTools $optionConfigTools;
  76.         $this->aclRepository $this->em->getRepository(Acl::class);
  77.         $this->aclPermissionRepository $this->em->getRepository(AclPermission::class);
  78.     }
  79.     // Plan.io Task #4453 [See AccessVoter for details]
  80.     public function supportsAttribute(string $attribute): bool
  81.     {
  82.         return in_array($attributeself::IS_GRANTED_CONSTANTStrue);
  83.     }
  84.     
  85.     protected function supports(string $attribute$subject null): bool
  86.     {
  87.         // if the attribute isn't one we support, return false
  88.         if (!in_array($attributeself::IS_GRANTED_CONSTANTS))
  89.         {
  90.             return false;
  91.         }
  92.         if ($subject !== null && !($subject instanceof HumanResource))
  93.         {
  94.             return false;
  95.         }
  96.         return true;
  97.     }
  98.     protected function voteOnAttribute(string $attribute$subjectTokenInterface $token): bool
  99.     {
  100.         $user $token->getUser();
  101.         if (!$user instanceof Access)
  102.         {
  103.             // the user must be logged in; if not, deny access
  104.             return false;
  105.         }
  106.         // The user must have a function; if not deny access
  107.         $function $user->getFunction();
  108.         if ($function === null)    return false;
  109.         // Plan.io Task #3710 : Get current group
  110.         $currentGroup $user->getSocietyGroup();
  111.         if ($currentGroup === null)    return false;
  112.         $this->currentGroup $currentGroup;
  113.         // Module activated ?
  114.         if ($this->moduleTools->isInactiveByCode($currentGroupModule::MODULE_HUMAN_RESOURCE))
  115.         {
  116.             return false;
  117.         }
  118.         // Option activated
  119.         if (!$this->optionConfigTools->isActive_HRVars($currentGroup))
  120.         {
  121.             return false;
  122.         }
  123.         // Check current group affectation
  124.         if ($subject !== null)
  125.         {
  126.             $subjectSociety $subject->getSociety();
  127.             if ($subjectSociety === null)
  128.                 return false;
  129.             $subjectGroup $subjectSociety->getGroup();
  130.             if ($subjectGroup === null)
  131.                 return false;
  132.             if (!$currentGroup->equals($subjectGroup))
  133.                 return false;
  134.         }
  135.         /** @var HumanResource $humanResource */
  136.         $humanResource $subject;
  137.         if ($humanResource !== null && !$humanResource->hasHrVars())
  138.         {
  139.             return false;
  140.         }
  141.         switch ($attribute)
  142.         {
  143.             case self::IS_ACTIVE:
  144.                 return true;
  145.             case self::ADD_HR_VARIABLE:
  146.                 return $this->canAddHRVariable($humanResource$user$function);
  147.             case self::VIEW_HR_VARIABLE:
  148.                 return $this->canViewHRVariable($humanResource$user$function);
  149.             case self::EDIT_HR_VARIABLE:
  150.                 return $this->canEditHRVariable($humanResource$user$function);
  151.             case self::EDIT_HR_VARIABLE_STATUS:
  152.                 return $this->canEditStatusHRVariable($humanResource$user$function);
  153.             case self::DELETE_HR_VARIABLE:
  154.                 return $this->canDeleteHRVariable($humanResource$user$function);
  155.             case self::ADD_OP_VARIABLE:
  156.                 return $this->canAddOPVariable($humanResource$user$function);
  157.             case self::VIEW_OP_VARIABLE:
  158.                 return $this->canViewOPVariable($humanResource$user$function);
  159.             case self::EDIT_OP_VARIABLE:
  160.                 return $this->canEditOPVariable($humanResource$user$function);
  161.             case self::EDIT_OP_VARIABLE_STATUS:
  162.                 return $this->canEditStatusOPVariable($humanResource$user$function);
  163.             case self::DELETE_OP_VARIABLE:
  164.                 return $this->canDeleteOPVariable($humanResource$user$function);
  165.         }
  166.         throw new \LogicException('This code should not be reached!');
  167.     }
  168.     // Check if the Society of the resource
  169.     // belongs to the societies of the $access
  170.     private function checkSociety(HumanResource $humanResourceAccess $access)
  171.     {
  172.         // Get all the societies of the access
  173.         $societies $access->getSocieties();
  174.         // Get the Society of the HumanResource
  175.         $hrSociety $humanResource->getSociety();
  176.         if ($hrSociety === null)
  177.         {
  178.             return false;
  179.         }
  180.         $found false;
  181.         foreach ($societies as $society)
  182.         {
  183.             if ($society->getId() == $hrSociety->getId())
  184.             {
  185.                 $found true;
  186.                 break;
  187.             }
  188.         }
  189.         return $found;
  190.     }
  191.     private function canAddHRVariable(HumanResource $humanResourceAccess $userAccessFunction $function)
  192.     {
  193.         // Get AclPermission
  194.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HR_VARIABLE_ADD);
  195.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HR_VARIABLE_ADD_SOCIETY);
  196.         // If all are null, exit
  197.         if ($aclPerm === null && $aclPermSociety === null)
  198.         {
  199.             return false;
  200.         }
  201.         // Get First one
  202.         if ($aclPerm !== null)
  203.         {
  204.             $acl $this->aclRepository->findOneBy(array(
  205.                 'function'        =>    $function,
  206.                 'permission'    =>    $aclPerm
  207.             ));
  208.             if ($acl !== null)
  209.             {
  210.                 if ($acl->getValue())
  211.                 {
  212.                     // A single positive answer is enough
  213.                     return true;
  214.                 }
  215.             }
  216.         }
  217.         // If we are here it means that nothing good has been found
  218.         // Load second permission
  219.         if ($aclPermSociety !== null)
  220.         {
  221.             $acl $this->aclRepository->findOneBy(array(
  222.                 'function'        =>    $function,
  223.                 'permission'    =>    $aclPermSociety
  224.             ));
  225.             if ($acl !== null)
  226.             {
  227.                 if ($acl->getValue())
  228.                 {
  229.                     return $this->checkSociety($humanResource$user);
  230.                 }
  231.             }
  232.         }
  233.         // If we are here, all hope is lost
  234.         return false;
  235.     }
  236.     private function canViewHRVariable(HumanResource $humanResourceAccess $userAccessFunction $function)
  237.     {
  238.         // Get AclPermission
  239.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HR_VARIABLE_VIEW);
  240.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HR_VARIABLE_VIEW_SOCIETY);
  241.         // If all are null, exit
  242.         if ($aclPerm === null && $aclPermSociety === null)
  243.         {
  244.             return false;
  245.         }
  246.         // Get First one
  247.         if ($aclPerm !== null)
  248.         {
  249.             $acl $this->aclRepository->findOneBy(array(
  250.                 'function'        =>    $function,
  251.                 'permission'    =>    $aclPerm
  252.             ));
  253.             if ($acl !== null)
  254.             {
  255.                 if ($acl->getValue())
  256.                 {
  257.                     // A single positive answer is enough
  258.                     return true;
  259.                 }
  260.             }
  261.         }
  262.         // If we are here it means that nothing good has been found
  263.         // Load second permission
  264.         if ($aclPermSociety !== null)
  265.         {
  266.             $acl $this->aclRepository->findOneBy(array(
  267.                 'function'        =>    $function,
  268.                 'permission'    =>    $aclPermSociety
  269.             ));
  270.             if ($acl !== null)
  271.             {
  272.                 if ($acl->getValue())
  273.                 {
  274.                     return $this->checkSociety($humanResource$user);
  275.                 }
  276.             }
  277.         }
  278.         // If we are here, all hope is lost
  279.         return false;
  280.     }
  281.     private function canEditHRVariable(HumanResource $humanResourceAccess $userAccessFunction $function)
  282.     {
  283.         // Get AclPermission
  284.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HR_VARIABLE_EDIT);
  285.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HR_VARIABLE_EDIT_SOCIETY);
  286.         // If all are null, exit
  287.         if ($aclPerm === null && $aclPermSociety === null)
  288.         {
  289.             return false;
  290.         }
  291.         // Get First one
  292.         if ($aclPerm !== null)
  293.         {
  294.             $acl $this->aclRepository->findOneBy(array(
  295.                 'function'        =>    $function,
  296.                 'permission'    =>    $aclPerm
  297.             ));
  298.             if ($acl !== null)
  299.             {
  300.                 if ($acl->getValue())
  301.                 {
  302.                     // A single positive answer is enough
  303.                     return true;
  304.                 }
  305.             }
  306.         }
  307.         // If we are here it means that nothing good has been found
  308.         // Load second permission
  309.         if ($aclPermSociety !== null)
  310.         {
  311.             $acl $this->aclRepository->findOneBy(array(
  312.                 'function'        =>    $function,
  313.                 'permission'    =>    $aclPermSociety
  314.             ));
  315.             if ($acl !== null)
  316.             {
  317.                 if ($acl->getValue())
  318.                 {
  319.                     return $this->checkSociety($humanResource$user);
  320.                 }
  321.             }
  322.         }
  323.         // If we are here, all hope is lost
  324.         return false;
  325.     }
  326.     private function canEditStatusHRVariable(HumanResource $humanResourceAccess $userAccessFunction $function)
  327.     {
  328.         // Get AclPermission
  329.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HR_VARIABLE_EDIT_STATUS);
  330.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HR_VARIABLE_EDIT_STATUS_SOCIETY);
  331.         // If all are null, exit
  332.         if ($aclPerm === null && $aclPermSociety === null)
  333.         {
  334.             return false;
  335.         }
  336.         // Get First one
  337.         if ($aclPerm !== null)
  338.         {
  339.             $acl $this->aclRepository->findOneBy(array(
  340.                 'function'        =>    $function,
  341.                 'permission'    =>    $aclPerm
  342.             ));
  343.             if ($acl !== null)
  344.             {
  345.                 if ($acl->getValue())
  346.                 {
  347.                     // A single positive answer is enough
  348.                     return true;
  349.                 }
  350.             }
  351.         }
  352.         // If we are here it means that nothing good has been found
  353.         // Load second permission
  354.         if ($aclPermSociety !== null)
  355.         {
  356.             $acl $this->aclRepository->findOneBy(array(
  357.                 'function'        =>    $function,
  358.                 'permission'    =>    $aclPermSociety
  359.             ));
  360.             if ($acl !== null)
  361.             {
  362.                 if ($acl->getValue())
  363.                 {
  364.                     return $this->checkSociety($humanResource$user);
  365.                 }
  366.             }
  367.         }
  368.         // If we are here, all hope is lost
  369.         return false;
  370.     }
  371.     private function canDeleteHRVariable(HumanResource $humanResourceAccess $userAccessFunction $function)
  372.     {
  373.         // Get AclPermission
  374.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HR_VARIABLE_DELETE);
  375.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_HR_VARIABLE_DELETE_SOCIETY);
  376.         // If all are null, exit
  377.         if ($aclPerm === null && $aclPermSociety === null)
  378.         {
  379.             return false;
  380.         }
  381.         // Get First one
  382.         if ($aclPerm !== null)
  383.         {
  384.             $acl $this->aclRepository->findOneBy(array(
  385.                 'function'        =>    $function,
  386.                 'permission'    =>    $aclPerm
  387.             ));
  388.             if ($acl !== null)
  389.             {
  390.                 if ($acl->getValue())
  391.                 {
  392.                     // A single positive answer is enough
  393.                     return true;
  394.                 }
  395.             }
  396.         }
  397.         // If we are here it means that nothing good has been found
  398.         // Load second permission
  399.         if ($aclPermSociety !== null)
  400.         {
  401.             $acl $this->aclRepository->findOneBy(array(
  402.                 'function'        =>    $function,
  403.                 'permission'    =>    $aclPermSociety
  404.             ));
  405.             if ($acl !== null)
  406.             {
  407.                 if ($acl->getValue())
  408.                 {
  409.                     return $this->checkSociety($humanResource$user);
  410.                 }
  411.             }
  412.         }
  413.         // If we are here, all hope is lost
  414.         return false;
  415.     }
  416.     private function canAddOPVariable(HumanResource $humanResourceAccess $userAccessFunction $function)
  417.     {
  418.         // Get AclPermission
  419.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_OP_VARIABLE_ADD);
  420.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_OP_VARIABLE_ADD_SOCIETY);
  421.         // If all are null, exit
  422.         if ($aclPerm === null && $aclPermSociety === null)
  423.         {
  424.             return false;
  425.         }
  426.         // Get First one
  427.         if ($aclPerm !== null)
  428.         {
  429.             $acl $this->aclRepository->findOneBy(array(
  430.                 'function'        =>    $function,
  431.                 'permission'    =>    $aclPerm
  432.             ));
  433.             if ($acl !== null)
  434.             {
  435.                 if ($acl->getValue())
  436.                 {
  437.                     // A single positive answer is enough
  438.                     return true;
  439.                 }
  440.             }
  441.         }
  442.         // If we are here it means that nothing good has been found
  443.         // Load second permission
  444.         if ($aclPermSociety !== null)
  445.         {
  446.             $acl $this->aclRepository->findOneBy(array(
  447.                 'function'        =>    $function,
  448.                 'permission'    =>    $aclPermSociety
  449.             ));
  450.             if ($acl !== null)
  451.             {
  452.                 if ($acl->getValue())
  453.                 {
  454.                     return $this->checkSociety($humanResource$user);
  455.                 }
  456.             }
  457.         }
  458.         // If we are here, all hope is lost
  459.         return false;
  460.     }
  461.     private function canViewOPVariable(HumanResource $humanResourceAccess $userAccessFunction $function)
  462.     {
  463.         // Get AclPermission
  464.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_OP_VARIABLE_VIEW);
  465.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_OP_VARIABLE_VIEW_SOCIETY);
  466.         // If all are null, exit
  467.         if ($aclPerm === null && $aclPermSociety === null)
  468.         {
  469.             return false;
  470.         }
  471.         // Get First one
  472.         if ($aclPerm !== null)
  473.         {
  474.             $acl $this->aclRepository->findOneBy(array(
  475.                 'function'        =>    $function,
  476.                 'permission'    =>    $aclPerm
  477.             ));
  478.             if ($acl !== null)
  479.             {
  480.                 if ($acl->getValue())
  481.                 {
  482.                     // A single positive answer is enough
  483.                     return true;
  484.                 }
  485.             }
  486.         }
  487.         // If we are here it means that nothing good has been found
  488.         // Load second permission
  489.         if ($aclPermSociety !== null)
  490.         {
  491.             $acl $this->aclRepository->findOneBy(array(
  492.                 'function'        =>    $function,
  493.                 'permission'    =>    $aclPermSociety
  494.             ));
  495.             if ($acl !== null)
  496.             {
  497.                 if ($acl->getValue())
  498.                 {
  499.                     return $this->checkSociety($humanResource$user);
  500.                 }
  501.             }
  502.         }
  503.         // If we are here, all hope is lost
  504.         return false;
  505.     }
  506.     private function canEditOPVariable(HumanResource $humanResourceAccess $userAccessFunction $function)
  507.     {
  508.         // Get AclPermission
  509.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_OP_VARIABLE_EDIT);
  510.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_OP_VARIABLE_EDIT_SOCIETY);
  511.         // If all are null, exit
  512.         if ($aclPerm === null && $aclPermSociety === null)
  513.         {
  514.             return false;
  515.         }
  516.         // Get First one
  517.         if ($aclPerm !== null)
  518.         {
  519.             $acl $this->aclRepository->findOneBy(array(
  520.                 'function'        =>    $function,
  521.                 'permission'    =>    $aclPerm
  522.             ));
  523.             if ($acl !== null)
  524.             {
  525.                 if ($acl->getValue())
  526.                 {
  527.                     // A single positive answer is enough
  528.                     return true;
  529.                 }
  530.             }
  531.         }
  532.         // If we are here it means that nothing good has been found
  533.         // Load second permission
  534.         if ($aclPermSociety !== null)
  535.         {
  536.             $acl $this->aclRepository->findOneBy(array(
  537.                 'function'        =>    $function,
  538.                 'permission'    =>    $aclPermSociety
  539.             ));
  540.             if ($acl !== null)
  541.             {
  542.                 if ($acl->getValue())
  543.                 {
  544.                     return $this->checkSociety($humanResource$user);
  545.                 }
  546.             }
  547.         }
  548.         // If we are here, all hope is lost
  549.         return false;
  550.     }
  551.     private function canEditStatusOPVariable(HumanResource $humanResourceAccess $userAccessFunction $function)
  552.     {
  553.         // Get AclPermission
  554.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_OP_VARIABLE_EDIT_STATUS);
  555.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_OP_VARIABLE_EDIT_STATUS_SOCIETY);
  556.         // If all are null, exit
  557.         if ($aclPerm === null && $aclPermSociety === null)
  558.         {
  559.             return false;
  560.         }
  561.         // Get First one
  562.         if ($aclPerm !== null)
  563.         {
  564.             $acl $this->aclRepository->findOneBy(array(
  565.                 'function'        =>    $function,
  566.                 'permission'    =>    $aclPerm
  567.             ));
  568.             if ($acl !== null)
  569.             {
  570.                 if ($acl->getValue())
  571.                 {
  572.                     // A single positive answer is enough
  573.                     return true;
  574.                 }
  575.             }
  576.         }
  577.         // If we are here it means that nothing good has been found
  578.         // Load second permission
  579.         if ($aclPermSociety !== null)
  580.         {
  581.             $acl $this->aclRepository->findOneBy(array(
  582.                 'function'        =>    $function,
  583.                 'permission'    =>    $aclPermSociety
  584.             ));
  585.             if ($acl !== null)
  586.             {
  587.                 if ($acl->getValue())
  588.                 {
  589.                     return $this->checkSociety($humanResource$user);
  590.                 }
  591.             }
  592.         }
  593.         // If we are here, all hope is lost
  594.         return false;
  595.     }
  596.     private function canDeleteOPVariable(HumanResource $humanResourceAccess $userAccessFunction $function)
  597.     {
  598.         // Get AclPermission
  599.         $aclPerm $this->aclPermissionRepository->findOneByName(self::ACL_PERM_OP_VARIABLE_DELETE);
  600.         $aclPermSociety $this->aclPermissionRepository->findOneByName(self::ACL_PERM_OP_VARIABLE_DELETE_SOCIETY);
  601.         // If all are null, exit
  602.         if ($aclPerm === null && $aclPermSociety === null)
  603.         {
  604.             return false;
  605.         }
  606.         // Get First one
  607.         if ($aclPerm !== null)
  608.         {
  609.             $acl $this->aclRepository->findOneBy(array(
  610.                 'function'        =>    $function,
  611.                 'permission'    =>    $aclPerm
  612.             ));
  613.             if ($acl !== null)
  614.             {
  615.                 if ($acl->getValue())
  616.                 {
  617.                     // A single positive answer is enough
  618.                     return true;
  619.                 }
  620.             }
  621.         }
  622.         // If we are here it means that nothing good has been found
  623.         // Load second permission
  624.         if ($aclPermSociety !== null)
  625.         {
  626.             $acl $this->aclRepository->findOneBy(array(
  627.                 'function'        =>    $function,
  628.                 'permission'    =>    $aclPermSociety
  629.             ));
  630.             if ($acl !== null)
  631.             {
  632.                 if ($acl->getValue())
  633.                 {
  634.                     return $this->checkSociety($humanResource$user);
  635.                 }
  636.             }
  637.         }
  638.         // If we are here, all hope is lost
  639.         return false;
  640.     }
  641. }