You are here

function _pmticket_migrate_migrate_single_node in Drupal PM (Project Management) 7.2

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

Helper function to migrate single pmticket.

1 call to _pmticket_migrate_migrate_single_node()
pmticket_migrate_field_data in pmticket/includes/pmticket.migrate.inc
Migrate pmticket node fields data to drupal user bundle.

File

pmticket/includes/pmticket.migrate.inc, line 97
Migration functions for the PM Ticket module.

Code

function _pmticket_migrate_migrate_single_node($nid, $vid, $ticket) {
  $node = node_load($nid, $vid);
  $assigned = _pmticket_get_drupal_uid_from_pmperson_nid($ticket->assigned_nid);
  if ($assigned) {
    $node->pm_assigned[LANGUAGE_NONE][0]['target_id'] = $assigned;
  }
  if ($ticket->ticketcategory) {
    $node->pm_category[LANGUAGE_NONE][0]['value'] = $ticket->ticketcategory;
  }
  if ($ticket->duration) {
    $node->pm_duration[LANGUAGE_NONE][0]['value'] = $ticket->duration;
  }
  if ($ticket->durationunit) {
    $node->pm_durationunit[LANGUAGE_NONE][0]['value'] = $ticket->durationunit;
  }
  if ($ticket->pricemode) {
    $node->pm_pricemode[LANGUAGE_NONE][0]['value'] = $ticket->pricemode;
  }
  if ($ticket->price) {
    $node->pm_price[LANGUAGE_NONE][0]['value'] = $ticket->price;
  }
  if ($ticket->currency) {
    $node->pm_currency[LANGUAGE_NONE][0]['value'] = $ticket->currency;
  }
  if ($ticket->ticketpriority) {
    $node->pm_priority[LANGUAGE_NONE][0]['value'] = $ticket->ticketpriority;
  }
  if ($ticket->ticketstatus) {
    $node->pm_status[LANGUAGE_NONE][0]['value'] = $ticket->ticketstatus;
  }
  if (isset($ticket->billed) and isset($ticket->billable)) {
    $new_value = $ticket->billed ? 'Billed' : ($ticket->billable ? 'Billable' : 'Not billable');
    $node->pm_billing_status[LANGUAGE_NONE][0]['value'] = $new_value;
  }
  if (isset($ticket->datebegin) and !empty($ticket->datebegin)) {
    $node->pm_date[LANGUAGE_NONE][0]['value'] = $ticket->datebegin;
    if (isset($ticket->dateend) and !empty($ticket->dateend)) {
      $node->pm_date[LANGUAGE_NONE][0]['value2'] = $ticket->dateend;
    }
  }
  if ($ticket->parent_nid) {
    $node->pmticket_parent[LANGUAGE_NONE][0]['target_id'] = $ticket->parent_nid;
  }
  elseif ($ticket->project_nid) {
    $node->pmticket_parent[LANGUAGE_NONE][0]['target_id'] = $ticket->project_nid;
  }
  node_save($node);
  return TRUE;
}