SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.View_CommunityJoinForum    Script Date: 2013-11-13 7:11:51 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[View_CommunityJoinForum]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[View_CommunityJoinForum]
GO

--===============================================================================
--==将 Forum 表中的 CommunityID  和 本身的 ID 结合起来形成一个新组合 ID，这样返回的记录用来作为 Community 和 Forum 级联选择时候的数据孤岛，
--==从 Community 中选择了一个记录， JavaScript 会从该数据孤岛中选取该 Community 对应的所有 Forum 填充到 Forum 选择框
--===============================================================================
--==版权所有 2001-2010 锐商企业CMS （COMSHARP CMS）- http://www.comsharp.com
--==最新修改 2008-10-20 
--==目前该 View 没有启用 （2010-11-24：UserAccountUI.cs.Render.Query 对该 View 的调用已经取消，该 View 暂时预留）
--===============================================================================

CREATE VIEW dbo.View_CommunityJoinForum
AS

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

--====================================================
--==返回
--====================================================
SELECT  TOP 100 PERCENT 

	fr.[ID] AS [ID],
	 (CONVERT(NVARCHAR(20),fr.CommunityID) +N':'+CONVERT(NVARCHAR(20),fr.[ID]))   COLLATE database_default AS CommunityIDJoinForumID,
	fr.[Name] AS [Name]

FROM dbo.Forum fr

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ































GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GRANT  SELECT  ON [dbo].[View_CommunityJoinForum]  TO [public]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.View_KnowledgeTree    Script Date: 2013-11-13 7:11:51 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[View_KnowledgeTree]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[View_KnowledgeTree]
GO

--===============================================================================
--==将 MainDirectory, SubDirectory, PageDirectory, Knowledge 结合成一个含 ID, Parent....结构的记录集
--===============================================================================
--==版权所有 2001-2010 锐商企业CMS （COMSHARP CMS）- http://www.comsharp.com
--==最新修改 2010-08-22
--===============================================================================

CREATE VIEW dbo.View_KnowledgeTree
AS

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

--====================================================
--==返回
--====================================================
SELECT TOP 100 PERCENT

	md.[ID] AS [ID],
	0 AS KnowledgeID,
	md.[Name] AS [Name],
	0 AS Parent,
	md.Serial AS Serial,
	0 AS Home,
	0 AS Overview,
	N'' AS ParentDirectory,
	N'MainDirectory' AS Directory,
	N'SubDirectory' AS ChildDirectory,
	mdc.Title AS Title,
	mdc.Culture AS Culture,
	ISNULL(mdc.Hidden,0) AS Hidden,
	ISNULL(mdc.HiddenInNavigationOnly,0) AS HiddenInNavigationOnly

FROM dbo.MainDirectory md
LEFT JOIN dbo.MainDirectoryContent mdc ON mdc.MainDirectoryID=md.[ID]


UNION


SELECT TOP 100 PERCENT

	sd.[ID] AS [ID],
	0 AS KnowledgeID,
	sd.[Name] AS [Name],
	sd.MainDirectoryID AS Parent,
	sd.Serial AS Serial,
	0 AS Home,
	ISNULL(sd.Overview,0) AS Overview,
	N'MainDirectory' AS ParentDirectory,
	N'SubDirectory' AS Directory,
	N'PageDirectory' AS ChildDirectory,
	sdc.Title AS Title,
	sdc.Culture AS Culture,
	ISNULL(sdc.Hidden,0) AS Hidden,
	ISNULL(sdc.HiddenInNavigationOnly,0) AS HiddenInNavigationOnly

FROM dbo.SubDirectory sd
LEFT JOIN dbo.SubDirectoryContent sdc ON sdc.SubDirectoryID=sd.[ID]


UNION

	
SELECT TOP 100 PERCENT

	pd.[ID] AS [ID],
	0 AS KnowledgeID,
	pd.[Name] AS [Name],
	pd.SubDirectoryID AS Parent,
	pd.Serial AS Serial,
	ISNULL(pd.Home,0) AS Home,
	ISNULL(pd.Overview,0) AS Overview,
	N'SubDirectory' AS ParentDirectory,
	N'PageDirectory' AS Directory,
	N'Knowledge' AS ChildDirectory,
	pdc.Title AS Title,
	pdc.Culture AS Culture,
	ISNULL(pdc.Hidden,0) AS Hidden,
	ISNULL(pdc.HiddenInNavigationOnly,0) AS HiddenInNavigationOnly

