From b4ec14747bfd8e40dfb196f0ce7d595ec071bfa6 Mon Sep 17 00:00:00 2001 From: Suha Can Date: Mon, 11 Apr 2011 11:47:17 -0700 Subject: [PATCH 1/2] Contribution by wmild to fix bug #17119. --HG-- branch : contributions --- .../Modules/Orchard.Media/Controllers/AdminController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Orchard.Web/Modules/Orchard.Media/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Media/Controllers/AdminController.cs index e3d7ad359..ef4087ea5 100644 --- a/src/Orchard.Web/Modules/Orchard.Media/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Media/Controllers/AdminController.cs @@ -41,6 +41,8 @@ namespace Orchard.Media.Controllers { foreach (string key in input.Keys) { if (key.StartsWith("Checkbox.") && input[key] == "true") { string folderName = key.Substring("Checkbox.".Length); + if (!Services.Authorizer.Authorize(Permissions.ManageMedia, T("Couldn't delete media folder"))) + return new HttpUnauthorizedResult(); _mediaService.DeleteFolder(folderName); } } From 891695b32821fbc537e11268d306a72036144d0c Mon Sep 17 00:00:00 2001 From: Suha Can Date: Mon, 9 May 2011 10:08:00 -0700 Subject: [PATCH 2/2] Contribution by sfmskywalker. As a theme developer we need to be able to override widget rendering (not widget the wrapper, but contenttypes that are sterotyped as a widget, e.g. RecentBlogPosts). This adds a new feature WidgetAlternates in the Orchard.DesignerTools module. --HG-- branch : contributions --- .../Modules/Orchard.DesignerTools/Module.txt | 9 +++-- .../Orchard.DesignerTools.csproj | 5 +++ .../Services/WidgetAlternatesFactory.cs | 34 +++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/Orchard.Web/Modules/Orchard.DesignerTools/Services/WidgetAlternatesFactory.cs diff --git a/src/Orchard.Web/Modules/Orchard.DesignerTools/Module.txt b/src/Orchard.Web/Modules/Orchard.DesignerTools/Module.txt index 80761c299..9fa065e27 100644 --- a/src/Orchard.Web/Modules/Orchard.DesignerTools/Module.txt +++ b/src/Orchard.Web/Modules/Orchard.DesignerTools/Module.txt @@ -2,8 +2,8 @@ Name: Designer Tools AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.0 -OrchardVersion: 1.0 +Version: 1.0.20 +OrchardVersion: 1.0.20 Description: Contains designer tools to ease the Themes development process FeatureName: Shape Tracing Category: Designer @@ -14,3 +14,8 @@ Features: Name: Url Alternates Category: Designer Description: Adds shape alternates for specific urls + WidgetAlternates: + Name: Widget Alternates + Category: Designer + Description: Adds shape alternates for content types stereotyped as widgets, allowing to customize shapes by widget and zone + Dependencies: Orchard.Widgets diff --git a/src/Orchard.Web/Modules/Orchard.DesignerTools/Orchard.DesignerTools.csproj b/src/Orchard.Web/Modules/Orchard.DesignerTools/Orchard.DesignerTools.csproj index b448d7a46..52f2ac387 100644 --- a/src/Orchard.Web/Modules/Orchard.DesignerTools/Orchard.DesignerTools.csproj +++ b/src/Orchard.Web/Modules/Orchard.DesignerTools/Orchard.DesignerTools.csproj @@ -99,6 +99,10 @@ {9916839C-39FC-4CEB-A5AF-89CA7E87119F} Orchard.Core + + {194D3CCC-1153-474D-8176-FDE8D7D0D0BD} + Orchard.Widgets + @@ -106,6 +110,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/WidgetAlternatesFactory.cs b/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/WidgetAlternatesFactory.cs new file mode 100644 index 000000000..03c8f3afd --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/WidgetAlternatesFactory.cs @@ -0,0 +1,34 @@ +using Orchard.DisplayManagement.Implementation; +using Orchard.Environment.Extensions; +using Orchard.ContentManagement; +using Orchard.Widgets.Models; + +namespace Orchard.DesignerTools.Services { + [OrchardFeature("WidgetAlternates")] + public class WidgetAlternatesFactory : ShapeDisplayEvents { + public override void Displaying(ShapeDisplayingContext context) { + context.ShapeMetadata.OnDisplaying(displayedContext => { + // We don't want the "Widget" content item itself, but the content item that consists of the Widget part (e.g. Parts.Blogs.RecentBlogPosts) + if (displayedContext.ShapeMetadata.Type != "Widget") { + ContentItem contentItem = displayedContext.Shape.ContentItem; + if (contentItem != null) { + // Is the contentItem a widget? (we could probably test for the stereotype setting, don't know if that is more efficient than selecting the WidgetPart) + var widgetPart = contentItem.As(); + if (widgetPart != null) { + var zoneName = widgetPart.Zone; + var shapeName = displayedContext.ShapeMetadata.Type; + var contentTypeName = contentItem.ContentType; + + // Add 2 alternates for flexible widget shape naming: + // [ShapeName]-[ZoneName].cshtml: (e.g. "Parts.Blogs.RecentBlogPosts-myZoneName.cshtml") + // [ContentTypeName]-[ZoneName].cshtml: (e.g. "RecentBlogPosts-myZoneName.cshtml") + displayedContext.ShapeMetadata.Alternates.Add(contentTypeName + "__" + zoneName); + displayedContext.ShapeMetadata.Alternates.Add(shapeName + "__" + zoneName); + } + } + } + }); + + } + } +} \ No newline at end of file