Quantcast

Determine whether current user can edit specified page

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Determine whether current user can edit specified page

Jim Safley
Hello,

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.

Thanks,
Jim

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Determine whether current user can edit specified page

b-jorsch
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
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Loading...