purplecat: Hand Drawn picture of a Toy Cat (programming)
purplecat ([personal profile] purplecat) wrote in [site community profile] dw_dev_training2013-03-27 06:18 pm
Entry tags:

Identifying community administrators in jquery.postform.js

I've been adding a stickies module to the entry post and edit pages as part of my work on Bug 2152 (multiple stickies). I had this set up so that if the user posts to a community all the sticky options quietly vanished and a little message appeared saying you couldn't sticky entries in communities. Unfortunately, as [personal profile] fu pointed out, administrators can sticky entries in communities.

My problem is I have no idea how to identify a community administrator from jquery.postform.js (which is where I'm controlling this from). Is that possible? If not is there an obvious work around?

If the worst comes to the worst I can always have the message direct people to Organise->Manage Accounts->Display but that wouldn't be optimal.
allen: extras (extras)

[personal profile] allen 2013-03-27 06:59 pm (UTC)(link)
Is user picking from a list of communities that they have posting access for? If so, you could find the code that generates the list of communities and add a data-administrator='1' to the ones that they're administrators of. Then when they select the community, you can use the jquery data API to check to see if the administrator flag is set on the list element. If it is, they can add stickies, and if not, they can't. (I assume that the backend code will also check for this at submit time, so that nobody does anything hinky.)

(Disclaimer: not looking at the code.)