You are here

function globallink_check_pending_submission in GlobalLink Connect for Drupal 7.6

Same name and namespace in other branches
  1. 7.5 globallink_locale_mapping.inc \globallink_check_pending_submission()

Checks pending submission by locale.

Parameters

string $locale: The locale.

Return value

bool TRUE if the submission has not yet been sent. FALSE otherwise.

1 call to globallink_check_pending_submission()
globallink_locale_submit in ./globallink_locale_mapping.inc
Handles submission of globallink_locale form.

File

./globallink_locale_mapping.inc, line 195
globallink_locale_mapping.inc is a file that contains most functions needed on the Locale Mapping UI.

Code

function globallink_check_pending_submission($locale) {
  $query1 = db_select('globallink_core', 'tc')
    ->fields('tc', array(
    'rid',
  ))
    ->condition('tc.status', array(
    'Sent for Translations',
    'Error',
  ), 'IN')
    ->condition(db_or()
    ->condition('tc.source', $locale)
    ->condition('tc.target', $locale));
  $table_arr = array(
    'tce' => 'globallink_core_entity',
    'tcb' => 'globallink_core_block',
    'tci' => 'globallink_core_interface',
    'tcm' => 'globallink_core_menu',
    'tct' => 'globallink_core_taxonomy',
    'tcw' => 'globallink_core_webform',
  );
  foreach ($table_arr as $key => $table) {
    if (db_table_exists($table)) {
      $query2 = db_select($table, $key)
        ->fields($key, array(
        'rid',
      ))
        ->condition($key . '.status', array(
        'Sent for Translations',
        'Error',
      ), 'IN')
        ->condition(db_or()
        ->condition($key . '.source', $locale)
        ->condition($key . '.target', $locale));
      $query1
        ->union($query2, 'UNION ALL');
    }
  }
  $result = $query1
    ->execute();
  foreach ($result as $row) {
    if (isset($row)) {
      return FALSE;
    }
  }
  return TRUE;
}