### Eclipse Workspace Patch 1.0 #P drupal-cvs Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.541 diff -u -r1.541 comment.module --- modules/comment/comment.module 30 Apr 2007 17:03:24 -0000 1.541 +++ modules/comment/comment.module 11 May 2007 12:48:45 -0000 @@ -1453,6 +1453,10 @@ global $user; $op = isset($_POST['op']) ? $_POST['op'] : ''; + + if (!$user->uid && variable_get('comment_anonymous', COMMENT_ANONYMOUS_MAYNOT_CONTACT) != COMMENT_ANONYMOUS_MAYNOT_CONTACT) { + drupal_add_js(drupal_get_path('module', 'comment') . '/comment.js'); + } if ($user->uid) { if (!empty($edit['cid']) && user_access('administer comments')) { @@ -1677,6 +1681,12 @@ } function comment_form_validate($form_id, $form_values) { + foreach (array('name', 'homepage', 'mail') as $field) { + //set cookie for 365 days + if (!setrawcookie('comment_info_' . $field, rawurlencode($form_values[$field]), time() + 31536000)) { + watchdog('content', 'Comment: failed to save cookie on node %node', array('%node' => $form_values['nid']), WATCHDOG_ERROR); + } + } comment_validate($form_values); } Index: modules/comment/comment.js =================================================================== RCS file: modules/comment/comment.js diff -N modules/comment/comment.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/comment/comment.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,29 @@ +// $Id: $ +if (Drupal.jsEnabled) { + $(document).ready(function() { + $("#comment-form input[@name=name]").val(Drupal.comment.getCookie('comment_info_name')); + $("#comment-form input[@name=mail]").val(Drupal.comment.getCookie('comment_info_mail')); + $("#comment-form input[@name=homepage]").val(Drupal.comment.getCookie('comment_info_homepage')); + }); +}; + +Drupal.comment = {}; + +Drupal.comment.getCookie = function(name) { + var search = name + '='; + var returnValue = ''; + + if (document.cookie.length > 0) { + offset = document.cookie.indexOf(search); + if (offset != -1) { + offset += search.length; + var end = document.cookie.indexOf(';', offset); + if (end == -1) { + end = document.cookie.length; + } + returnValue = unescape(document.cookie.substring(offset, end)); + } + } + + return returnValue; +}