FROM dbo.PageDirectory pd
LEFT JOIN dbo.PageDirectoryContent pdc ON pdc.PageDirectoryID=pd.[ID]


UNION 


SELECT TOP 100 PERCENT

	now.[ID] AS [ID],
	now.[ID] AS KnowledgeID,
	pd.[Name] AS [Name],
	now.PageDirectoryID AS Parent,
	now.Serial AS Serial,
	0 AS Home,
	0 AS Overview,
	N'PageDirectory' AS ParentDirectory,
	N'Knowledge' AS Directory,
	N'' AS ChildDirectory,
	nowc.Title AS Title,
	nowc.Culture AS Culture,
	ISNULL(nowc.Hidden,0) AS Hidden,
	0 AS HiddenInNavigationOnly

FROM dbo.Knowledge now
LEFT JOIN dbo.KnowledgeContent nowc ON nowc.KnowledgeID=now.[ID]
LEFT JOIN dbo.PageDirectory pd ON pd.[ID]=now.PageDirectoryID

--====================================================
--==使用 UNION 的时候，只有最后一个 UNION 语句才可以使用 ORDER BY
--====================================================
ORDER BY Serial


--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ





















































GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GRANT  SELECT  ON [dbo].[View_KnowledgeTree]  TO [public]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.View_CommunityTree    Script Date: 2013-11-13 7:11:51 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[View_CommunityTree]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[View_CommunityTree]
GO

--===============================================================================
--==将 Community, Forum 结合成一个含 ID, Parent....结构的记录集
--===============================================================================
--==版权所有 2001-2010 锐商企业CMS （COMSHARP CMS）- http://www.comsharp.com
--==最新修改 2010-04-08
--===============================================================================

CREATE VIEW dbo.View_CommunityTree
AS

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

--====================================================
--==返回
--====================================================
SELECT TOP 100 PERCENT

	co.[ID] AS [ID],
	0 AS Parent,
	co.Serial AS Serial,
	N'' AS ParentDirectory,
	N'Community' AS Directory,
	N'Forum' AS ChildDirectory,
	co.[Name] AS [Name],
	coc.Culture AS Culture,
	coc.Title AS Title,
	coc.[Description] AS [Description],
	ISNULL(coc.Hidden,0) AS Hidden

FROM dbo.Community co
LEFT JOIN dbo.CommunityContent coc ON coc.CommunityID=co.[ID]


UNION


SELECT TOP 100 PERCENT

	fo.[ID] AS [ID],
	fo.CommunityID AS Parent,
	fo.Serial AS Serial,
	N'Community' AS ParentDirectory,
	N'Forum' AS Directory,
	N'' AS ChildDirectory,
	fo.[Name] AS [Name],
	foc.Culture AS Culture,
	foc.Title AS Title,
	foc.[Description] AS [Description],
	ISNULL(foc.Hidden,0) AS Hidden

FROM dbo.Forum fo
LEFT JOIN dbo.ForumContent foc ON foc.ForumID=fo.[ID]


--====================================================
--==使用 UNION 的时候，只有最后一个 UNION 语句才可以使用 ORDER BY
--====================================================
ORDER BY Serial

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ











































GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GRANT  SELECT  ON [dbo].[View_CommunityTree]  TO [public]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.View_OptionCat    Script Date: 2013-11-13 7:11:51 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[View_OptionCat]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[View_OptionCat]
GO

--===============================================================================
--==从 Option / OptionContent 交叉表，返回所有 Option 的类别（不同语言下的）
--==将 en-us 下的作为 DefaultCulture，防止用户使用了本系统界面尚不支持的语种进行界面操作，比如，韩语，在韩语下进入系统管理 | 系统选项，将默认使用英文界面
--===============================================================================
--==版权所有 2001-2010 锐商企业CMS （COMSHARP CMS）- http://www.comsharp.com
--==最新修改 2009-03-01  
--===============================================================================

CREATE VIEW dbo.View_OptionCat
AS

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

--====================================================
--==返回
--====================================================
SELECT TOP 100 PERCENT 

	opt.Cat AS Cat,
	opt.RightIndent AS RightIndent,
	opc.CatTitle AS CatTitleWithSerial,
	RIGHT(opc.CatTitle,LEN(opc.CatTitle)-2) AS CatTitle,
	opc.Culture AS Culture,
	CASE opc.Culture WHEN N'en-us' THEN 1 ELSE 0 END AS CultureDefault

