Dictionary items - prevent deleting for certain users
Hi,
I would like to disable deleting dictionary items for certain user group. While LocalizationService Events not realy delete dictionary item - backend notification still shows build-in message and not mine. Dictionary item first dissapeared from the tree - till next tree refresh. But this is confusing for editor, because he thinks that item has been deleted, but has been not. Here is the code. Any hint?
private void DeletingDictionaryItem(ILocalizationService sender, DeleteEventArgs<IDictionaryItem> e)
{
bool isEditorPlus = false;
var userService = ApplicationContext.Current.Services.UserService;
var currentUser = userService.GetByUsername(HttpContext.Current.User.Identity.Name);
foreach (var group in currentUser.Groups)
{
if (group.Alias.ToLower() == "editorplus")
{
isEditorPlus = true;
}
}
if (isEditorPlus)
{
e.CancelOperation(new EventMessage("Restricted", "User cannot delete dictionary items!", EventMessageType.Error));
//e.Cancel = true;
// neither this work
//e.Messages.Add(new EventMessage("Restricted", "User cannot delete dictionary items!", EventMessageType.Error));
}
}
Dictionary items - prevent deleting for certain users
Hi,
I would like to disable deleting dictionary items for certain user group. While LocalizationService Events not realy delete dictionary item - backend notification still shows build-in message and not mine. Dictionary item first dissapeared from the tree - till next tree refresh. But this is confusing for editor, because he thinks that item has been deleted, but has been not. Here is the code. Any hint?
EventMessage never appears...
Regards,
/Asembli
is working on a reply...