2
I designed a function that lists all modules and sub-modules within the system. But I need it to be different, I need that in this same listing, only come the modules and submodules that the customer has access to, rather than checking whether he has permission or not. I’ll expose how I did:
Function for Listing 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 do the following check:
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 working 100%, but I need to do it differently. I want you to list all the modules, just look for the allowed modules.
Return field permissions within table permissions:
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";}
I have the impression that you should use the comments instead of using the "answer" option for this.
– Wallace Maxters
Exactly, because the permission is recorded separately... I write inside the permission table, as if I create several types of permissions, and then only select which permission the client has... But I managed to settle the matter differently.
– Sr. André Baill
I would, but I still can’t comment on the question, I can’t say why but tell me I need 50 points.
– Ricardo Silva
Ue, if you decided to put your answer and mark your answer as right. Someone may have the same doubt. Sorry for the lack of accents.
– Ricardo Silva