Commit ac15de31 authored by webchick's avatar webchick

Issue #2551631 by quietone, Ryan Weal, phenaproxima: D6 user_mail tokens do not get converted

parent 7d08e330
...@@ -694,6 +694,12 @@ public function load() { ...@@ -694,6 +694,12 @@ public function load() {
))->values(array( ))->values(array(
'name' => 'user_mail_register_no_approval_required_subject', 'name' => 'user_mail_register_no_approval_required_subject',
'value' => 's:38:"Account details for !username at !site";', 'value' => 's:38:"Account details for !username at !site";',
))->values(array(
'name' => 'user_mail_register_pending_approval_body',
'value' => "s:267:\"!username,\n\nThank you for registering at !site. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- !site team\";",
))->values(array(
'name' => 'user_mail_register_pending_approval_subject',
'value' => 's:63:"Account details for !username at !site (pending admin approval)";',
))->values(array( ))->values(array(
'name' => 'user_mail_status_activated_body', 'name' => 'user_mail_status_activated_body',
'value' => "s:419:\"!username,\n\nYour account at !site has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\nOnce you have set your own password, you will be able to log in to !login_uri in the future using:\n\nusername: !username\n\";", 'value' => "s:419:\"!username,\n\nYour account at !site has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\nOnce you have set your own password, you will be able to log in to !login_uri in the future using:\n\nusername: !username\n\";",
...@@ -718,12 +724,6 @@ public function load() { ...@@ -718,12 +724,6 @@ public function load() {
))->values(array( ))->values(array(
'name' => 'user_mail_status_deleted_subject', 'name' => 'user_mail_status_deleted_subject',
'value' => 's:48:"Account details for !username at !site (deleted)";', 'value' => 's:48:"Account details for !username at !site (deleted)";',
))->values(array(
'name' => 'user_mail_user_mail_register_pending_approval_body',
'value' => "s:267:\"!username,\n\nThank you for registering at !site. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- !site team\";",
))->values(array(
'name' => 'user_mail_user_mail_register_pending_approval_subject',
'value' => 's:63:"Account details for !username at !site (pending admin approval)";',
))->values(array( ))->values(array(
'name' => 'user_register', 'name' => 'user_register',
'value' => 'i:0;', 'value' => 'i:0;',
...@@ -734,4 +734,4 @@ public function load() { ...@@ -734,4 +734,4 @@ public function load() {
} }
} }
#dd0717c35d3b181c80e5ad74ea2ed2f7 #f34f009027a42145859ceca526d4c297
...@@ -15,25 +15,53 @@ source: ...@@ -15,25 +15,53 @@ source:
- user_mail_register_admin_created_body - user_mail_register_admin_created_body
- user_mail_register_no_approval_required_subject - user_mail_register_no_approval_required_subject
- user_mail_register_no_approval_required_body - user_mail_register_no_approval_required_body
- user_mail_user_mail_register_pending_approval_subject - user_mail_register_pending_approval_subject
- user_mail_user_mail_register_pending_approval_body - user_mail_register_pending_approval_body
- user_mail_status_blocked_subject - user_mail_status_blocked_subject
- user_mail_status_blocked_body - user_mail_status_blocked_body
process: process:
'status_activated/subject': user_mail_status_activated_subject 'status_activated/subject':
'status_activated/body': user_mail_status_activated_body plugin: convert_tokens
'password_reset/subject': user_mail_password_reset_subject source: user_mail_status_activated_subject
'password_reset/body': user_mail_password_reset_body 'status_activated/body':
'cancel_confirm/subject': user_mail_status_deleted_subject plugin: convert_tokens
'cancel_confirm/body': user_mail_status_deleted_body source: user_mail_status_activated_body
'register_admin_created/subject': user_mail_register_admin_created_subject 'password_reset/subject':
'register_admin_created/body': user_mail_register_admin_created_body plugin: convert_tokens
'register_no_approval_required/subject': user_mail_register_no_approval_required_subject source: user_mail_password_reset_subject
'register_no_approval_required/body': user_mail_register_no_approval_required_body 'password_reset/body':
'register_pending_approval/subject': user_mail_user_mail_register_pending_approval_subject plugin: convert_tokens
'register_pending_approval/body': user_mail_user_mail_register_pending_approval_body source: user_mail_password_reset_body
'status_blocked/subject': user_mail_status_blocked_subject 'cancel_confirm/subject':
'status_blocked/body': user_mail_status_blocked_body plugin: convert_tokens
source: user_mail_status_deleted_subject
'cancel_confirm/body':
plugin: convert_tokens
source: user_mail_status_deleted_body
'register_admin_created/subject':
plugin: convert_tokens
source: user_mail_register_admin_created_subject
'register_admin_created/body':
plugin: convert_tokens
source: user_mail_register_admin_created_body
'register_no_approval_required/subject':
plugin: convert_tokens
source: user_mail_register_no_approval_required_subject
'register_no_approval_required/body':
plugin: convert_tokens
source: user_mail_register_no_approval_required_body
'register_pending_approval/subject':
plugin: convert_tokens
source: user_mail_register_pending_approval_subject
'register_pending_approval/body':
plugin: convert_tokens
source: user_mail_register_pending_approval_body
'status_blocked/subject':
plugin: convert_tokens
source: user_mail_status_blocked_subject
'status_blocked/body':
plugin: convert_tokens
source: user_mail_status_blocked_body
destination: destination:
plugin: config plugin: config
config_name: user.mail config_name: user.mail
<?php
/**
* @file
* Contains \Drupal\user\Plugin\migrate\process\ConvertTokens.
*/
namespace Drupal\user\Plugin\migrate\process;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* Plugin to replace !tokens with [tokens].
*
* @MigrateProcessPlugin(
* id = "convert_tokens",
* handle_multiples = TRUE
* )
*/
class ConvertTokens extends ProcessPluginBase {
/**
* {@inheritdoc}
*
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$tokens = array(
'!site' => '[site:name]',
'!username' => '[user:name]',
'!mailto' => '[user:mail]',
'!login_uri' => '[site:login-url]',
'!uri_brief' => '[site:url-brief]',
'!edit_uri' => '[user:edit-url]',
'!login_url' => '[user:one-time-login-url]',
'!uri' => '[site:url]',
'!date' => '[date:medium]',
'!password' => '',
);
if (is_string($value)) {
return str_replace(array_keys($tokens), $tokens, $value);
}
else {
throw new MigrateException('Value must be a string.');
}
}
}
...@@ -33,20 +33,21 @@ protected function setUp() { ...@@ -33,20 +33,21 @@ protected function setUp() {
*/ */
public function testUserMail() { public function testUserMail() {
$config = $this->config('user.mail'); $config = $this->config('user.mail');
$this->assertIdentical('Account details for !username at !site (approved)', $config->get('status_activated.subject'));
$this->assertIdentical("!username,\n\nYour account at !site has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\nOnce you have set your own password, you will be able to log in to !login_uri in the future using:\n\nusername: !username\n", $config->get('status_activated.body')); $this->assertIdentical('Account details for [user:name] at [site:name] (approved)', $config->get('status_activated.subject'));
$this->assertIdentical('Replacement login information for !username at !site', $config->get('password_reset.subject')); $this->assertIdentical("[user:name],\n\nYour account at [site:name] has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n[user:one-time-login-url]\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to [user:edit-url] so you can change your password.\n\nOnce you have set your own password, you will be able to log in to [site:login-url] in the future using:\n\nusername: [user:name]\n", $config->get('status_activated.body'));
$this->assertIdentical("!username,\n\nA request to reset the password for your account has been made at !site.\n\nYou may now log in to !uri_brief by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.", $config->get('password_reset.body')); $this->assertIdentical('Replacement login information for [user:name] at [site:name]', $config->get('password_reset.subject'));
$this->assertIdentical('Account details for !username at !site (deleted)', $config->get('cancel_confirm.subject')); $this->assertIdentical("[user:name],\n\nA request to reset the password for your account has been made at [site:name].\n\nYou may now log in to [site:url-brief] by clicking on this link or copying and pasting it in your browser:\n\n[user:one-time-login-url]\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to [user:edit-url] so you can change your password." , $config->get('password_reset.body'));
$this->assertIdentical("!username,\n\nYour account on !site has been deleted.", $config->get('cancel_confirm.body')); $this->assertIdentical('Account details for [user:name] at [site:name] (deleted)', $config->get('cancel_confirm.subject'));
$this->assertIdentical('An administrator created an account for you at !site', $config->get('register_admin_created.subject')); $this->assertIdentical("[user:name],\n\nYour account on [site:name] has been deleted.", $config->get('cancel_confirm.body'));
$this->assertIdentical("!username,\n\nA site administrator at !site has created an account for you. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n-- !site team", $config->get('register_admin_created.body')); $this->assertIdentical('An administrator created an account for you at [site:name]', $config->get('register_admin_created.subject'));
$this->assertIdentical('Account details for !username at !site', $config->get('register_no_approval_required.subject')); $this->assertIdentical("[user:name],\n\nA site administrator at [site:name] has created an account for you. You may now log in to [site:login-url] using the following username and password:\n\nusername: [user:name]\npassword: \n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n[user:one-time-login-url]\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to [user:edit-url] so you can change your password.\n\n\n-- [site:name] team", $config->get('register_admin_created.body'));
$this->assertIdentical("!username,\n\nThank you for registering at !site. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n-- !site team", $config->get('register_no_approval_required.body')); $this->assertIdentical('Account details for [user:name] at [site:name]', $config->get('register_no_approval_required.subject'));
$this->assertIdentical('Account details for !username at !site (pending admin approval)', $config->get('register_pending_approval.subject')); $this->assertIdentical("[user:name],\n\nThank you for registering at [site:name]. You may now log in to [site:login-url] using the following username and password:\n\nusername: [user:name]\npassword: \n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n[user:one-time-login-url]\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to [user:edit-url] so you can change your password.\n\n\n-- [site:name] team", $config->get('register_no_approval_required.body'));
$this->assertIdentical("!username,\n\nThank you for registering at !site. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- !site team", $config->get('register_pending_approval.body')); $this->assertIdentical('Account details for [user:name] at [site:name] (pending admin approval)', $config->get('register_pending_approval.subject'));
$this->assertIdentical('Account details for !username at !site (blocked)', $config->get('status_blocked.subject')); $this->assertIdentical("[user:name],\n\nThank you for registering at [site:name]. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- [site:name] team", $config->get('register_pending_approval.body'));
$this->assertIdentical("!username,\n\nYour account on !site has been blocked.", $config->get('status_blocked.body')); $this->assertIdentical('Account details for [user:name] at [site:name] (blocked)', $config->get('status_blocked.subject'));
$this->assertIdentical("[user:name],\n\nYour account on [site:name] has been blocked.", $config->get('status_blocked.body'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'user.mail', $config->get()); $this->assertConfigSchema(\Drupal::service('config.typed'), 'user.mail', $config->get());
} }
......
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