예제 #1
0
function carregarModulos()
{
    include '../dao/Modulos.php';
    include '../dao/ModulosDAO.php';
    include '../dao/Operacaomodulos.php';
    include '../dao/OperacaomodulosDAO.php';
    include '../dao/Permissoes.php';
    include '../dao/PermissoesDAO.php';
    $modulosDAO = new ModulosDAO();
    $operacaomodulosDAO = new OperacaomodulosDAO();
    $permissoesDAO = new PermissoesDAO();
    // Busca todos os modulos do sistema
    $modulosList = $modulosDAO->selectListaTodosRegistros();
    if (!$modulosList) {
        finalize("Nenhum módulo encontrado!");
    }
    $list['success'] = 1;
    $list['data'] = array();
    $list['data']['modulo'] = array();
    $idUsuario = $_POST["idUsuario"];
    foreach ($modulosList as $mod) {
        $operacaoList = $operacaomodulosDAO->selectListaRegistrosPorModulo($mod->getIdmodulo());
        if ($operacaoList) {
            $arrTmp = array();
            foreach ($operacaoList as $op) {
                $permissoes = $permissoesDAO->selectRegistro($op->getIdoperacaomodulo(), $idUsuario);
                $acesso = true;
                if (!$permissoes) {
                    $acesso = false;
                }
                $arrTmp[] = array("descricao" => $op->getDescricao(), "acesso" => $acesso, "idoperacaomodulo" => $op->getIdoperacaomodulo());
            }
        }
        $list['data']['modulo'][] = array("nomeModulo" => $mod->getNome(), "operacoes" => $arrTmp);
    }
    echo json_encode($list);
}
예제 #2
0
function buscarPermissoesCRM()
{
    include '../dao/Operacaomodulos.php';
    include '../dao/OperacaomodulosDAO.php';
    include '../dao/Permissoes.php';
    include '../dao/PermissoesDAO.php';
    $operacaomodulosDAO = new OperacaomodulosDAO();
    $permissoesDAO = new PermissoesDAO();
    // Buscar as operações do módulo id=2 (CRM)
    $operacoesList = $operacaomodulosDAO->selectListaRegistrosPorModulo(1);
    if (!$operacoesList) {
        finalize(NULL);
    }
    $list['success'] = 1;
    $list['data'] = array();
    foreach ($operacoesList as $op) {
        $permissoes = $permissoesDAO->selectRegistro($op->getIdoperacaomodulo(), $_SESSION["id"]);
        if (!$permissoes) {
            continue;
        }
        $list['data'][] = $op->getDescricao();
    }
    echo json_encode($list);
}