Advertisement
Advertisement
| 03.13.2008 at 07:14PM PDT, ID: 23240681 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: |
ALTER PROCEDURE [dbo].[GetDocumentLibraryDocumentDetailsByCriteria]
@CategoryIds nvarchar(50),
@ForPublic bit,
@UserId int
AS
BEGIN
CREATE TABLE #ValueList (ListValue int NOT NULL)
IF @CategoryIds IS NOT NULL AND @CategoryIds <> ''
BEGIN
declare @curPos int
declare @prevCurPos int
set @curPos = -1
set @prevCurPos = 1
While @curPos <>0
begin
set @curPos = charindex(',', @CategoryIds, @curPos + 1)
if @curPos <> 0
begin
insert into #ValueList values( CONVERT(int, substring(@CategoryIds, @prevCurPos, @curPos-@prevCurPos)) )
end
else
begin
insert into #ValueList values( CONVERT(int, substring(@CategoryIds, @prevCurPos, len(@CategoryIds)-@prevCurPos +1)) )
end
Set @prevCurPos = @curPos+1
end
END
SELECT * FROM DocumentLibraryDocumentDetails
WHERE DocumentLibraryDocumentDetailsId IN (SELECT DISTINCT DD.DocumentLibraryDocumentDetailsId FROM DocumentLibraryDocumentDetails DD
LEFT JOIN DocumentLibraryDocumentCategory DC ON DC.DocumentLibraryDocumentDetailsId = DD.DocumentLibraryDocumentDetailsId
LEFT JOIN DocumentLibraryCategory DLC ON DLC.DocumentLibraryCategoryId = DC.DocumentLibraryCategoryId
LEFT JOIN DocumentLibraryDocumentGroup DLDG ON DLDG.DocumentDetailsId = DD.DocumentLibraryDocumentDetailsId
WHERE
(@CategoryIds = '' OR @CategoryIds IS NULL
OR ((DC.[DocumentLibraryCategoryId]) IN (SELECT ListValue FROM #ValueList))
)
AND (
(@ForPublic = 1
AND ((DD.[InheritPermissions] = 0 AND
(
(SELECT COUNT(DU.UserId) FROM DocumentLibraryDocumentUser DU WHERE DU.DocumentLibraryDocumentDetailsId = DD.DocumentLibraryDocumentDetailsId) = 0
AND (SELECT COUNT(DG.GroupId) FROM DocumentLibraryDocumentGroup DG WHERE DG.DocumentDetailsId = DD.DocumentLibraryDocumentDetailsId) = 0
)
OR @UserId IN (SELECT DU.UserId FROM DocumentLibraryDocumentUser DU WHERE DU.DocumentLibraryDocumentDetailsId = DD.DocumentLibraryDocumentDetailsId)
OR @UserId IN (SELECT RGM.UserId FROM [RoleGroup] RG INNER JOIN [RoleGroupMember] RGM ON RGM.RoleGroupId = RG.RoleGroupId WHERE RG.RoleGroupId IN (SELECT DG.GroupId FROM DocumentLibraryDocumentGroup DG WHERE DG.DocumentDetailsId = DD.DocumentLibraryDocumentDetailsId))
)
OR (DD.[InheritPermissions] = 1 AND
(
(SELECT COUNT(DLCU.UserId) FROM DocumentLibraryCategoryUser DLCU WHERE DLCU.DocumentLibraryCategoryId = DLC.DocumentLibraryCategoryId OR DLCU.DocumentLibraryCategoryId = DLCP.DocumentLibraryCategoryId) = 0
AND (SELECT COUNT(DLCG.RoleGroupId) FROM DocumentLibraryCategoryRoleGroup DLCG WHERE DLCG.DocumentLibraryCategoryId = DLC.DocumentLibraryCategoryId OR DLCG.DocumentLibraryCategoryId = DLCP.DocumentLibraryCategoryId) = 0
)
OR @UserId IN (SELECT DLCU.UserId FROM DocumentLibraryCategoryUser DLCU WHERE DLCU.DocumentLibraryCategoryId = DLC.DocumentLibraryCategoryId OR DLCU.DocumentLibraryCategoryId = DLCP.DocumentLibraryCategoryId)
OR @UserId IN (SELECT RGM.UserId FROM [RoleGroup] RG INNER JOIN [RoleGroupMember] RGM ON RGM.RoleGroupId = RG.RoleGroupId WHERE RG.RoleGroupId IN (SELECT DLCG.RoleGroupId FROM DocumentLibraryCategoryRoleGroup DLCG WHERE DLCG.DocumentLibraryCategoryId = DLC.DocumentLibraryCategoryId OR DLCG.DocumentLibraryCategoryId = DLCP.DocumentLibraryCategoryId))
)
)
)
OR (@ForPublic <> 1)
)
)
END
|