You are here

public function OgUiSetRoles::__construct in Organic groups 7.2

General initialization of a Migration object.

Overrides Migration::__construct

File

og_ui/includes/migrate/7000/set_roles.inc, line 15
Set permissions on group to upgrade group visibility.

Class

OgUiSetRoles
@file Set permissions on group to upgrade group visibility.

Code

public function __construct() {
  parent::__construct();
  $this->description = t('Set permissions on group to upgrade group visibility.');
  foreach (node_type_get_names() as $bundle => $value) {

    // Dependent on a dynamic migration.
    $machine_name = 'OgUiPopulateField' . ucfirst($bundle);
    if (MigrationBase::getInstance($machine_name, 'OgUiPopulateField', array(
      'bundle' => $bundle,
    ))) {
      $this->dependencies[] = $machine_name;
    }
  }
  $query = db_select('d6_og', 'og');
  $query
    ->innerJoin('node', 'n', 'og.nid = n.nid');
  $query
    ->fields('og', array(
    'og_selective',
  ))
    ->fields('n', array(
    'nid',
    'type',
  ))
    ->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 MigrateDestinationTable('node');
  $this
    ->addFieldMapping('nid', 'nid');
}