[Tags] Add setting to allow discussion authors to edit tags
tobyzerner opened this issue · 4 comments
From @tobscure on August 27, 2015 13:49
In the same way that the admin CP permissions page has a setting to let users rename their discussions "indefinitely", "for 10 minutes", or "until the next reply" – there should be a setting to let users edit their discussion's tags.
What needs to be done:
- In the tags admin JS extension, extend the PermissionsGrid
startItems
method and add aConfigDropdown
, using core's "allowRenaming" item as an example. - Listen to the ModelAllow event and give the "tag" permission to users based on the setting, using the event listener defined in core's DiscussionsServiceProvider as an example.
Copied from original issue: flarum/tags#12
Hello,
my name is David and together with my fellow student Friedrich, we'd like to participate in the Flarum project.
It is a part of our university master course about processes in software design at "Freie Universität Berlin" to contribute to an open source project.
We are both really interested in the software as we were looking for good board software for quite a while now, and thus think that Flarum is an awesome project to contribute to.
We hereby want to present our solution strategy based on the above points and would ask for any things that we should consider as well.
- Create a new add*.js-file in the tag extension js/admin/src to store our modifications to the PermissionGrid.
- Add an item for editing the tags to the PermissionGrid similar to the item for renaming a post. The Dropdown can borrow the fields from the renaming item
- Alter tags' DiscussionPolicy and add a new event listener for the event that a discussion is changed. Is this the "DiscussionWillBeSaved"-Event?
- In the event listener, we check if the tags were changed and look if the user has the permissions. ($actor->hasPermissions)
We hope that the above steps will fix this issue.
If there is anything we have to consider, we would like to hear from you.
We are already familiar with the used coding style guide and will adhere to these.
Best wishes,
David and Friedrich
Hello David, that's amazing, thanks for the offer! And greetings from Potsdam. =)
Yes, your plan of attack looks good. If you want to, you can open a pull request already, while you're making progress. That way, we can give you feedback even while you're still working on it.
Feel free to ask here if you encounter any problems.
And cheers again, thanks for the offer.
Hi,
I have a question. In the class "AddDiscussionTagsRelationship" there is a method "prepareApiAttributes". This method sets a field "canTag" in the DiscussionSerializer, which is used to display the "Edit Tags" button. The field is set as the actor's permission for 'tag'. But I cannot find, where this policy is defined. Can you give me a hint, where I have to look? I would alter this part to take the setting into account.
Thanks in advance!
I have an idea: Is this handled in Flarum\Tags\Access\DiscussionPolicy in the before method?
Edit: ok, it is there. Sorry for bothering!