function globallink_update_node_change_flag in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.5 globallink_node.inc \globallink_update_node_change_flag()
Updates node modified flag.
Parameters
array $nids: Array of node nids.
string $source: GlobalLink locale code.
array $tgts: Array of GlobalLink locale codes.
1 call to globallink_update_node_change_flag()
- globallink_node_form_clear_submit in ./
globallink_send_translations.inc - Handles clearing the "Changed" status on GlobalLink nodes that have been sent.
File
- ./
globallink_node.inc, line 194
Code
function globallink_update_node_change_flag($nids, $source, $tgts) {
watchdog('GlobalLink', 'CHANGED Status Cleared for Node Ids - [%nids]', array(
'%nids' => implode(',', $nids),
), WATCHDOG_INFO);
$insert_arr = array();
$tgt_arr = array_keys($tgts);
foreach ($tgt_arr as $tgt) {
foreach ($nids as $nid) {
$insert_arr[$tgt][$nid] = TRUE;
}
}
foreach ($tgt_arr as $tgt) {
foreach ($nids as $nid) {
$result = db_select('globallink_core', 'tc')
->fields('tc')
->condition('nid', $nid, '=')
->condition('target', $tgt, '=')
->execute();
foreach ($result as $item) {
db_update('globallink_core')
->fields(array(
'timestamp' => REQUEST_TIME,
'changed' => 2,
))
->condition('rid', $item->rid, '=')
->execute();
$insert_arr[$tgt][$nid] = FALSE;
}
}
}
foreach ($tgt_arr as $tgt) {
foreach ($nids as $nid) {
if (!isset($insert_arr[$tgt]) || !isset($insert_arr[$tgt][$nid])) {
continue;
}
if (!$insert_arr[$tgt][$nid]) {
continue;
}
$node = node_load($nid);
db_insert('globallink_core')
->fields(array(
'nid' => $nid,
'vid' => $node->vid,
'type' => $node->type,
'title' => $node->title,
'source' => $source,
'target' => $tgt,
'document_ticket' => '',
'submission' => '',
'submission_ticket' => '',
'status' => 'Pending Translations',
'timestamp' => REQUEST_TIME,
'last_modified' => $node->changed,
'changed' => 2,
))
->execute();
}
}
}