You are here

function globallink_entity_update_ticket_id in GlobalLink Connect for Drupal 7.6

Same name and namespace in other branches
  1. 7.5 globallink_entity/globallink_entity.inc \globallink_entity_update_ticket_id()

Updates entity ticket ID.

Parameters

array $arr: Array of GlobalLink objects.

string $project_code: The entity's project code.

1 call to globallink_entity_update_ticket_id()
globallink_entity_dashboard_form_submit in globallink_entity/globallink_entity_send.inc
Handles entity form submission.

File

globallink_entity/globallink_entity.inc, line 123

Code

function globallink_entity_update_ticket_id($arr, $project_code) {
  module_load_include('inc', 'globallink', 'globallink');
  foreach ($arr as $globallink) {
    $nid = $globallink->nid;
    $node = node_load($nid);
    $target_locale_arr = $globallink->targetLocale;
    $source_locale_code = globallink_get_drupal_locale_code($globallink->sourceLocale);
    foreach ($target_locale_arr as $target_locale) {
      $row = globallink_entity_get_row_by_nid_and_locale($nid, $globallink->sourceLocale, $target_locale);
      $title = $node->title;
      if ($row) {
        db_update('globallink_core_entity')
          ->fields(array(
          'vid' => $globallink->vid,
          'title' => $title,
          'document_ticket' => $globallink->documentTicket,
          'submission' => $globallink->submissionName,
          'submission_ticket' => $globallink->submissionTicket,
          'status' => 'Sent for Translations',
          'timestamp' => REQUEST_TIME,
          'last_modified' => $node->changed,
          'changed' => 0,
          'project_code' => $project_code,
        ))
          ->condition('rid', $row->rid, '=')
          ->execute();
      }
      else {
        db_insert('globallink_core_entity')
          ->fields(array(
          'nid' => $globallink->nid,
          'vid' => $globallink->vid,
          'type' => $globallink->type,
          'title' => $title,
          'source' => $globallink->sourceLocale,
          'target' => $target_locale,
          'document_ticket' => $globallink->documentTicket,
          'submission' => $globallink->submissionName,
          'submission_ticket' => $globallink->submissionTicket,
          'status' => 'Sent for Translations',
          'timestamp' => REQUEST_TIME,
          'last_modified' => $node->changed,
          'changed' => 0,
          'project_code' => $project_code,
        ))
          ->execute();
      }
    }
  }
}