On Mon, Mar 07, 2011 at 04:09:52PM -0500, Jim Safley wrote:
> 
> Using the API, what is the best way to determine whether the current
> user can edit a specified page? I could use:
> 
> ?action=query&prop=info&intoken=edit&titles={title}
> 
> to detect an "Action 'edit' is not allowed for the current user"
> warning, but this doesn't account for users with edit rights who
> attempt to edit a protected page.

I don't know if it's the best way, but you can retrieve the user's
access rights with:

 ?action=query&meta=userinfo&uiprop=rights

And you can query the protection of the page when retrieving the token:

 ?action=query&prop=info&intoken=edit&inprop=protection&titles={title}

Then it's a simple matter of comparing the protection against the
rights. This won't work against the title blacklist, but your bot
hitting *that* should be rare.

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

Reply via email to