You are here

function redhen_org_group_group_types in RedHen CRM 7

Return all redhen_org bundles that are groupified.

Parameters

bool $private: If true, only return private groups.

string $bundle: If provided, only orgs which support the given bundle will be returned.

Return value

array An array of redhen_org types keyed by bundle.

1 call to redhen_org_group_group_types()
redhen_org_group_contact_groups in modules/redhen_org_group/redhen_org_group.module
Return all redhen_org groups that a given user belongs to.

File

modules/redhen_org_group/redhen_org_group.module, line 275

Code

function redhen_org_group_group_types($private = FALSE, $bundle = NULL) {
  $group_types = array();
  $org_types = redhen_org_get_types();
  foreach ($org_types as $org_type) {

    // Is this group active and groupified?
    if (isset($org_type->group) && $org_type->group && ($org_type->redhen_state = REDHEN_STATE_ACTIVE)) {

      // Either we don't care about private groups, or return those that are
      // marked as private.
      if (!$private || $private && (isset($org_type->group_settings['private']) && $org_type->group_settings['private'])) {

        // Either we don't care about which bundles can be posted into a group,
        // or return groups matching a given bundle.
        if (!$bundle || $bundle && isset($org_type->group_settings['content_types']) && in_array($bundle, $org_type->group_settings['content_types'])) {
          $group_types[$org_type->name] = $org_type;
        }
      }
    }
  }
  return $group_types;
}