Você está na página 1de 3

Como Criar Permissões no Athenas3000 Por Grupo de Usuários

1. Execute os scripts abaixo no banco de dados


--SCRIPT 1
CREATE DOMAIN INTPEQ AS SMALLINT DEFAULT 0;
--SCRIPT 2
ALTER TABLE TABACESSOSUSUARIO ADD EDITANDO INTPEQ; /* INTPEQ = SMALLINT
DEFAULT 0 */
--SCRIPT 3
UPDATE TABACESSOSUSUARIO SET TABACESSOSUSUARIO = 0;
--SCRIPT 4
CREATE OR ALTER TRIGGER TABACES_USU_GRUPO_AU0 FOR TABACESSOSUSUARIO
ACTIVE AFTER UPDATE POSITION 990
AS
declare variable strScriptAlteracao varchar(10000);
declare variable strSQL varchar(10000);
begin
if (new.editando = 0) then
begin
strScriptAlteracao = 'editando = 1';
if (new.visivel is distinct from old.visivel) then
strScriptAlteracao = strScriptAlteracao || ', visivel = ' || coalesce(new.visivel, 0);
if (new.ativo is distinct from old.ativo) then
strScriptAlteracao = strScriptAlteracao || ', ativo = ' || coalesce(new.ativo, 0);
if (new.incluir is distinct from old.incluir) then
strScriptAlteracao = strScriptAlteracao || ', incluir = ' || coalesce(new.incluir, 0);
if (new.alterar is distinct from old.alterar) then
strScriptAlteracao = strScriptAlteracao || ', alterar = ' || coalesce(new.alterar,
0);
if (new.excluir is distinct from old.excluir ) then
strScriptAlteracao = strScriptAlteracao || ', excluir = ' || coalesce(new.excluir,
0);
if (new.listar is distinct from old.listar) then
strScriptAlteracao = strScriptAlteracao || ', listar = ' || coalesce(new.listar, 0);

if (strScriptAlteracao <> 'editando = 1') then


begin
strSQL = '';
strSQL = strSQL || 'update tabacessosusuario set ' || strScriptAlteracao || ' ';
strSQL = strSQL || 'where nomecomponente = ''' || new.nomecomponente ||
''' ';
strSQL = strSQL || 'and nomeformulario = ''' || new.nomeformulario || ''' ';
strSQL = strSQL || 'and itemmenu = ''' || new.itemmenu || ''' ';
strSQL = strSQL || 'and menumae = ''' || new.menumae || ''' ';
strSQL = strSQL || 'and tipo = ''' || new.tipo || ''' ';
strSQL = strSQL || 'and codigo in (';
strSQL = strSQL || 'Select P1.codigosubordinado ';
strSQL = strSQL || 'From tabresponsabilidade P1 inner join tabresponsabilidade
P2 on ';
strSQL = strSQL || 'P1.codigosubordinado <> ' || new.codigo || ' and ';
strSQL = strSQL || 'P2.codigosubordinado = ' || new.codigo || ' and ';
strSQL = strSQL || 'P1.codigoresponsavel = P2.codigoresponsavel and ';
strSQL = strSQL || 'Coalesce(P1.codigoresponsavel, 0) <> 0 and ';
strSQL = strSQL || 'Coalesce(P1.codigoresponsavel, 0) <> 0) ';

execute statement :strSQL;

strSQL = '';
strSQL = strSQL || 'update tabacessosusuario set editando = 0 ';
strSQL = strSQL || 'where nomecomponente = ''' || new.nomecomponente ||
''' ';
strSQL = strSQL || 'and nomeformulario = ''' || new.nomeformulario || ''' ';
strSQL = strSQL || 'and itemmenu = ''' || new.itemmenu || ''' ';
strSQL = strSQL || 'and menumae = ''' || new.menumae || ''' ';
strSQL = strSQL || 'and tipo = ''' || new.tipo || ''' ';
strSQL = strSQL || 'and codigo in (';
strSQL = strSQL || 'Select P1.codigosubordinado ';
strSQL = strSQL || 'From tabresponsabilidade P1 inner join tabresponsabilidade
P2 on ';
strSQL = strSQL || 'P1.codigosubordinado <> ' || new.codigo || ' and ';
strSQL = strSQL || 'P2.codigosubordinado = ' || new.codigo || ' and ';
strSQL = strSQL || 'P1.codigoresponsavel = P2.codigoresponsavel and ';
strSQL = strSQL || 'Coalesce(P1.codigoresponsavel, 0) <> 0 and ';
strSQL = strSQL || 'Coalesce(P1.codigoresponsavel, 0) <> 0) ';

execute statement :strSQL;

end
end
end

2. Crie os Grupos de usuários que você deseja ter e vincule aos usuários de acordo com o
grupo a que pertencem.
3. Pronto. Sempre que você alterar as permissões (programas) para um usuário, todos do
mesmo grupo terão as permissões alteradas.

Você também pode gostar