FROM dbo.[Option] opt
LEFT JOIN dbo.[OptionContent] opc ON opc.OptionID=opt.[ID]

GROUP BY opt.Cat,  opt.RightIndent,  opc.CatTitle,  RIGHT(opc.CatTitle,LEN(opc.CatTitle)-2),  opc.Culture
ORDER BY opc.CatTitle




















GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GRANT  SELECT  ON [dbo].[View_OptionCat]  TO [public]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.View_UserGroups    Script Date: 2013-11-13 7:11:51 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[View_UserGroups]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[View_UserGroups]
GO

--===============================================================================
--==将 UserGroup 和 UserGroups 两个表结合在一起
--===============================================================================
--==版权所有 2001-2010 锐商企业CMS （COMSHARP CMS）- http://www.comsharp.com
--==最新修改 2009-04-12 
--===============================================================================

CREATE VIEW dbo.View_UserGroups
AS

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

--====================================================
--==返回
--====================================================
SELECT

	ugs.[ID] AS [ID],
	ug.[ID] AS UserGroupID,
	ug.[GroupName] AS [GroupName],
	ugs.[User] AS [User]

FROM dbo.UserGroups ugs
INNER JOIN dbo.UserGroup ug ON ug.[ID]=ugs.UserGroupID





GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GRANT  SELECT  ON [dbo].[View_UserGroups]  TO [public]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.View_KnowledgePermission    Script Date: 2013-11-13 7:11:51 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[View_KnowledgePermission]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[View_KnowledgePermission]
GO

--===============================================================================
--==将 MainDirectory, SubDirectory, PageDirectory 的 DedicatedTo 和 CommentsPermission 强加到 Knowledge 的  DedicatedTo 和 CommentsPermission 上
--==在 MenuMainDirectorySubDirectoryPageDirectory 中调用以便根据 DedicatedTo 设置的访问权限，让系统知道该输出哪些目录结构
--===============================================================================
--==版权所有 2001-2010 锐商企业CMS （COMSHARP CMS）- http://www.comsharp.com
--==最新修改 2009-04-12 
--===============================================================================

CREATE VIEW dbo.View_KnowledgePermission

AS

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

--====================================================
--==返回
--==注意：这里使用 RIGHT JOIN 是为了照顾那些还没有输出内容（Knowledge）的 md, sd,pd； 如果使用 LEFT JOIN ，还没输入内容（Knowledge）的 md, sd, pd 就丢失了
--====================================================
SELECT
 
	md.[ID] AS MainDirectoryID,
	sd.[ID] AS SubDirectoryID,
	pd.[ID] AS PageDirectoryID,
	now.[ID] AS KnowledgeID,

	COALESCE(CONVERT(NVARCHAR(4000),md.DedicatedTo) + N',',N'') + 
	COALESCE(CONVERT(NVARCHAR(4000),sd.DedicatedTo) + N',',N'') + 
	COALESCE(CONVERT(NVARCHAR(4000),pd.DedicatedTo) + N',',N'') + 
	CONVERT(NVARCHAR(4000),ISNULL(now.DedicatedTo,N'')) AS DedicatedTo, 

	COALESCE(CONVERT(NVARCHAR(4000),md.CommentsPermission) + N',',N'') + 
	COALESCE(CONVERT(NVARCHAR(4000),sd.CommentsPermission) + N',',N'') + 
	COALESCE(CONVERT(NVARCHAR(4000),pd.CommentsPermission) + N',',N'') + 
	CONVERT(NVARCHAR(4000),ISNULL(now.CommentsPermission,N'')) AS CommentsPermission

FROM dbo.Knowledge now

RIGHT JOIN dbo.PageDirectory pd on pd.[ID]=now.PageDirectoryID
RIGHT JOIN dbo.SubDirectory sd on sd.[ID]=pd.SubDirectoryID
RIGHT JOIN dbo.MainDirectory md on md.[ID]=sd.MainDirectoryID

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ







GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GRANT  SELECT  ON [dbo].[View_KnowledgePermission]  TO [public]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.View_ForumPermission    Script Date: 2013-11-13 7:11:51 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[View_ForumPermission]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[View_ForumPermission]
GO

