On Wed, Aug 31, 2011 at 15:13, Marius Dumitru Florea <
[email protected]> wrote:

> On Wed, Aug 31, 2011 at 3:00 PM, Thomas Mortagne
> <[email protected]> wrote:
> > On Wed, Aug 31, 2011 at 11:45 AM, Marius Dumitru Florea
> > <[email protected]> wrote:
> >> Hi devs,
> >>
> >> I tried to use:
> >>
> >> $someDoc.hasProgrammingRights()
> >>
> >> but unfortunately this method checks the current/context document, not
> >> the one on which it is called. The code is in com.xpn.xwiki.api.Api:
> >>
> >> /**
> >>  * Check if the current document has programming rights, meaning that
> >> it was last saved by a user with the
> >>  * programming right globally granted.
> >>  *
> >>  * @return <tt>true</tt> if the current document has the Programming
> >> right or <tt>false</tt> otherwise.
> >>  */
> >> public boolean hasProgrammingRights()
> >> {
> >>    com.xpn.xwiki.XWiki xwiki = this.context.getWiki();
> >>    return xwiki.getRightService().hasProgrammingRights(this.context);
> >> }
> >>
> >> So how do you check if a specific document has programming rights?
> >> AFAICS I need to either access the rights service or change the
> >> context document, but both require programming rights.. How can I
> >> check programming rights without needing them?
> >
>
> > $xwiki.hasAccessLevel("programming", $mydoc.contentAuthor,
> > "anydocumentitsnotusedanyway")
> >
> > should work well.
>
> What about the rest of the tests done in
> XWikiRightsServiceImpl#hasProgrammingRights(XWikiDocument,
> XWikiContext) ? hasAccessLevel('programming', ..) is called only at
> the end. I suppose they are needed, otherwise hasProgrammingRights
> would have just called hasAccessLevel no?
>

Thomas has proposed the most correct answer but I see one potential issue if
$mydoc.contentAuthor does not return a fully qualified username (including
the database), so you may need to at least proceed to the addition of the
database of the document to the content author name if it does not contains
a ':'

Denis


> Thanks,
> Marius
>
> >
> >>
> >> Thanks,
> >> Marius
> >> _______________________________________________
> >> devs mailing list
> >> [email protected]
> >> http://lists.xwiki.org/mailman/listinfo/devs
> >>
> >
> >
> >
> > --
> > Thomas Mortagne
> > _______________________________________________
> > devs mailing list
> > [email protected]
> > http://lists.xwiki.org/mailman/listinfo/devs
> >
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
>



-- 
Denis Gervalle
SOFTEC sa - CEO
eGuilde sarl - CTO
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to