samborn
07/11/2024, 11:15 AMpublic class EditorSendingContentNotificationHandler : INotificationHandler<SendingContentNotification>
{
private readonly IBackOfficeSecurityAccessor _backOfficeSecurity;
public EditorSendingContentNotificationHandler(
IBackOfficeSecurityAccessor backOfficeSecurity)
{
_backOfficeSecurity = backOfficeSecurity;
}
public void Handle(SendingContentNotification notification)
{
if (notification.Content.ContentTypeAlias.Equals("mygrid"))
{
if(!( _backOfficeSecurity?.BackOfficeSecurity?.CurrentUser.Groups.Any(x=>x.Alias.Equals("admin")))){
makeBlockGridReadOnly(notification.Content, new List<string>{"blocks", "testblock"});
}
}
private void makeBlockGridReadOnly(ContentItemDisplay contentItemDisplay, List<string> propertyAlias)
{
if(propertyAlias.Any())
{
foreach(var tab in contentItemDisplay.Variants.FirstOrDefault().Tabs)
{
foreach(var prop in tab.properties)
{
if(propertyAlias.Contains(prop.Alias) && prop.View.Contains("blockgrid"))
{
prop.Readonly = true;
}
}
}
}
}
https://cdn.discordapp.com/attachments/1260917308587638804/1260917308780449813/Blockgrid.png?ex=66911041&is=668fbec1&hm=194519dc5ae8aaa5065f81637c78ff2de51f7c315a7a89b97b17d051acfabc6c&samborn
07/22/2024, 5:47 PMJanae
07/22/2024, 5:50 PM