You are here

function og_subscriber_count_link in Organic groups 6.2

Same name and namespace in other branches
  1. 5.8 og.module \og_subscriber_count_link()
  2. 5 og.module \og_subscriber_count_link()
  3. 5.3 og.module \og_subscriber_count_link()
  4. 5.7 og.module \og_subscriber_count_link()
  5. 6 og.module \og_subscriber_count_link()

Determine the number of active and pending members and the current user's membership state.

Return value

array An array containing two strings. One for the number of members and another containing 'active' or 'requested'

1 call to og_subscriber_count_link()
og_details_links in ./og.module
Create group-contextual links, such as the group details block.

File

./og.module, line 2716
Code for the Organic Groups module.

Code

function og_subscriber_count_link($node) {
  global $user;
  $result = db_query(og_list_users_sql(0, 0, NULL), $node->nid);
  $cntpending = $cntall = 0;
  $subscription = '';
  while ($row = db_fetch_object($result)) {
    $cntall++;
    if ($row->is_active == 0) {
      $cntpending++;
    }
    if ($row->uid == $user->uid) {
      if ($row->is_active) {
        $subscription = 'active';
      }
      else {
        $subscription = 'requested';
      }
    }
  }
  $txt = format_plural($cntall - $cntpending, '1 member', '@count members');

  // The hyperlinked version of this text is supplied by og_views.module in alter hook.
  $txt .= $cntpending ? " ({$cntpending})" : '';
  return array(
    $txt,
    $subscription,
  );
}