From e77286c45077cdd55ea66b81180e0f58ae4902c0 Mon Sep 17 00:00:00 2001 From: Luc Gosso Date: Thu, 12 Oct 2017 10:17:22 +0200 Subject: [PATCH] Issue #2 solved --- Properties/AssemblyInfo.cs | 4 ++-- QuickNavigatorItemProvider.cs | 42 ++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index f079318..39056ae 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0")] -[assembly: AssemblyFileVersion("1.2.0")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] diff --git a/QuickNavigatorItemProvider.cs b/QuickNavigatorItemProvider.cs index 0185b21..a3d5c77 100644 --- a/QuickNavigatorItemProvider.cs +++ b/QuickNavigatorItemProvider.cs @@ -47,7 +47,9 @@ public IDictionary GetMenuItems(ContentReference { if (!String.IsNullOrEmpty(item)) { - dictionary.Add(item, DoMagic(item, currentContent)); + var menu = DoMagic(item, currentContent); + if (menu!=null) + dictionary.Add(item, menu); } } @@ -73,31 +75,35 @@ private QuickNavigatorMenuItem DoMagic(string item, ContentReference currentCont return new QuickNavigatorMenuItem("Find", find, null, "true", null); } - if (HttpContext.Current.User.IsInRole("WebAdmins")) + + if (item == "admin") { - if (item == "admin") - { + if (!HttpContext.Current.User.IsInRole("WebAdmins")) + return null; - var editUrl = GetEditUrl() + EPiServer.Editor.PageEditing.GetEditUrl(currentContent); - editUrl = editUrl.Replace("#", "admin/#"); + var editUrl = GetEditUrl() + EPiServer.Editor.PageEditing.GetEditUrl(currentContent); + editUrl = editUrl.Replace("#", "admin/#"); - return new QuickNavigatorMenuItem("/shell/cms/menu/admin", editUrl, null, "true", null); - } + return new QuickNavigatorMenuItem("/shell/cms/menu/admin", editUrl, null, "true", null); + } - if (item == "contenttype") - { - var editUrl = GetEditUrl() + EPiServer.Editor.PageEditing.GetEditUrl(currentContent); + if (item == "contenttype") + { + if (!HttpContext.Current.User.IsInRole("WebAdmins")) + return null; + + var editUrl = GetEditUrl() + EPiServer.Editor.PageEditing.GetEditUrl(currentContent); - PageData pd = null; + PageData pd = null; - if (this.contentLoader.TryGet(currentContent, out pd)) - { - editUrl = editUrl.Replace("#", "admin/?customdefaultpage=admin/EditContentType.aspx?typeId=" + pd.ContentTypeID + "#"); - var n = LocalizationService.Current.GetString("/addon/quicknav/pagetype", "Admin pagetype") + " " + pd.PageTypeName; - return new QuickNavigatorMenuItem(n, editUrl, null, "true", null); - } + if (this.contentLoader.TryGet(currentContent, out pd)) + { + editUrl = editUrl.Replace("#", "admin/?customdefaultpage=admin/EditContentType.aspx?typeId=" + pd.ContentTypeID + "#"); + var n = LocalizationService.Current.GetString("/addon/quicknav/pagetype", "Admin pagetype") + " " + pd.PageTypeName; + return new QuickNavigatorMenuItem(n, editUrl, null, "true", null); } } + if (item == "logout") {