function globallink_beans_update_ticket_id in GlobalLink Connect for Drupal 7.6
Updates bean's ticket ID.
Parameters
array $arr: Array of GlobalLink objects.
string $project_code: The bean's project code.
1 call to globallink_beans_update_ticket_id()
- globallink_beans_dashboard_form_submit in globallink_beans/
globallink_beans_send.inc - Handles beans form submission.
File
- globallink_beans/
globallink_beans.inc, line 454
Code
function globallink_beans_update_ticket_id($arr, $project_code) {
foreach ($arr as $globallink) {
$target_locale_arr = $globallink->targetLocale;
$type = $globallink->type;
if ($type != 'bean') {
continue;
}
$bid = $globallink->otherObjectId;
$bean_arr = entity_load('bean', array(
$bid,
));
$key = key($bean_arr);
$bean = $bean_arr[$key];
foreach ($target_locale_arr as $target_locale) {
$row = globallink_bean_get_row($bid, $globallink->sourceLocale, $target_locale);
$title = 'Title Not Found';
if (!empty($bean->title)) {
$title = $bean->title;
}
else {
if (!empty($bean->admin_title)) {
$title = $bean->admin_title;
}
}
if ($row) {
db_update('globallink_core_beans')
->fields(array(
'title' => $title,
'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_beans')
->fields(array(
'object_id' => $bid,
'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' => REQUEST_TIME,
'project_code' => $project_code,
))
->execute();
}
}
}
}