function sms_user_login_metadata in SMS Framework 6.2
Same name and namespace in other branches
- 7 modules/sms_user/sms_user.module \sms_user_login_metadata()
Store metadata related to SMS users registering/logging in.
Drupal core doesn't really provide a way to pass user metadata around that's related to a user registering (meaning during the registration cycle), so we provide a storage mechanism here.
Since it seems sloppy to handle registration cycles with one method and logins with another, this function handles all SMS-related metadata related to logging in and registering.
The data is placed in this storage mechansim for the duration of the page load, and is placed here before the user hooks are invoked by sms_user, therefore it should be available to all modules that need it.
Parameters
$uid: The uid of the user to store/fetch. If NULL, return all cached accounts.
$metadata: The metadata to store, or the metadata to fetch if NULL. The metadata is stored/retrieved as an associative array with the following key/value pairs:
'register' => A boolean indicating if the user is just registering. 'login' => A boolean indicating if the user is logging in. 'number' => The SMS number the message was sent from. 'message' => The SMS message sent with the registration/login. 'options' => The SMS message metadata passed from the gateway.
$reset: If TRUE, reset the accounts cache.
Return value
No uid set: An array, key = uid, value = An associative array of account metadata. uid set, no metadata set: An associative array of account metadata. uid set, metadata set: Cache the metadata for the user, return TRUE.
2 calls to sms_user_login_metadata()
- sms_user_register_new_user in modules/
sms_user/ sms_user.module - Registers a new user via SMS
- sms_user_sms_incoming in modules/
sms_user/ sms_user.module - Implementation of hook_sms_incoming().
File
- modules/
sms_user/ sms_user.module, line 630 - Provides integration between the SMS Framework and Drupal users.
Code
function sms_user_login_metadata($uid = NULL, $metadata = NULL, $reset = FALSE) {
static $accounts = array();
if ($reset) {
$accounts = array();
}
if (!isset($uid)) {
return $accounts;
}
if (isset($metadata)) {
$accounts[$uid] = $metadata;
return TRUE;
}
elseif (isset($accounts[$uid])) {
return $accounts[$uid];
}
else {
return FALSE;
}
}