function showRolesResourcesPermissions($groupID) { $resourcesData = $this->getAllResources(); foreach ($resourcesData as $resources) { echo "<div style='width:100%;font-weight:bolder;'>" . $resources["ERI_Name"] . "</div>"; // get all roles associated to the resources $rolesResourcesSelect = new ExtranetRolesResources(); $select = $rolesResourcesSelect->select()->setIntegrityCheck(false); $select->from('Extranet_RolesResources')->join('Extranet_RolesResourcesIndex', 'ERRI_RoleResourceID = ERR_ID')->where('ERR_ResourceID = ?', $resources["ERI_ResourceID"])->where('ERRI_LanguageID = ?', Zend_Registry::get("languageID")); $rolesData = $rolesResourcesSelect->fetchAll($select)->toArray(); echo "<ul>"; echo "<li>"; echo "<input type='radio' id='radio_role_0' name='radio_resource_" . $resources["ERI_ResourceID"] . "' value='0' checked='checked'>"; echo $this->view->getCibleText('form_label_noRight'); echo "</li>"; foreach ($rolesData as $role) { echo "<li>"; if ($this->checkGroupRoleResource($groupID, $role["ERRI_RoleResourceID"])) { echo "<input type='radio' id='radio_role_" . $role["ERRI_RoleResourceID"] . "' name='radio_resource_" . $resources["ERI_ResourceID"] . "' value='" . $role["ERRI_RoleResourceID"] . "' checked='checked'>"; } else { echo "<input type='radio' id='radio_role_" . $role["ERRI_RoleResourceID"] . "' name='radio_resource_" . $resources["ERI_ResourceID"] . "' value='" . $role["ERRI_RoleResourceID"] . "'>"; } echo $role["ERRI_Name"] . " (" . $role["ERRI_Description"] . ")"; echo "</li>"; } echo "</ul>"; } }
public static function addAllRolesResourcesPermissionsUser($acl, $userID, $roleRessourceID) { $roleResourceSelect = new ExtranetRolesResources(); $select = $roleResourceSelect->select()->setIntegrityCheck(false); $select->from('Extranet_RolesResources', array('ResourceName' => 'Extranet_Resources.ER_ControlName', 'RoleName' => 'Extranet_Roles.ER_ControlName', 'ERR_InheritedParentID', 'ERR_ID'))->join('Extranet_Resources', 'Extranet_Resources.ER_ID = ERR_ResourceID')->join('Extranet_Roles', 'Extranet_Roles.ER_ID = ERR_RoleID')->where('ERR_ID = ?', $roleRessourceID); $roleResourceData = $roleResourceSelect->fetchAll($select)->toArray(); //print_r($roleResourceData); foreach ($roleResourceData as $roleResource) { if ($roleResource['ERR_InheritedParentID'] != 0) { $acl = Cible_FunctionsAdministrators::addAllRolesResourcesPermissionsUser($acl, $userID, $roleResource['ERR_InheritedParentID']); } // get all permission //$this->view->dump($roleResource); // get all permission of a role resources associated $roleResourcePermissionsSelect = new ExtranetRolesResourcesPermissions(); $select = $roleResourcePermissionsSelect->select()->setIntegrityCheck(false); $select->from('Extranet_RolesResourcesPermissions')->join('Extranet_Permissions', 'EP_ID = ERRP_PermissionID')->where('ERRP_RoleResourceID = ?', $roleResource['ERR_ID']); $roleResourcePermissionsData = $roleResourcePermissionsSelect->fetchAll($select); //$this->view->dump($roleResourcePermissionsData->toArray()); foreach ($roleResourcePermissionsData as $permission) { $acl->allow($userID, $roleResource['ResourceName'], $permission['EP_ControlName']); } } return $acl; }