protected virtual void FireAfterAddProtection(Document doc, AddProtectionEventArgs e) { if (AfterAddProtection != null) { AfterAddProtection(doc, e); } }
protected virtual void FireBeforeAddProtection(Document doc, AddProtectionEventArgs e) { if (BeforeAddProtection != null) { BeforeAddProtection(doc, e); } }
public static void ProtectPage(bool Simple, int DocumentId, int LoginDocumentId, int ErrorDocumentId) { AddProtectionEventArgs e = new AddProtectionEventArgs(); new Access().FireBeforeAddProtection(new Document(DocumentId), e); if (!e.Cancel) { XmlElement x = (XmlElement)getPage(DocumentId); if (x == null) { x = (XmlElement)_accessXmlContent.CreateNode(XmlNodeType.Element, "page", ""); AccessXml.DocumentElement.AppendChild(x); } // if using simple mode, make sure that all existing groups are removed else if (Simple) { x.RemoveAll(); } x.SetAttribute("id", DocumentId.ToString()); x.SetAttribute("loginPage", LoginDocumentId.ToString()); x.SetAttribute("noRightsPage", ErrorDocumentId.ToString()); x.SetAttribute("simple", Simple.ToString()); save(); clearCheckPages(); new Access().FireAfterAddProtection(new Document(DocumentId), e); } }
public static void ProtectPage(bool Simple, int DocumentId, int LoginDocumentId, int ErrorDocumentId) { var doc = new Document(DocumentId); var e = new AddProtectionEventArgs(); new Access().FireBeforeAddProtection(doc, e); if (e.Cancel) { return; } var loginContent = ApplicationContext.Current.Services.ContentService.GetById(LoginDocumentId); if (loginContent == null) { throw new NullReferenceException("No content item found with id " + LoginDocumentId); } var noAccessContent = ApplicationContext.Current.Services.ContentService.GetById(ErrorDocumentId); if (noAccessContent == null) { throw new NullReferenceException("No content item found with id " + ErrorDocumentId); } var entry = ApplicationContext.Current.Services.PublicAccessService.GetEntryForContent(doc.ContentEntity.Id.ToString()); if (entry != null) { if (Simple) { // if using simple mode, make sure that all existing groups are removed entry.ClearRules(); } //ensure the correct ids are applied entry.LoginNodeId = loginContent.Id; entry.NoAccessNodeId = noAccessContent.Id; } else { entry = new PublicAccessEntry(doc.ContentEntity, ApplicationContext.Current.Services.ContentService.GetById(LoginDocumentId), ApplicationContext.Current.Services.ContentService.GetById(ErrorDocumentId), new List <PublicAccessRule>()); } if (ApplicationContext.Current.Services.PublicAccessService.Save(entry)) { Save(); new Access().FireAfterAddProtection(new Document(DocumentId), e); } }
protected virtual void FireAfterAddProtection(Document doc, AddProtectionEventArgs e) { if (AfterAddProtection != null) AfterAddProtection(doc, e); }
protected virtual void FireBeforeAddProtection(Document doc, AddProtectionEventArgs e) { if (BeforeAddProtection != null) BeforeAddProtection(doc, e); }