When a user edits an article where an admin with 'administer comments' changed the 'User comments' settings these settings are not kept and are reset to the defaults for the node type....

bad code here.... The code is correct for new nodes, not for edited nodes

    case 'validate':
      if (!user_access('administer comments')) {
        // Force default for normal users:
        $node->comment = variable_get("comment_$node->type", 2);
      }

I have no clue yet of how to fix this...

Comments

bwynants’s picture

This will fix it I think. However is that the way it's usually done?

    case 'form pre':
      if (user_access('administer comments')) {
        $selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", 2);
        $output = form_radios('', 'comment', $selected, array(t('Disabled'), t('Read only'), t('Read/write')));
        return form_group(t('User comments'), $output);
      }
      else {
	  // make sure we preserve current value
        <strong>if (isset($node->comment)) {
	    return form_hidden('comment', $node->comment);
	  }</strong>
      }
      break;

    case 'load':
      return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid));
    case 'validate':
      if (!user_access('administer comments')) {
        <strong>if (!isset($node->comment)) {</strong>
          // Force default for normal users if not yet set:
          $node->comment = variable_get("comment_$node->type", 2);
        }
      }
      break;

magico’s picture

Version: 4.6.6 » 4.6.9
Status: Active » Needs work
magico’s picture

Status: Needs work » Closed (fixed)

Nobody cared. It isn't critical. The majority already uses 4.7+