function getAllResources()
 {
     // get all resources
     $resourcesSelect = new ExtranetResources();
     $select = $resourcesSelect->select()->setIntegrityCheck(false);
     $select->join('Extranet_ResourcesIndex', 'ERI_ResourceID = ER_ID')->where('ERI_LanguageID = ?', Zend_Registry::get("languageID"))->order('ERI_Name');
     return $resourcesSelect->fetchAll($select)->toArray();
 }
Exemplo n.º 2
0
 public static function getACLUser($authID)
 {
     // get user data
     //$authData = $this->view->user;
     //$authID     = $authData['EU_ID'];
     $acl = new Zend_Acl();
     /***************** ADDING ALL RESOURCES ************************/
     $resourcesSelect = new ExtranetResources();
     $select = $resourcesSelect->select();
     $resourcesData = $resourcesSelect->fetchAll($select);
     foreach ($resourcesData as $resource) {
         $resource = new Zend_Acl_Resource($resource['ER_ControlName']);
         $acl->add($resource);
     }
     /*************** ADDING ALL ROLES ********************************/
     $rolesSelect = new ExtranetRoles();
     $select = $rolesSelect->select();
     $rolesData = $rolesSelect->fetchAll($select);
     $rolesArray = array();
     foreach ($rolesData as $role) {
         $rolesArray[$role['ER_ID']]['name'] = $role['ER_ControlName'];
         $rolesArray[$role['ER_ID']]['parent'] = array();
         $rolesParentSelect = new ExtranetRolesResources();
         $select = $rolesParentSelect->select()->setIntegrityCheck(false);
         $select->where('ERR_RoleID = ?', $role['ER_ID'])->order('ERR_InheritedParentID');
         $rolesParentData = $rolesParentSelect->fetchAll($select);
         $rolesParentArray = array();
         foreach ($rolesParentData as $roleParent) {
             if ($roleParent['ERR_InheritedParentID'] != 0) {
                 $roleSelect = new ExtranetRolesResources();
                 $select = $roleSelect->select()->setIntegrityCheck(false);
                 $select->from('Extranet_RolesResources')->join('Extranet_Roles', 'ER_ID = ERR_RoleID')->where('ERR_ID = ?', $roleParent['ERR_InheritedParentID']);
                 $roleData = $roleSelect->fetchRow($select);
                 if (!in_array($roleData['ER_ControlName'], $rolesParentArray)) {
                     $rolesParentArray[count($rolesParentArray)] = $roleData['ER_ControlName'];
                 }
             }
         }
     }
     $rolesArray[$role['ER_ID']]['parent'] = $rolesParentArray;
     foreach ($rolesArray as $roleArray) {
         $role = new Zend_Acl_Role($roleArray['name']);
         $acl->addRole($role, $roleArray['parent']);
     }
     $role = new Zend_Acl_Role($authID);
     $acl->addRole($role);
     // get all groups of the current user
     $groupsData = Cible_FunctionsAdministrators::getAllUserGroups($authID);
     $admin = false;
     foreach ($groupsData as $group) {
         if ($group['EUG_GroupID'] == 1) {
             $admin = true;
         }
         $groupRoleResourceSelect = new ExtranetGroupsRolesResources();
         $select = $groupRoleResourceSelect->select();
         $select->where('EGRRP_GroupID = ?', $group['EUG_GroupID']);
         $groupRoleResourceData = $groupRoleResourceSelect->fetchAll($select)->toArray();
         //$this->view->dump($groupRoleResourceData);
         foreach ($groupRoleResourceData as $groupRoleResource) {
             $acl = Cible_FunctionsAdministrators::addAllRolesResourcesPermissionsUser($acl, $authID, $groupRoleResource['EGRRP_RoleResourceID']);
         }
     }
     return $acl;
     //echo $acl->isAllowed($authID, 'news', 'publish') ? "autorisé" : "refusé";
 }