--===============================================================================
--==将 Community 的 Moderator, Public, ReadPermission, TopicWritePermission 和 FollowUpWritePermission 强加到 Forum  的  Moderator, Public, ReadPermission, TopicWritePermission 和 FollowUpWritePermission 上
--==在 MenuCommunityForum 中调用以便根据 Moderator, Public, ReadPermission, TopicWritePermission 和 FollowUpWritePermission 设置的访问权限，让系统知道该输出哪些 Community 和 Forum 项目
--===============================================================================
--==版权所有 2001-2010 锐商企业CMS （COMSHARP CMS）- http://www.comsharp.com
--==最新修改 2010-11-24 
--===============================================================================

CREATE VIEW dbo.View_ForumPermission

AS

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

--====================================================
--==返回
--==注意：这里使用 RIGHT JOIN 是为了照顾那些还没有 Forum 的 Community； 如果使用 LEFT JOIN ，还没有 Forum 的 Community  就丢失了 （这应该不可能发生）
--====================================================
SELECT
 
	co.[ID] AS CommunityID,
	fo.[ID] AS ForumID,

	COALESCE(CONVERT(NVARCHAR(4000),co.Moderator) + N',',N'') + 
	CONVERT(NVARCHAR(4000),ISNULL(fo.Moderator,N'')) AS Moderator, 

	COALESCE(CONVERT(NVARCHAR(4000),co.[Public]) + N',',N'') + 
	CONVERT(NVARCHAR(4000),ISNULL(fo.[Public],N'')) AS [Public], 

	COALESCE(CONVERT(NVARCHAR(4000),co.ReadPermission) + N',',N'') + 
	CONVERT(NVARCHAR(4000),ISNULL(fo.ReadPermission,N'')) AS ReadPermission, 

	COALESCE(CONVERT(NVARCHAR(4000),co.TopicWritePermission) + N',',N'') + 
	CONVERT(NVARCHAR(4000),ISNULL(fo.TopicWritePermission,N'')) AS TopicWritePermission,

	COALESCE(CONVERT(NVARCHAR(4000),co.FollowUpWritePermission) + N',',N'') + 
	CONVERT(NVARCHAR(4000),ISNULL(fo.FollowUpWritePermission,N'')) AS FollowUpWritePermission

FROM dbo.Forum fo

RIGHT JOIN dbo.Community co on co.[ID]=fo.CommunityID

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ










GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GRANT  SELECT  ON [dbo].[View_ForumPermission]  TO [public]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.View_ForumUiCustomization    Script Date: 2013-11-13 7:11:51 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[View_ForumUiCustomization]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[View_ForumUiCustomization]
GO

--===============================================================================
--==返回 ForumContent  的 CommandTitleTaskList, CommandTitleTaskListDescription ... 等设定
--==假如 ForumContent 中这些设置为空，则取其上级 CommunityContent 中的对应值
--==在 MenuCommunityForum 中调用
--===============================================================================
--==版权所有 2001-2010 锐商企业CMS （COMSHARP CMS）- http://www.comsharp.com
--==最新修改 2010-11-24 
--===============================================================================

CREATE VIEW dbo.View_ForumUiCustomization

AS

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

