| 1 |
<?php |
<?php |
| 2 |
// ; $Id$ |
// ; $Id: user_edit_notify.module,v 1.3 2009/08/10 01:41:18 davistv Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 12 |
* @param section which section of the site we're displaying help |
* @param section which section of the site we're displaying help |
| 13 |
* @return help text for section |
* @return help text for section |
| 14 |
*/ |
*/ |
| 15 |
function user_edit_notify_help($section='') { |
function user_edit_notify_help($path='', $arg) { |
| 16 |
|
|
| 17 |
$output = ''; |
$output = ''; |
| 18 |
|
|
| 19 |
switch ($section) { |
switch ($path) { |
| 20 |
case "admin/help#user_edit_notify": |
case "admin/help#user_edit_notify": |
| 21 |
$output = '<p>'. t("Notifies a configurable email of changes to user profiles. |
$output = '<p>'. t("Notifies a configurable email of changes to user profiles. |
| 22 |
Falls back on sending email to site_mail or sendmail_from if possible. |
Falls back on sending email to site_mail or sendmail_from if possible. |
| 46 |
switch ($op) { |
switch ($op) { |
| 47 |
case 'after_update': |
case 'after_update': |
| 48 |
if ($account->status) { |
if ($account->status) { |
| 49 |
|
$params['account'] = $account; |
| 50 |
$user_edit_notify_mailto = variable_get('user_edit_notify_mailto', ''); |
$user_edit_notify_mailto = variable_get('user_edit_notify_mailto', ''); |
| 51 |
if ($user_edit_notify_mailto == '') { |
if ($user_edit_notify_mailto == '') { |
| 52 |
$user_edit_notify_mailto = variable_get('site_mail', ''); |
$user_edit_notify_mailto = variable_get('site_mail', ''); |
| 57 |
if ($user_edit_notify_mailto == '') { |
if ($user_edit_notify_mailto == '') { |
| 58 |
# Can't send email, abort |
# Can't send email, abort |
| 59 |
} else { |
} else { |
|
$account_info = user_load(array('uid' => $account->uid)); |
|
|
$subject = t('Edited account details for !username at !site', array('!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'))); |
|
|
|
|
| 60 |
$to = $from = $user_edit_notify_mailto; |
$to = $from = $user_edit_notify_mailto; |
| 61 |
$body = t("!user (!uri) has edited their profile.\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))); |
drupal_mail('usereditnotify', 'notice', $to, language_default(), $params, $from); |
|
|
|
|
$body = $body . "\n\nAccount Information:\n\n"; |
|
|
|
|
|
$body = $body . "Email: " . $account->mail . "\n\n"; |
|
|
|
|
|
$result = db_query('SELECT * FROM {profile_fields} ORDER BY category, weight'); |
|
|
while ($field = db_fetch_object($result)) { |
|
|
$options[$field->name] = $field->title; |
|
|
} |
|
|
foreach ($options as $key => $value) { |
|
|
$body = $body . $value . ": " . $account_info->$key . "\n\n"; |
|
|
} |
|
|
|
|
|
drupal_mail( |
|
|
'user-edit-notify-admin', |
|
|
$to, |
|
|
$subject, |
|
|
$body, |
|
|
$from |
|
|
); |
|
| 62 |
} |
} |
| 63 |
} |
} |
| 64 |
break; |
break; |
| 65 |
} |
} |
| 66 |
} |
} |
| 67 |
|
|
| 68 |
|
function usereditnotify_mail ($key, &$message, $params) { |
| 69 |
|
$account_info = user_load(array('uid' => $params['account']->uid)); |
| 70 |
|
$subject = t('Edited account details for !username at !site', array('!username' => $account_info->name, '!site' => variable_get('site_name', 'Drupal'))); |
| 71 |
|
|
| 72 |
|
$body = t("!user (!uri) has edited their profile.\n\n!edit-uri", array('!uri' => url("user/$account_info->uid", array('absolute' => TRUE)), '!user' => $account_info->name, '!edit-uri' => url("user/$account_info->uid/edit", array('absolute' => TRUE)))); |
| 73 |
|
|
| 74 |
|
$body = $body . "\n\nAccount Information:\n\n"; |
| 75 |
|
$body = $body . "Email: " . $account_info->mail . "\n\n"; |
| 76 |
|
|
| 77 |
|
$result = db_query('SELECT * FROM {profile_fields} ORDER BY category, weight'); |
| 78 |
|
while ($field = db_fetch_object($result)) { |
| 79 |
|
$options[$field->name] = $field->title; |
| 80 |
|
} |
| 81 |
|
foreach ($options as $key => $value) { |
| 82 |
|
$body = $body . $value . ": " . $account_info->$key . "\n\n"; |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
$language = language_default(); |
| 86 |
|
$variables = user_mail_tokens($params['account'], $language); |
| 87 |
|
$message['subject'] = t($subject, $variables, $language->language); |
| 88 |
|
$message['body'][] = t($body, $variables, $language->language); |
| 89 |
|
} |
| 90 |
|
|
| 91 |
/** |
/** |
| 92 |
* Implementation of hook_menu(). |
* Implementation of hook_menu(). |
| 93 |
*/ |
*/ |
| 94 |
function user_edit_notify_menu($may_cache) { |
function user_edit_notify_menu() { |
| 95 |
$items = array(); |
$items = array(); |
| 96 |
if ($may_cache) { |
$items['admin/settings/edit_notify'] = array( |
| 97 |
$items[] = array( |
'title' => 'User edit notification', |
| 98 |
'path' => 'admin/settings/edit_notify', |
'page callback' => 'drupal_get_form', |
| 99 |
'title' => t('User edit notification'), |
'page arguments' => array('user_edit_notify_admin'), |
| 100 |
'callback' => 'drupal_get_form', |
'description' => 'Configure the User edit notification module.', |
| 101 |
'callback arguments' => array('user_edit_notify_settings'), |
'access arguments' => array('administer user_edit_notify settings'), |
|
'description' => t('Configure the User edit notification module.'), |
|
|
'access' => user_access('administer user_edit_notify settings'), |
|
| 102 |
'type' => MENU_NORMAL_ITEM, |
'type' => MENU_NORMAL_ITEM, |
| 103 |
); |
); |
|
} |
|
| 104 |
return $items; |
return $items; |
| 105 |
} |
} |
| 106 |
|
|
| 108 |
/** |
/** |
| 109 |
* Menu callback for admin settings form. |
* Menu callback for admin settings form. |
| 110 |
*/ |
*/ |
| 111 |
function user_edit_notify_settings() { |
function user_edit_notify_admin() { |
| 112 |
$def_val = variable_get('site_mail', ''); |
$def_val = variable_get('site_mail', ''); |
| 113 |
if ($def_val == '') { |
if ($def_val == '') { |
| 114 |
$def_val = ini_get('sendmail_from'); |
$def_val = ini_get('sendmail_from'); |
| 123 |
); |
); |
| 124 |
return system_settings_form($form); |
return system_settings_form($form); |
| 125 |
} |
} |
| 126 |
|
|
| 127 |
|
|