42
									
								
								USER_1754162-15-language-in-login-cancel-links.patch → 1754162-29-language-in-login-cancel-links.patch
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										42
									
								
								USER_1754162-15-language-in-login-cancel-links.patch → 1754162-29-language-in-login-cancel-links.patch
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							@@ -1,11 +1,11 @@
 | 
				
			|||||||
diff --git a/modules/user/user.module b/modules/user/user.module
 | 
					diff --git a/modules/user/user.module b/modules/user/user.module
 | 
				
			||||||
index 47ac642..c204f6d 100644
 | 
					index bdfd36f..d33a528 100644
 | 
				
			||||||
--- a/modules/user/user.module
 | 
					--- a/modules/user/user.module
 | 
				
			||||||
+++ b/modules/user/user.module
 | 
					+++ b/modules/user/user.module
 | 
				
			||||||
@@ -2286,14 +2286,26 @@ function user_external_login_register($name, $module) {
 | 
					@@ -2328,14 +2328,26 @@ function user_external_login_register($name, $module) {
 | 
				
			||||||
  *
 | 
					  *   following properties:
 | 
				
			||||||
  * @param object $account
 | 
					  *   - uid: The user ID number.
 | 
				
			||||||
  *   An object containing the user account.
 | 
					  *   - login: The UNIX timestamp of the user's last login.
 | 
				
			||||||
+ * @param array $options
 | 
					+ * @param array $options
 | 
				
			||||||
+ *   (optional) A keyed array of settings. Supported options are:
 | 
					+ *   (optional) A keyed array of settings. Supported options are:
 | 
				
			||||||
+ *   - langcode: A language code to be used when generating locale-sensitive
 | 
					+ *   - langcode: A language code to be used when generating locale-sensitive
 | 
				
			||||||
@@ -18,7 +18,7 @@ index 47ac642..c204f6d 100644
 | 
				
			|||||||
-function user_pass_reset_url($account) {
 | 
					-function user_pass_reset_url($account) {
 | 
				
			||||||
+function user_pass_reset_url($account, $options = array()) {
 | 
					+function user_pass_reset_url($account, $options = array()) {
 | 
				
			||||||
   $timestamp = REQUEST_TIME;
 | 
					   $timestamp = REQUEST_TIME;
 | 
				
			||||||
-  return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE));
 | 
					-  return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), array('absolute' => TRUE));
 | 
				
			||||||
+  $url_options = array('absolute' => TRUE);
 | 
					+  $url_options = array('absolute' => TRUE);
 | 
				
			||||||
+  if (isset($options['langcode'])) {
 | 
					+  if (isset($options['langcode'])) {
 | 
				
			||||||
+    $languages = language_list();
 | 
					+    $languages = language_list();
 | 
				
			||||||
@@ -27,29 +27,29 @@ index 47ac642..c204f6d 100644
 | 
				
			|||||||
+  else {
 | 
					+  else {
 | 
				
			||||||
+    $url_options['language'] = user_preferred_language($account);
 | 
					+    $url_options['language'] = user_preferred_language($account);
 | 
				
			||||||
+  }
 | 
					+  }
 | 
				
			||||||
+  return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options);
 | 
					+  return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), $url_options);
 | 
				
			||||||
 }
 | 
					 }
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
 /**
 | 
					 /**
 | 
				
			||||||
@@ -2305,6 +2317,10 @@ function user_pass_reset_url($account) {
 | 
					@@ -2347,6 +2359,10 @@ function user_pass_reset_url($account) {
 | 
				
			||||||
  *   - uid: The user uid number.
 | 
					  *   - uid: The user ID number.
 | 
				
			||||||
  *   - pass: The hashed user password string.
 | 
					  *   - pass: The hashed user password string.
 | 
				
			||||||
  *   - login: The user login name.
 | 
					  *   - login: The UNIX timestamp of the user's last login.
 | 
				
			||||||
+ * @param array $options
 | 
					+ * @param array $options
 | 
				
			||||||
+ *   (optional) A keyed array of settings. Supported options are:
 | 
					+ *   (optional) A keyed array of settings. Supported options are:
 | 
				
			||||||
+ *   - langcode: A language code to be used when generating locale-sensitive
 | 
					+ *   - langcode: A language code to be used when generating locale-sensitive
 | 
				
			||||||
+  *    urls. If langcode is NULL the users preferred language is used.
 | 
					+ *    urls. If langcode is NULL the users preferred language is used.
 | 
				
			||||||
  *
 | 
					  *
 | 
				
			||||||
  * @return
 | 
					  * @return
 | 
				
			||||||
  *   A unique URL that may be used to confirm the cancellation of the user
 | 
					  *   A unique URL that may be used to confirm the cancellation of the user
 | 
				
			||||||
@@ -2313,9 +2329,17 @@ function user_pass_reset_url($account) {
 | 
					@@ -2355,9 +2371,17 @@ function user_pass_reset_url($account) {
 | 
				
			||||||
  * @see user_mail_tokens()
 | 
					  * @see user_mail_tokens()
 | 
				
			||||||
  * @see user_cancel_confirm()
 | 
					  * @see user_cancel_confirm()
 | 
				
			||||||
  */
 | 
					  */
 | 
				
			||||||
