function _role_email_user in Ubercart 5
Function sends a specified message to a user regarding role status
@return: Sends result of drupal_mail
Parameters
$status: The condition of role status
- grant: new role
- revoke: loose role
- renew: update role's expirations date
- reminder: expiration will occur soon
$user: The Drupal user object
$role: The role expiration object associated with message
$order: The order object associated with message
2 calls to _role_email_user()
- uc_roles_cron in uc_roles/
uc_roles.module - Implementation of hook_cron().
- uc_roles_order in uc_roles/
uc_roles.module - Implementation of hook_order().
File
- uc_roles/
uc_roles.module, line 961 - Grants roles upon accepted payment of products
Code
function _role_email_user($status, $user, $role, $order = NULL) {
$token_filters = array(
'global' => NULL,
'user' => $user,
'order' => $order,
'uc_roles' => $role,
);
switch ($status) {
case 'grant':
if (!variable_get('uc_roles_grant_notification', FALSE)) {
return;
}
$key = 'uc_roles_grant_notify';
$to = $order->primary_email;
$subject = variable_get('uc_roles_grant_notification_subject', uc_get_message('uc_roles_grant_subject'));
$body = variable_get('uc_roles_grant_notification_message', uc_get_message('uc_roles_grant_message'));
$body = check_markup($body, variable_get('uc_roles_grant_notification_format', 3), FALSE);
break;
case 'revoke':
if (!variable_get('uc_roles_revocation_notification', FALSE)) {
return;
}
$key = 'uc_roles_revoke_notify';
$to = $user->mail;
$subject = variable_get('uc_roles_revocation_notification_subject', uc_get_message('uc_roles_revoke_subject'));
$body = variable_get('uc_roles_revocation_notification_message', uc_get_message('uc_roles_revoke_message'));
$body = check_markup($body, variable_get('uc_roles_revocation_notification_format', 3), FALSE);
break;
case 'renew':
if (!variable_get('uc_roles_renewal_notification', FALSE)) {
return;
}
$key = 'uc_roles_renewal_notify';
$to = $order->primary_email;
$subject = variable_get('uc_roles_renewal_notification_subject', uc_get_message('uc_roles_renew_subject'));
$body = variable_get('uc_roles_renewal_notification_message', uc_get_message('uc_roles_renew_message'));
$body = check_markup($body, variable_get('uc_roles_renewal_notification_format', 3), FALSE);
break;
case 'reminder':
if (variable_get('uc_roles_reminder_granularity', 'never') == 'never') {
return;
}
$key = 'uc_roles_reminder_notify';
$to = $user->mail;
$subject = variable_get('uc_roles_reminder_subject', uc_get_message('uc_roles_reminder_subject'));
$body = variable_get('uc_roles_reminder_message', uc_get_message('uc_roles_reminder_message'));
$body = check_markup($body, variable_get('uc_roles_reminder_format', 3), FALSE);
break;
default:
break;
}
$from = uc_store_email_from();
$subject = token_replace_multiple($subject, $token_filters);
$body = token_replace_multiple($body, $token_filters);
//drupal_set_message("Mail Sent<br />key: $key, <br />to: $to, <br />subject: $subject, <br />body: $body, <br />from: $from, <br />");
return drupal_mail($key, $to, $subject, $body, $from, uc_notify_headers());
}