Index: comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment.module,v retrieving revision 1.437 diff -u -r1.437 comment.module --- comment.module 27 Feb 2006 14:54:24 -0000 1.437 +++ comment.module 3 Mar 2006 00:48:20 -0000 @@ -236,6 +236,23 @@ return $links; } +/** + * Implementation of hook_comment(). + */ +function comment_comment($comment, $op) { + if (($op == 'update') || ($op == 'insert')) { + if ($comment['remember']) { + $fields = array('name', 'mail', 'homepage', 'remember'); + foreach ($fields as $field) { + $_SESSION['comment_anon'][$field] = $comment[$field]; + } + } + else { + unset($_SESSION['comment_anon']); + } + } +} + function comment_form_alter($form_id, &$form) { if (isset($form['type'])) { if ($form['type']['#value'] .'_node_settings' == $form_id) { @@ -479,6 +496,8 @@ if ($op == t('Preview comment')) { if (user_access('post comments')) { + // We won't be merging $_SESSION['comment_anon'] here because it should be there + // already as this is the preview form. $output .= comment_form(array('pid' => $pid, 'nid' => $nid), NULL); } else { @@ -503,7 +522,7 @@ drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error'); } else if (user_access('post comments')) { - $output .= comment_form(array('pid' => $pid, 'nid' => $nid), t('Reply')); + $output .= comment_form(array_merge($_SESSION['comment_anon'], array('pid' => $pid, 'nid' => $nid)), t('Reply')); } else { drupal_set_message(t('You are not authorized to post comments.'), 'error'); @@ -846,7 +865,7 @@ // If enabled, show new comment form. if (user_access('post comments') && node_comment_mode($nid) == COMMENT_NODE_READ_WRITE && (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW)) { - $output .= comment_form(array('nid' => $nid), t('Post new comment')); + $output .= comment_form(array_merge($_SESSION['comment_anon'], array('nid' => $nid)), t('Post new comment')); } } return $output; @@ -1288,6 +1307,8 @@ ); $form['homepage'] = array('#type' => 'textfield', '#title' => t('Homepage'), '#maxlength' => 255, '#size' => 30, '#default_value' => $edit['homepage']); + + $form['remember'] = array('#type' => 'checkbox', '#title' => t('Remember me'), '#default_value' => $edit['remember']); } else if (variable_get('comment_anonymous', COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MUST_CONTACT) { $form['name'] = array('#type' => 'textfield', '#title' => t('Your name'), '#maxlength' => 60, '#size' => 30, '#default_value' => $edit['name'] ? $edit['name'] : variable_get('anonymous', 'Anonymous'), '#required' => TRUE); @@ -1295,6 +1316,8 @@ $form['mail'] = array('#type' => 'textfield', '#title' => t('E-mail'), '#maxlength' => 64, '#size' => 30, '#default_value' => $edit['mail'],'#description' => t('The content of this field is kept private and will not be shown publicly.'), '#required' => TRUE); $form['homepage'] = array('#type' => 'textfield', '#title' => t('Homepage'), '#maxlength' => 255, '#size' => 30, '#default_value' => $edit['homepage']); + + $form['remember'] = array('#type' => 'checkbox', '#title' => t('Remember me'), '#default_value' => $edit['remember']); } if (variable_get('comment_subject_field', 1) == 1) {