You are here

function notifications_load_subscription in Notifications 6

Same name and namespace in other branches
  1. 5 notifications.module \notifications_load_subscription()
  2. 6.4 notifications.module \notifications_load_subscription()
  3. 6.2 notifications.module \notifications_load_subscription()
  4. 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

... See full list

File

./notifications.module, line 744
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];
}