You are here

function lingotek_save_config_profile in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.6 lingotek.admin.inc \lingotek_save_config_profile()
2 calls to lingotek_save_config_profile()
lingotek_admin_additional_translation_settings_form_submit in ./lingotek.admin.inc
lingotek_update_7603 in ./lingotek.install
Create translation profile for Lingotek settings of config items.

File

./lingotek.admin.inc, line 1053

Code

function lingotek_save_config_profile($form_state) {
  $project_id = isset($form_state['values']['addtl_project_id']) ? $form_state['values']['addtl_project_id'] : variable_get('lingotek_project', '');
  $vault_id = isset($form_state['values']['addtl_vault_id']) ? $form_state['values']['addtl_vault_id'] : variable_get('lingotek_vault', '');
  $workflow_id = isset($form_state['values']['addtl_workflow_id']) ? $form_state['values']['addtl_workflow_id'] : variable_get('lingotek_translate_config_workflow_id', '');
  $prefill_phase = isset($form_state['values']['addtl_prefill_phase_select']) ? $form_state['values']['addtl_prefill_phase_select'] : NULL;
  $config_checkbox = isset($form_state['values']['addtl_prefill_phases_checkbox']) ? $form_state['values']['addtl_prefill_phases_checkbox'] : FALSE;
  $overwrite_config_set_workflow = isset($form_state['values']['overwrite_config_set_workflow']) ? $form_state['values']['overwrite_config_set_workflow'] : TRUE;
  $profile = array(
    'project_id' => $project_id,
    'vault_id' => $vault_id,
    'name' => 'lingotek_config',
    'workflow_id' => $workflow_id,
    'auto_upload' => 0,
    'auto_download' => 1,
  );
  try {
    LingotekProfile::create(LingotekSync::PROFILE_CONFIG, $profile);
  } catch (LingotekException $e) {
    LingotekProfile::update(LingotekSync::PROFILE_CONFIG, $profile);
  }
  if ($config_checkbox == TRUE) {
    $document_ids = $overwrite_config_set_workflow == TRUE ? LingotekConfigSet::getAllConfigDocIds() : LingotekConfigSet::getAllUnsetWorkflowConfigDocIds();

    // Change all other workflows retroactively
    if ($overwrite_config_set_workflow == TRUE) {
      LingotekConfigSet::deleteConfigSetWorkflowIds();

      //removes workflows set on config sets. Defaults to the config default.
    }
    if (!empty($document_ids)) {
      $api = LingotekApi::instance();
      $api
        ->changeWorkflow($document_ids, $workflow_id, $prefill_phase);
    }
  }
}