-function user_cancel_url($account) {
 | 
					-function user_cancel_url($account) {
 | 
				
			||||||
+function user_cancel_url($account, $options = array()) {
 | 
					+function user_cancel_url($account, $options = array()) {
 | 
				
			||||||
   $timestamp = REQUEST_TIME;
 | 
					   $timestamp = REQUEST_TIME;
 | 
				
			||||||
-  return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE));
 | 
					-  return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), array('absolute' => TRUE));
 | 
				
			||||||
+  $url_options = array('absolute' => TRUE);
 | 
					+  $url_options = array('absolute' => TRUE);
 | 
				
			||||||
+  if (isset($options['langcode'])) {
 | 
					+  if (isset($options['langcode'])) {
 | 
				
			||||||
+    $languages = language_list();
 | 
					+    $languages = language_list();
 | 
				
			||||||
@@ -58,20 +58,20 @@ index 47ac642..c204f6d 100644
 | 
				
			|||||||
+  else {
 | 
					+  else {
 | 
				
			||||||
+    $url_options['language'] = user_preferred_language($account);
 | 
					+    $url_options['language'] = user_preferred_language($account);
 | 
				
			||||||
+  }
 | 
					+  }
 | 
				
			||||||
+  return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options);
 | 
					+  return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), $url_options);
 | 
				
			||||||
 }
 | 
					 }
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
 /**
 | 
					 /**
 | 
				
			||||||
@@ -2752,7 +2776,7 @@ Your account on [site:name] has been canceled.
 | 
					@@ -2843,7 +2867,7 @@ Your account on [site:name] has been canceled.
 | 
				
			||||||
   if ($replace) {
 | 
					   if ($replace) {
 | 
				
			||||||
     // We do not sanitize the token replacement, since the output of this
 | 
					     // We do not sanitize the token replacement, since the output of this
 | 
				
			||||||
     // replacement is intended for an e-mail message, not a web browser.
 | 
					     // replacement is intended for an e-mail message, not a web browser.
 | 
				
			||||||
-    return token_replace($text, $variables, array('language' => $language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
 | 
					-    return token_replace($text, $variables, array('language' => $language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
 | 
				
			||||||
+    return token_replace($text, $variables, array('langcode' => $langcode, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
 | 
					+    return token_replace($text, $variables, array('language' => $language, 'langcode' => $langcode, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
   return $text;
 | 
					   return $text;
 | 
				
			||||||
@@ -2779,8 +2803,8 @@ Your account on [site:name] has been canceled.
 | 
					@@ -2870,8 +2894,8 @@ Your account on [site:name] has been canceled.
 | 
				
			||||||
  */
 | 
					  */
 | 
				
			||||||
 function user_mail_tokens(&$replacements, $data, $options) {
 | 
					 function user_mail_tokens(&$replacements, $data, $options) {
 | 
				
			||||||
   if (isset($data['user'])) {
 | 
					   if (isset($data['user'])) {
 | 
				
			||||||
@@ -83,10 +83,10 @@ index 47ac642..c204f6d 100644
 | 
				
			|||||||
 }
 | 
					 }
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
diff --git a/modules/user/user.test b/modules/user/user.test
 | 
					diff --git a/modules/user/user.test b/modules/user/user.test
 | 
				
			||||||
index b53db07..0417642 100644
 | 
					index 07be4c2..4536e0c 100644
 | 
				
			||||||
--- a/modules/user/user.test
 | 
					--- a/modules/user/user.test
 | 
				
			||||||
+++ b/modules/user/user.test
 | 
					+++ b/modules/user/user.test
 | 
				
			||||||
@@ -2012,6 +2012,26 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
 | 
					@@ -2145,6 +2145,26 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
 | 
				
			||||||
     );
 | 
					     );
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
@@ -113,9 +113,9 @@ index b53db07..0417642 100644
 | 
				
			|||||||
   /**
 | 
					   /**
 | 
				
			||||||
    * Creates a user, then tests the tokens generated from it.
 | 
					    * Creates a user, then tests the tokens generated from it.
 | 
				
			||||||
    */
 | 
					    */
 | 
				
			||||||
