You are here

function lingotek_admin_account_status_form in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.3 lingotek.admin.inc \lingotek_admin_account_status_form()
  2. 7.4 lingotek.admin.inc \lingotek_admin_account_status_form()
  3. 7.5 lingotek.admin.inc \lingotek_admin_account_status_form()
  4. 7.6 lingotek.admin.inc \lingotek_admin_account_status_form()

Form constructor for the administration form.

Return value

array A FAPI form array.

1 string reference to 'lingotek_admin_account_status_form'
lingotek_admin_configuration_view in ./lingotek.admin.inc

File

./lingotek.admin.inc, line 16

Code

function lingotek_admin_account_status_form($form, &$form_state, $show_fieldset = FALSE) {
  lingotek_is_module_setup();
  $account = LingotekAccount::instance();
  $show_advanced = $account
    ->showAdvanced();

  // Account Status
  $account_status = $account
    ->getStatusText();
  $form['status'] = array(
    '#type' => $show_fieldset ? 'fieldset' : 'item',
    '#title' => t('Account'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => 'administrative_settings',
  );
  $form['status']['account_summary'] = array(
    '#type' => 'hidden',
    '#value' => $account_status,
    '#attributes' => array(
      'id' => array(
        'account_summary',
      ),
    ),
  );

  // Account Information
  $activation_details = variable_get('lingotek_activation_first_name', '') . ' ' . variable_get('lingotek_activation_last_name', '');
  $activation_email = variable_get('lingotek_activation_email', '');
  $activation_details .= strlen($activation_email) ? ' (' . $activation_email . ')' : '';
  $activation_details = strlen(trim($activation_details)) ? $activation_details : 'NA';
  drupal_add_js(array(
    'lingotek-disconnect-style' => array(
      'modalSize' => array(
        'type' => 'fixed',
        'width' => 600,
        'height' => 250,
      ),
      'closeImage' => theme('image', array(
        'path' => drupal_get_path('module', 'lingotek') . '/images/close.png',
        'alt' => t('Close window'),
        'title' => t('Close window'),
      )),
      'closeText' => '',
      'animation' => 'fadeIn',
    ),
  ), 'setting');
  $btn_disconnect_lingotek_account = array(
    '#type' => 'button',
    '#value' => t('Disconnect'),
    '#attributes' => array(
      'class' => array(
        'ctools-use-modal',
        'ctools-modal-lingotek-disconnect-style',
      ),
      'style' => 'background: red; color: white;',
    ),
    '#id' => 'ctools-lingotek-disconnect-button',
  );
  $form['switch_url'] = array(
    '#type' => 'hidden',
    // The name of the class is the #id of $btn_disconnect_account with "-url" suffix.
    '#attributes' => array(
      'class' => array(
        'ctools-lingotek-disconnect-button-url',
        'red',
      ),
    ),
    '#value' => url(LINGOTEK_MENU_MAIN_BASE_URL . '/disconnect'),
  );
  $disconnect_account_row = array(
    array(
      'data' => array(
        '#type' => 'markup',
        '#prefix' => t('Disconnect Account') . ' <i>' . t('(use with caution)') . '</i>' . '<div class="description">',
        '#markup' => t("Should only be used to completely change the Lingotek account or to have this page point to a different project and/or TM vault.<br/>" . "This is useful if the Drupal database was copied from a different site and translation content needs to be disassociated between the sites."),
        '#suffix' => '</div>',
      ),
    ),
    array(
      'data' => $btn_disconnect_lingotek_account,
    ),
  );
  $community = lingotek_get_community_name() . ' (' . variable_get('lingotek_community_identifier', '') . ')';
  $project = lingotek_get_project_name() . ' (' . variable_get('lingotek_project', '') . ') ' . l(t('Edit defaults'), LINGOTEK_MENU_LANG_BASE_URL . '/edit-defaults');
  $workflow_id = variable_get('lingotek_workflow', NULL);
  $workflow_name = lingotek_get_workflow_name();
  $workflow = $workflow_name . ' (' . $workflow_id . ') ' . l(t('Edit defaults'), LINGOTEK_MENU_LANG_BASE_URL . '/edit-defaults');
  $vault_id = variable_get('lingotek_vault', '');
  $vault_name = lingotek_get_vault_name();
  $vault = $vault_name . ' (' . $vault_id . ') ' . l(t('Edit defaults'), LINGOTEK_MENU_LANG_BASE_URL . '/edit-defaults');
  $form['status'][] = array(
    '#type' => 'item',
    '#markup' => theme('table', array(
      'header' => array(),
      'rows' => array(
        array(
          t('Status:'),
          $account_status,
        ),
        array(
          t('Enterprise:'),
          $show_advanced ? '<span style="color: green;">' . t('Yes') . '</span>' : '<span>' . t('No') . '</span>',
        ),
        array(
          t('Activation Name:'),
          $activation_details,
        ),
        array(
          t('OAuth Credentials:') . ' <a id="lingotek-oauth-secret-btn"><i class="fa fa-lock fa-lg' . '" alt="' . t('lock/unlock') . '" style="cursor: pointer;"></i></a>',
          '<input type="text" value="' . variable_get('lingotek_oauth_consumer_id', '') . '" readonly="readonly" style="background: none; width: 80%;"/><span class="description">' . t('Key') . '</span>' . '<br/></span><span id="lingotek-oauth-secret" style="display:none;">' . '<input type="text" value="' . variable_get('lingotek_oauth_consumer_secret', '') . '" readonly="readonly" style="background: none; width: 80%;"/>' . '</span>' . '<span id="lingotek-oauth-secret-placeholder">' . '<input type="password" value="' . variable_get('lingotek_oauth_consumer_secret', '') . '" readonly="readonly" style="background: none; width: 80%;"/></span><span class="description">' . t('Secret') . '</span>',
        ),
        array(
          t('Integration Method ID:'),
          variable_get('lingotek_integration_method', ''),
        ),
        array(
          t('External ID:'),
          variable_get('lingotek_login_id', ''),
        ),
        array(
          t('Community:'),
          $community,
        ),
        array(
          t('Project ID:'),
          $project,
        ),
        array(
          t('Workflow:'),
          $workflow,
        ),
        array(
          t('Vault:'),
          $vault,
        ),
        array(
          t('Notify URL:'),
          '<span title="' . variable_get('lingotek_notify_url', '') . '">' . truncate_utf8(variable_get('lingotek_notify_url', ''), 45, FALSE, TRUE) . '</span>',
        ),
        $disconnect_account_row,
      ),
    )),
  );
  return $form;
}