I could be being blind, but is there a permission to stop users from "Unpublishing" pages? There is one for publish but I couldn't spot one the other way.
I'm doing this as well with content events. Especially to prevent users from unpublishing or deleting nodes that are needed for a functioning website (e.g. homepage)
Here is the code I have :
public class BootManager : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentService.UnPublishing += this.ContentServiceOnUnPublishing;
}
private void ContentServiceOnUnPublishing(IPublishingStrategy sender, PublishEventArgs<IContent> publishEventArgs)
{
var doctypes = new[]
{
"Website",
"Homepage"
};
foreach (var entity in publishEventArgs.PublishedEntities)
{
if (doctypes.Contains(entity.ContentType.Alias))
{
publishEventArgs.CancelOperation(new EventMessage("Warning", "This page can not be unpublished", EventMessageType.Warning));
}
}
}
}
You can see i'm trying to show a warning message to the user when the unpublish is cancelled. However that is not working because of bug in Umbraco. The unpublishing is cancelled, but you don't have feedback to the user
Prevent users from Unpublishing
Hi All,
I could be being blind, but is there a permission to stop users from "Unpublishing" pages? There is one for publish but I couldn't spot one the other way.
Nik
Nik,
In the past we have done this with content events so on the before unpublish you cancel the publish.
Regards
Ismail
Hi Nik,
I'm doing this as well with content events. Especially to prevent users from unpublishing or deleting nodes that are needed for a functioning website (e.g. homepage)
Here is the code I have :
You can see i'm trying to show a warning message to the user when the unpublish is cancelled. However that is not working because of bug in Umbraco. The unpublishing is cancelled, but you don't have feedback to the user
The bug is found here : http://issues.umbraco.org/issue/U4-7757
Vote it up if you wan't to have it fixed.
Dave
I also have this issue in 7.5.4 when trying to CancelOperation for a Media trashing event.
is working on a reply...