function notifications_load_subscription in Notifications 6.2
Same name and namespace in other branches
- 5 notifications.module \notifications_load_subscription()
- 6.4 notifications.module \notifications_load_subscription()
- 6 notifications.module \notifications_load_subscription()
- 6.3 notifications.module \notifications_load_subscription()
Get an individual subscription.
Parameters
$subs: Either a subscription object or a subscription id (sid).
$refresh: Force cache refresh
Return value
Subscriptions object.
10 calls to notifications_load_subscription()
- NotificationsBasicTests::testNotificationsBasicAPI in tests/
notifications_api.test - Play with creating, retrieving, deleting a pair subscriptions
- notifications_get_subscriptions in ./
notifications.module - Get subscriptions that fit a set of conditions.
- notifications_manage_subscriptions_form in ./
notifications.manage.inc - Administer user subscriptions
- notifications_multiple_delete_confirm in ./
notifications.manage.inc - Form for multiple delete. When account passed check that all subscriptions belong to the user account
- notifications_page_unsubscribe in ./
notifications.pages.inc - Menu callback for unsubscribe page
File
- ./
notifications.module, line 773 - Notifications module
Code
function notifications_load_subscription($subs, $refresh = FALSE) {
static $cache = array();
if (is_object($subs)) {
$sid = $subs->sid;
$subscription = $subs;
}
else {
$sid = $subs;
}
if ($refresh || !array_key_exists($sid, $cache)) {
if (!isset($subscription)) {
$subscription = db_fetch_object(db_query("SELECT * FROM {notifications} WHERE sid = %d", $sid));
}
if ($subscription) {
$subscription->fields = array();
$result = db_query("SELECT * FROM {notifications_fields} WHERE sid = %d", $sid);
while ($condition = db_fetch_object($result)) {
$subscription->fields[$condition->field] = $condition->value;
}
}
$cache[$sid] = $subscription;
}
return $cache[$sid];
}