function notifications_ui_subscribe_options in Notifications 6.2
Same name and namespace in other branches
- 6 notifications_ui/notifications_ui.module \notifications_ui_subscribe_options()
- 6.3 notifications_ui/notifications_ui.module \notifications_ui_subscribe_options()
Get list of possible and existing subscriptions for user/object
Parameters
$account: User account to get options/subscriptions for
$type: Subscription type to get options: 'user', 'node'
$object: The object to subscribe. It may be $node or $user
$load: Whether to load current subscriptions for each option
Return value
Array of subscription options The enabled ones will have a 'subscriptions' element loaded
5 calls to notifications_ui_subscribe_options()
- notifications_ui_block in notifications_ui/
notifications_ui.module - Implementation of hook_block()
- notifications_ui_link in notifications_ui/
notifications_ui.module - Implementation of hook_link()
- notifications_ui_nodeapi in notifications_ui/
notifications_ui.module - Display a button + js overlay
- notifications_ui_node_subform in notifications_ui/
notifications_ui.module - Form for node subscriptions @ TODO: offer the same form in a block to be put in the contents region.
- notifications_ui_user in notifications_ui/
notifications_ui.module
File
- notifications_ui/
notifications_ui.module, line 445 - User Interface for subscriptions modules
Code
function notifications_ui_subscribe_options($account, $type, $object, $load = TRUE) {
// Get allowed node options and current subscriptions
$subscribe_options = notifications_module_information("{$type} options", $account, $object);
$allowed_types = notifications_ui_allowed_types();
$allowed_options = array();
// We also keep track of event types for each subscription type
$event_types = array(
'node' => TRUE,
);
foreach ($subscribe_options as $index => $option) {
if (isset($allowed_types[$option['type']]) && notifications_user_allowed('subscription', $account, (object) $option)) {
$allowed_options[] = $option;
// We add the event type to our list
$event_types[$allowed_types[$option['type']]['event_type']] = TRUE;
}
}
if ($load) {
notifications_ui_load_subscriptions($allowed_options, $account);
}
return $allowed_options;
}