You are here

function globallink_get_active_submission_by_nid in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.7 globallink_node.inc \globallink_get_active_submission_by_nid()
  2. 7.6 globallink_node.inc \globallink_get_active_submission_by_nid()

Gets active submission from nid.

Parameters

int $nid: The node id to pass in.

Return value

array An array representing the active submission.

1 call to globallink_get_active_submission_by_nid()
globallink_dashboard_node_form in ./globallink_send_translations.inc
Builds form to create a GlobalLink submission.

File

./globallink_node.inc, line 1231

Code

function globallink_get_active_submission_by_nid($nid) {
  $query = db_select('globallink_core', 'tc');
  $query
    ->condition('status', array(
    'Sent for Translations',
    'Error',
  ), 'IN');
  $query
    ->condition('nid', $nid, '=');
  $query
    ->fields('tc');
  $results = $query
    ->execute();
  $arr = array();
  foreach ($results as $row) {
    if (array_key_exists($row->submission, $arr)) {
      $t_arr = $arr[$row->submission];
      $t_arr[$row->target] = $row->vid;
      $arr[$row->submission] = $t_arr;
    }
    else {
      $_arr = array(
        $row->target => $row->vid,
      );
      $arr[$row->submission] = $_arr;
    }
  }
  return $arr;
}