📄 rightsforone.asp
字号:
<%
'返回 0 用户或记录不存在;
'返回 1 用户对此记录无权限;
'返回 2 用户对此记录有浏览权限;
'返回 3 用户对此记录有编辑权限。
Function RightsForOne(ID,LoginName)
Set tempRs=Server.CreateObject("ADODB.RecordSet")
tempRs.Open "Select Unit,Dept,FGDept,ZhiBie,ReadAtt From tblUserLogin Where LoginName like '"&LoginName&"'",conn,1,1
If tempRs.eof Then '如果用户不存在返回0
tempRs.Close
RightsForOne=0
Else
UserUnit=tempRs("Unit")
UserDept=tempRs("Dept")
UserFGDept=Trim(tempRs("FGDept"))
UserZhiBie=tempRs("ZhiBie")
UserReadAtt=Trim(tempRs("ReadAtt"))
tempRs.Close
tempRs.Open "Select Attribute,InputLogin,Unit,Department From tblBase Where ID="&ID,conn,1,1
If tempRs.eof Then '如果记录不存在返回0
tempRs.Close
RightsForOne=0
Else
Attribute=Trim(tempRs("Attribute"))
InputLogin=Trim(tempRs("InputLogin"))
Unit=tempRs("Unit")
Dept=tempRs("Department")
tempRs.Close
'开始判断用户对此记录是否有权限
If UserUnit<>Unit Then '单位不同返回1
RightsForOne=1
Else
If UserDept=Dept Then '部门相同
If UserZhiBie=1 Then '如果用户是领导返回3
RightsForOne=3
Else
If LoginName=InputLoginName Then '如果用户是项目录入者返回3
RightsForOne=3
Else
RightsForOne=2
End If
End If
Else '部门不相同
If UserDept=0 Then '如果用户是领导
If UserFGDept="" Then '如果没有分管部门返回1
RightsForOne=1
Else
If Instr(1,UserFGDept,Dept,1) Then '如果此领导分管此部门返回3
RightsForOne=3
Else
If UserReadAtt="" Then '如果没有特殊浏览权限返回1
RightsForOne=1
Else
If Attribute="" Then '如果此记录的属性为空返回1
RightsForOne=1
Else
If CompTwoData(Attribute,UserFGDept) Then
'如果此记录属性包含用户特殊浏览权限返回2
RightsForOne=2
Else
RightsForOne=1
End If
End If
End If
End If
End If
Else '如果部门不同且用户不是领导
If UserReadAtt="" Then '如果没有特殊浏览权限返回1
RightsForOne=1
Else
If Attribute="" Then '如果此记录的属性为空返回1
RightsForOne=1
Else
If CompTwoData(Attribute,UserFGDept) Then
'如果此记录属性包含用户特殊浏览权限返回2
RightsForOne=2
Else
RightsForOne=1
End If
End If
End If
End If
End If
End If
End If
End If
Set tempRs=Nothing
End Function
Function CompTwoData(Data1,Data2)
If Not Instr(1,Data2,",",1) Then
If Instr(1,Data1,Data2,1) Then
CompTwoData=True
Else
CompTwoData=False
End If
Else
Do While Instr(1,Data2,",",1)
E=Instr(1,Data2,",",1)
Str=Mid(Data2,1,E-1)
If Instr(1,Data1,Str,1) Then
CompTwoData=True
Exit Function
End If
Data2=Replace(Data2,"","",E+1,1)
Loop
Str=Data2
If Instr(1,Data1,Str,1) then
CompTwoData=True
Else
CompTwoData=False
End If
End If
End Function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -