On 02/24/2011 04:58 PM, Lukapt wrote: > > Hi, > > I'm trying to set rights over a document automatically. > > In my wiki i have the "Publication" concept. Each Publication has one or > more authors. Each author is an "Researcher" that is directly related to an > XWikiUser. What I want to do is to set editing rights only for the authors > of that publication. If I add (or remove) an author he should be able (not > able) to edit the document. > > What i thought first was to check and add user rights every time the > document was loaded. However this didn't worked because, initially, users > don't have rights to add new rights (lol). That doesn't seemed a good > practice anyway. > > What is the best way to do this? Maybe after every change in editing mode, > system may apply the rights? How can I do that?
With a Groovy listener. See this tutorial for a starting point: http://platform.xwiki.org/xwiki/bin/DevGuide/GroovyNotificationTutorial Or you can go low level and write a Java component that does the same thing, this should be a bit more bulletproof (you have to register the groovy listener when the wiki restarts). An alternative is not to update rights when changing the document, but to plug in a different XWikiRightsService implementation that checks the authors instead of the rights objects when determining if the current user has edit right on a document. For other rights, or if there are no authors, fall back to the default XWikiRightServiceImpl base class. > Btw, I'm using this snippet to add the user rights: > http://extensions.xwiki.org/xwiki/bin/view/Extension/Setting+Rights > > Thanks in advance, > > Luís Braga -- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users