You are here

function globallink_interface_update_ticket_id in GlobalLink Connect for Drupal 7.6

Updates interface ticket ID.

Parameters

array $arr: Array of GlobalLink objects.

string $project_code: The interface's project code.

1 call to globallink_interface_update_ticket_id()
globallink_interface_dashboard_form_submit in globallink_interface/globallink_interface_send.inc
Handles interface form submission.

File

globallink_interface/globallink_interface.inc, line 114

Code

function globallink_interface_update_ticket_id($arr, $project_code) {
  foreach ($arr as $globallink) {
    $target_locale_arr = $globallink->targetLocale;
    $type = $globallink->type;
    if ($type != 'interface') {
      continue;
    }
    $lid = $globallink->otherObjectId;
    $interface = globallink_load_source_data($lid);
    foreach ($target_locale_arr as $target_locale) {
      $row = globallink_interface_get_row($lid, $type, $globallink->sourceLocale, $target_locale);
      if ($row) {
        db_update('globallink_core_interface')
          ->fields(array(
          'title' => $interface[0]->source,
          'document_ticket' => $globallink->documentTicket,
          'submission' => $globallink->submissionName,
          'submission_ticket' => $globallink->submissionTicket,
          'status' => 'Sent for Translations',
          'timestamp' => REQUEST_TIME,
          'last_modified' => REQUEST_TIME,
          'project_code' => $project_code,
        ))
          ->condition('rid', $row->rid, '=')
          ->execute();
      }
      else {
        db_insert('globallink_core_interface')
          ->fields(array(
          'object_id' => $lid,
          'object_type' => $globallink->type,
          'title' => $interface[0]->source,
          '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' => REQUEST_TIME,
          'project_code' => $project_code,
        ))
          ->execute();
      }
    }
  }
}