diff --git a/src/Orchard.Tests/UI/Navigation/NavigationManagerTests.cs b/src/Orchard.Tests/UI/Navigation/NavigationManagerTests.cs index fe2a8c24b..a64c91417 100644 --- a/src/Orchard.Tests/UI/Navigation/NavigationManagerTests.cs +++ b/src/Orchard.Tests/UI/Navigation/NavigationManagerTests.cs @@ -5,6 +5,7 @@ using System.Web.Routing; using Autofac; using NUnit.Framework; using Orchard.ContentManagement; +using Orchard.Core.Navigation.Services; using Orchard.Data; using Orchard.Localization; using Orchard.Security; diff --git a/src/Orchard.Web/Core/Navigation/Security/ContentMenuItemAuthorizationEventHandler.cs b/src/Orchard.Web/Core/Navigation/Security/ContentMenuItemAuthorizationEventHandler.cs new file mode 100644 index 000000000..233575bd2 --- /dev/null +++ b/src/Orchard.Web/Core/Navigation/Security/ContentMenuItemAuthorizationEventHandler.cs @@ -0,0 +1,37 @@ + using System; +using System.Collections.Generic; +using System.Linq; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Aspects; +using Orchard.Core.Common.Models; + using Orchard.Core.Navigation.Models; + using Orchard.Security; + +namespace Orchard.Core.Navigation.Security { + public class ContentMenuItemAuthorizationEventHandler : IAuthorizationServiceEventHandler{ + private readonly IAuthorizationService _authorizationService; + + public ContentMenuItemAuthorizationEventHandler(IAuthorizationService authorizationService) { + _authorizationService = authorizationService; + } + + public void Checking(CheckAccessContext context) { } + public void Adjust(CheckAccessContext context) { } + + public void Complete(CheckAccessContext context) { + if (context.Content == null) { + return; + } + + var part = context.Content.As(); + + // if the content item has no right attached, check on the container + if (part == null) { + return; + } + + context.Granted = _authorizationService.TryCheckAccess(context.Permission, context.User, part.Content); + context.Adjusted = true; + } + } +} \ No newline at end of file diff --git a/src/Orchard/UI/Navigation/NavigationManager.cs b/src/Orchard.Web/Core/Navigation/Services/NavigationManager.cs similarity index 96% rename from src/Orchard/UI/Navigation/NavigationManager.cs rename to src/Orchard.Web/Core/Navigation/Services/NavigationManager.cs index 03df46a0a..43d27426e 100644 --- a/src/Orchard/UI/Navigation/NavigationManager.cs +++ b/src/Orchard.Web/Core/Navigation/Services/NavigationManager.cs @@ -7,10 +7,11 @@ using Orchard.ContentManagement; using Orchard.Logging; using Orchard.Security; using Orchard.Security.Permissions; -using Orchard.UI.Admin; +using Orchard.UI; +using Orchard.UI.Navigation; using Orchard.Utility; -namespace Orchard.UI.Navigation { +namespace Orchard.Core.Navigation.Services { public class NavigationManager : INavigationManager { private readonly IEnumerable _navigationProviders; private readonly IEnumerable _menuProviders; @@ -106,7 +107,7 @@ namespace Orchard.UI.Navigation { hasDebugShowAllMenuItems || // a content item is linked and the user can view it - item.Content != null && item.Permissions.Concat(new [] { Permission.Named("ViewContent") }).Any(x => _authorizationService.TryCheckAccess(x, _orchardServices.WorkContext.CurrentUser, item.Content)) || + item.Content != null && item.Permissions.Concat(new[] { Contents.Permissions.ViewContent }).Any(x => _authorizationService.TryCheckAccess(x, _orchardServices.WorkContext.CurrentUser, item.Content)) || // it's the admin menu and permissions are effective isAdminMenu && (!item.Permissions.Any() || item.Permissions.Any(x => _authorizationService.TryCheckAccess(x, _orchardServices.WorkContext.CurrentUser, null))) ) { diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index c0b0f0b24..a3579ca58 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -152,10 +152,12 @@ + + diff --git a/src/Orchard/Orchard.Framework.csproj b/src/Orchard/Orchard.Framework.csproj index 1020bb423..a998c0342 100644 --- a/src/Orchard/Orchard.Framework.csproj +++ b/src/Orchard/Orchard.Framework.csproj @@ -880,7 +880,6 @@ -