Last active
September 9, 2020 15:00
-
-
Save TimGeyssens/5e4e2a0cca5821fb69b17fc49e32e85a to your computer and use it in GitHub Desktop.
Revisions
-
TimGeyssens renamed this gist
Sep 9, 2020 . 1 changed file with 3 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,16 +17,10 @@ namespace MySite.Custom { [RuntimeLevel(MinLevel = RuntimeLevel.Run)] public class CustomEventComposer : ComponentComposer<CustomEventComponent> { } public class CustomEventComponent : IComponent { public void Initialize() { -
TimGeyssens revised this gist
Sep 9, 2020 . 1 changed file with 2 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,19 +32,10 @@ public void Initialize() { EditorModelEventManager.SendingContentModel += EditorModelEventManager_SendingContentModel; } private void EditorModelEventManager_SendingContentModel(System.Web.Http.Filters.HttpActionExecutedContext sender, EditorModelEventArgs<Umbraco.Web.Models.ContentEditing.ContentItemDisplay> e) { var identity = (UmbracoBackOfficeIdentity)System.Web.HttpContext.Current.User.Identity; -
TimGeyssens revised this gist
Sep 9, 2020 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -47,14 +47,12 @@ private void ContentService_Deleting(IContentService sender, DeleteEventArgs<Umb private void EditorModelEventManager_SendingContentModel(System.Web.Http.Filters.HttpActionExecutedContext sender, EditorModelEventArgs<Umbraco.Web.Models.ContentEditing.ContentItemDisplay> e) { var identity = (UmbracoBackOfficeIdentity)System.Web.HttpContext.Current.User.Identity; var currentUSer = Current.Services.UserService.GetByProviderKey(identity.Id); if (!currentUSer.Groups.Any(x => x.Alias == "admin")) { foreach (var variant in e.Model.Variants) variant.Tabs = variant.Tabs.Where(x => x.Label != "Admin"); } } -
TimGeyssens created this gist
Sep 9, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ using System.Web.Security; using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Events; using Umbraco.Core.Scoping; using Umbraco.Core.Services; using Umbraco.Core.Services.Implement; using System.Linq; using System; using Umbraco.Core.Security; using Umbraco.Web.Editors; using Umbraco.Web; using Umbraco.Web.Dashboards; using Umbraco.Web.PublishedModels; namespace MySite.Custom { [RuntimeLevel(MinLevel = RuntimeLevel.Run)] public class CustomComposer : IUserComposer { public void Compose(Composition composition) { composition.Components().Append<CustomComponent>(); } } public class CustomComponent : IComponent { public void Initialize() { EditorModelEventManager.SendingContentModel += EditorModelEventManager_SendingContentModel; ContentService.Deleting += ContentService_Deleting; } private void ContentService_Deleting(IContentService sender, DeleteEventArgs<Umbraco.Core.Models.IContent> e) { foreach(var entity in e.DeletedEntities) { if (entity.GetValue<bool>(AdminSettings.GetModelPropertyType(d => d.DontDelete).Alias)) e.Cancel = true; } } private void EditorModelEventManager_SendingContentModel(System.Web.Http.Filters.HttpActionExecutedContext sender, EditorModelEventArgs<Umbraco.Web.Models.ContentEditing.ContentItemDisplay> e) { var identity = (UmbracoBackOfficeIdentity)System.Web.HttpContext.Current.User.Identity; var currentUSer = Current.Services.UserService.GetByProviderKey(identity.Id); var canSeeAdminTab = currentUSer.Groups.Any(x => x.Alias == "admin"); foreach (var variant in e.Model.Variants) { if (!canSeeAdminTab) variant.Tabs = variant.Tabs.Where(x => x.Label != "Admin"); } } public void Terminate() { } } }