You are here

function og_install in Organic groups 7

Same name and namespace in other branches
  1. 5.8 og.install \og_install()
  2. 5 og.install \og_install()
  3. 5.2 og.install \og_install()
  4. 5.3 og.install \og_install()
  5. 5.7 og.install \og_install()
  6. 6.2 og.install \og_install()
  7. 6 og.install \og_install()
  8. 7.2 og.install \og_install()

Implements hook_install().

File

./og.install, line 11
Install, update, and uninstall functions for the Organic groups module.

Code

function og_install() {
  _field_info_collate_fields(TRUE);
  _field_info_collate_types(TRUE);

  // Add group audience to users by default.
  og_create_field(OG_AUDIENCE_FIELD, 'user', 'user');

  // Add "User request" to the default group membership type.
  $field_name = OG_MEMBERSHIP_REQUEST_FIELD;
  if (!field_info_field($field_name)) {
    $field = array(
      'field_name' => $field_name,
      'type' => 'text_long',
      'entity_types' => array(
        'og_membership',
      ),
      'cardinality' => 1,
      // Although we would prefer to not allow deleting this field, we can not
      // lock it, as it will not allow adding it to other bundles.
      'locked' => FALSE,
    );
    $field = field_create_field($field);
  }
  if (!field_info_instance('og_membership', $field_name, OG_MEMBERSHIP_TYPE_DEFAULT)) {
    $instance = array(
      'field_name' => $field_name,
      'bundle' => OG_MEMBERSHIP_TYPE_DEFAULT,
      'entity_type' => 'og_membership',
      'label' => t('Request message'),
      'description' => t('This is the text a user may send to the group administrators.'),
      'required' => FALSE,
    );
    field_create_instance($instance);
  }
}