Index: user_register_notify.module =================================================================== RCS file: /cvs/drupal/contributions/modules/user_register_notify/user_register_notify.module,v retrieving revision 1.2 diff -u -p -r1.2 user_register_notify.module --- user_register_notify.module 2 Jan 2007 10:46:21 -0000 1.2 +++ user_register_notify.module 21 Feb 2007 22:29:16 -0000 @@ -7,6 +7,55 @@ */ /** + * Implementation of hook_menu(). + */ +function user_register_notify_menu($may_cache) { + $items = array(); + + if($may_cache) { + $items[] = array('path' => 'admin/settings/user_register_notify', 'title' => t('User Registration Notification Email'), + 'description' => 'User Registration Notification Email Settings', + 'callback' => 'drupal_get_form', + 'callback arguments' => 'user_register_notify_admin', + 'access' => user_access('access administration pages'), + 'type' => MENU_NORMAL_ITEM); + } + return $items; +} + +function user_register_notify_admin() { + $form['user_register_notify_recipient'] = array( + '#type' => 'textfield', + '#title' => t('Email Recipient'), + '#required' => TRUE, + '#default_value' => variable_get('user_register_notify_recipient', variable_get('site_mail', ini_get('sendmail_from')) ), + '#weight' => -5, + '#description' => t('Recipient of user registration messages') + ); + + $form['user_register_notify_subject'] = array( + '#type' => 'textfield', + '#title' => t('Email Subject'), + '#default_value' => variable_get('user_register_notify_subject', 'User Registration Notification'), + '#required' => TRUE, + '#weight' => -2, + '#description' => t('Subject of user registration messages') + ); + + $form['user_register_notify_body'] = array( + '#type' => 'textarea', + '#title' => t('Email Body'), + '#default_value' => variable_get('user_register_notify_body', '!username (!uri) has created account.\n\n!edit-uri'), + '#rows' => 8, + '#required' => TRUE, + '#weight' => 0, + '#description' => t('Customize the body of the user registration notification email.') .' '. t('Available variables are:') .' !username, !site, !uri, !uri_brief, !date, !edit_uri.' + ); + + return system_settings_form($form); +} + +/** * Implementation of hook_user(). */ function user_register_notify_user($op, &$edit, &$account, $category = NULL) { @@ -17,23 +66,27 @@ function user_register_notify_user($op, // In case when accounts must be created with administrator's approval // there is already a 'pending approval' e-mail notification. if ($account->uid != 1 && $account->status) { + $variables = array('!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'), '!uri' => $base_url, '!uri_brief' => substr($base_url, strlen('http://')), '!mailto' => $account->mail, '!date' => format_date(time()), '!edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE) ); + + $subject = t(variable_get('user_register_notify_subject','Email Change'), $variables); + $body = t(variable_get('user_register_notify_body',''), $variables); + $from = variable_get('site_mail', ini_get('sendmail_from')); + $to = variable_get('user_register_notify_recipient', variable_get('site_mail', ini_get('sendmail_from'))); + + if (defined('VERSION') && version_compare(VERSION, '5.0 dev', '>=')) { - $subject = t('Account details for !username at !site', array('!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'))); - $to = $from = variable_get('site_mail', ini_get('sendmail_from')); drupal_mail( 'user-register-notify-admin', $to, $subject, - t("!user (!uri) has created account.\n\n!edit-uri", array('!uri' => url("user/$account->uid", NULL, NULL, TRUE), '!user' => $account->name, '!edit-uri' => url("user/$account->uid/edit", NULL, NULL, TRUE))), + $body, $from ); } // Else we have Drupal 4.7. else { - $subject = t('Account details for %username at %site', array('%username' => $account->name, '%site' => variable_get('site_name', 'drupal'))); - $from = variable_get('site_mail', ini_get('sendmail_from')); - user_mail($from, $subject, t("%user (%uri) has created account.\n\n%edit-uri", array('%uri' => url("user/$account->uid", NULL, NULL, TRUE), '%user' => $account->name, '%edit-uri' => url("user/$account->uid/edit", NULL, NULL, TRUE))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + user_mail($to, $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); } } break;