You are here

function lingotek_grid_upload_edited in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.5 lingotek.bulk_grid.inc \lingotek_grid_upload_edited()
  2. 7.6 lingotek.bulk_grid.inc \lingotek_grid_upload_edited()
1 string reference to 'lingotek_grid_upload_edited'
lingotek_menu in ./lingotek.module
Implements hook_menu().

File

./lingotek.bulk_grid.inc, line 1363

Code

function lingotek_grid_upload_edited($entity_type, $comma_separated_ids = NULL) {
  if ($entity_type === 'config') {
    config_upload_edited($comma_separated_ids, $entity_type);
    return;
  }
  if ($comma_separated_ids !== NULL) {
    $entity_ids = explode(",", $comma_separated_ids);
  }
  elseif (isset($_SESSION['grid_filters'][$entity_type]) && isset($_SESSION['grid_filters'][$entity_type]['filtered_ids'])) {
    empty_array_check($_SESSION['grid_filters'][$entity_type]['filtered_ids'], $entity_type, "There are no entities ready for upload for this filter");
    $selected_ids = $_SESSION['grid_filters'][$entity_type]['filtered_ids'];

    //check lid selection for dirty statuses
    $entity_ids = LingotekSync::getEntityIdsToUpload($entity_type, $selected_ids);
    empty_array_check($entity_ids, $entity_type, "There are no entities ready for upload for this selection. Note: To upload disassociated content, select it using the checkboxes first.");
  }
  else {

    // Get all lids that are ready to upload
    $entity_ids = LingotekSync::getEntityIdsToUpload($entity_type);
  }
  if (!empty($entity_ids)) {
    $operations = array();
    foreach ($entity_ids as $id) {
      $operations[] = array(
        'lingotek_entity_upload',
        array(
          $id,
          $entity_type,
        ),
      );
    }
    $redirect = 'admin/settings/lingotek/manage/' . $entity_type;
    $batch = array(
      'title' => t('Uploading documents'),
      'finished' => 'lingotek_sync_upload_node_finished',
      'operations' => $operations,
    );
    batch_set($batch);
    batch_process($redirect);
  }
  else {
    drupal_set_message(t('There are no edited entities ready for <i>Re-upload</i>.'));
    drupal_goto('admin/settings/lingotek/manage/' . $entity_type);
  }
}