You are here

public function Group::getMemberCountRecursive in Group 7

Get the amount of members in a group, including subgroup members.

Return value

int The total amount of group members.

File

classes/group.inc, line 348
Defines the Entity API class for groups.

Class

Group
Main class for groups.

Code

public function getMemberCountRecursive() {
  drupal_set_message(t('Deprecation notice!<br />Group::getMemberCountRecursive() will soon be removed. Please look towards solutions involving the use of use Group::getMemberCount() instead.'), 'warning');

  // Retrieve the gids of the group's subgroups and add the group's gid.
  $gids = array_merge(array(
    $this->gid,
  ), array_keys($this
    ->getSubgroups()));
  $query = db_select('group_membership', 'gm');
  $query
    ->condition('gm.gid', $gids, 'IN');
  $query
    ->addField('gm', 'uid');
  $query
    ->distinct();
  return $query
    ->countQuery()
    ->execute()
    ->fetchField();
}