You are here

function _pmtask_migrate_migrate_single_node in Drupal PM (Project Management) 7.2

Same name and namespace in other branches
  1. 8 pmtask/includes/pmtask.migrate.inc \_pmtask_migrate_migrate_single_node()
  2. 7.3 pmtask/includes/pmtask.migrate.inc \_pmtask_migrate_migrate_single_node()

Helper function to migrate single pmtask.

1 call to _pmtask_migrate_migrate_single_node()
pmtask_migrate_field_data in pmtask/includes/pmtask.migrate.inc
Migrate pmtask node fields data to drupal user bundle.

File

pmtask/includes/pmtask.migrate.inc, line 96
Migration functions for the PM Task module.

Code

function _pmtask_migrate_migrate_single_node($nid, $vid, $task) {
  $node = node_load($nid, $vid);
  $assigned = _pmtask_get_drupal_uid_from_pmperson_nid($task->assigned_nid);
  if ($assigned) {
    $node->pm_assigned[LANGUAGE_NONE][0]['target_id'] = $assigned;
  }
  if ($task->taskcategory) {
    $node->pm_category[LANGUAGE_NONE][0]['value'] = $task->taskcategory;
  }
  if ($task->duration) {
    $node->pm_duration[LANGUAGE_NONE][0]['value'] = $task->duration;
  }
  if ($task->durationunit) {
    $node->pm_durationunit[LANGUAGE_NONE][0]['value'] = $task->durationunit;
  }
  if ($task->pricemode) {
    $node->pm_pricemode[LANGUAGE_NONE][0]['value'] = $task->pricemode;
  }
  if ($task->price) {
    $node->pm_price[LANGUAGE_NONE][0]['value'] = $task->price;
  }
  if ($task->currency) {
    $node->pm_currency[LANGUAGE_NONE][0]['value'] = $task->currency;
  }
  if ($task->taskpriority) {
    $node->pm_priority[LANGUAGE_NONE][0]['value'] = $task->taskpriority;
  }
  if ($task->taskstatus) {
    $node->pm_status[LANGUAGE_NONE][0]['value'] = $task->taskstatus;
  }
  if ($task->stepno) {
    $node->pm_step_number[LANGUAGE_NONE][0]['value'] = $task->stepno;
  }
  if ($task->weight) {
    $node->pm_weight[LANGUAGE_NONE][0]['value'] = $task->weight;
  }
  if (isset($task->billed) and isset($task->billable)) {
    $new_value = $task->billed ? 'Billed' : ($task->billable ? 'Billable' : 'Not
billable');
    $node->pm_billing_status[LANGUAGE_NONE][0]['value'] = $new_value;
  }
  if (isset($task->datebegin) and !empty($task->datebegin)) {
    $node->pm_date[LANGUAGE_NONE][0]['value'] = $task->datebegin;
    if (isset($task->dateend) and !empty($task->dateend)) {
      $node->pm_date[LANGUAGE_NONE][0]['value2'] = $task->dateend;
    }
  }
  if ($task->parent_nid) {
    $node->pmtask_parent[LANGUAGE_NONE][0]['target_id'] = $task->parent_nid;
  }
  elseif ($task->project_nid) {
    $node->pmtask_parent[LANGUAGE_NONE][0]['target_id'] = $task->project_nid;
  }
  node_save($node);
  return TRUE;
}