@@ -2062,6 +2082,39 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
 | 
					@@ -2195,6 +2215,39 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
 | 
				
			||||||
       $output = token_replace($input, array('user' => $account), array('language' => $language, 'sanitize' => FALSE));
 | 
					       $output = token_replace($input, array('user' => $account), array('language' => $language, 'sanitize' => FALSE));
 | 
				
			||||||
       $this->assertEqual($output, $expected, t('Unsanitized user token %token replaced.', array('%token' => $input)));
 | 
					       $this->assertEqual($output, $expected, format_string('Unsanitized user token %token replaced.', array('%token' => $input)));
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
+
 | 
					+
 | 
				
			||||||
+    $languages = language_list();
 | 
					+    $languages = language_list();
 | 
				
			||||||
@@ -1,30 +0,0 @@
 | 
				
			|||||||
diff --git a/misc/autocomplete.js b/misc/autocomplete.js
 | 
					 | 
				
			||||||
index 8f7ac60..5679081 100644
 | 
					 | 
				
			||||||
--- a/misc/autocomplete.js
 | 
					 | 
				
			||||||
+++ b/misc/autocomplete.js
 | 
					 | 
				
			||||||
@@ -114,6 +114,7 @@ Drupal.jsAC.prototype.onkeyup = function (input, e) {
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
 Drupal.jsAC.prototype.select = function (node) {
 | 
					 | 
				
			||||||
   this.input.value = $(node).data('autocompleteValue');
 | 
					 | 
				
			||||||
+  $(this.input).trigger('autocompleteSelect', [node]);
 | 
					 | 
				
			||||||
 };
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 /**
 | 
					 | 
				
			||||||
@@ -167,7 +168,7 @@ Drupal.jsAC.prototype.unhighlight = function (node) {
 | 
					 | 
				
			||||||
 Drupal.jsAC.prototype.hidePopup = function (keycode) {
 | 
					 | 
				
			||||||
   // Select item if the right key or mousebutton was pressed.
 | 
					 | 
				
			||||||
   if (this.selected && ((keycode && keycode != 46 && keycode != 8 && keycode != 27) || !keycode)) {
 | 
					 | 
				
			||||||
-    this.input.value = $(this.selected).data('autocompleteValue');
 | 
					 | 
				
			||||||
+    this.select(this.selected);
 | 
					 | 
				
			||||||
   }
 | 
					 | 
				
			||||||
   // Hide popup.
 | 
					 | 
				
			||||||
   var popup = this.popup;
 | 
					 | 
				
			||||||
@@ -220,7 +221,7 @@ Drupal.jsAC.prototype.found = function (matches) {
 | 
					 | 
				
			||||||
   for (key in matches) {
 | 
					 | 
				
			||||||
     $('<li></li>')
 | 
					 | 
				
			||||||
       .html($('<div></div>').html(matches[key]))
 | 
					 | 
				
			||||||
-      .mousedown(function () { ac.select(this); })
 | 
					 | 
				
			||||||
+      .mousedown(function () { ac.hidePopup(this); })
 | 
					 | 
				
			||||||
       .mouseover(function () { ac.highlight(this); })
 | 
					 | 
				
			||||||
       .mouseout(function () { ac.unhighlight(this); })
 | 
					 | 
				
			||||||
       .data('autocompleteValue', key)
 | 
					 | 
				
			||||||
@@ -2348,14 +2348,26 @@ function user_external_login_register($name, $module) {
 | 
				
			|||||||
 *   following properties:
 | 
					 *   following properties:
 | 
				
			||||||
 *   - uid: The user ID number.
 | 
					 *   - uid: The user ID number.
 | 
				
			||||||
 *   - login: The UNIX timestamp of the user's last login.
 | 
					 *   - login: The UNIX timestamp of the user's last login.
 | 
				
			||||||
 | 
					 * @param array $options
 | 
				
			||||||
 | 
					 *   (optional) A keyed array of settings. Supported options are:
 | 
				
			||||||
 | 
					 *   - langcode: A language code to be used when generating locale-sensitive
 | 
				
			||||||
 | 
					 *    urls. If langcode is NULL the users preferred language is used.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @return
 | 
					 * @return
 | 
				
			||||||
 *   A unique URL that provides a one-time log in for the user, from which
 | 
					 *   A unique URL that provides a one-time log in for the user, from which
 | 
				
			||||||
 *   they can change their password.
 | 
					 *   they can change their password.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
function user_pass_reset_url($account) {
 | 
					function user_pass_reset_url($account, $options = array()) {
 | 
				
			||||||
  $timestamp = REQUEST_TIME;
 | 
					  $timestamp = REQUEST_TIME;
 | 
				
			||||||
  return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), array('absolute' => TRUE));
 | 
					  $url_options = array('absolute' => TRUE);
 | 
				
			||||||
 | 
					  if (isset($options['langcode'])) {
 | 
				
			||||||
 | 
					    $languages = language_list();
 | 
				
			||||||
 | 
					    $url_options['language'] = $languages[$options['langcode']];
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  else {
 | 
				
			||||||
 | 
					    $url_options['language'] = user_preferred_language($account);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), $url_options);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -2367,6 +2379,10 @@ function user_pass_reset_url($account) {
 | 
				
			|||||||
 *   - uid: The user ID number.
 | 
					 *   - uid: The user ID number.
 | 
				
			||||||
 *   - pass: The hashed user password string.
 | 
					 *   - pass: The hashed user password string.
 | 
				
			||||||
 *   - login: The UNIX timestamp of the user's last login.
 | 
					 *   - login: The UNIX timestamp of the user's last login.
 | 
				
			||||||
 | 
					 * @param array $options
 | 
				
			||||||
 | 
					 *   (optional) A keyed array of settings. Supported options are:
 | 
				
			||||||
 | 
					 *   - langcode: A language code to be used when generating locale-sensitive
 | 
				
			||||||
 | 
					 *    urls. If langcode is NULL the users preferred language is used.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @return
 | 
					 * @return
 | 
				
			||||||
 *   A unique URL that may be used to confirm the cancellation of the user
 | 
					 *   A unique URL that may be used to confirm the cancellation of the user
 | 
				
			||||||
@@ -2375,9 +2391,17 @@ function user_pass_reset_url($account) {
 | 
				
			|||||||
 * @see user_mail_tokens()
 | 
					 * @see user_mail_tokens()
 | 
				
			||||||
 * @see user_cancel_confirm()
 | 
					 * @see user_cancel_confirm()
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
function user_cancel_url($account) {
 | 
					function user_cancel_url($account, $options = array()) {
 | 
				
			||||||
  $timestamp = REQUEST_TIME;
 | 
					  $timestamp = REQUEST_TIME;
 | 
				
			||||||
  return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), array('absolute' => TRUE));
 | 
					  $url_options = array('absolute' => TRUE);
 | 
				
			||||||
 | 
					  if (isset($options['langcode'])) {
 | 
				
			||||||
 | 
					    $languages = language_list();
 | 
				
			||||||
 | 
					    $url_options['language'] = $languages[$options['langcode']];
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  else {
 | 
				
			||||||
 | 
					    $url_options['language'] = user_preferred_language($account);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), $url_options);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -2863,7 +2887,7 @@ Your account on [site:name] has been canceled.
 | 
				
			|||||||
  if ($replace) {
 | 
					  if ($replace) {
 | 
				
			||||||
    // We do not sanitize the token replacement, since the output of this
 | 
					    // We do not sanitize the token replacement, since the output of this
 | 
				
			||||||
    // replacement is intended for an e-mail message, not a web browser.
 | 
					    // replacement is intended for an e-mail message, not a web browser.
 | 
				
			||||||
    return token_replace($text, $variables, array('language' => $language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
 | 
					    return token_replace($text, $variables, array('language' => $language, 'langcode' => $langcode, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return $text;
 | 
					  return $text;
 | 
				
			||||||
@@ -2890,8 +2914,8 @@ Your account on [site:name] has been canceled.
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
function user_mail_tokens(&$replacements, $data, $options) {
 | 
					function user_mail_tokens(&$replacements, $data, $options) {
 | 
				
			||||||
  if (isset($data['user'])) {
 | 
					  if (isset($data['user'])) {
 | 
				
			||||||
    $replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user']);
 | 
					    $replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user'], $options);
 | 
				
			||||||
    $replacements['[user:cancel-url]'] = user_cancel_url($data['user']);
 | 
					    $replacements['[user:cancel-url]'] = user_cancel_url($data['user'], $options);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4070
									
								
								modules/user/user.module.orig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4070
									
								
								modules/user/user.module.orig
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -2145,6 +2145,26 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function setUp() {
 | 
				
			||||||
 | 
					    parent::setUp('locale');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $account = $this->drupalCreateUser(array('access administration pages', 'administer languages'));
 | 
				
			||||||
 | 
					    $this->drupalLogin($account);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Add language.
 | 
				
			||||||
 | 
					    $edit = array('langcode' => 'de');
 | 
				
			||||||
 | 
					    $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Enable URL language detection and selection.
 | 
				
			||||||
 | 
					    $edit = array('language[enabled][locale-url]' => 1);
 | 
				
			||||||
 | 
					    $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Reset static caching.
 | 
				
			||||||
 | 
					    drupal_static_reset('language_list');
 | 
				
			||||||
 | 
					    drupal_static_reset('locale_url_outbound_alter');
 | 
				
			||||||
 | 
					    drupal_static_reset('locale_language_url_rewrite_url');
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Creates a user, then tests the tokens generated from it.
 | 
					   * Creates a user, then tests the tokens generated from it.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
@@ -2195,6 +2215,39 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase {
 | 
				
			|||||||
      $output = token_replace($input, array('user' => $account), array('language' => $language, 'sanitize' => FALSE));
 | 
					      $output = token_replace($input, array('user' => $account), array('language' => $language, 'sanitize' => FALSE));
 | 
				
			||||||
      $this->assertEqual($output, $expected, format_string('Unsanitized user token %token replaced.', array('%token' => $input)));
 | 
					      $this->assertEqual($output, $expected, format_string('Unsanitized user token %token replaced.', array('%token' => $input)));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $languages = language_list();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Generate login and cancel link.
 | 
				
			||||||
 | 
					    $tests = array();
 | 
				
			||||||
 | 
					    $tests['[user:one-time-login-url]'] = user_pass_reset_url($account);
 | 
				
			||||||
 | 
					    $tests['[user:cancel-url]'] = user_cancel_url($account);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Generate tokens with interface language.
 | 
				
			||||||
 | 
					    $link = url('user', array('absolute' => TRUE));
 | 
				
			||||||
 | 
					    foreach ($tests as $input => $expected) {
 | 
				
			||||||
 | 
					      $output = token_replace($input, array('user' => $account), array('langcode' => $language->language, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
 | 
				
			||||||
 | 
					      $this->assertTrue(strpos($output, $link) === 0, 'Generated URL is in interface language.');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Generate tokens with the user's preferred language.
 | 
				
			||||||
 | 
					    $edit['language'] = 'de';
 | 
				
			||||||
 | 
					    $account = user_save($account, $edit);
 | 
				
			||||||
 | 
					    $link = url('user', array('language' => $languages[$account->language], 'absolute' => TRUE));
 | 
				
			||||||
 | 
					    foreach ($tests as $input => $expected) {
 | 
				
			||||||
 | 
					      $output = token_replace($input, array('user' => $account), array('callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
 | 
				
			||||||
 | 
					      $this->assertTrue(strpos($output, $link) === 0, "Generated URL is in the user's preferred language.");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Generate tokens with one specific language.
 | 
				
			||||||
 | 
					    $link = url('user', array('language' => $languages['de'], 'absolute' => TRUE));
 | 
				
			||||||
 | 
					    foreach ($tests as $input => $expected) {
 | 
				
			||||||
 | 
					      foreach (array($user1, $user2) as $account) {
 | 
				
			||||||
 | 
					        $output = token_replace($input, array('user' => $account), array('langcode' => 'de', 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE));
 | 
				
			||||||
 | 
					        $this->assertTrue(strpos($output, $link) === 0, "Generated URL in in the requested language.");
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user