You are here

function og_node_import_fields in Node import 6

Implementation of hook_node_import_fields().

File

supported/og/og.inc, line 11
Support file for the og (Organic Groups) module.

Code

function og_node_import_fields($type) {
  $fields = array();
  if (($node_type = node_import_type_is_node($type)) !== FALSE) {
    if (og_is_group_type($node_type)) {
      $fields['og_description'] = array(
        'title' => t('Description'),
        'group' => t('Organic group'),
        'map_required' => TRUE,
      );
      $fields['og_selective'] = array(
        'title' => t('Membership requests'),
        'group' => t('Organic group'),
        'allowed_values' => og_selective_map(),
        'default_value' => OG_OPEN,
      );
      $fields['og_register'] = array(
        'title' => t('Registration form'),
        'group' => t('Organic group'),
        'input_format' => 'boolean',
      );
      $visibility = variable_get('og_visibility_registration', OG_REGISTRATION_CHOOSE_FALSE);
      if (user_access('administer nodes')) {
        $visibility = in_array($visibility, array(
          OG_REGISTRATION_NEVER,
          OG_REGISTRATION_CHOOSE_FALSE,
        )) ? OG_REGISTRATION_CHOOSE_FALSE : OG_REGISTRATION_CHOOSE_TRUE;
      }
      $default = FALSE;
      switch ($visibility) {
        case OG_REGISTRATION_ALWAYS:
          $default = TRUE;

        // fall through
        case OG_REGISTRATION_NEVER:
          $fields['og_register']['is_mappable'] = FALSE;
          break;
        case OG_REGISTRATION_CHOOSE_TRUE:
          $default = TRUE;

        // fall through
        case OG_REGISTRATION_CHOOSE_FALSE:
          break;
      }
      $fields['og_register']['default_value'] = $default;
      $fields['og_directory'] = array(
        'title' => t('List in groups directory'),
        'group' => t('Organic group'),
        'input_format' => 'boolean',
      );
      $visibility = variable_get('og_visibility_directory', OG_DIRECTORY_CHOOSE_TRUE);
      if (user_access('administer nodes')) {
        $visibility = in_array($visibility, array(
          OG_DIRECTORY_NEVER,
          OG_DIRECTORY_CHOOSE_FALSE,
        )) ? OG_DIRECTORY_CHOOSE_FALSE : OG_DIRECTORY_CHOOSE_TRUE;
      }
      $default = FALSE;
      switch ($visibility) {
        case OG_DIRECTORY_ALWAYS:
          $default = TRUE;

        // fall through
        case OG_DIRECTORY_NEVER:
          $fields['og_directory']['is_mappable'] = FALSE;
          break;
        case OG_DIRECTORY_CHOOSE_TRUE:
          $default = TRUE;

        // fall through
        case OG_DIRECTORY_CHOOSE_FALSE:
          break;
      }
      $fields['og_directory']['default_value'] = $default;
      if (module_exists('locale') && ($languages = locale_language_list())) {
        $fields['og_language'] = array(
          'title' => t('Group language'),
          'group' => t('Organic group'),
        );
      }
    }
    if (og_is_group_post_type($node_type)) {
      $fields['og_groups'] = array(
        'title' => t('Audience'),
        'group' => t('Organic group'),
        'input_format' => 'nodereference',
        'has_multiple' => TRUE,
        'is_checkboxes' => TRUE,
        'allowed_values' => _node_import_og_groups(),
      );
    }
  }
  return $fields;
}