Extending poll plugin to include weighted polls and more granular permissions
We currently use this poll plugin but we've found it doesn't have everything we need it to. What we are looking for is it to extend it and add:
Group-based permissions (select groups that can and can't vote in the poll in the ACP)
Weighted polls based on the group the user is part of. i.e. a person in group one would have their poll vote have a weight of 1, a person in group 2 would have a poll vote weight of 2 and so on. Configurable in the ACP.
That's it, I did tinker around with trying to do it myself but I don't know the plugin system well enough to do it effectively.
@mimo the first thing is implemented but the label is broken. That's why the rows are moved weirdly. Right click and inspect element on the group permission boxes to find it.
@Tom_Rade I'm not seeing that you are referring to, my privlages page looks like this:
and the corrisponding inspect element markup looks like this:
There is no reference to any poll permissions anywhere in either of those two areas. We're running NodeBB 1.10.2.
@mimo It doesn't work for global privileges... You have to select a category above first
@jtsimoes I set them in a test category but it doesn't look like it worked when I used a test account put into a group that wasn't supposed to be able to use the poll, the account could still vote in it. I'll have to keep playing around with them. Does that permission restrict the creation of a poll or the ability to participate in one?
@mimo That permission is only to allow create polls (that's what it says). Everybody can vote, there is no restriction for that...
And it's working fine for me:
Gives me an error when I clicking on "Create Poll" in a category that I don't have the permission "Create Poll" checked.
Read and understand the advice below that privileges page, that could be the problem...
" If the registered-users group is granted a specific privilege, all other groups receive an implicit privilege, even if they are not explicitly defined/checked. This implicit privilege is shown to you because all users are part of the registered-users user group, and so, privileges for additional groups need not be explicitly granted. "
And, of course, if you are an admin, you can create polls everywhere (because you have all permissions by default)
I did create a test account but because the permission only says "Poll" it was unclear whether or not if it controlled participation or creation. But you've answered that. Looks like I'll have to figure out how to modify the plugin for a permission to control participation base on group. Thanks for the in depth answer.
because the permission only says "Poll" it was unclear whether or not if it controlled participation or creation
Weird... The text in the translation, according to
"creator_title": "Create a poll"... Shouldn't be just only "Poll".
Looks like I'll have to figure out how to modify the plugin for a permission to control participation base on group
The most simple way that you could do that is using "view topic" ou "view category" permission. The group you want to not allow to vote, don't have the permission and cannot see that topic/category. With this, users of that group can't vote because they can't see the poll... Not the same but it's a little trick!
@jtsimoes unfortunately we want the restricted groups to still have view/comment access to posts with polls in them. I think my only solution will be to either find another poll plugin (which seems unlikely) or figure out how to modify the existing one to have more garnular permissions.
@mimo Humm... Okay, I tried my best...
Good luck with that!