You are here

function globallink_webform_update_ticket_id in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.6 globallink_webform/globallink_webform.inc \globallink_webform_update_ticket_id()

Updates webform ticket ID.

Parameters

array $arr: Array of GlobalLink objects.

string $project_code: The webform's project code.

1 call to globallink_webform_update_ticket_id()
globallink_webform_dashboard_form_submit in globallink_webform/globallink_webform_send.inc
Handles webform form submission.

File

globallink_webform/globallink_webform.inc, line 133

Code

function globallink_webform_update_ticket_id($arr, $project_code) {
  foreach ($arr as $globallink) {
    $target_locale_arr = $globallink->targetLocale;
    $type = $globallink->type;
    if ($type != 'webform') {
      continue;
    }
    $lid = $globallink->otherObjectId;
    $webform = globallink_load_source_data($lid);
    foreach ($target_locale_arr as $target_locale) {
      $row = globallink_webform_get_row($lid, $type, $globallink->sourceLocale, $target_locale);
      if ($row) {
        db_update('globallink_core_webform')
          ->fields(array(
          'title' => $webform[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_webform')
          ->fields(array(
          'object_id' => $lid,
          'object_type' => $globallink->type,
          'title' => $webform[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();
      }
    }
  }
}