On Wed, Aug 31, 2011 at 2:58 PM, Caleb James DeLisle <[email protected]> wrote:
Since all PR checks are run against the document xwiki:XWiki.XWikiPreferences you would need to do:
$xwiki.getDocument('xwiki:XWiki.XWikiPreferences').hasAccessLevel('programming', $doc.getContentAuthor())
I don't think you understood my question. I want to test if a specific document, different from the current document, has programming rights. I don't see how $doc.contentAuthor could help me. Also, in my previous mail I said that hasAccessLevel('programming', ...) is not enough because XWikiRightsServiceImpl#hasProgrammingRights(XWikiDocument, XWikiContext) does a few checks before making the above call. For instance it checks if the content author is from the main wiki. I don't want to duplicate that code.. Thanks, Marius
Caleb
On 08/31/2011 07:22 AM, Marius Dumitru Florea wrote:
On Wed, Aug 31, 2011 at 1:45 PM, Jerome Velociter <[email protected]> wrote:
Hi Marius,
Would hasAccessLevel("programming", "Some.Doc") work ?
Nop. I tried:
$someDoc.hasAccessLevel('programming')
but it tells me if the current user can save with programming rights the specified document. That's not what I need. Programming rights check on a document shouldn't depend on the current user, but on the last author.
I could use:
$someDoc.hasAccessLevel('programming', $someDoc.contentAuthor)
but it's not enough because XWikiRightsServiceImpl#hasProgrammingRights(XWikiDocument, XWikiContext) does a few checks before making the above call. For instance it checks if the content author is from the main wiki. I don't want to duplicate this code..
Thanks, Marius
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?
Thanks, Marius _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Jerome Velociter Winesquare http://www.winesquare.net/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs