You are here

function notifications_load_user in Notifications 6.3

Same name and namespace in other branches
  1. 5 notifications.cron.inc \notifications_load_user()
  2. 6.4 notifications.module \notifications_load_user()
  3. 6 notifications.cron.inc \notifications_load_user()
  4. 6.2 notifications.cron.inc \notifications_load_user()

Get users with static caching for existing users

If not uid passed it will return an anonymous fake user (with destination, send_method) We need to pass the send method to produce the right tokens later

This provides some API support for user-less subscriptions, i.e. when we've got just an email address but no user associated. The idea is that these fake users will be properly handled by messaging module

@todo Possibly all this should be handled by messaging layer

Parameters

$uid: Uid of the user account to load, none to use anonymous user

$destination: Messaging destination (mail, sms number, etc..), just for anonymous users

$send_method: Messaging send method key (mail, sms, xmpp, etc..), just for anonymous users

2 calls to notifications_load_user()
Notifications_Message::set_sender in classes/notifications_message.class.inc
Set sender uid or user account
notifications_token_values in ./notifications.module
Implementation of hook_token_values()

File

./notifications.cron.inc, line 616

Code

function notifications_load_user($uid, $destination = NULL, $send_method = NULL) {
  if ($uid) {
    return messaging_load_user($uid);
  }
  else {
    $account = drupal_anonymous_user();
    $account->destination = $destination;
    $account->send_method = $send_method;
    return $account;
  }
}