I have users who can create/edit Forum topics and post comments without approval -- but no other content type (so they don't have the "administer nodes" permission). I want them to be able to choose to "receive node follow-up notification e-mails" but so far I don't see how I can do this. Am I missing something or is this a bug, or...?

Let me know if I should provide any other details.

Thank you!

CommentFileSizeAuthor
#6 comment_notify_user-access.patch536 bytesalison

Comments

alison’s picture

So after posting this I dug around more myself and found the part of comment_notify.module related to permissions & the comment notify settings on the "edit user account" page. Looks like the reason I'm having a problem is that the "create forum topics" permission doesn't follow the same syntax as all the other "create [content-type-machine-name] content" permissions, so it doesn't get "counted" when the module checks if the user has permission to create nodes. The function I'm looking at is "comment_notify_user" at line 275. Here's what it says (in part): (starting at line 287)

// Only show the node followup UI if the user has permission to create nodes.
$nodes = FALSE;
foreach (node_get_types() as $type) {
  if (user_access('create '. $type->type .' content')) {
    $nodes = TRUE;
    break;
  }
}
if (user_access('administer nodes') || $nodes) {
  $form['comment_notify_settings']['node_notify_mailalert'] = array(
    '#type' => 'checkbox',
    '#title' => t('Receive node follow-up notification e-mails'),
    '#default_value' => isset($edit['node_notify_mailalert']) ? $edit['node_notify_mailalert'] : variable_get('node_notify_default_mailalert', FALSE),
    '#description' => t('Check this box to receive an e-mail notification for follow-ups on your nodes (pages, forum topics, etc). You can not disable notifications for individual threads.')
  );
}
else {
  $form['comment_notify_settings']['node_notify_mailalert'] = array(
    '#type' => 'hidden',
    '#value' => COMMENT_NOTIFY_DISABLED,
  );
}

Also it occurred to me that this is probably an issue for users who can create blog entries (but no other content type) as well. So... maybe adding something simple after the "foreach" would be good enough, like this?-- (starting at 287 again)

// Only show the node followup UI if the user has permission to create nodes.
$nodes = FALSE;
foreach (node_get_types() as $type) {
  if (user_access('create '. $type->type .' content')) {
    $nodes = TRUE;
    break;
  }
}
if (user_access('create blog entries') || user_access('create blog entries')) {
  $nodes = TRUE;
}

(Obviously if there's something nicer that's more all-encompassing or whatever, that's great, this is just a first thought.)

alison’s picture

Just a note to follow-up on my previous comment with the code change idea -- if people think this is a decent way to address the issue, I'll create a patch version of the code change. (I haven't created a patch before -- I know I can do it, but because this will be my first, I'm sure it will take a bit of time, and I'd rather not put too much in if it's all for nothing.)

I'd greatly appreciate any input/feedback anyone has -- thanks!

alison’s picture

Anyone have any thoughts about this? I'd be happy to provide more details if it's helpful, just let me know.

greggles’s picture

Title: "Receive node follow-up notification e-mails" option for Forum users » "Receive node follow-up notification e-mails" option for blog/Forum users

This seems like a duplicate of #717590: When content creation permission is only blog, it doesn't show checkbox., though there were some reports that the node_access test didn't work quite properly.

I'd be fine with the suggestion in #1.

alison’s picture

Cool beans, thanks! I'll make a patch.

alison’s picture

StatusFileSize
new536 bytes

Hi again. Sorry for the delay, didn't have time, and then when I finally got to it I discovered that you don't just write a thing in a text editor to create a patch, so that was another learning experience -- and an incomplete one. I haven't been able to successfully log in to wherever I'm supposed to log in via SSH (I did the Git access thing in my user account, but haven't successfully gone through whatever the next step is -- I'm not sure if I was trying to log in to the wrong hostname, or what, but obviously that's a separate problem).

So I faked it -- attached is a "patch" I created from a patch file I had handy (one that didn't have any diff/git things at the top). I don't know what to put for "revision" -- hopefully that's the only thing missing?

(Don't try to apply this patch, it probably won't work, if for no other reason than that it says "revision ???".)

Hope this isn't creating more work for y'all, I want to help, and I want to figure out how to do this myself, just not all the way there yet...

Thank you for your patience and help!

iamEAP’s picture

Status: Active » Closed (duplicate)

@alisonjo2786: It looks like your logic here is a little flawed. It would be redundant to OR the same values.

if (user_access('create blog entries') || user_access('create blog entries'))

Also, based on the code you wrote, this is very likely a duplicate of the issue referenced by Greggles #717590: When content creation permission is only blog, it doesn't show checkbox.. Read through that issue and see the patch by Dave at the end of it. I can't verify this 100%, but I found myself here after trying to do the same with forums. The patch hasn't been rolled out in a stable release, but you'll see it's been applied in the dev release.

alison’s picture

Ah, definitely a typo there, sorry... I had it as "create blog entries" and "create forum posts" (or whatever the wording was) on my actual site, but clearly I messed it up when creating this patch.

Anyway, I'll check out that other issue, the only one I found that seemed related (but wasn't quite the same) when I searched other issues was this one -- http://drupal.org/node/1100932 -- so thanks!