diff --git a/src/cambridge/cambridge.install b/src/cambridge/cambridge.install index e79b3ea80800c5675992f9ddbfe570f4c82737e4..4262c544fa178c9b328ad84db30880dbbd64873e 100644 --- a/src/cambridge/cambridge.install +++ b/src/cambridge/cambridge.install @@ -219,6 +219,9 @@ function cambridge_install() { ->condition('name', $name) ->execute(); } + + // Fix usernames in emails + cambridge_update_7101(); } /** @@ -237,3 +240,39 @@ function cambridge_update_7100() { variable_set('menu_trail_by_path_breadcrumb_handling', FALSE); } + +/** + * Stop names appearing where usernames should in emails. + * + * See https://drupal.org/node/1827980 + */ +function cambridge_update_7101() { + global $conf; + + if (FALSE === module_exists('realname')) { + return; + } + + $emails = array('register_admin_created_body', 'register_no_approval_required_body', 'status_activated_body'); + + foreach ($emails as $email) { + $key = 'user_mail_' . $email; + + $current_variable = variable_get($key); + $conf[$key] = FALSE; // temporarily hide a customised message + $default_message = _user_mail_text($email, NULL, array(), FALSE); // find the default + $conf[$key] = $current_variable; // revert back + + $current_message = _user_mail_text($email, NULL, array(), FALSE); // find the current + + $current_message = preg_replace('~\R~u', "\n", $current_message); // normalise line endings + + if ($current_message === $default_message) { + // only change cases where the message is still Drupal's default + + $new_message = str_replace('username: [user:name]', 'username: [user:name-raw]', $default_message); + + variable_set($key, $new_message); + } + } +} diff --git a/src/cambridge/cambridge.make b/src/cambridge/cambridge.make index 1c7fd28dd4186ee6c868d24c5bbff42aa0e4b897..9c6801f3c6d544aa8f6d5254c7b6a680bf0993c4 100644 --- a/src/cambridge/cambridge.make +++ b/src/cambridge/cambridge.make @@ -43,7 +43,7 @@ projects[menu_force] = "1.2" projects[menu_trail_by_path] = "2.0" projects[nodequeue] = "2.0-beta1" projects[pathologic] = "2.12" -projects[realname] = "1.1" +projects[realname] = "1.2" projects[redirect][version] = "1.0-rc1" projects[redirect][subdir] = "patched" projects[redirect][patch][] = "http://drupal.org/files/redirect-prevent_circular_redirects-1817976-42.patch"