You are here

function _pmteam_migrate_migrate_single_node in Drupal PM (Project Management) 7.3

Same name and namespace in other branches
  1. 8 pmteam/includes/pmteam.migrate.inc \_pmteam_migrate_migrate_single_node()
  2. 7.2 pmteam/includes/pmteam.migrate.inc \_pmteam_migrate_migrate_single_node()

Helper function to migrate single pmteam.

1 call to _pmteam_migrate_migrate_single_node()
_pmteam_migrate_field_data in pmteam/includes/pmteam.migrate.inc
Helper function to migrate single node, given any pmteam row.

File

pmteam/includes/pmteam.migrate.inc, line 115
Migration functions for the PM Team module.

Code

function _pmteam_migrate_migrate_single_node($nid, $vid, $members) {
  $update_needed_flag = FALSE;
  $users = array();
  $pmorganizations = array();
  foreach ($members as $mnid) {
    if ($pmperson = _pmteam_migrate_load_data('pmperson', $mnid)) {
      $users[] = $pmperson->user_uid;
    }
    elseif (_pmteam_migrate_load_data('pmorganization', $mnid)) {
      $pmorganizations[] = $mnid;
    }
  }
  $node = node_load($nid, $vid);
  if (!empty($users)) {
    foreach ($users as $uid) {
      $node->pmteam_user[LANGUAGE_NONE][] = array(
        'target_id' => $uid,
      );
      $update_needed_flag = TRUE;
    }
  }
  if (!empty($pmorganizations)) {
    foreach ($pmorganizations as $node_id) {
      $node->pmteam_organization[LANGUAGE_NONE][] = array(
        'target_id' => $node_id,
      );
      $update_needed_flag = TRUE;
    }
  }
  if ($update_needed_flag) {
    node_save($node);
  }
  return TRUE;
}