summaryrefslogtreecommitdiff
path: root/modules/comment.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-12-05 09:11:33 +0000
committerDries Buytaert <dries@buytaert.net>2005-12-05 09:11:33 +0000
commit28fdb3975e2bc53061277f4fdb1147dc8d3ba128 (patch)
tree06c355049d6e98b30417addd2a0942962e4f18cc /modules/comment.module
parent3e36be3b24423566e6d9de2c1c8cbea5ca68b295 (diff)
downloadbrdo-28fdb3975e2bc53061277f4fdb1147dc8d3ba128.tar.gz
brdo-28fdb3975e2bc53061277f4fdb1147dc8d3ba128.tar.bz2
- Patch #39778 by chx: obliterate nodeapi op form in favor of the forms API's way of doing things. Tested with help from webchick.
Diffstat (limited to 'modules/comment.module')
-rw-r--r--modules/comment.module34
1 files changed, 21 insertions, 13 deletions
diff --git a/modules/comment.module b/modules/comment.module
index e34b4b610..7e2b3e0f7 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -232,8 +232,26 @@ function comment_link($type, $node = 0, $main = 0) {
}
function comment_form_alter($form_id, &$form) {
- if (isset($form['type']) && $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 (isset($form['type'])) {
+ 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')) {
+ $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,
+ );
+ $form['user_comments']['comment'] = array(
+ '#type' => 'radios',
+ '#parents' => array('comment'),
+ '#default_value' => $selected,
+ '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
+ );
+ }
}
}
@@ -246,15 +264,6 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
case 'fields':
return array('comment');
- case 'form':
- if (user_access('administer comments')) {
- $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);
- $form['user_comments']['comment'] = array('#type' => 'radios', '#parents' => array('comment'), '#default_value' => $selected, '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')));
- return $form;
- }
- 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':
@@ -1156,8 +1165,7 @@ function comment_form($edit, $title = NULL) {
$form['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => $edit['comment'] ? $edit['comment'] : $user->signature, '#required' => TRUE
);
- $form = array_merge($form, filter_form($node->format));
- $form['format']['#weight'] = 18;
+ $form['format'] = filter_form($node->format, 18);
$form['cid'] = array('#type' => 'value', '#value' => $edit['cid']);
$form['pid'] = array('#type' => 'value', '#value' => $edit['pid']);