You are here

function lingotek_admin_profile_manage in Lingotek Translation 7.4

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

File

./lingotek.admin.inc, line 1347

Code

function lingotek_admin_profile_manage($profile_id) {
  $profiles = lingotek_get_profiles();
  if ($profile_id == 'add') {
    $profile = (object) array(
      'name' => '',
      'lingotek_nodes_translation_method' => 'field',
      'create_lingotek_document' => 1,
      'sync_method' => 1,
      'allow_community_translation' => 0,
      'url_alias_translation' => 0,
    );
    end($profiles);
    $profile_id = key($profiles) + 1;

    //set the id to one more than the last
  }
  else {
    $profile = lingotek_get_global_profile();
    $profile = array_merge($profile, $profiles[$profile_id]);
  }
  ctools_include('node.pages', 'node', '');
  ctools_include('modal');
  ctools_include('ajax');
  $form_state = array(
    'ajax' => TRUE,
  );
  $form_state['values']['profile_id'] = $profile_id;
  foreach ($profile as $key => $value) {
    $form_state['values'][$key] = $value;
  }
  $output = ctools_modal_form_wrapper('lingotek_admin_profile_form', $form_state);
  if (!empty($form_state['executed'])) {

    // Create ajax command array, dismiss the modal window.
    $commands = array();
    $commands[] = ctools_modal_command_dismiss();
    $commands[] = ctools_ajax_command_reload();
    print ajax_render($commands);
    drupal_exit();
  }
  print ajax_render($output);
}