With the comment module, one needs the administer comments permission to be able to change the disabled/read-only/read-write setting for comments on a particular node. This patch adds a permission to override this for specific node types.

I find this feature particularly interesting in conjunction with Organic Groups (OG), because it allows group administrators to edit the comment settings for posts in their groups (posts they can edit).

Comments

anrikun’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.38 KB

Very nice patch!

I have just updated the new permission name so that it becomes:

override NODE_TYPE comment settings option

Just to respect module's permissions naming conventions :-)

David Lesieur’s picture

I'm not sure how good "settings option" sounds, but I don't mind the change. :)

anrikun’s picture

It's up to maintainers to decide.
Anyway, I hope one of these 2 patches get committed soon!

timmillwood’s picture

Assigned: Unassigned » timmillwood
Status: Reviewed & tested by the community » Fixed

I have just committed this to the 6.x-1.11 release.

(Will patch D5 and D7 versions this week)

dave reid’s picture

Status: Fixed » Needs work
+    // Add access to the 'Comment settings' fieldset.
+    if (module_exists('comment') && isset($form['comment_settings']) && !user_access('administer comments')) {
+      $form['comment_settings']['#access'] = user_access('override ' . $node->type . ' comment settings option');
+    }

This should likely be using a bit-wise boolean operation instead of re-assigning #access since comment.module already assigns $form['comment_settings']['#access'] = user_access('administer comments'). So in the case the user has that base permission but not the override permission, their fieldset will go missing, when it should still be visible.

So in summary, the third line in the above code be:

$form['comment_settings']['#access'] |= user_access('override ' . $node->type . ' comment settings option');
David Lesieur’s picture

Given that the condition !user_access('administer comments') is checked before replacing $form['comment_settings']['#access'], the use of the bit-wise assignment does not seem necessary. However, we could use the bit-wise assignment and remove the condition.

dave reid’s picture

Ah, hah I missed that condition, but I think we can just simplify it with an OR anyway. That's how we're currently using it. If a user does not have the 'override comment options' permission but does have some other permission or module that shows this setting it shouldn't clobber it; cooperation and not competition.

David Lesieur’s picture

Version: 6.x-1.10 » 6.x-1.x-dev
Assigned: timmillwood » David Lesieur
Status: Needs work » Needs review
StatusFileSize
new1.11 KB

Fully agree. Here's a patch!

mariusz.slonina’s picture

StatusFileSize
new1.14 KB

Hi, This is the patch for the D7 release - I've simply rewritten patches above for D7-dev

fuerst’s picture

Version: 6.x-1.x-dev » 7.x-1.12
Status: Needs review » Reviewed & tested by the community

#9 works for 7.x-1.12

David Lesieur’s picture

Assigned: David Lesieur » Unassigned
Softwar’s picture

Issue summary: View changes

Hello,

I've used the last patch in comment #9 and I've solved a problem. If you apply this patch, sometimes this patch doesn't work because form comment settings is called before the others forms (for example before publishing options).

The solution is to modify call order of form with hook_module_implements_alter like that :

/**
 * Implements hook_module_implements_alter().
 *
 * Make sure that our form alter is called AFTER the same hook provided in xxx
 */
function override_node_options_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'form_alter') {
    $group = $implementations['override_node_options'];
    unset($implementations['override_node_options']);
    $implementations['override_node_options'] = $group;
  }
}

After that, this patch is called normally.

Best regards.

Softwar

opdavies’s picture

Version: 7.x-1.12 » 7.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

The patch is #9 doesn't apply to the latest 7.x-1.x version of ONO, so it will need re-rolling.

opdavies’s picture

Issue tags: +Needs reroll
Softwar’s picture

Hi,

I've created a patch to apply modifications in comment #9 in order to answer at comment #15.

Enjoy.

Softwar’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll

The last submitted patch, override_node_options-comment-settings.patch, failed testing.

The last submitted patch, 1: override_node_options-comment-settings.patch, failed testing.

The last submitted patch, 8: override_node_options-comment-settings-826522-8.patch, failed testing.

The last submitted patch, 9: 826522_D7.patch, failed testing.

opdavies’s picture

opdavies’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #16 works, although the module weight needs to be adjusted in order for it to do so.

As per #1090696: Reduce module weight, the default module weight is set to -1 so that it does not interfere with Date Popup Authored module, but I think if it's blocking ONO's core functionality, it should be set back and people can adjust module weights as per their own requirements.

  • opdavies committed 27624e1 on 7.x-1.x authored by Softwar
    Issue #826522 by David Lesieur, Softwar, anrikun, mariusz.slonina: Add...
  • opdavies committed 616a5ae on 7.x-1.x
    Issue #826522: Adjusted module weight
    
  • opdavies committed acf3e6b on 7.x-1.x
    Issue #826522: Removed whitespace
    
opdavies’s picture

Status: Reviewed & tested by the community » Fixed

The patch in #16 has been committed, along with some whitespace clean-up, and the module weight amendments.

opdavies’s picture

I've added a new issue, #2561447: Add tests for comment settings, to add tests for this new option.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.