You are here

function oa_core_get_all_groups in Open Atrium Core 7.2

Return a list of all Groups

Parameters

$match string for autocomplete lookup:

$match_operator string for autocomplete lookup:

$limit int number to limit, or zero for no limit:

Return value

An array of group nid, title, keyed by the group nid.

4 calls to oa_core_get_all_groups()
OaGroupsSelectionHandler::getReferencableEntities in plugins/entityreference/selection/OaGroupsSelectionHandler.class.php
Implements EntityReferenceHandler::getReferencableEntities().
oa_access_group_permissions_form in modules/oa_access/oa_access.admin.inc
Form constructor for the Group permissions form.
oa_core_members_widget_add_group_form in plugins/content_types/oa_core_members_widget.inc
Render the form for Add Group
_oa_access_is_overridden in modules/oa_access/oa_access.module
Helper function to determine if a permission is overridden by Group or Team.

File

includes/oa_core.util.inc, line 1002
Code for Utility functions for OpenAtrium spaces

Code

function oa_core_get_all_groups($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
  $query = db_select('node', 'n');
  $query
    ->fields('n', array(
    'nid',
    'title',
  ))
    ->condition('n.type', OA_GROUP_TYPE)
    ->addTag('node_access');
  if (!empty($match)) {
    $match = $match_operator == 'CONTAINS' ? '%' . $match . '%' : $match;
    $match = $match_operator == 'STARTS_WITH' ? '%' . $match : $match;
    $query
      ->condition('n.title', $match, 'LIKE');
  }
  if (!empty($limit)) {
    $query
      ->range(0, $limit);
  }
  return $query
    ->execute()
    ->fetchAllAssoc('nid');
}