function notifications_subscription_type_enabled in Notifications 6.4
Same name and namespace in other branches
- 7 notifications.module \notifications_subscription_type_enabled()
Check if this type is enabled
The settings will be an array with type => type when enabled or type => 0 when disabled
Parameters
$type: Type to check, or nothing to return all
$setvalue: Set this type as enabled (TRUE) / disabled (FALSE)
10 calls to notifications_subscription_type_enabled()
- notifications_admin_subscriptions_settings in ./
notifications.admin.inc - Subscription settings
- notifications_admin_subscriptions_settings_submit in ./
notifications.admin.inc - Subscription settings submit, disable all subscriptions not allowed
- notifications_content_type_enabled in notifications_content/
notifications_content.module - Get subscription options for this content type
- notifications_custom_build_list in notifications_custom/
notifications_custom.module - Retrieve list of custom subscription types true objects
- notifications_object_subscribe_options in includes/
object.inc - Get subscription options for object, account. Only enabled subscription types
1 string reference to 'notifications_subscription_type_enabled'
- notifications_admin_subscriptions_settings_submit in ./
notifications.admin.inc - Subscription settings submit, disable all subscriptions not allowed
File
- ./
notifications.module, line 1080 - Notifications module
Code
function notifications_subscription_type_enabled($type = NULL, $setvalue = NULL) {
// By using a static, modules can peek and change this settings for specific pages
$types =& messaging_static(__FUNCTION__);
if (!isset($types)) {
$types = variable_get('notifications_subscription_types', array());
// For types not set, we assume enabled
$type_keys = array_keys(notifications_subscription_types());
// Workaround for array_combine() php bug when $type_keys is an empty array.
// @see http://bugs.php.net/bug.php?id=34857
$types += $type_keys === array() ? array() : array_combine($type_keys, $type_keys);
}
if (isset($setvalue)) {
$types[$type] = $setvalue ? $type : 0;
variable_set('notifications_subscription_types', $types);
}
elseif ($type) {
// If we don't have a setting yet for this type, return true
return isset($types[$type]) ? (bool) $types[$type] : TRUE;
}
else {
// Return only the types enabled
return array_filter($types);
}
}