function globallink_get_active_submission_rows_by_nid in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.5 globallink_node.inc \globallink_get_active_submission_rows_by_nid()
Gets active submission rows from nid.
Parameters
int $nids: The node id to pass in.
Return value
array The array of the active submission.
1 call to globallink_get_active_submission_rows_by_nid()
- globallink_dashboard_node_form in ./
globallink_send_translations.inc - Builds form to create a GlobalLink submission.
File
- ./
globallink_node.inc, line 1271
Code
function globallink_get_active_submission_rows_by_nid($nids) {
$query = db_select('globallink_core', 'tc');
$query
->condition('status', array(
'Sent for Translations',
'Error',
), 'IN');
$query
->condition('nid', $nids, 'IN');
$query
->fields('tc');
$results = $query
->execute();
$arr = array();
foreach ($results as $row) {
if (array_key_exists($row->nid, $arr)) {
array_push($arr[$row->nid], $row);
}
else {
$arr[$row->nid] = array(
$row,
);
}
}
$final_arr = array();
foreach ($arr as $nid => $nid_arr) {
$sub_arr = array();
foreach ($nid_arr as $r) {
if (array_key_exists($r->submission, $sub_arr)) {
array_push($sub_arr[$r->submission], $r->target);
}
else {
$sub_arr[$r->submission] = array(
$r->vid => $r->target,
);
}
}
if (count($sub_arr) > 0) {
$final_arr[$nid] = $sub_arr;
}
}
if (count($final_arr) > 0) {
return $final_arr;
}
return FALSE;
}