I'm currently trying to cancel the saving of a stylesheet file.
For this i want to add a new event handler that gets called bevor saving of a stylesheet.
I tried it in two ways:
First one:
StyleSheet.BeforeSave += Stylesheet_BeforeSave;
private void Stylesheet_BeforeSave(StyleSheet sender, SaveEventArgs e)
{
//Do what you need to do. In this case logging to the Umbraco log
//Log.Add(LogTypes.Debug, sender.Id, "Test some properties of stylesheet " + sender.Text + ": " + sender.nodeObjectType);
//cancel the publishing if you want.
LockEntry myLock = this._db.SingleOrDefault<LockEntry>(sender.Id);
if (null != myLock)
{
Log.Add(LogTypes.Debug, sender.Id, "the stylesheet " + sender.Text + " has a lock");
if (myLock.UserId != User.GetCurrent().Id)
{
Log.Add(LogTypes.Debug, sender.Id, "the stylesheet " + sender.Text + " is locked by another user");
e.Cancel = true;
}
else
{
Log.Add(LogTypes.Debug, sender.Id, "the stylesheet " + sender.Text + " is about to be saved");
this._db.Delete(myLock);
sender.saveCssToFile();
}
}
else
{
Log.Add(LogTypes.Debug, sender.Id, "the stylesheet " + sender.Text + " has no lock: save file");
sender.saveCssToFile();
}
}
This makes use of the old event system. The event gets actually called. I set the cancel property of the SaveEventArgs but the Stylesheet gets saved.
Cancel saving of Stylesheet in Umbraco 6.1.3
Hi all,
I'm currently trying to cancel the saving of a stylesheet file. For this i want to add a new event handler that gets called bevor saving of a stylesheet.
I tried it in two ways:
First one:
This makes use of the old event system. The event gets actually called. I set the cancel property of the SaveEventArgs but the Stylesheet gets saved.
Second one:
This never gets called.
Any suggestions on how to cancel the saving? Try to create a basic lock feature as a prototype like the MyLock package does for content items.
Any help welcome.
is working on a reply...