在PB前台设好要加权限对象的Id。在后台数据库设计好一个表和它对应然后在该对象所在的窗口的OPEN事件中做如下的范围代码:
int ls_count[15]
if gs_use_id="List" then return
select m_bumen,m_yuangong,m_luduan,m_kehu,m_kehu2,m_airline,m_yunshu,m_huowu,m_quyu,m_xiadangl,m_handkong,w_xiadan_tab_1,w_xiadan_tab_2,m_quanxian,m_backup into :ls_count[1],:ls_count[2],:ls_count[3],:ls_count[4],:ls_count[5],:ls_count[6],:ls_count[7],:ls_count[8],:ls_count[9],:ls_count[10],:ls_count[11],:ls_count[12],:ls_count[13],:ls_count[14],:ls_count[15] from DL where dl_id=:gs_use_id using sqlca;
if ls_count[1]=1 then
m_main.m_xtzl.m_bumen.enabled=true
else
m_main.m_xtzl.m_bumen.enabled=false
end if
if ls_count[2]=1 then
m_main.m_xtzl.m_yuangong.enabled=true
else
m_main.m_xtzl.m_yuangong.enabled=false
end if
if ls_count[3]=1 then
m_main.m_xtzl.m_luduan.enabled=true
else
m_main.m_xtzl.m_luduan.enabled=false
end if
if ls_count[4]=1 then
m_main.m_xtzl.m_kehu.enabled=true
else
m_main.m_xtzl.m_kehu.enabled=false
end if
if ls_count[5]=1 then
m_main.m_xtzl.m_kehu2.enabled=true
else
m_main.m_xtzl.m_kehu2.enabled=false
end if
if ls_count[6]=1 then
m_main.m_xtzl.m_airline.enabled=true
else
m_main.m_xtzl.m_airline.enabled=false
end if
if ls_count[7]=1 then
m_main.m_xtzl.m_yunshu.enabled=true
else
m_main.m_xtzl.m_yunshu.enabled=false
end if
if ls_count[8]=1 then
m_main.m_xtzl.m_huowu.enabled=true
else
m_main.m_xtzl.m_huowu.enabled=false
end if
if ls_count[9]=1 then
m_main.m_xtzl.m_quyu.enabled=true
else
m_main.m_xtzl.m_quyu.enabled=false
end if
if ls_count[10]=1 then
m_main.m_xiadan.m_xiadangl.enabled=true
else
m_main.m_xiadan.m_xiadangl.enabled=false
end if
if ls_count[14]=1 then
m_main.m_xiadan.m_quanxian.enabled=true
else
m_main.m_xiadan.m_quanxian.enabled=false
end if
if ls_count[11]=1 then
m_main.m_yunjiagl.m_hangkong.enabled=true
else
m_main.m_yunjiagl.m_hangkong.enabled=false
end if
if ls_count[15]=1 then
m_main.m_xiadan.m_backup.enabled=true
else
m_main.m_xiadan.m_backup.enabled=false
end if
用户A继承组A组B组C拥有权限1、2、3、4、5
同时自己设定权限6,取消权限3
当组C被删除时应该具有1、2、3、4、6
但实际删除如果仅仅去掉3、4、5的话,用户A的权限就成了1、2、6
我还没找到合适的办法解决这个问题
---------------------------------------------
对于这个问题,建议你这样设计用户权限获取过程
1。用户自定义权限和组权限分开,在获取用户权限的时候,使用联合查询,分别从组权限表和用户自定义权限表中获取;
2。对于用户自定义权限的优先性,通过你的描述,你应该采用的是组权限+用户自定义权限。采用这种方式的话,要禁止用户使用多个组权限中的功能,不得不把所有包含这个功能的组关系去掉,这就造成了你前面的问题。建议你采用下面的方式:在定义用户-功能关系表时,加上一个标志字段,如果某个关系(如用户A-功能C)的标志为false,则强制把该项功能禁掉。
这样获取用户权限的查询语句可以写成这样:
select distinct funcid from role_func where roleid in (select roleid from user_role where userid='youruser') and funcid not in (select funcid from user_func where userid='youruser' and flag=false) union select funcid from user_func where userid='youruser' and flag=true。
以上观点没有经过实践,仅供参考。用到子查询,但如果管理员不多的话,应该对性能没什么影响。