我的权限系统是
用户,功能,角色
一个用户可以是多个角色,
一个角色拥有多个功能
当然也可以是用户,功能,组,角色,但这不是这个问题的重点我现在可以组合出
用户拥有的功能和用户不拥有的功能两个表了.我想知道有什么方法根据这两个表实现根据不同用户登陆时实际用户权限的设置
在网上很多大侠都讲用ACTIONLIST,但我不知道使用方法,不知道他们是如何利用它实现不同用户的权限设置的.
在使用这种方法的人能给我分享吗?因为我水平有限,如愿意请详细一点信箱:[email protected]

解决方案 »

  1.   

    大概说一下,你参考改之
    作一个字符串,使所有权限的连结
    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
      

  2.   

    ACTIONLIST如何与表进行对比,有没有这方面的代码,最好能把代码贴上来
      

  3.   

    yq3woaini已经说了,根据你的权限控制设置action是否enable。
    用for循环即可if S[i] = '1' then
    ActionList.actions[i].enable := true
    else
    ActionList.actions[i].enable := false
      

  4.   

    如何访问Actionlist里的功能,比如Actionlist1中RIGHT组中有名为actedit,actnew,actdelete三个功能,一个ID为1的用户可用权限视图简略如下
    1  actedit
    1  actnew也就说这个用户拥有有actedit,actnew功能,窗口中ACTION属性引用actnew,actedit的按钮和菜单都可用了.如何动态改变功能ACTNEW的ENABLE属性,是不是仅仅改变这一个属性就可以控制他的可用和不可用了,我用手动改变它的ENABLED属性为TRUE了,但它为什么还是显示为灰色呢?判断ACTIONLIST中的功能,是否出现在用户的可用权限视图中,具体的代码是怎样的,楼上的朋友给了来的代理,我不会使用.
      

  5.   

    根据功能项为true或false置对应的actionlist项的enable为true or false
      

  6.   

    我用手动改变它的ENABLED属性为TRUE了,但它为什么还是显示为灰色呢?------------------------------------------
    如果ActionList中的功能里没写代码,即使Enabled属性设为True,它关联的按钮也是灰色
      

  7.   

    说的是ActionList1??这个玩意不是定义热键用的.怎么还能定义权限?
    -------------------------------------------------
    我真納悶這你都不知道?
      

  8.   

    你可以将ActionList中的TAction的Tag值设置为唯一值借助于这个属性可以实现控制权限的需求
      

  9.   

    这是我用过的,只有用户,组,权限是针对组设定的。
    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;