我的权限系统是
用户,功能,角色
一个用户可以是多个角色,
一个角色拥有多个功能
当然也可以是用户,功能,组,角色,但这不是这个问题的重点我现在可以组合出
用户拥有的功能和用户不拥有的功能两个表了.我想知道有什么方法根据这两个表实现根据不同用户登陆时实际用户权限的设置
在网上很多大侠都讲用ACTIONLIST,但我不知道使用方法,不知道他们是如何利用它实现不同用户的权限设置的.
在使用这种方法的人能给我分享吗?因为我水平有限,如愿意请详细一点信箱:[email protected]
用户,功能,角色
一个用户可以是多个角色,
一个角色拥有多个功能
当然也可以是用户,功能,组,角色,但这不是这个问题的重点我现在可以组合出
用户拥有的功能和用户不拥有的功能两个表了.我想知道有什么方法根据这两个表实现根据不同用户登陆时实际用户权限的设置
在网上很多大侠都讲用ACTIONLIST,但我不知道使用方法,不知道他们是如何利用它实现不同用户的权限设置的.
在使用这种方法的人能给我分享吗?因为我水平有限,如愿意请详细一点信箱:[email protected]
作一个字符串,使所有权限的连结
01010101010
代表用户有2,4,6,8的权限
101010
代表用户有1,3,5的权限S:= '1000';
if S[0] = '1' then
ActionList.actions[0].enable := true
else
ActionList.actions[0].enable := false把这个东西取出来
在ActionList中把允许1的置成True 把0的置成False
用for循环即可if S[i] = '1' then
ActionList.actions[i].enable := true
else
ActionList.actions[i].enable := false
1 actedit
1 actnew也就说这个用户拥有有actedit,actnew功能,窗口中ACTION属性引用actnew,actedit的按钮和菜单都可用了.如何动态改变功能ACTNEW的ENABLE属性,是不是仅仅改变这一个属性就可以控制他的可用和不可用了,我用手动改变它的ENABLED属性为TRUE了,但它为什么还是显示为灰色呢?判断ACTIONLIST中的功能,是否出现在用户的可用权限视图中,具体的代码是怎样的,楼上的朋友给了来的代理,我不会使用.
如果ActionList中的功能里没写代码,即使Enabled属性设为True,它关联的按钮也是灰色
-------------------------------------------------
我真納悶這你都不知道?
var
qry:TQuery;
lstRouting:TStrings;
strGroupName:string;
i:Integer;
begin
lstRouting := TStringlist.Create;
qry := TQuery.Create(Nil);
with qry do
try
databasename := cbde_dbalias;
SessionName := cSessionName;
sql.add('select groupname from users');
sql.add('where username=''' + username + '''');
Open;
if Not IsEmpty then
begin
strGroupName := Fieldbyname('Groupname').asString;
close;
sql.clear;
sql.add('select Routingid from Authority where groupname=''' +
strGroupName + ''' and isexecute=0');
open;
while not eof do
begin
lstRouting.Add(inttostr(Fieldbyname('RoutingID').asInteger));
Next;
end;
Close;
end;
close;
for i:=0 to ActionList.ActionCount -1 do
begin
if comparetext(username,'voidname')=0 then
TAction(ActionList.Actions[i]).Enabled := False
else
if lstRouting.indexof(inttostr(Actionlist.Actions[i].Tag)) <> -1 then
TAction(ActionList.Actions[i]).Enabled := False
else
TAction(ActionList.Actions[i]).Enabled := True;
end;
finally
free;
end;
lstRouting.Free;