You are here

public function Notifications_Event::get_subscriptions in Notifications 7

Get subscriptions

Parameters

$limit: Whether to limit the number of subscriptions. If so we'll use last_sid and 'notifications_batch_size'

Return value

array Array of subscription ids

1 call to Notifications_Event::get_subscriptions()
Notifications_Event::send_all in ./notifications.event.inc
Send message to all subscriptions

File

./notifications.event.inc, line 492
Drupal Notifications Framework - Default class file

Class

Notifications_Event
Notifications Event class

Code

public function get_subscriptions($limit = 0) {
  if ($condition = $this
    ->subscriptions_conditions()) {
    $query = $this
      ->query_subscriptions()
      ->fields('s', array(
      'sid',
      'conditions',
    ));
    $query
      ->leftJoin('notifications_subscription_fields', 'f', 's.sid = f.sid');
    $query
      ->condition($condition);
    $query
      ->groupBy('s.sid');
    $query
      ->groupBy('s.conditions');
    $query
      ->having('COUNT(f.sid) = s.conditions');
    if ($limit) {
      $query
        ->condition('s.sid', $this->last_sid, '>')
        ->orderBy('s.sid')
        ->range(0, $limit);
    }
    return $query
      ->execute()
      ->fetchCol();
  }
  else {
    return array();
  }
}