You are here

function notifications_get_subscriptions in Notifications 6.3

Same name and namespace in other branches
  1. 5 notifications.module \notifications_get_subscriptions()
  2. 6.4 notifications.module \notifications_get_subscriptions()
  3. 6 notifications.module \notifications_get_subscriptions()
  4. 6.2 notifications.module \notifications_get_subscriptions()
  5. 7 notifications.module \notifications_get_subscriptions()

Get subscriptions that fit a set of conditions.

@todo Check field types for building the query

Parameters

$params: Array of parameters for the query

$conditions: Optional array of condition fields

$limit: Whether to limit the result to subscriptions with exactly that condition fields

$key: Optional key field to use as the array index. Will default to sid For notifications with one field, it may be 'value' or 'intval'

$pager: Whether to throw a pager query

Return value

Array of subscriptions indexed by uid, module, field, value, author

6 calls to notifications_get_subscriptions()
NotificationsBasicTests::testNotificationsBasicAPI in tests/notifications_api.test
Play with creating, retrieving, deleting a pair subscriptions
notifications_content_page_nodetype in notifications_content/notifications_content.pages.inc
User subscriptions to content types
notifications_save_subscription in ./notifications.module
Update or create subscription
notifications_tags_user_form in notifications_tags/notifications_tags.module
Returns the taxonomy subscription form
notifications_ui_load_subscriptions in notifications_ui/notifications_ui.module
Load subscriptions for available options

... See full list

File

./notifications.module, line 933
Notifications module

Code

function notifications_get_subscriptions($params, $conditions = array(), $limit = TRUE, $key = 'sid', $pager = NULL) {

  // Build query conditions using the query builder
  $query = notifications_subscriptions_query_build($params, $conditions, $limit);
  $query['select'][] = 'n.*';
  list($sql, $args) = notifications_query_sql($query);
  if ($pager) {
    $sql .= ' ORDER BY n.sid';
    $result = pager_query($sql, $pager, 0, NULL, $args);
  }
  else {
    $result = db_query($sql, $args);
  }
  $subscriptions = array();
  while ($subs = db_fetch_object($result)) {
    $load = notifications_load_subscription($subs);
    if ($key == 'value' || $key == 'intval') {
      $field = array_shift(_notifications_fields($load->fields));
      $subscriptions[$field->value] = $load;
    }
    else {
      $subscriptions[$subs->{$key}] = $load;
    }
  }
  return $subscriptions;
}