You are here

function og_subscriber_count_link in Organic groups 5.7

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. 6.2 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_og_block_details in ./og.module

File

./og.module, line 2661

Code

function og_subscriber_count_link($node) {
  global $user;
  $result = db_query(og_list_users_sql(0), $node->nid);
  $cntall = db_num_rows($result);
  $cntpending = 0;
  while ($row = db_fetch_object($result)) {
    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');
  $txt = og_is_picture() ? l($txt, "og/users/{$node->nid}/faces") : l($txt, "og/users/{$node->nid}");
  $txt .= $cntpending ? " ({$cntpending})" : '';
  return array(
    $txt,
    $subscription,
  );
}