You are here

function globallink_taxonomy_get_active_submission_rows in GlobalLink Connect for Drupal 7.6

Same name and namespace in other branches
  1. 7.5 globallink_taxonomy/globallink_taxonomy.inc \globallink_taxonomy_get_active_submission_rows()

Gets active taxonomy submission rows by object ID.

Parameters

string $object_id: The object ID.

Return value

Associative array of taxonomy active submission rows. FALSE if the array is empty.

1 call to globallink_taxonomy_get_active_submission_rows()
globallink_taxonomy_dashboard_form in globallink_taxonomy/globallink_taxonomy_send.inc
Builds form to create a taxonomy submission.

File

globallink_taxonomy/globallink_taxonomy.inc, line 1014

Code

function globallink_taxonomy_get_active_submission_rows($object_id) {
  $query = db_select('globallink_core_taxonomy', 'tc');
  $query
    ->condition('status', 'Sent for Translations', '=');
  $query
    ->condition('object_id', $object_id, '=');
  $query
    ->fields('tc');
  $results = $query
    ->execute();
  $arr = array();
  foreach ($results as $row) {
    if (array_key_exists($row->object_id, $arr)) {
      array_push($arr[$row->object_id], $row);
    }
    else {
      $arr[$row->object_id] = array(
        $row,
      );
    }
  }
  $final_arr = array();
  foreach ($arr as $bid => $bid_arr) {
    $sub_arr = array();
    foreach ($bid_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->target,
        );
      }
    }
    if (count($sub_arr) > 0) {
      $final_arr[$bid] = $sub_arr;
    }
  }
  if (count($final_arr) > 0) {
    return $final_arr;
  }
  return FALSE;
}