You are here

function privatemsg_groups_count_recipients in Privatemsg 7.2

Return the number of users in a group.

1 string reference to 'privatemsg_groups_count_recipients'
privatemsg_groups_privatemsg_recipient_type_info in privatemsg_groups/privatemsg_groups.module
Implements hook_privatemsg_recipient_type_info().

File

privatemsg_groups/privatemsg_groups.module, line 167
Allows to send messages to all members of an organic group

Code

function privatemsg_groups_count_recipients($recipient) {
  $group_type = _privatemsg_groups_get_group_type($recipient->type);
  $gid = $recipient->recipient;
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'og_membership')
    ->propertyCondition('group_type', $group_type)
    ->propertyCondition('gid', $gid)
    ->propertyCondition('entity_type', 'user')
    ->propertyCondition('state', OG_STATE_ACTIVE);
  return $query
    ->count()
    ->execute();
}