--====================================================
--==返回 （注：因为不可能发生 Community 下不存在 Forum 的情形，因此这里使用 LEFT JOIN 就可以了）
--====================================================
SELECT 

	co.[ID] AS CommunityID,
	fo.[ID] AS ForumID,
	coc.[ID] AS CommunityContentID,
	foc.[ID] AS ForumContentID,

	foc.Culture AS Culture,

	CASE	
		WHEN ISNULL(foc.CommandTitleTaskList,N'')=N'' THEN ISNULL(coc.CommandTitleTaskList,N'')
		ELSE ISNULL(foc.CommandTitleTaskList,N'')		
	END
	AS CommandTitleTaskList,

	CASE	
		WHEN ISNULL(foc.CommandTitleTaskListDescription,N'')=N'' THEN ISNULL(coc.CommandTitleTaskListDescription,N'')
		ELSE ISNULL(foc.CommandTitleTaskListDescription,N'')		
	END
	AS CommandTitleTaskListDescription,

	CASE	
		WHEN ISNULL(foc.CommandTitleAdd,N'')=N'' THEN ISNULL(coc.CommandTitleAdd,N'')
		ELSE ISNULL(foc.CommandTitleAdd,N'')		
	END
	AS CommandTitleAdd,

	CASE	
		WHEN ISNULL(foc.CommandTitleAddDescription,N'')=N'' THEN ISNULL(coc.CommandTitleAddDescription,N'')
		ELSE ISNULL(foc.CommandTitleAddDescription,N'')		
	END
	AS CommandTitleAddDescription,

	CASE	
		WHEN ISNULL(foc.CommandTitleQuery,N'')=N'' THEN ISNULL(coc.CommandTitleQuery,N'')
		ELSE ISNULL(foc.CommandTitleQuery,N'')		
	END
	AS CommandTitleQuery,

	CASE	
		WHEN ISNULL(foc.CommandTitleQueryDescription,N'')=N'' THEN ISNULL(coc.CommandTitleQueryDescription,N'')
		ELSE ISNULL(foc.CommandTitleQueryDescription,N'')		
	END
	AS CommandTitleQueryDescription,




	CASE	
		WHEN ISNULL(foc.TopicStatusCustomizationEmptyTopic,N'')=N'' THEN ISNULL(coc.TopicStatusCustomizationEmptyTopic,N'')
		ELSE ISNULL(foc.TopicStatusCustomizationEmptyTopic,N'')		
	END
	AS TopicStatusCustomizationEmptyTopic,

	CASE	
		WHEN ISNULL(foc.TopicStatusCustomizationSolidTopic,N'')=N'' THEN ISNULL(coc.TopicStatusCustomizationSolidTopic,N'')
		ELSE ISNULL(foc.TopicStatusCustomizationSolidTopic,N'')		
	END
	AS TopicStatusCustomizationSolidTopic,

	CASE	
		WHEN ISNULL(foc.TopicStatusCustomizationHotTopic,N'')=N'' THEN ISNULL(coc.TopicStatusCustomizationHotTopic,N'')
		ELSE ISNULL(foc.TopicStatusCustomizationHotTopic,N'')		
	END
	AS TopicStatusCustomizationHotTopic,

	CASE	
		WHEN ISNULL(foc.TopicStatusCustomizationEliteTopic,N'')=N'' THEN ISNULL(coc.TopicStatusCustomizationEliteTopic,N'')
		ELSE ISNULL(foc.TopicStatusCustomizationEliteTopic,N'')		
	END
	AS TopicStatusCustomizationEliteTopic,

	CASE	
		WHEN ISNULL(foc.TopicStatusCustomizationTabooTopic,N'')=N'' THEN ISNULL(coc.TopicStatusCustomizationTabooTopic,N'')
		ELSE ISNULL(foc.TopicStatusCustomizationTabooTopic,N'')		
	END
	AS TopicStatusCustomizationTabooTopic,

	CASE	
		WHEN ISNULL(foc.TopicStatusCustomizationStickyTopic,N'')=N'' THEN ISNULL(coc.TopicStatusCustomizationStickyTopic,N'')
		ELSE ISNULL(foc.TopicStatusCustomizationStickyTopic,N'')		
	END
	AS TopicStatusCustomizationStickyTopic,

	CASE	
		WHEN ISNULL(foc.TopicCommandSetEliteTopic,N'')=N'' THEN ISNULL(coc.TopicCommandSetEliteTopic,N'')
		ELSE ISNULL(foc.TopicCommandSetEliteTopic,N'')		
	END
	AS TopicCommandSetEliteTopic,

	CASE	
		WHEN ISNULL(foc.TopicCommandSetTabooTopic,N'')=N'' THEN ISNULL(coc.TopicCommandSetTabooTopic,N'')
		ELSE ISNULL(foc.TopicCommandSetTabooTopic,N'')		
	END
	AS TopicCommandSetTabooTopic,

	CASE	
		WHEN ISNULL(foc.TopicCommandSetStickyTopic,N'')=N'' THEN ISNULL(coc.TopicCommandSetStickyTopic,N'')
		ELSE ISNULL(foc.TopicCommandSetStickyTopic,N'')		
	END
	AS TopicCommandSetStickyTopic


FROM dbo.ForumContent foc
LEFT JOIN dbo.Forum fo ON fo.[ID]=foc.ForumID

LEFT JOIN dbo.Community co ON co.[ID]=fo.CommunityID
LEFT JOIN dbo.CommunityContent coc ON coc.[CommunityID]=co.[ID] AND coc.Culture=foc.Culture

--ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ













GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GRANT  SELECT  ON [dbo].[View_ForumUiCustomization]  TO [public]
GO

