You are here

function lingotek_community_select_form in Lingotek Translation 7.2

Same name and namespace in other branches
  1. 7.7 lingotek.setup.inc \lingotek_community_select_form()
  2. 7.3 lingotek.setup.inc \lingotek_community_select_form()
  3. 7.4 lingotek.setup.inc \lingotek_community_select_form()
  4. 7.5 lingotek.setup.inc \lingotek_community_select_form()
  5. 7.6 lingotek.setup.inc \lingotek_community_select_form()

Community Select Screen (for Current Users) - Form

1 string reference to 'lingotek_community_select_form'
lingotek_menu in ./lingotek.module
Implements hook_menu().

File

./lingotek.setup.inc, line 312
Lingotek Easy Install Process.

Code

function lingotek_community_select_form() {
  $login_id = variable_get('lingotek_login_id', '');
  $password = variable_get('lingotek_password', '');
  $form = array();

  // V3 API Calls for Legacy Users
  $lingotek_url = variable_get('lingotek_url', LINGOTEK_API_SERVER);
  $communities = lingotek_get_communities_v4($login_id, $password, $lingotek_url . '/lingopoint/api/4');
  if ($communities === FALSE) {
    drupal_set_message(t('Invalid login or password.'), 'error');
    drupal_goto('admin/config/lingotek/account-settings');

    // Shouldnt be here.  So something messed up.  Go back.
  }
  else {
    $count = count($communities);
    if ($count == 1) {

      // Just one community, use that.
      $community_keys = array_keys($communities);
      $community_id = array_pop($community_keys);
      variable_set('lingotek_community_identifier', $community_id);
      drupal_goto('admin/config/lingotek/project-select');

      // Default path, if they only have 1 community.
    }
    elseif ($count > 1) {

      // More then 1 community
      // Stay on this page
    }
    else {

      // 0 Results, we have an error.  Or, we should create a community for them.
      drupal_set_message(t('Error Accessing Account. Please contact customer service.'), 'error');
      drupal_goto('admin/config/lingotek/account-settings');

      // Shouldnt be here.  So something messed up.  Go back.
    }
  }

  // END:  Community Select Paths
  $form['lingotek_user_directions_1'] = array(
    '#markup' => '<p>Your account is associated with multiple Lingotek communities.</p><p>Which community should we associate your Drupal site with?</p>',
  );
  $form['lingotek_top_spacer'] = array(
    '#markup' => '<div>&nbsp;</div>',
  );
  $form['lingotek_site_community'] = array(
    '#title' => t('Community'),
    '#type' => 'select',
    '#options' => $communities,
    //'#default_value' => ,

    //'#description' => t( '' ),
    '#required' => TRUE,
  );
  $form['lingotek_button_spacer'] = array(
    '#markup' => '<div>&nbsp;</div>',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Next'),
  );
  if (is_array($_SESSION['lingotek_setup_path'])) {
    if (end($_SESSION['lingotek_setup_path']) == 'admin/config/lingotek/community-select') {
      $null = array_pop($_SESSION['lingotek_setup_path']);
    }

    // if the user went back, remove the last element, which is this page.
    $form['lingotek_back_button'] = lingotek_setup_link(end($_SESSION['lingotek_setup_path']), t('Previous Step'));
  }
  $form['lingotek_support_footer'] = lingotek_support_footer();
  return $form;
}