You are here

function lingotek_admin_profile_manage in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.4 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 1835

Code

function lingotek_admin_profile_manage($profile_id) {
  $profiles = lingotek_get_profiles(FALSE);
  $profile = lingotek_get_global_profile();
  if ($profile_id == 'add') {
    end($profiles);

    // Set ID to one more than the current count, and then increment as needed.
    $profile_id = count($profiles) + 1;
    while (isset($profiles[$profile_id])) {
      $profile_id++;
    }
  }
  else {
    $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_redirect('admin/settings/lingotek/settings', 0, array(
      'fragment' => 'ltk-profiles',
    ));
    $commands[] = ctools_ajax_command_reload();
    print ajax_render($commands);
    drupal_exit();
  }
  print ajax_render($output);
}