⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logic_role.asp

📁 学习管理 校友录有关的系统 本人学习的结果 与大家共享
💻 ASP
字号:
<%
''===================================================================
'= ASP FILENAME	: /inc/logic/logic_role.asp
'= CREATED TIME : 2006-5-3
'= LAST MODIFIED: 2006-5-3
'= VERSION INFO : CCASP Framework Ver 2.0.1 ALL RIGHTS RESERVED BY www.cclinux.com
'= DESCRIPTION  : 权限管理逻辑
'= Change Log:
'==================================================================='
%>

<%
'== 常量定义
Const CONST_ROLE_DEFAULT = 1		'== 缺省用户权限
Const CONST_ROLE_NORMAL = 0			'== 一般用户权限

Const CONST_ACTION_VIEW = 0			'== 浏览型请求
Const CONST_ACTION_EXEC = 1			'== 执行型请求

''===================================================================
'= Function    : GetRolesLogic()
'= Time		   : Created At 2006-5-5
'= Input	   : strWhere : 符合条件
'= Return      : boolean
'= Description : 取用户权限记录集
'==================================================================='
Function GetRolesLogic(strWhere)
	GBL_objPubDB.Clear()
	GBL_objPubDB.AllSQL = "SELECT * FROM CLASS_ROLE WHERE 1=1 " & strWhere & " ORDER BY ROLE_ID DESC"
	If Not GBL_objPubDB.SQLRSExecute() Then
		GetRolesLogic = False
		Exit Function
	End If
	GetRolesLogic = True
End Function

''===================================================================
'= Function    : GetRoleLogic()
'= Time		   : Created At 2006-5-5
'= Input	   : strWhere : 符合条件
'= Return      : boolean
'= Description : 取用户权限记录
'==================================================================='
Function GetRoleLogic(strWhere)
	GBL_objPubDB.Clear()
	GBL_objPubDB.AllSQL = "SELECT ROLE_NAME,ROLE_DESC,ROLE_ADD_TIME FROM CLASS_ROLE WHERE 1=1" & strWhere
	If Not GBL_objPubDB.SQLRSExecute() Then
		GetRoleLogic = False
		Exit Function
	End If
	GetRoleLogic = True
End Function

''===================================================================
'= Function    : GetActionsLogic()
'= Time		   : Created At 2006-5-5
'= Input	   : strWhere : 符合条件
'= Return      : boolean
'= Description : 取页面请求记录集
'==================================================================='
Function GetActionsLogic(strWhere)
	GBL_objPubDB.Clear()
	GBL_objPubDB.AllSQL = "SELECT * FROM CLASS_ACTION WHERE 1=1 " & strWhere & " ORDER BY ACTION_ID DESC"
	If Not GBL_objPubDB.SQLRSExecute() Then
		GetActionsLogic = False
		Exit Function
	End If
	GetActionsLogic = True
End Function

''===================================================================
'= Function    : RemoveRolesLogic()
'= Time		   : Created At 2006-5-5
'= Input	   : strWhere : 符合条件
'= Return      : boolean
'= Description : 删除用户权限
'==================================================================='
Function RemoveRolesLogic(strWhere)
	'== 默认记录不能删除
	If Not GetRolesLogic(strWhere &" AND ROLE_IS_DEFAULT=" & CONST_ROLE_DEFAULT) Then
		RemoveRolesLogic = False	
		Exit Function
	End If
	If GBL_objPubDB.intRSNum > 0 Then
		Call GBL_objException.catchErr(E_USER_PUB,"缺省的用户权限不能删除")
		RemoveRolesLogic = False
		Exit Function
	End If

	'== 判断是否用户使用
	'== 删除操作表
	GBL_objPubDB.Clear()
	GBL_objPubDB.TableName = "CLASS_MANAGE"
	GBL_objPubDB.SQLType = "DELETE"
	GBL_objPubDB.Where = " MANAGE_ROLE_ID IN (SELECT ROLE_ID FROM CLASS_ROLE WHERE 1=1 " & strWhere & ")"
	If Not GBL_objPubDB.SQLRSExecute() Then
		RemoveRolesLogic = False
		Exit Function
	End If

	'==删除本表
	GBL_objPubDB.Clear()
	GBL_objPubDB.TableName = "CLASS_ROLE"
	GBL_objPubDB.SQLType = "DELETE"
	GBL_objPubDB.Where = "1=1 " & strWhere
	If Not GBL_objPubDB.SQLRSExecute() Then
		RemoveRolesLogic = False
		Exit Function
	End If
	RemoveRolesLogic = True
End Function

