You are here

function migrate_extras_migrate_complete_node in Migrate Extras 6

Implementation of hook_migrate_complete_node().

File

./migrate_extras.module, line 235

Code

function migrate_extras_migrate_complete_node($node, $tblinfo, $row) {

  //store node mappings in a master node map table
  if (variable_get('migrate_extras_use_master_node_map', 0) && $node->nid) {
    $sourcekey = $tblinfo->sourcekey;
    static $maptables = array();
    if (!isset($maptables[$mcsid])) {
      $maptables[$mcsid] = migrate_map_table_name($tblinfo->mcsid);
    }

    //cehck and see if this nid is going to be added or updated.
    $needs_update = db_result(db_query('SELECT needs_update
                                        FROM {' . $maptables[$mcsid] . "}\n                                        WHERE sourceid='%s'", $row->{$sourcekey}));
    if ($needs_update == 1) {

      //it's going to updated, no need to do anything
    }
    elseif ($needs_update !== 0) {

      //it's going to inserted, we better insert into our node map too.
      db_query("INSERT INTO {migrate_extras_node_map} (sourceid, destid)\n                VALUES('%s', %d)", $row->{$sourcekey}, $node->nid);
    }
  }
}