Commit f3a8fa9e authored by Dries's avatar Dries

- Patch #763444 by jpmckinney: user_cookie_save() has a weird/awkward function signature.

parent dde5c67b
......@@ -2104,7 +2104,7 @@ function comment_form_submit($form, &$form_state) {
if (user_access('post comments') && (user_access('administer comments') || $node->comment == COMMENT_NODE_OPEN)) {
// Save the anonymous user information to a cookie for reuse.
if (!$comment->uid) {
user_cookie_save($form_state['values']);
user_cookie_save(array_intersect_key($form_state['values'], array_flip(array('name', 'mail', 'homepage'))));
}
comment_save($comment);
......
......@@ -139,7 +139,7 @@ function contact_site_form_submit($form, &$form_state) {
// Save the anonymous user information to a cookie for reuse.
if (!$user->uid) {
user_cookie_save($values);
user_cookie_save(array_intersect_key($values, array_flip(array('name', 'mail'))));
}
// Get the to and from e-mail addresses.
......@@ -272,7 +272,7 @@ function contact_personal_form_submit($form, &$form_state) {
// Save the anonymous user information to a cookie for reuse.
if (!$user->uid) {
user_cookie_save($values);
user_cookie_save(array_intersect_key($values, array_flip(array('name', 'mail'))));
}
// Get the to and from e-mail addresses.
......
......@@ -84,7 +84,7 @@ function openid_user_insert(&$edit, $account, $category) {
function openid_user_login(&$edit, $account) {
if (isset($_SESSION['openid'])) {
// The user has logged in via OpenID.
user_cookie_save($_SESSION['openid']['user_login_values'], array('openid_identifier'));
user_cookie_save(array_intersect_key($_SESSION['openid']['user_login_values'], array_flip(array('openid_identifier'))));
unset($_SESSION['openid']);
}
}
......
......@@ -2721,7 +2721,7 @@ function system_admin_compact_mode() {
* Valid values are 'on' and 'off'.
*/
function system_admin_compact_page($mode = 'off') {
user_cookie_save(array('admin_compact_mode' => ($mode == 'on')), array('admin_compact_mode'));
user_cookie_save(array('admin_compact_mode' => ($mode == 'on')));
drupal_goto();
}
......
......@@ -3494,17 +3494,12 @@ function user_login_destination() {
* Saves visitor information as a cookie so it can be reused.
*
* @param $values
* An array of submitted form values with identifying information about the
* current user, typically $form_state['values'] from a submit handler.
* @param $fields
* An array of key values from $values to be saved into a cookie.
*/
function user_cookie_save(array $values, array $fields = array('name', 'mail', 'homepage')) {
foreach ($fields as $field) {
if (isset($values[$field])) {
// Set cookie for 365 days.
setrawcookie('Drupal.visitor.' . $field, rawurlencode($values[$field]), REQUEST_TIME + 31536000, '/');
}
* An array of key/value pairs to be saved into a cookie.
*/
function user_cookie_save(array $values) {
foreach ($values as $field => $value) {
// Set cookie for 365 days.
setrawcookie('Drupal.visitor.' . $field, rawurlencode($value), REQUEST_TIME + 31536000, '/');
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment