Commit e8adcce2 authored by joelwallis's avatar joelwallis Committed by hass
Browse files

Issue #2453291 by hass, joelwallis: Allow suppressing [user:name-raw]

token warning in e-mail templates
parent e3103c15
......@@ -27,6 +27,13 @@ function realname_settings_form($form, &$form_state) {
'#dialog' => TRUE,
);
$form['realname_suppress_user_name_mail_validation'] = array(
'#type' => 'checkbox',
'#title' => t('Suppress missing token warning in e-mail templates'),
'#description' => t('With Real name module enabled you need to replace the token <code>[user:name]</code> with <code>[user:name-raw]</code> in your <a href="@people">e-mail</a> templates. If you are running modules like <em>Email Registration</em> you may like to suppress this warning and use a different token.', array('@people' => url('admin/config/people/accounts', array('fragment' => 'edit-email-admin-created')))),
'#default_value' => variable_get('realname_suppress_user_name_mail_validation', FALSE),
);
$form['#submit'][] = 'realname_settings_form_submit';
return system_settings_form($form);
}
......
......@@ -51,7 +51,7 @@ function realname_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
if (strpos(variable_get('user_mail_register_admin_created_body', FALSE), '[user:name-raw]') === FALSE) {
if (!variable_get('realname_suppress_user_name_mail_validation', FALSE) && strpos(variable_get('user_mail_register_admin_created_body', FALSE), '[user:name-raw]') === FALSE) {
$requirements['user_mail_register_admin_created_body'] = array(
'title' => t('E-mail: "Welcome (new user created by administrator)" template'),
'value' => t('Not configured'),
......@@ -59,7 +59,7 @@ function realname_requirements($phase) {
'description' => t('Replace the token <code>[user:name]</code> with <code>[user:name-raw]</code> in <a href="@people">e-mail</a> template, if using username for login.', array('@people' => url('admin/config/people/accounts', array('fragment' => 'edit-email-admin-created')))),
);
}
if (strpos(variable_get('user_mail_register_no_approval_required_body', FALSE), '[user:name-raw]') === FALSE) {
if (!variable_get('realname_suppress_user_name_mail_validation', FALSE) && strpos(variable_get('user_mail_register_no_approval_required_body', FALSE), '[user:name-raw]') === FALSE) {
$requirements['user_mail_register_no_approval_required_body'] = array(
'title' => t('E-mail: "Welcome (no approval required)" template'),
'value' => t('Not configured'),
......@@ -67,7 +67,7 @@ function realname_requirements($phase) {
'description' => t('Replace the token <code>[user:name]</code> with <code>[user:name-raw]</code> in <a href="@people">e-mail</a> template, if using username for login.', array('@people' => url('admin/config/people/accounts', array('fragment' => 'edit-email-no-approval-required')))),
);
}
if (strpos(variable_get('user_mail_status_activated_body', FALSE), '[user:name-raw]') === FALSE) {
if (!variable_get('realname_suppress_user_name_mail_validation', FALSE) && strpos(variable_get('user_mail_status_activated_body', FALSE), '[user:name-raw]') === FALSE) {
$requirements['user_mail_status_activated_body'] = array(
'title' => t('E-mail: "Account activation" template'),
'value' => t('Not configured'),
......@@ -92,6 +92,7 @@ function realname_disable() {
*/
function realname_uninstall() {
variable_del('realname_pattern');
variable_del('realname_suppress_user_name_mail_validation');
}
/**
......
......@@ -456,7 +456,11 @@ function realname_form_user_admin_settings_alter(&$form, &$form_state, $form_id)
function realname_username_raw_token_validate(&$element, &$form_state) {
$value = isset($element['#value']) ? $element['#value'] : $element['#default_value'];
if (strpos($value, '[user:name-raw]') === FALSE) {
// Warns the site administrator that [user:name-raw], required to log in, is
// missing. You can force the deactivation of this message by setting the
// variable `realname_suppress_user_name_mail_validation` to TRUE (or any
// value that converts to TRUE, like '1').
if (!variable_get('realname_suppress_user_name_mail_validation', FALSE) && strpos($value, '[user:name-raw]') === FALSE) {
drupal_set_message(t('The %element-title does not contain the <code>[user:name-raw]</code> token, which is necessary when using username for login.', array('%element-title' => $element['#title'])), 'warning');
}
......
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