From 4946252f7e9324de891481c2587298355e6bba6e Mon Sep 17 00:00:00 2001 From: Daniel Lackenby Date: Tue, 17 Nov 2015 15:47:41 +0000 Subject: [PATCH 1/2] Filter out when no contentTypeNames provided Previously, when no content type names where provided (from a prior conditional statement, so there is an initialized array but it is empty) then the filtering steps are skipped and instead of serving "no content types", as an empty array would state: all content types are served. When contentTypeNamed.Length == 0, still .Select() as this is safe for empty collections and will filter out all types in this event. --- src/Orchard/ContentManagement/DefaultContentQuery.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard/ContentManagement/DefaultContentQuery.cs b/src/Orchard/ContentManagement/DefaultContentQuery.cs index befcd03aa..a1cf3ad4f 100644 --- a/src/Orchard/ContentManagement/DefaultContentQuery.cs +++ b/src/Orchard/ContentManagement/DefaultContentQuery.cs @@ -92,7 +92,7 @@ namespace Orchard.ContentManagement { } private void ForType(params string[] contentTypeNames) { - if (contentTypeNames != null && contentTypeNames.Length != 0) { + if (contentTypeNames != null) { var contentTypeIds = contentTypeNames.Select(GetContentTypeRecordId).ToArray(); // don't use the IN operator if not needed for performance reasons if (contentTypeNames.Length == 1) { From c6b1754bd788dc0bc9a4f9d32ad386cf3303281a Mon Sep 17 00:00:00 2001 From: Daniel Lackenby Date: Wed, 18 Nov 2015 16:08:50 +0000 Subject: [PATCH 2/2] Limit Admin Menu for Content Limit the Content Menu item by whether you have the base Permission EditOwnContent. EditContent implies EditOwnContent so either permission (which you need at least one of to do any management of content be it create or edit) will allow this menu item to display. --- src/Orchard.Web/Core/Contents/AdminMenu.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Orchard.Web/Core/Contents/AdminMenu.cs b/src/Orchard.Web/Core/Contents/AdminMenu.cs index b95bf0561..7feb18d7f 100644 --- a/src/Orchard.Web/Core/Contents/AdminMenu.cs +++ b/src/Orchard.Web/Core/Contents/AdminMenu.cs @@ -22,6 +22,7 @@ namespace Orchard.Core.Contents { var contentTypeDefinitions = _contentDefinitionManager.ListTypeDefinitions().OrderBy(d => d.Name); builder.AddImageSet("content") .Add(T("Content"), "1.4", menu => menu + .Permission(Permissions.EditOwnContent) .Add(T("Content Items"), "1", item => item.Action("List", "Admin", new { area = "Contents", id = "" }).LocalNav())); var contentTypes = contentTypeDefinitions.Where(ctd => ctd.Settings.GetModel().Creatable).OrderBy(ctd => ctd.DisplayName); if (contentTypes.Any()) {