--- hosting_client.module.org 2009-06-25 20:39:50.000000000 +0100 +++ hosting_client.module 2009-06-26 18:46:50.000000000 +0100 @@ -259,33 +259,31 @@ $to = $node->email; } - $variables = array( - '!username' => $user->name, - '!site' => variable_get('site_name', 'Drupal'), - '!password' => $pass, - '!uri' => $GLOBALS['base_url'], - '!uri_brief' => substr($base_url, strlen('http://')), - '!date' => format_date(time()), - '!login_uri' => url('user', array('absolute' => TRUE)), - '!edit_uri' => url('user/'. $account->uid .'/edit', array('absolute' => TRUE)), - '!login_url' => user_pass_reset_url($user)); - // No e-mail verification is required, create new user account, and login user immediately. - $subject = _hosting_client_mail_text('welcome_subject', $variables); - $body = _hosting_client_mail_text('welcome_body', $variables); -// drupal_mail('hosting-client-register-welcome', $to, $subject, $body); - /* TODO Create a hook_mail($key, &$message, $params) function to generate - the message body when called by drupal_mail. */ - $account = array(); // Set this as needed + $account = user_load(array('uid' => $user->uid)); + $account->password = $pass; $language = user_preferred_language($account); - $object = array(); // Replace this as needed - $context['subject'] = $subject; - $context['body'] = $body; - $params = array('account' => $account, 'object' => $object, 'context' => $context); + $params = array('account' => $account); + drupal_mail('hosting_client', 'hosting-client-register-welcome', $to, $language, $params); } } /** + * Implementation of hook_mail(). + * + */ +function hosting_client_mail($key, &$message, $params) { + $language = $message['language']; + $variables = user_mail_tokens($params['account'], $language); + switch($key) { + case 'hosting-client-register-welcome': + $message['subject'] = _hosting_client_mail_text('welcome_subject', $variables); + $message['body'] = _hosting_client_mail_text('welcome_body', $variables); + break; + } +} + +/** * Implementation of hook_update(). * * As an existing node is being updated in the database, we need to do our own