class OgMigrateAddFields

  1. cis7 sites/all/modules/ulmus/og/includes/migrate/7000/og_add_fields.inc OgMigrateAddFields
  2. cle7 sites/all/modules/ulmus/og/includes/migrate/7000/og_add_fields.inc OgMigrateAddFields
  3. elmsmedia7 sites/all/modules/ulmus/og/includes/migrate/7000/og_add_fields.inc OgMigrateAddFields
  4. icor7 sites/all/modules/ulmus/og/includes/migrate/7000/og_add_fields.inc OgMigrateAddFields
  5. meedjum_blog7 sites/all/modules/ulmus/og/includes/migrate/7000/og_add_fields.inc OgMigrateAddFields
  6. mooc7 sites/all/modules/ulmus/og/includes/migrate/7000/og_add_fields.inc OgMigrateAddFields

Hierarchy

Expanded class hierarchy of OgMigrateAddFields

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
OgMigrateAddFields::import public function Create group, group-audience and group description fields.
OgMigrateAddFields::isComplete public function
OgMigrateAddFields::__construct public function

File

sites/all/modules/ulmus/og/includes/migrate/7000/og_add_fields.inc, line 8
Add OG related fields to group and group-content node-types.

View source
class OgMigrateAddFields extends MigrationBase {

  public function __construct() {
    parent::__construct();
    $this->description = t('Add OG related fields to group and group-content node-types.');
    $this->enabled = !$this->isComplete();
  }

  public function isComplete() {
    return !variable_get('og_7000_add_field', FALSE);
  }

  /**
   * Create group, group-audience and group description fields.
   */
  public function import() {
    og_create_field(OG_AUDIENCE_FIELD, 'user', 'user');
    foreach (node_type_get_types() as $type) {
      // Check if the variable exists.
      if ($type_usage = variable_get('og_content_type_usage_' . $type->type)) {
        switch ($type_usage) {
          case 'group':
            $content_type['group'][] = $type->type;
            break;

          case 'group_post_standard':
          case 'group_post_wiki':
            // The type of the group content is now determined via the
            // group permissions. We only care about adding the group content
            // fields to the node.
            $content_type['group content'][] = $type->type;
            break;

        }
      }
    }

    if ($content_type) {
      // Add group and group content fields to content types.
      $field_names = array(
        'group' => OG_GROUP_FIELD,
        'group content' => OG_AUDIENCE_FIELD,
      );
      foreach ($field_names as $key => $field_name) {
        $content_type += array($key => array());
        foreach ($content_type[$key] as $type) {
          og_create_field($field_name, 'node', $type);

          if ($key == 'group') {

            if (!field_info_field('og_description')) {
              $field = array(
                'field_name' => 'og_description',
                'type' => 'text',
                'entity_types' => array('node'),
                'cardinality' => 1,
              );
              $field = field_create_field($field);
            }

            if (!field_info_instance('node', 'og_description', $type)) {
              // Create the "description" field for the bundle.
              $instance = array(
                'field_name' => 'og_description',
                'bundle' => $type,
                'entity_type' => 'node',
                'label' => t('Group description'),
                'description' => t('This is description of the group.'),
              );
              field_create_instance($instance);

              // Delete the OG6 variable.
              variable_del('og_content_type_usage_' . $type);
            }
          }
        }
      }
    }

    // Delete the field that indicates we still need to add fields.
    variable_del('og_7000_add_field');

    return MigrationBase::RESULT_COMPLETED;
  }
}
3 string references to 'OgMigrateAddFields'
OgMigrateGroup::__construct in sites/all/modules/ulmus/og/includes/migrate/7000/og_group.inc
OgMigrateOgurRoles::__construct in sites/all/modules/ulmus/og/includes/migrate/7000/og_ogur_roles.migrate.inc
Override constructor from Migration class.
og_migrate_api in sites/all/modules/ulmus/og/og.module
Implements hook_migrate_api().
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.