コード例 #1
0
 public function registraAcesso($usrId)
 {
     unset($sqlFuncoes);
     $sql = "\n\t\tINSERT INTO acessos (acessoIp,usrId)\n\t\tVALUES ('" . $_SERVER['REMOTE_ADDR'] . "','" . $usrId . "');\n\t\t";
     $sqlFuncoes = new sqlFuncoes();
     $sqlFuncoes->setSql($sql);
     $sqlFuncoes->incluiRegisto();
 }
コード例 #2
0
    $permissoesAtuais[] = $permissoes[$p]['acaoId'];
}
// gera lista de todas as permissoes possiveis para o usuario
$sql = "\nSELECT acaoId, moduloId, acaoPagina\nFROM modulos_acao\nWHERE usrRoot = 'n'\nAND acaoRestrita = 's'\nORDER BY moduloId, acaoId ASC;\n";
$sqlFuncoes = new sqlFuncoes();
$sqlFuncoes->setSql($sql);
$permissoesPossiveis = $sqlFuncoes->listaRegistros();
unset($sqlFuncoes);
// ###########################################################################################
// ALATERA AS PERMISSOES NO BANCO DE DADOS ###################################################
foreach ($permissoesPossiveis as $chave => $permissao) {
    if (in_array($permissao['acaoId'], $permissoesAtuais) and !array_key_exists($permissao['acaoPagina'], $_POST)) {
        $sql = "\n\t\tDELETE\n\t\tFROM modulos_permissao\n\t\tWHERE acaoId = " . $permissao['acaoId'] . "\n\t\tAND usrId = " . $usrId . "\n\t\tLIMIT 1;\n\t\t";
        $sqlFuncoes = new sqlFuncoes();
        $sqlFuncoes->setSql($sql);
        $sqlFuncoes->excluiRegistro();
        unset($sqlFuncoes);
    } elseif (!in_array($permissao['acaoId'], $permissoesAtuais) and array_key_exists($permissao['acaoPagina'], $_POST)) {
        $sql = "\n\t\tINSERT INTO modulos_permissao\n\t\t\t(acaoId, moduloId, usrId)\n\t\tVALUES\n\t\t\t(" . $permissao['acaoId'] . ", " . $permissao['moduloId'] . ", " . $usrId . ");\n\t\t";
        $sqlFuncoes = new sqlFuncoes();
        $sqlFuncoes->setSql($sql);
        $sqlFuncoes->incluiRegisto();
        unset($sqlFuncoes);
    }
}
// ###########################################################################################
// REDIRECIONA PARA A PAGINA DE PERMISSOES DO USUARIO ########################################
setcookie('msgOk', 'Permissões alteradas com sucessos.', time() + 10, '/administracao/usuario-permissao/');
header("Location: /administracao/usuario-permissao/" . $usrId);
exit;
// ###########################################################################################