You are here

function yandex_services_auth_admin_settings in Yandex Services Authorization API 7

Same name and namespace in other branches
  1. 6 yandex_services_auth.admin.inc \yandex_services_auth_admin_settings()

Menu callback; the application authorization form.

1 string reference to 'yandex_services_auth_admin_settings'
yandex_services_auth_menu in ./yandex_services_auth.module
Implements hook_menu().

File

./yandex_services_auth.admin.inc, line 10
Admin pages for the Yandex Services Authorization API module.

Code

function yandex_services_auth_admin_settings() {

  // Show instructions from hook_help() in case system help block is disabled
  // for the current theme.
  if (!_yandex_services_auth_is_system_help_block_enabled()) {
    $form['help'] = array(
      '#markup' => module_invoke('yandex_services_auth', 'help', 'admin/config/system/yandex_services_auth', drupal_help_arg()),
    );
  }
  $auth_token = variable_get('yandex_services_auth_token', '');
  $auth_timestamp = variable_get('yandex_services_auth_timestamp', '');
  switch (yandex_services_auth_status()) {
    case 'not authorized':
      $auth_status = '<span style="color:red;">' . t('The application is not authorized yet.') . '</span>';
      break;
    case 'authorized':
      $auth_status = '<span style="color:green;">' . t('The application is already authorized.') . '</span>';
      break;
    case 'expiring':
      $auth_status = '<span style="color:yellow;">' . t('The application authorization is expiring.') . '</span>';
      break;
    case 'expired':
      $auth_status = '<span style="color:red;">' . t('The application authorization has expired.') . '</span>';
      break;
  }
  $form['yandex_services_auth_text'] = array(
    '#type' => 'item',
    '#markup' => $auth_status,
  );
  $form['yandex_services_auth_client_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Client ID'),
    '#description' => t('Your application client ID.'),
    '#required' => TRUE,
    '#default_value' => variable_get('yandex_services_auth_client_id', ''),
  );
  $form['yandex_services_auth_client_secret'] = array(
    '#type' => 'textfield',
    '#title' => t('Client Secret'),
    '#description' => t('Your application secret.'),
    '#default_value' => variable_get('yandex_services_auth_client_secret', ''),
  );
  $form['yandex_services_auth_timestamp'] = array(
    '#type' => 'item',
    '#title' => t('Expiration time'),
    '#markup' => $auth_timestamp ? format_date($auth_timestamp) : t('Not available'),
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => !empty($auth_token) ? t('Re-Authorize') : t('Authorize'),
  );
  return $form;
}