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;
}
}
}
}
}samborn
07/22/2024, 5:47 PMJanae
07/22/2024, 5:50 PM