You are here

function tmgmt_job_item_load_latest in Translation Management Tool 7

Same name and namespace in other branches
  1. 8 tmgmt.module \tmgmt_job_item_load_latest()

Loads active job entities that have a job item with the identifiers.

Parameters

$plugin: The source plugin.

$item_type: The source item type.

$item_id: The source item id.

string $source_language: The source language of the item.

Return value

array An array of job entities.

Related topics

12 calls to tmgmt_job_item_load_latest()
TMGMTEntityDefaultSourceUIController::getEntitiesTranslationData in sources/entity/tmgmt_entity.ui.inc
Gets entities data of provided type needed to build overview form list.
TMGMTI18nStringDefaultSourceUIController::getTranslationData in sources/i18n_string/tmgmt_i18n_string.ui.inc
Helper function to create translation data list for the sources page list.
TMGMTLocaleSourceUIController::getTranslationData in sources/locale/tmgmt_locale.ui.inc
Helper function to create translation data list for the sources page list.
TMGMTLocaleSourceUiTestCase::testOverview in sources/locale/tmgmt_locale.ui.test
TMGMTNodeSourceUITestCase::testTranslateTabAutomatedCheckout in sources/node/ui/tmgmt_node_ui.test
Test the translate tab for a single checkout.

... See full list

File

./tmgmt.module, line 362
Main module file for the Translation Management module.

Code

function tmgmt_job_item_load_latest($plugin, $item_type, $item_id, $source_language) {
  $query = db_select('tmgmt_job_item', 'tji');
  $query
    ->innerJoin('tmgmt_job', 'tj', 'tj.tjid = tji.tjid');
  $result = $query
    ->condition('tj.source_language', $source_language)
    ->condition('tj.state', array(
    TMGMT_JOB_STATE_UNPROCESSED,
    TMGMT_JOB_STATE_ACTIVE,
  ))
    ->condition('tji.state', TMGMT_JOB_ITEM_STATE_ACCEPTED, '<>')
    ->condition('tji.plugin', $plugin)
    ->condition('tji.item_type', $item_type)
    ->condition('tji.item_id', $item_id)
    ->fields('tji', array(
    'tjiid',
  ))
    ->fields('tj', array(
    'target_language',
  ))
    ->orderBy('tji.changed', 'DESC')
    ->groupBy('tj.target_language')
    ->groupBy('tji.tjiid')
    ->groupBy('tji.changed')
    ->execute();
  if ($items = $result
    ->fetchAllKeyed()) {
    $return = array();
    foreach (tmgmt_job_item_load_multiple(array_keys($items)) as $key => $item) {
      $return[$items[$key]] = $item;
    }
    return $return;
  }
  return FALSE;
}