You are here

function globallink_entity_get_active_submission_by_nid in GlobalLink Connect for Drupal 7.6

Same name and namespace in other branches
  1. 7.7 globallink_entity/globallink_entity.inc \globallink_entity_get_active_submission_by_nid()
  2. 7.5 globallink_entity/globallink_entity.inc \globallink_entity_get_active_submission_by_nid()

Gets active entity submission by node ID.

Parameters

string $nid: The entity node ID.

Return value

array Associative array representing the active entity submission.

1 call to globallink_entity_get_active_submission_by_nid()
globallink_entity_dashboard_form in globallink_entity/globallink_entity_send.inc
Builds form to create an entity submission.

File

globallink_entity/globallink_entity.inc, line 967

Code

function globallink_entity_get_active_submission_by_nid($nid) {
  $query = db_select('globallink_core_entity', '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;
}