function globallink_entity_update_change_flag in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.5 globallink_entity/globallink_entity.inc \globallink_entity_update_change_flag()
Clears "Changed" status for entities.
Parameters
array $nids: The array of entity node IDs.
string $source: The source of the nodes.
array $tgts: The targets of the nodes.
1 call to globallink_entity_update_change_flag()
- globallink_entity_form_clear_submit in globallink_entity/
globallink_entity_send.inc - Handles clearing the "Changed" status on entities that have been sent.
File
- globallink_entity/
globallink_entity.inc, line 240
Code
function globallink_entity_update_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_entity', 'tc')
->fields('tc')
->condition('nid', $nid, '=')
->condition('target', $tgt, '=')
->execute();
foreach ($result as $item) {
db_update('globallink_core_entity')
->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])) {
if ($insert_arr[$tgt][$nid]) {
$node = node_load($nid);
db_insert('globallink_core_entity')
->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();
}
}
}
}
}