You are here

function notifications_custom_load in Notifications 6

Same name and namespace in other branches
  1. 6.4 notifications_custom/notifications_custom.module \notifications_custom_load()

Load custom subscription type

Parameters

$key: It may be csid (integer) or type (string)

2 calls to notifications_custom_load()
notifications_custom_build_subscription in notifications_custom/notifications_custom.module
Get subscription object from custom subscription type
notifications_custom_form_validate in notifications_custom/notifications_custom.admin.inc
Validate subscription type. Just check for 'type' duplicates

File

notifications_custom/notifications_custom.module, line 297
Custom notifications module

Code

function notifications_custom_load($key) {
  static $cache;
  if (!isset($cache[$key])) {
    if (is_numeric($key)) {
      $where = 'csid = %d';
    }
    else {
      $where = "type = '%s'";
    }
    $subs = db_fetch_object(db_query('SELECT * FROM {notifications_custom} WHERE ' . $where, $key));
    if ($subs) {
      $subs->fields = empty($subs->fields) ? array() : unserialize($subs->fields);

      // Cache by type and id
      $cache[$subs->csid] = $subs;
      $cache[$subs->type] = $subs;
    }
    else {
      $cache[$key] = FALSE;
    }
  }
  return $cache[$key];
}