### 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.542 diff -u -r1.542 comment.module --- modules/comment/comment.module 14 May 2007 13:43:35 -0000 1.542 +++ modules/comment/comment.module 17 May 2007 10:52:41 -0000 @@ -1457,7 +1457,11 @@ 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')) { if (!empty($edit['author'])) { @@ -1681,6 +1685,10 @@ } function comment_form_validate($form_values, $form, &$form_state) { + foreach (array('name', 'homepage', 'mail') as $field) { + //set cookie for 365 days + setrawcookie('comment_info_' . $field, rawurlencode($form_values[$field]), time() + 31536000); + } 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,34 @@ +// $Id: $ +if (Drupal.jsEnabled) { + $(document).ready(function() { + var parts = new Array("name", "homepage", "mail"); + var cookie = ''; + for (i=0;i<3;i++) { + cookie = Drupal.comment.getCookie('comment_info_' + parts[i]); + if (cookie != '') { + $("#comment-form input[@name=" + parts[i] + "]").val(cookie); + } + } + }); +}; + +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; +}