Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hey Umbraco
When trying to set the public access via the APi, my event just ends in a infinite loop.
After:
Access.AddMembershipRoleToDocument(doc.Id, memberRole);
it returns to
Document doc = sender;
and starts over...again...
Below is the full eventcode
public class SetAccess : ApplicationBase{ public SetAccess() { Document.BeforePublish += Document_BeforePublish; } private void Document_BeforePublish(Document sender, PublishEventArgs e) { Document doc = sender; var MemberGroups = new List<string> { "DefaultGroup" }; if (doc.getProperty("groupOne").Value.ToString() == "1") { MemberGroups.Add("groupOneDpt1"); MemberGroups.Add("groupOneDpt2"); MemberGroups.Add("groupOneDpt3"); } if (doc.getProperty("groupTwo").Value.ToString() == "1") { MemberGroups.Add("groupTwoDpt1"); MemberGroups.Add("groupTwoDpt2"); MemberGroups.Add("groupTwoDpt3"); } int loginDocID = LOGIN_PAGE_ID; int errorDocID = ERROR_PAGE_ID; Access.ProtectPage(false, doc.Id, loginDocID, errorDocID); foreach (string memberRole in MemberGroups) { Access.AddMembershipRoleToDocument(doc.Id, memberRole); } doc.Publish(new User(0)); library.UpdateDocumentCache(doc.Id); }}
Been using this as inspiration
http://our.umbraco.org/forum/developers/api-questions/5669-Setting-Public-Access-on-a-node-programatically
To make it easy for the editors, I've created two true/false on the document, so the editor only needs to check this, to set the access-rights on a node before publish
Anyone ?
Oh DAMN! Rookie mistake.....
Second to last line.....
doc.Publish = run Before.Publish method....over and over again... well...
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Setting Public Acces Programmaticly ends in loop
Hey Umbraco
When trying to set the public access via the APi, my event just ends in a infinite loop.
After:
it returns to
and starts over...again...
Below is the full eventcode
Been using this as inspiration
http://our.umbraco.org/forum/developers/api-questions/5669-Setting-Public-Access-on-a-node-programatically
To make it easy for the editors, I've created two true/false on the document, so the editor only needs to check this, to set the access-rights on a node before publish
Anyone ?
Oh DAMN! Rookie mistake.....
Second to last line.....
doc.Publish = run Before.Publish method....over and over again... well...
is working on a reply...