function notifications_ui_load_subscriptions in Notifications 6.2
Same name and namespace in other branches
- 6 notifications_ui/notifications_ui.module \notifications_ui_load_subscriptions()
- 6.3 notifications_ui/notifications_ui.module \notifications_ui_load_subscriptions()
Load subscriptions for available options
Parameters
$options: Subscription types with field values
$account: Alternate user account to get subscriptions for, will default to current user
1 call to notifications_ui_load_subscriptions()
- notifications_ui_subscribe_options in notifications_ui/
notifications_ui.module - Get list of possible and existing subscriptions for user/object
File
- notifications_ui/
notifications_ui.module, line 476 - User Interface for subscriptions modules
Code
function notifications_ui_load_subscriptions(&$options, $account = NULL) {
global $user;
$account = $account ? $account : $user;
$subscriptions = array();
foreach ($options as $index => $info) {
// If the 'subscription' property is already set, skip loading
if (!isset($options[$index]['subscription']) && ($subs_type = notifications_get_subscriptions(array(
'uid' => $account->uid,
'type' => $info['type'],
), $info['fields'], TRUE))) {
// Take the first subscription only, there may be cases when there are more than one
$subscriptions = array_merge($subscriptions, $subs_type);
$options[$index]['subscription'] = array_shift($subs_type);
}
}
}