function notifications_load_subscription in Notifications 6.3
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.2 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_digest_build_long in notifications_digest/
notifications_digest.module - Digest multiple events in a single message, long format.
- notifications_digest_build_short in notifications_digest/
notifications_digest.module - Digest multiple events in a single message, short format.
- 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
File
- ./
notifications.module, line 773 - Notifications module
Code
function notifications_load_subscription($subs, $refresh = FALSE) {
$cache =& messaging_static(__FUNCTION__);
if (is_object($subs)) {
$sid = $subs->sid;
$subscription = $subs;
}
else {
$sid = $subs;
}
if ($refresh || !$cache || !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];
}