You are here

function lingotek_workbench_moderation_moderate in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.3 lingotek.batch.inc \lingotek_workbench_moderation_moderate()
1 call to lingotek_workbench_moderation_moderate()
lingotek_notifications in ./lingotek.sync.inc
Registers the site translation notfication callback.
1 string reference to 'lingotek_workbench_moderation_moderate'
lingotek_post_download_workbench_moderation in ./lingotek.sync.inc

File

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

Code

function lingotek_workbench_moderation_moderate($nid, $options_index, $trans_options = array()) {
  $options = lingotek_get_workbench_moderation_options();
  $option = $options[$options_index];
  $node = lingotek_node_load_default($nid);
  $target_statuses = LingotekSync::getAllTargetStatusNotCurrent($nid);
  if (empty($target_statuses)) {

    // if not all of the targets have been translated and downloaded
    // if workbench_moderation is not enabled for this node
    if (module_exists('workbench_moderation') && isset($node->workbench_moderation)) {
      if ($options_index == 'no_moderation') {
        return;
      }
      elseif ($options_index == 'increment') {
        $transitions_from = $node->workbench_moderation['current']->state;
        $transitions_to = $trans_options[$transitions_from];
        workbench_moderation_moderate($node, $transitions_to);
      }
      else {
        $states = lingotek_get_workbench_moderation_states();
        $index = 0;
        foreach ($states as $state) {
          if ($index == $options_index) {
            workbench_moderation_moderate($node, $state);
            return;
          }
          $index++;
        }
      }
    }
  }
  return;
}