You are here

function subscriptions_get in Subscriptions 6

Same name and namespace in other branches
  1. 5.2 subscriptions.module \subscriptions_get()
  2. 7 subscriptions.module \subscriptions_get()
  3. 2.0.x subscriptions.module.old.php \subscriptions_get()

Get subscriptions.

Parameters

$params: Array of parameters for the query.

Return value

Array of subscriptions indexed by uid, module, field, value, author_uid.

File

./subscriptions.module, line 484
Subscriptions module.

Code

function subscriptions_get($params) {

  // Build query
  foreach ($params as $field => $value) {
    if (is_numeric($value)) {
      $conditions[] = $field . ' = %d';
    }
    else {
      $conditions[] = "{$field} = '%s'";
    }
    $args[] = $value;
  }
  $sql = "SELECT * FROM {subscriptions} WHERE " . implode(' AND ', $conditions);
  $result = db_query($sql, $args);
  $subscriptions = array();
  while ($s = db_fetch_object($result)) {
    $subscriptions[$s->recipient_uid][$s->module][$s->field][$s->value][$s->author_uid] = 1;
  }
  return $subscriptions;
}