cs_system_usercanreadsection.prc

来自「community server 源码」· PRC 代码 · 共 55 行

PRC
55
字号
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[cs_system_UserCanReadSection]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[cs_system_UserCanReadSection]
GO

CREATE PROCEDURE [dbo].cs_system_UserCanReadSection
(
	@UserID int,
	@SectionID int,
	@SettingsID int
)
AS
/*
Figure out if an user has View or Read access permissions on provided Section ID.
*/
SET Transaction Isolation Level Read UNCOMMITTED
BEGIN

DECLARE @HasAccess bit
 
-- Set default values
SET @HasAccess = 0

-- Has view & read access permission?
IF EXISTS(
	SELECT TOP 1 
		UserID
	FROM
		cs_vw_UsersInRoles ur
		INNER JOIN cs_SectionPermissions sp ON ur.RoleId = sp.RoleID AND sp.SettingsID = @SettingsID
	WHERE
		ur.UserID = @UserID AND 
		sp.SectionID = @SectionID AND
		sp.AllowMask & convert(bigint, 0x0000000000000001) = convert(bigint, 0x0000000000000001) AND
    sp.AllowMask & convert(bigint, 0x0000000000000002) = convert(bigint, 0x0000000000000002)
)	
	SET @HasAccess = 1

RETURN @HasAccess

END

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

grant execute on [dbo].[cs_system_UserCanReadSection] to public

⌨️ 快捷键说明

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