src/Security/ExportVoter.php line 196

Open in your IDE?
  1. <?php
  2. //------------------------------------------------------------------------------
  3. // src/Security/ExportVoter.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\Config;
  11. use App\Entity\Config\Module;
  12. use App\Entity\HR\AccessFunction;
  13. use App\Entity\Security\Acl;
  14. use App\Entity\Security\AclPermission;
  15. use App\Services\Config\ModuleTools;
  16. class ExportVoter extends Voter
  17. {
  18.     //--------------------------------------------------------------------------------
  19.     // is_granted constants
  20.     const IS_ACTIVE "export_is_active";
  21.     const EXPORT_ANY "export_data";
  22.     const EXPORT_INVOICE "export_invoices";
  23.     const EXPORT_INVOICE_SOCIETY "export_invoices_society";
  24.     const EXPORT_INVOICE_ANY "export_invoices_any";
  25.     const EXPORT_DEVIS "export_devis";
  26.     const EXPORT_DEVIS_SOCIETY "export_devis_society";
  27.     const EXPORT_DEVIS_ANY "export_devis_any";
  28.     const EXPORT_COMMAND "export_commands";
  29.     const EXPORT_COMMAND_SOCIETY "export_commands_society";
  30.     const EXPORT_COMMAND_ANY "export_commands_any";
  31.     const EXPORT_TASK "export_tasks";
  32.     const EXPORT_TASK_SOCIETY "export_tasks_society";
  33.     const EXPORT_TASK_ANY "export_tasks_any";
  34.     const EXPORT_MISSION "export_missions";
  35.     const EXPORT_MISSION_SOCIETY "export_missions_society";
  36.     const EXPORT_MISSION_ANY "export_missions_any";
  37.     const EXPORT_IND "export_individuals";
  38.     const EXPORT_IND_SOCIETY "export_individuals_society";
  39.     const EXPORT_IND_ANY "export_individuals_any";
  40.     const EXPORT_RFI "export_rfi";
  41.     const EXPORT_RFI_SOCIETY "export_rfi_society";
  42.     const EXPORT_RFI_ANY "export_rfi_any";
  43.     const EXPORT_ANOMALY "export_anomaly";
  44.     const EXPORT_ANOMALY_SOCIETY "export_anomaly_society";
  45.     const EXPORT_ANOMALY_ANY "export_anomaly_any";
  46.     const EXPORT_INSTALLMENT "export_installment";
  47.     const EXPORT_INSTALLMENT_SOCIETY "export_installment_society";
  48.     const EXPORT_INSTALLMENT_ANY "export_installment_any";
  49.     const EXPORT_EQUIPMENT "export_equipment";
  50.     const EXPORT_EQUIPMENT_SOCIETY "export_equipment_society";
  51.     const EXPORT_EQUIPMENT_ANY "export_equipment_any";
  52.     // Plan.io Tasks #3621 #3653
  53.     const EXPORT_IKEA_SERVICE_ORDER "export_ikea_service_orders";
  54.     const EXPORT_IKEA_SERVICE_ORDER_SOCIETY "export_ikea_service_orders_society";
  55.     const EXPORT_IKEA_SERVICE_ORDER_ANY "export_ikea_service_orders_any";
  56.     const EXPORT_SALARY "export_salary";
  57.     const EXPORT_SALARY_SOCIETY "export_salary_society";
  58.     const EXPORT_SALARY_ANY "export_salary_any";
  59.     const EXPORT_DEMAND "export_demand";
  60.     const EXPORT_DEMAND_SOCIETY "export_demand_society";
  61.     const EXPORT_DEMAND_ANY "export_demand_any";
  62.     // Task plan.io #3889 : No right for society
  63.     const EXPORT_ITASK "export_itask";
  64.     const EXPORT_ITASK_ANY "export_itask_any";
  65.     // Task plan.io #4426
  66.     const EXPORT_COST "export_cost";
  67.     const EXPORT_COST_SOCIETY "export_cost_society";
  68.     const EXPORT_COST_ANY "export_cost_any";
  69.     const IS_GRANTED_CONSTANTS = array(
  70.         self::IS_ACTIVE,
  71.         self::EXPORT_ANY,
  72.         self::EXPORT_INVOICE,
  73.         self::EXPORT_INVOICE_SOCIETY,
  74.         self::EXPORT_INVOICE_ANY,
  75.         self::EXPORT_DEVIS,
  76.         self::EXPORT_DEVIS_SOCIETY,
  77.         self::EXPORT_DEVIS_ANY,
  78.         self::EXPORT_COMMAND,
  79.         self::EXPORT_COMMAND_SOCIETY,
  80.         self::EXPORT_COMMAND_ANY,
  81.         self::EXPORT_TASK,
  82.         self::EXPORT_TASK_SOCIETY,
  83.         self::EXPORT_TASK_ANY,
  84.         self::EXPORT_MISSION,
  85.         self::EXPORT_MISSION_SOCIETY,
  86.         self::EXPORT_MISSION_ANY,
  87.         self::EXPORT_IND,
  88.         self::EXPORT_IND_SOCIETY,
  89.         self::EXPORT_IND_ANY,
  90.         self::EXPORT_RFI,
  91.         self::EXPORT_RFI_SOCIETY,
  92.         self::EXPORT_RFI_ANY,
  93.         self::EXPORT_ANOMALY,
  94.         self::EXPORT_ANOMALY_SOCIETY,
  95.         self::EXPORT_ANOMALY_ANY,
  96.         self::EXPORT_INSTALLMENT,
  97.         self::EXPORT_INSTALLMENT_SOCIETY,
  98.         self::EXPORT_INSTALLMENT_ANY,
  99.         self::EXPORT_EQUIPMENT,
  100.         self::EXPORT_EQUIPMENT_SOCIETY,
  101.         self::EXPORT_EQUIPMENT_ANY,
  102.         // Plan.io Tasks #3621 #3653
  103.         self::EXPORT_IKEA_SERVICE_ORDER,
  104.         self::EXPORT_IKEA_SERVICE_ORDER_SOCIETY,
  105.         self::EXPORT_IKEA_SERVICE_ORDER_ANY,
  106.         self::EXPORT_SALARY,
  107.         self::EXPORT_SALARY_SOCIETY,
  108.         self::EXPORT_SALARY_ANY,
  109.         self::EXPORT_DEMAND,
  110.         self::EXPORT_DEMAND_SOCIETY,
  111.         self::EXPORT_DEMAND_ANY,
  112.         self::EXPORT_ITASK,
  113.         self::EXPORT_ITASK_ANY,
  114.         self::EXPORT_COST,
  115.         self::EXPORT_COST_SOCIETY,
  116.         self::EXPORT_COST_ANY,
  117.     );
  118.     //--------------------------------------------------------------------------------
  119.     // acl constants
  120.     const ACL_PERM_EXPORT_INVOICE "invoice_export";
  121.     const ACL_PERM_EXPORT_INVOICE_SOCIETY "invoice_export_society";
  122.     const ACL_PERM_EXPORT_DEVIS "devis_export";
  123.     const ACL_PERM_EXPORT_DEVIS_SOCIETY "devis_export_society";
  124.     const ACL_PERM_EXPORT_COMMAND "command_export";
  125.     const ACL_PERM_EXPORT_COMMAND_SOCIETY "command_export_society";
  126.     const ACL_PERM_EXPORT_TASK "task_export";
  127.     const ACL_PERM_EXPORT_TASK_SOCIETY "task_export_society";
  128.     const ACL_PERM_EXPORT_MISSION "mission_export";
  129.     const ACL_PERM_EXPORT_MISSION_SOCIETY "mission_export_society";
  130.     const ACL_PERM_EXPORT_IND "ind_export";
  131.     const ACL_PERM_EXPORT_IND_SOCIETY "ind_export_society";
  132.     const ACL_PERM_EXPORT_RFI "webapp_doc_export_rfi";
  133.     const ACL_PERM_EXPORT_RFI_SOCIETY "webapp_doc_export_rfi_society";
  134.     const ACL_PERM_EXPORT_ANOMALY "webapp_doc_export_anomaly";
  135.     const ACL_PERM_EXPORT_ANOMALY_SOCIETY "webapp_doc_export_anomaly_society";
  136.     const ACL_PERM_EXPORT_INSTALLMENT "installment_export";
  137.     const ACL_PERM_EXPORT_INSTALLMENT_SOCIETY "installment_export_society";
  138.     const ACL_PERM_EXPORT_EQUIPMENT "equipment_export";
  139.     const ACL_PERM_EXPORT_EQUIPMENT_SOCIETY "equipment_export_society";
  140.     // Plan.io Tasks #3621 #3653
  141.     const ACL_PERM_EXPORT_IKEA_SERVICE_ORDER "ikea_service_order_export";
  142.     const ACL_PERM_EXPORT_IKEA_SERVICE_ORDER_SOCIETY "ikea_service_order_export_society";
  143.     // Plan.io Task #3884
  144.     const ACL_PERM_EXPORT_SALARY "salary_export";
  145.     const ACL_PERM_EXPORT_SALARY_SOCIETY "salary_export_society";
  146.     // Plan.io Task #3889
  147.     const ACL_PERM_EXPORT_DEMAND "demand_export";
  148.     const ACL_PERM_EXPORT_DEMAND_SOCIETY "demand_export_society";
  149.     // Plan.io Task #3889
  150.     const ACL_PERM_EXPORT_ITASK "itask_export";
  151.     // Plan.io Task #4426
  152.     const ACL_PERM_EXPORT_COST "cost_export";
  153.     const ACL_PERM_EXPORT_COST_SOCIETY "cost_export_society";
  154.     //--------------------------------------------------------------------------------
  155.     public function __construct(ManagerRegistry $doctrineModuleTools $moduleTools)
  156.     {
  157.         $this->em $doctrine->getManager();
  158.         $this->moduleTools $moduleTools;
  159.         $this->aclRepository $this->em->getRepository(Acl::class);
  160.         $this->aclPermissionRepository $this->em->getRepository(AclPermission::class);
  161.     }
  162.     // Plan.io Task #4453 [See AccessVoter for details]
  163.     public function supportsAttribute(string $attribute): bool
  164.     {
  165.         return in_array($attributeself::IS_GRANTED_CONSTANTStrue);
  166.     }
  167.     
  168.     protected function supports(string $attribute$subject null): bool
  169.     {
  170.         // if the attribute isn't one we support, return false
  171.         if (!in_array($attributeself::IS_GRANTED_CONSTANTS))
  172.         {
  173.             return false;
  174.         }
  175.         return true;
  176.     }
  177.     protected function voteOnAttribute(string $attribute$subjectTokenInterface $token): bool
  178.     {
  179.         $user $token->getUser();
  180.         if (!$user instanceof Access)
  181.         {
  182.             // the user must be logged in; if not, deny access
  183.             return false;
  184.         }
  185.         // The user must have a function; if not deny access
  186.         $function $user->getFunction();
  187.         if ($function === null)        return false;
  188.         // Plan.io Task #3710 : Get current group
  189.         $currentGroup $user->getSocietyGroup();
  190.         if ($currentGroup === null)
  191.             return false;
  192.         // Module activated ?
  193.         if ($this->moduleTools->isInactiveByCode($currentGroupModule::MODULE_EXPORT))
  194.         {
  195.             return false;
  196.         }
  197.         // No subject for this voter
  198.         switch ($attribute)
  199.         {
  200.             case self::IS_ACTIVE:
  201.                 return true;
  202.             case self::EXPORT_ANY:
  203.                 return $this->canExportAnyGeneric($user$function);
  204.             case self::EXPORT_INVOICE:
  205.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_INVOICE);
  206.             case self::EXPORT_INVOICE_SOCIETY:
  207.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_INVOICE_SOCIETY);
  208.             case self::EXPORT_INVOICE_ANY:
  209.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_INVOICEself::ACL_PERM_EXPORT_INVOICE_SOCIETY);
  210.             case self::EXPORT_DEVIS:
  211.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_DEVIS);
  212.             case self::EXPORT_DEVIS_SOCIETY:
  213.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_DEVIS_SOCIETY);
  214.             case self::EXPORT_DEVIS_ANY:
  215.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_DEVISself::ACL_PERM_EXPORT_DEVIS_SOCIETY);
  216.             case self::EXPORT_COMMAND:
  217.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_COMMAND);
  218.             case self::EXPORT_COMMAND_SOCIETY:
  219.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_COMMAND_SOCIETY);
  220.             case self::EXPORT_COMMAND_ANY:
  221.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_COMMANDself::ACL_PERM_EXPORT_COMMAND_SOCIETY);
  222.             case self::EXPORT_TASK:
  223.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_TASK);
  224.             case self::EXPORT_TASK_SOCIETY:
  225.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_TASK_SOCIETY);
  226.             case self::EXPORT_TASK_ANY:
  227.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_TASKself::ACL_PERM_EXPORT_TASK_SOCIETY);
  228.             case self::EXPORT_MISSION:
  229.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_MISSION);
  230.             case self::EXPORT_MISSION_SOCIETY:
  231.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_MISSION_SOCIETY);
  232.             case self::EXPORT_MISSION_ANY:
  233.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_MISSIONself::ACL_PERM_EXPORT_MISSION_SOCIETY);
  234.             case self::EXPORT_IND:
  235.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_IND);
  236.             case self::EXPORT_IND_SOCIETY:
  237.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_IND_SOCIETY);
  238.             case self::EXPORT_IND_ANY:
  239.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_INDself::ACL_PERM_EXPORT_IND_SOCIETY);
  240.             case self::EXPORT_RFI:
  241.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_RFI);
  242.             case self::EXPORT_RFI_SOCIETY:
  243.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_RFI_SOCIETY);
  244.             case self::EXPORT_RFI_ANY:
  245.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_RFIself::ACL_PERM_EXPORT_RFI_SOCIETY);
  246.             case self::EXPORT_ANOMALY:
  247.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_ANOMALY);
  248.             case self::EXPORT_ANOMALY_SOCIETY:
  249.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_ANOMALY_SOCIETY);
  250.             case self::EXPORT_ANOMALY_ANY:
  251.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_ANOMALYself::ACL_PERM_EXPORT_ANOMALY_SOCIETY);
  252.             case self::EXPORT_INSTALLMENT:
  253.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_INSTALLMENT);
  254.             case self::EXPORT_INSTALLMENT_SOCIETY:
  255.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_INSTALLMENT_SOCIETY);
  256.             case self::EXPORT_INSTALLMENT_ANY:
  257.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_INSTALLMENTself::ACL_PERM_EXPORT_INSTALLMENT_SOCIETY);
  258.             case self::EXPORT_EQUIPMENT:
  259.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_EQUIPMENT);
  260.             case self::EXPORT_EQUIPMENT_SOCIETY:
  261.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_EQUIPMENT_SOCIETY);
  262.             case self::EXPORT_EQUIPMENT_ANY:
  263.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_EQUIPMENTself::ACL_PERM_EXPORT_EQUIPMENT_SOCIETY);
  264.             // Plan.io Tasks #3621 #3653 : Begin
  265.             case self::EXPORT_IKEA_SERVICE_ORDER:
  266.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_IKEA_SERVICE_ORDER);
  267.             case self::EXPORT_IKEA_SERVICE_ORDER_SOCIETY:
  268.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_IKEA_SERVICE_ORDER_SOCIETY);
  269.             case self::EXPORT_IKEA_SERVICE_ORDER_ANY:
  270.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_IKEA_SERVICE_ORDERself::ACL_PERM_EXPORT_IKEA_SERVICE_ORDER_SOCIETY);
  271.             // Plan.io Tasks #3621 #3653 : End
  272.             case self::EXPORT_SALARY:
  273.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_SALARY);
  274.             case self::EXPORT_SALARY_SOCIETY:
  275.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_SALARY_SOCIETY);
  276.             case self::EXPORT_SALARY_ANY:
  277.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_SALARYself::ACL_PERM_EXPORT_SALARY_SOCIETY);
  278.             case self::EXPORT_DEMAND:
  279.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_DEMAND);
  280.             case self::EXPORT_DEMAND_SOCIETY:
  281.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_DEMAND_SOCIETY);
  282.             case self::EXPORT_DEMAND_ANY:
  283.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_DEMANDself::ACL_PERM_EXPORT_DEMAND_SOCIETY);
  284.             case self::EXPORT_ITASK:
  285.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_ITASK);
  286.             case self::EXPORT_ITASK_ANY:
  287.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_ITASKnull);
  288.             case self::EXPORT_COST:
  289.                 return $this->canExport($user$functionself::ACL_PERM_EXPORT_COST);
  290.             case self::EXPORT_COST_SOCIETY:
  291.                 return $this->canExportSociety($user$functionself::ACL_PERM_EXPORT_COST_SOCIETY);
  292.             case self::EXPORT_COST_ANY:
  293.                 return $this->canExportAny($user$functionself::ACL_PERM_EXPORT_COSTself::ACL_PERM_EXPORT_COST_SOCIETY);
  294.         }
  295.         throw new \LogicException('This code should not be reached!');
  296.     }
  297.     private function canExportAnyGeneric(Access $userAccessFunction $function)
  298.     {
  299.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_INVOICEself::ACL_PERM_EXPORT_INVOICE_SOCIETY))
  300.             return true;
  301.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_DEVISself::ACL_PERM_EXPORT_DEVIS_SOCIETY))
  302.             return true;
  303.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_COMMANDself::ACL_PERM_EXPORT_COMMAND_SOCIETY))
  304.             return true;
  305.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_TASKself::ACL_PERM_EXPORT_TASK_SOCIETY))
  306.             return true;
  307.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_MISSIONself::ACL_PERM_EXPORT_MISSION_SOCIETY))
  308.             return true;
  309.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_INDself::ACL_PERM_EXPORT_IND_SOCIETY))
  310.             return true;
  311.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_RFIself::ACL_PERM_EXPORT_RFI_SOCIETY))
  312.             return true;
  313.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_ANOMALYself::ACL_PERM_EXPORT_ANOMALY_SOCIETY))
  314.             return true;
  315.         // Plan.io Tasks #3621 #3653
  316.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_IKEA_SERVICE_ORDERself::ACL_PERM_EXPORT_IKEA_SERVICE_ORDER_SOCIETY))
  317.             return true;
  318.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_SALARYself::ACL_PERM_EXPORT_SALARY_SOCIETY))
  319.             return true;
  320.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_DEMANDself::ACL_PERM_EXPORT_DEMAND_SOCIETY))
  321.             return true;
  322.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_ITASKnull))
  323.             return true;
  324.         if ($this->canExportAny($user$functionself::ACL_PERM_EXPORT_COSTself::ACL_PERM_EXPORT_COST_SOCIETY))
  325.             return true;
  326.         return false;
  327.     }
  328.     private function canExport(Access $userAccessFunction $function$aclPermConstant)
  329.     {
  330.         // Get Acl_Permission
  331.         $aclPerm $this->aclPermissionRepository->findOneByName($aclPermConstant);
  332.         if ($aclPerm === null)        return false;
  333.         // Get Acl
  334.         $acl $this->aclRepository->findOneBy(array(
  335.             'function'        =>    $function,
  336.             'permission'    =>    $aclPerm
  337.         ));
  338.         if ($acl === null)        return false;
  339.         // Since only one acl type can exist
  340.         // we can return the result of the acl_permission
  341.         return $acl->getValue();
  342.     }
  343.     private function canExportSociety(Access $userAccessFunction $function$aclPermConstant)
  344.     {
  345.         // Get Acl_Permission
  346.         $aclPerm $this->aclPermissionRepository->findOneByName($aclPermConstant);
  347.         if ($aclPerm === null)        return false;
  348.         // Get Acl
  349.         $acl $this->aclRepository->findOneBy(array(
  350.             'function'        =>    $function,
  351.             'permission'    =>    $aclPerm
  352.         ));
  353.         if ($acl === null)        return false;
  354.         // Since only one acl type can exist
  355.         // we can return the result of the acl_permission
  356.         // Further filtering is done in the Controller
  357.         return $acl->getValue();
  358.     }
  359.     private function canExportAny(Access $userAccessFunction $function$aclPermConstant$aclPermConstantSociety)
  360.     {
  361.         // Three Acl_Permission may exist
  362.         $aclPerm $this->aclPermissionRepository->findOneByName($aclPermConstant);
  363.         $aclPermSociety $this->aclPermissionRepository->findOneByName($aclPermConstantSociety);
  364.         // If all are null, exit
  365.         if ($aclPerm === null && $aclPermSociety === null)
  366.             return false;
  367.         // Get First one
  368.         if ($aclPerm !== null)
  369.         {
  370.             $acl $this->aclRepository->findOneBy(array(
  371.                 'function'        =>    $function,
  372.                 'permission'    =>    $aclPerm
  373.             ));
  374.             if ($acl !== null)
  375.             {
  376.                 if ($acl->getValue())
  377.                 {
  378.                     // A single positive answer is enough
  379.                     return true;
  380.                 }
  381.             }
  382.         }
  383.         // If we are here it means that nothing good has been found
  384.         // Load second permission
  385.         if ($aclPermSociety !== null)
  386.         {
  387.             $acl $this->aclRepository->findOneBy(array(
  388.                 'function'        =>    $function,
  389.                 'permission'    =>    $aclPermSociety
  390.             ));
  391.             if ($acl !== null)
  392.             {
  393.                 if ($acl->getValue())
  394.                 {
  395.                     // A single positive answer is enough
  396.                     return true;
  397.                 }
  398.             }
  399.         }
  400.         // If we are here, all hope is lost
  401.         return false;
  402.     }
  403. }