You are here

populate_field.inc in Organic groups 7.2

Upgrade group visibility (e.g. open, moderated, closed) from OG6.

File

og_ui/includes/migrate/7000/populate_field.inc
View source
<?php

/**
 * @file
 * Upgrade group visibility (e.g. open, moderated, closed) from OG6.
 */
class OgUiPopulateField extends Migration {

  /**
   * Indicate we are updating existing data.
   */
  protected $systemOfRecord = Migration::DESTINATION;
  public function __construct($arguments = array()) {
    parent::__construct($arguments);
    $bundle = $arguments['bundle'];
    $this->description = t('Upgrade group visibility (e.g. open, moderated, closed) from OG6.');
    $this->dependencies = array(
      'OgUiMigrateAddField',
    );
    $query = db_select('d6_og', 'og');
    $query
      ->innerJoin('node', 'n', 'og.nid = n.nid');
    $query
      ->fields('og')
      ->condition('n.type', $bundle)
      ->orderBy('n.nid');
    $this->query = $query;
    $source_key = MigrateDestinationNode::getKeySchema();

    // Set the alias, so the query in MigrateSourceSQL::performRewind()
    // will not fail.
    $source_key['nid']['alias'] = 'n';
    $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationNode::getKeySchema());
    $this->source = new MigrateSourceSQL($this->query);
    $this->destination = new MigrateDestinationNode($bundle);
    $this
      ->addFieldMapping('nid', 'nid');
    $this
      ->addFieldMapping(OG_DEFAULT_ACCESS_FIELD, NULL)
      ->defaultValue(TRUE);
  }

  /**
   * Construct the machine name from the bundle.
   */
  protected function generateMachineName($class_name = NULL) {
    return drupal_strtolower('OgUiPopulateField' . ucfirst($this->arguments['bundle']));
  }

}

Classes

Namesort descending Description
OgUiPopulateField @file Upgrade group visibility (e.g. open, moderated, closed) from OG6.