diff options
Diffstat (limited to 'modules/contact/contact.pages.inc')
-rw-r--r-- | modules/contact/contact.pages.inc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/contact/contact.pages.inc b/modules/contact/contact.pages.inc index d4a15bea5..5ad41d6f1 100644 --- a/modules/contact/contact.pages.inc +++ b/modules/contact/contact.pages.inc @@ -52,6 +52,11 @@ function contact_site_form($form, &$form_state) { } } + if (!$user->uid) { + $form['#attached']['library'][] = array('system', 'cookie'); + $form['#attached']['js'][] = drupal_get_path('module', 'contact') . '/contact.js'; + } + $form['#token'] = $user->uid ? $user->name . $user->mail : ''; $form['name'] = array( '#type' => 'textfield', @@ -117,10 +122,15 @@ function contact_site_form_validate($form, &$form_state) { * Form submission handler for contact_site_form(). */ function contact_site_form_submit($form, &$form_state) { - global $language; + global $user, $language; $values = $form_state['values']; + // Save the anonymous user information to a cookie for reuse. + if (!$user->uid) { + user_cookie_save($values); + } + // E-mail address of the sender: as the form field is a text field, // all instances of \r and \n have been automatically stripped from it. $from = $values['mail']; |