summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/comment.module44
-rw-r--r--modules/comment/comment.module44
2 files changed, 52 insertions, 36 deletions
diff --git a/modules/comment.module b/modules/comment.module
index fd4d35135..9ae46087e 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -236,22 +236,29 @@ function comment_form_alter($form_id, &$form) {
if ($form['type']['#value'] .'_node_settings' == $form_id) {
$form['workflow']['comment_'. $form['type']['#value']] = array('#type' => 'radios', '#title' => t('Default comment setting'), '#default_value' => variable_get('comment_'. $form['type']['#value'], COMMENT_NODE_READ_WRITE), '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')), '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'));
}
- if ($form['type']['#value'] .'_node_form' == $form_id && user_access('administer comments')) {
+ if ($form['type']['#value'] .'_node_form' == $form_id) {
$node = $form['#node'];
- $selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
- $form['user_comments'] = array(
- '#type' => 'fieldset',
- '#title' => t('User comments'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#weight' => 30,
- );
- $form['user_comments']['comment'] = array(
- '#type' => 'radios',
- '#parents' => array('comment'),
- '#default_value' => $selected,
- '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
- );
+ if (user_access('administer comments')) {
+ $form['user_comments'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('User comments'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#weight' => 30,
+ );
+ $form['user_comments']['comment'] = array(
+ '#type' => 'radios',
+ '#parents' => array('comment'),
+ '#default_value' => $node->comment,
+ '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
+ );
+ }
+ else {
+ $form['user_comments']['comment'] = array(
+ '#type' => 'value',
+ '#value' => $node->comment,
+ );
+ }
}
}
}
@@ -267,9 +274,10 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
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')) {
- // Force default for normal users:
+ break;
+
+ case 'prepare':
+ if (!isset($node->comment)) {
$node->comment = variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
}
break;
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index fd4d35135..9ae46087e 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -236,22 +236,29 @@ function comment_form_alter($form_id, &$form) {
if ($form['type']['#value'] .'_node_settings' == $form_id) {
$form['workflow']['comment_'. $form['type']['#value']] = array('#type' => 'radios', '#title' => t('Default comment setting'), '#default_value' => variable_get('comment_'. $form['type']['#value'], COMMENT_NODE_READ_WRITE), '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')), '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'));
}
- if ($form['type']['#value'] .'_node_form' == $form_id && user_access('administer comments')) {
+ if ($form['type']['#value'] .'_node_form' == $form_id) {
$node = $form['#node'];
- $selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
- $form['user_comments'] = array(
- '#type' => 'fieldset',
- '#title' => t('User comments'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#weight' => 30,
- );
- $form['user_comments']['comment'] = array(
- '#type' => 'radios',
- '#parents' => array('comment'),
- '#default_value' => $selected,
- '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
- );
+ if (user_access('administer comments')) {
+ $form['user_comments'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('User comments'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#weight' => 30,
+ );
+ $form['user_comments']['comment'] = array(
+ '#type' => 'radios',
+ '#parents' => array('comment'),
+ '#default_value' => $node->comment,
+ '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
+ );
+ }
+ else {
+ $form['user_comments']['comment'] = array(
+ '#type' => 'value',
+ '#value' => $node->comment,
+ );
+ }
}
}
}
@@ -267,9 +274,10 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
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')) {
- // Force default for normal users:
+ break;
+
+ case 'prepare':
+ if (!isset($node->comment)) {
$node->comment = variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
}
break;