You are here

function _field_group_install_read_groups in Field Group 7

Same name and namespace in other branches
  1. 7.2 field_group.install \_field_group_install_read_groups()

Utility function: fetch all the field_group definitions from the database.

1 call to _field_group_install_read_groups()
field_group_install in ./field_group.install
Implements of hook_install().

File

./field_group.install, line 103
Fieldgroup module install file.

Code

function _field_group_install_read_groups() {
  $groups = array();
  if (db_table_exists('content_group')) {
    $query = db_select('content_group', 'cg', array(
      'fetch' => PDO::FETCH_ASSOC,
    ))
      ->fields('cg')
      ->condition('group_type', 'standard');
    foreach ($query
      ->execute() as $record) {
      $record['settings'] = unserialize($record['settings']);
      $groups[$record['group_name'] . '-' . $record['type_name']] = $record;
    }
    foreach ($groups as $key => $group) {
      $query2 = db_select('content_group_fields', 'cgf', array(
        'fetch' => PDO::FETCH_ASSOC,
      ))
        ->fields('cgf')
        ->condition('group_name', $group['group_name']);
      foreach ($query2
        ->execute() as $field) {
        $groups[$field['group_name'] . '-' . $field['type_name']]['children'][] = $field;
      }
    }
  }
  return $groups;
}