''===================================================================
'= Function    : SaveRoleLogic()
'= Time		   : Created At 2006-5-5
'= Input	   : intRoleId : Role ID ""--add other--edit
'= Return      : boolean
'= Description : 添加/编辑用户权限
'==================================================================='
Function SaveRoleLogic(intRoleId,objFormData)
	Dim strName,strDesc,strSql

	'== 获取数据
	strName = objFormData.Item("Name")
	strDesc = objFormData.Item("Desc")

	'== 是否重复
	strSql = " AND ROLE_NAME='" & strName & "' "
	If intRoleId <> "" Then strSql = strSql & " AND ROLE_ID <> " & intRoleId 
	If Not GetRoleLogic(strSql) Then
		SaveRoleLogic = False
		Exit Function
	End If
	If GBL_objPubDB.intRSNum > 0 Then
		Call GBL_objException.catchErr(E_USER_PUB,"该用户权限名(" & strName & ")已存在")
		SaveRoleLogic = False
		Exit Function
	End If

	GBL_objPubDB.Clear()
	GBL_objPubDB.TableName = "CLASS_ROLE"
	If intRoleId = "" Then
		GBL_objPubDB.SQLType = "INSERT"
		GBL_objPubDB.AddField "ROLE_ADD_TIME",Now()
		GBL_objPubDB.AddField "ROLE_ADD_ADMIN_ID",GBL_intAdminId
	Else
		GBL_objPubDB.SQLType = "UPDATE"
	End If
	GBL_objPubDB.AddField "ROLE_NAME",strName
	GBL_objPubDB.AddField "ROLE_DESC",strDesc
	GBL_objPubDB.AddField "ROLE_LAST_TIME",Now()
	GBL_objPubDB.AddField "ROLE_IS_DEFAULT",CONST_ROLE_NORMAL
	GBL_objPubDB.AddField "ROLE_LAST_ADMIN_ID",GBL_intAdminId
	If intRoleId <> "" Then GBL_objPubDB.Where = "ADMIN_ID=" & intAdminId
	If Not GBL_objPubDB.SQLRSExecute() Then
		SaveRoleLogic = False
		Exit Function
	End If
	SaveRoleLogic = True
End Function

''===================================================================
'= Function    : GetRoleActionStrLogic()
'= Time		   : Created At 2006-5-5
'= Input	   : intRoleId : Role ID 
'= Input	   : strRoleAction : 构造请求字符串
'= Return      : boolean
'= Description : 构造权限请求字符串
'==================================================================='
Function GetRoleActionStrLogic(intRoleId,ByRef strRoleAction)
	GBL_objPubDB.Clear()
	GBL_objPubDB.TableName = "CLASS_MANAGE"
	GBL_objPubDB.SQLType = "SELECT"
	GBL_objPubDB.AddField "MANAGE_ACTION_ID",""
	GBL_objPubDB.Where = "MANAGE_ROLE_ID=" & intRoleId
	If Not GBL_objPubDB.SQLRSExecute() Then
		GetRoleActionStrLogic = False
		Exit Function
	End If
	strRoleAction = ""
	While Not GBL_objPubDB.objPubRS.Eof	
		strRoleAction = strRoleAction & "|" & GBL_objPubDB.objPubRS("MANAGE_ACTION_ID")
		GBL_objPubDB.objPubRS.MoveNext
	Wend
	GetRoleActionStrLogic = True
End Function

''===================================================================
'= Function    : RoleActionCheck()
'= Time		   : Created At 2006-5-5
'= Input	   : intActionId : Acton ID 
'= Input	   : strRoleAction : 请求字符串
'= Return      : boolean
'= Description : 权限请求分配中中选checkbox
'==================================================================='
Function RoleActionCheck(intActionId,strRoleAction)
	strRoleAction = strRoleAction & "|"
	intActionId = "|" & intActionId & "|"
	If Instr(strRoleAction,intActionId) > 0 Then
		RoleActionCheck = " checked "
		Exit Function
	End If
End Function

''===================================================================
'= Function    : SaveUserActonsLogic()
'= Time		   : Created At 2006-5-5
'= Input	   : intActionId : Acton ID 
'= Input	   : strIds : 
'= Return      : boolean
'= Description : 保存用户权限
'==================================================================='
Function SaveUserActonsLogic(intRoleId,strIds)
	Dim arrIds,i
	'== 删除目前权限请求
	GBL_objPubDB.Clear()
	GBL_objPubDB.TableName = "CLASS_MANAGE"
	GBL_objPubDB.SQLType = "DELETE"
	GBL_objPubDB.Where = "MANAGE_ROLE_ID=" & intRoleId
	If Not GBL_objPubDB.SQLRSExecute() Then
		SaveUserActonsLogic = False
		Exit Function
	End If
	'== 插入新权限请求
	arrIds = Split(strIds,",")
	For i = Lbound(arrIds) To UBound(arrIds)
		GBL_objPubDB.Clear()
		GBL_objPubDB.TableName = "CLASS_MANAGE"
		GBL_objPubDB.SQLType = "INSERT"
		GBL_objPubDB.AddField "MANAGE_ROLE_ID",intRoleId
		GBL_objPubDB.AddField "MANAGE_ACTION_ID",arrIds(i)
		GBL_objPubDB.AddField "MANAGE_ADD_TIME",Now()
		GBL_objPubDB.AddField "MANAGE_ADD_ADMIN_ID",GBL_intAdminId
		If Not GBL_objPubDB.SQLExecute() Then
			SaveUserActonsLogic = False
			Exit Function
		End If
	Next
	SaveUserActonsLogic = True
End Function

''===================================================================
'= Function    : GetActionTypeLogic()
'= Time		   : Created At 2006-5-13
'= Input	   : intType : 请求数字
'= Return      : 请求的中文含义
'= Description : 取请求
'==================================================================='
Function GetActionTypeLogic(intType)
	Dim strTmp
	Select Case intType
		Case CONST_ACTION_VIEW:
			strTmp = "浏览型"
		Case CONST_ACTION_EXEC::
			strTmp = "执行型"
	End Select
	GetActionTypeLogic = strTmp
End Function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -