I've built a function that lists all modules and submodules within the system. But I need it to be different, I need that in this same listing, just come the modules and submodules that the client has access to, rather than checking whether he has permission or not. I'll state how I did it:
Function for Listing the Modules:
public function getModulosCategoria(){
$sql = "SELECT * FROM modulos WHERE idModuloBase = '0'";
$consulta = $this->db->query($sql)->result();
foreach($consulta as &$valor){
$sql_model = "SELECT * FROM modulos WHERE idModuloBase = '{$valor->idModulo}'";
$valor->subModulo = $this->db->query($sql_model)->result();
}
return $consulta;
}
In the listing I make the following verification:
foreach($modulo->subModulo as $submodulo){
$permissao = "a".ucfirst($submodulo->pasta);
if($this->permission->checkPermission($this->session->userdata('permissao'),$permissao)){
Exibe o Link para o Modulo...
So far it's running 100%, but I need to do this differently. I want you to list all modules, just look for the allowed modules.
Permissionstable:
Returnfromthepermissionsfieldwithinthepermissionstable:
a:12:{i:0;s:9:"aCedentes";i:1;s:9:"eCedentes";i:2;s:9:"dCedentes";i:3;s:9:"vCedentes";i:4;s:9:"aUsuarios";i:5;s:9:"eUsuarios";i:6;s:9:"dUsuarios";i:7;s:9:"vUsuarios";i:8;s:13:"aFornecedores";i:9;s:13:"eFornecedores";i:10;s:13:"dFornecedores";i:11;s:13:"vFornecedores";}