Hello,

I don't know if it is the right module but I wonder if there is a way to control comment permissions by adding users (with user reference) to a node.

When a user creates a node, he can refer other users, and those users would have the permission to write comments to that node.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ycle’s picture

from our software engineering prof me and a fellow student (we are currently doing our masters studies in computer science) got the task to identify and work on an oss project's bug or feature request of our choice. we decided to choose drupal, because i have already worked a lot with it and have also developed some modules or at least extended some modules to fulfill my special requirements. so we are no rookies, at all.

that was just to introduce us and our intention. we chose this exact feature request to implement and for this reason wanted to ask you, if it's neccessary/reasonable at all..?

our idea is not just to implement that proposed functionality, but to allow users to restrict others by role as well.

this question first goes to the main developers of this module.. is it reasonable to get this module doing that stuff? and is it ok to temporarily join this project in order to satisfy etcetera9 and our prof? :)

Sinan Erdem’s picture

Here is a method I used in order to achieve this:

- Enabled node template page from Panels module. So now I am showing content as panel.
- Enabled Node Access User Reference module. This module allows the author to give edit node permissions for referenced users.
- I display the comment form as a panel pane. In this pane, I add a visibility rule to display the pane for users who have edit content permission.

So now, only users referenced in the node can see and use the comment form. A minor problem with this setting is that referenced users also have the edit node permission, which in my case is not a problem.

But, of course if ycle improves the Comment Access module for this, it would be far better... I am ready for testing if you need.

ycle’s picture

This is just a summary of the problem and our intended solution suggestion. Any feedback would be nice.

The CommentAccess module provides users with the possibility to decide whether others are allowed to comment on their generated content. In order to do this, he uses the content’s edit-menu and sets the values “closed”, “open” and “hidden” which are stored in the column “comment” of the assigned node in the “nodes-table”. This functionality is provided by the function “commentaccess_form_alter()”. We are going to edit it in order to provide users with the possibility to allow specific users or users with specific roles to comment on their content. Furthermore, we will add (a) new permission(s) to the module, using the function commentaccess_permission(), so that administrators can allow users to change their content permissions this way. We are going to use a new table to store information concerning which users are allowed to comment on which content. If a user is not assigned to a specific content in this table, he is not allowed to comment on it. He should not be able to e.g. see the “Add-Comment-Form” which means we have to delete (unset) the appropriate element of the $link variable, which is set by the comment module. As the important routines to be extended we identified those which build the comment area, perform the comment submits, build the node edit form and extend the role system.

ycle’s picture

Hi guys,
we have finished. As we said, we edited the function “commentaccess_form_alter” in order to provide users with the possibility to allow specific users to comment on their content. Unfortunately, we didn’t have enough time to implement the roles stuff as well. Anyway, users are able to select other users from a list and thus to grant them rights to comment on their content. We used the “node_submit”- and “node_insert”-hooks and wrote a function called “commentaccess_writeUsersNodereferencesToDB” to store user- and nodeIDs in a new database-reference-table called “commentaccess_user_reference”. Only users whose IDs are stored assigned to a specific nodeID are able to comment on this node. Users’ authorization is validated in the hooks “node_view” and “form_submit” using the new function “commentaccess_hasUserNodeRef”. You can find our functions at the bottom of the functions.module and our tests in the file “commentaccess.test”. We wrote tests for all our functions and two “drupal function tests”. They are all sufficiently commented, ioho.
We are looking for your feedback.
Thx a lot. ;)

attention: unfortunately, we could not yet implement the module update function. so, when applying the patch, you should either create the tables on your own or wait for us to hand it in later.

Sinan Erdem’s picture

Hello,

Thanks for the effort. I am waiting for the update function :)

ycle’s picture

hey, there we are.

now, the update function works as well, so you can use the module and give some feedback.

this especially concerns the module maintainer and those responsible: we ask you to review that patch and to possibly include it to the master branch as a new version.

we await your feedback!

bye

rschwab’s picture

Status: Active » Needs work

Hi sinanerdem and ycle!

Thanks for suggestion, and especially to ycle for contributing the code! I really appreciate that. I'm sorry I wasn't around to respond while you were working on this for class.

I think this is a good idea, but perhaps beyond the scope of the original module. I think this would be a great addition as a submodule attached to it though. Ycle if you're still around and able to adapt this that would be fantastic and I'd love to include it. Otherwise I'll circle back to this once I've got the rest of the issue queue a little better under control.

Thanks again!