--- W:\drupal-5.9\sites\all\modules\user_register_notify\user_register_notify.module_old +++ W:\drupal-5.9\sites\all\modules\user_register_notify\user_register_notify.module @@ -58,8 +58,15 @@ '#type' => 'textfield', '#title' => t('Send notifications to this custom email address'), '#description' => t('If you leave this blank, the site email address, %mailto, will be used.', array('%mailto' => variable_get('site_mail', ini_get('sendmail_from')))), - '#default_value' => variable_get('user_register_notify_mailto', variable_get('site_mail', ini_get('sendmail_from'))), - ); + '#default_value' => variable_get('user_register_notify_mailto', ''), + ); + $form['user_notify']['user_register_notify_mailfrom'] = array( + '#type' => 'textfield', + '#title' => t('Send notifications from this custom email address'), + '#description' => t('If you leave this blank, the site email address, %mailto, will be used.', array('%mailto' => variable_get('site_mail', ini_get('sendmail_from')))) . t('Available variables are:') .' !user_name, !user_mail ', + '#default_value' => variable_get('user_register_notify_mailfrom', ''), + ); + $user_roles = user_roles(TRUE); $form['user_notify']['user_register_notify_roles'] = array( '#type' => 'checkboxes', @@ -68,6 +75,7 @@ '#description' => t('All users with these checked roles will receive a notification email when selected.'), '#default_value' => variable_get('user_register_notify_roles', ''), ); + $form['user_register_notify_subject'] = array( '#type' => 'textfield', '#title' => t('Email Subject'), @@ -173,16 +181,29 @@ '!og' => check_plain($og_data), '!action' => $action == 'insert'? 'create' : 'update', ); - $subject = t(variable_get('user_register_notify_subject', USER_REGISTER_NOTIFY_SUBJECT), $variables); - $body = t(variable_get('user_register_notify_body', USER_REGISTER_NOTIFY_BODY), $variables); - $from = variable_get('site_mail', ini_get('sendmail_from')); + $fromvars = array('!user_name' => $variables['!user_name'], '!user_mail' => $variables['!user_mail']); + $subject = strtr(variable_get('user_register_notify_subject', USER_REGISTER_NOTIFY_SUBJECT), $variables); + $body = strtr(variable_get('user_register_notify_body', USER_REGISTER_NOTIFY_BODY), $variables); + $from = variable_get('user_register_notify_mailfrom', ''); + if ($from) { + $from = strtr($from, $fromvars); + } + else { + $from = variable_get('site_mail', ini_get('sendmail_from')); + } switch ($notify_type) { case 'Custom': - $to = variable_get('user_register_notify_mailto', $from); + $to = variable_get('user_register_notify_mailto', ''); + if (!$to) { + $to = variable_get('site_mail', ini_get('sendmail_from')); + } break; case 'Both': - $to = variable_get('user_register_notify_mailto', $from); + $to = variable_get('user_register_notify_mailto', ''); + if (!$to) { + $to = variable_get('site_mail', ini_get('sendmail_from')); + } // There is no break there for a reson. case 'Role': $roles = implode(',', variable_get('user_register_notify_roles', array()));