function tripal_contact_sync_contact

1.x contact_sync.inc tripal_contact_sync_contact($contact)

Parameters

$contact: A contactlication object

Return value

A new Drupal node object on success. FALSE on failure

Related topics

1 call to tripal_contact_sync_contact()
tripal_contact_sync_contacts in tripal_contact/includes/contact_sync.inc

File

tripal_contact/includes/contact_sync.inc, line 62

Code

function tripal_contact_sync_contact($contact) {
  global $user;

  $new_node = new stdClass();
  $new_node->contact_id = $contact->contact_id;
  $new_node->type = 'chado_contact';
  $new_node->title = $contact->name;
  $new_node->description = $contact->description;
  $new_node->type_id = $contact->type_id;

  node_validate($new_node);
  $errors = form_get_errors();
  if (!$errors) {
    $node = node_submit($new_node);
    node_save($node);
    if ($node->nid) {
      print "Added " . $contact->contact_id . "\n";
    }
    else {
      print "ERROR: Unable to create " . $contact->name . "\n";
      return FALSE;
    }
  }
  else {
    print "ERROR: Unable to create " . $contact->name . "\n" . print_r($errors, TRUE) . "\n";
    return FALSE;
  }
  return $node;
}