You are here

function lingotek_sync_upload_node_finished in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.4 lingotek.batch.inc \lingotek_sync_upload_node_finished()
  2. 7.5 lingotek.batch.inc \lingotek_sync_upload_node_finished()
  3. 7.6 lingotek.batch.inc \lingotek_sync_upload_node_finished()
1 call to lingotek_sync_upload_node_finished()
lingotek_sync_upload_config_finished in ./lingotek.batch.inc
2 string references to 'lingotek_sync_upload_node_finished'
lingotek_grid_action_submit in ./lingotek.bulk_grid.inc
Submit function for The Grid's actions The action corresponds to the key of the option selected Often redirects to batch operations or to other pages entirely
lingotek_grid_upload_edited in ./lingotek.bulk_grid.inc

File

./lingotek.batch.inc, line 310
Central location for batch create functions, before control is handed off to individual batch command files.

Code

function lingotek_sync_upload_node_finished($success, $results, $operations, $config = FALSE) {
  if ($success) {
    $count = isset($results['uploads']) ? $results['uploads'] : 0;
    $node_message = format_plural($count, 'One entity uploaded to Lingotek.', '@count entities uploaded to Lingotek.');
    $config_message = format_plural($count, 'Uploaded one set of config items to Lingotek.', 'Uploaded @count sets of config items to Lingotek.');
    if ($config === TRUE) {
      $message = $config_message;
      if (isset($results['upload_fails']) && isset($results['upload_fail_cids'])) {
        $failed_cids = $results['upload_fail_cids'];
        $cids = 'Config set IDs: ';
        $pos = 0;
        foreach ($failed_cids as $cid) {
          $cids .= $cid;
          if ($pos !== count($failed_cids) - 1) {
            $cids .= ', ';
          }
          $pos++;
        }
        $message = t('Some config items failed to upload because the previous config set didn\'t finish uploading. Please wait and upload again. (' . $cids . ')');

        // Coder review error (does not end with a space)
      }
    }
    else {
      $message = $node_message;
    }
    $message .= isset($results['uploaded_nids']) && is_array($results['uploaded_nids']) ? ' (' . format_plural($count, 'entity id', 'entity ids') . ': ' . implode(", ", $results['uploaded_nids']) . ')' : '';
    $message .= isset($results['disabled']) ? ' ' . t("<i>(Note: entities with the Disabled profile must be set to an enabled profile to be uploaded)</i>") : "";
    $status = isset($results['disabled']) || isset($results['upload_fails']) ? 'warning' : 'status';
    drupal_set_message(filter_xss($message), $status);
  }
  else {
    $message = t('Finished with an error.');
    drupal_set_message(filter_xss($message), 'error');
  }
}