You are here

function globallink_taxonomy_update_ticket_id in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.6 globallink_taxonomy/globallink_taxonomy.inc \globallink_taxonomy_update_ticket_id()

Updates taxonomy ticket ID on GlobalLink.

Parameters

array $arr: Array of GlobalLink objects.

string $project_code: The taxonomy's project code.

1 call to globallink_taxonomy_update_ticket_id()
globallink_taxonomy_dashboard_form_submit in globallink_taxonomy/globallink_taxonomy_send.inc
Handles taxonomy form submission.

File

globallink_taxonomy/globallink_taxonomy.inc, line 245

Code

function globallink_taxonomy_update_ticket_id($arr, $project_code) {
  foreach ($arr as $globallink) {
    $target_locale_arr = $globallink->targetLocale;
    $type = $globallink->type;
    if ($type != 'taxonomy') {
      continue;
    }
    $bid = $globallink->otherObjectId;
    $taxonomy = taxonomy_term_load($bid);
    foreach ($target_locale_arr as $target_locale) {
      $row = globallink_taxonomy_get_row($bid, $type, $globallink->sourceLocale, $target_locale);
      if ($row) {
        db_update('globallink_core_taxonomy')
          ->fields(array(
          'title' => $taxonomy->name,
          '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_taxonomy')
          ->fields(array(
          'object_id' => $bid,
          'object_type' => $globallink->type,
          'title' => $taxonomy->name,
          '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();
      }
    }
  }
}