You are here

function yandex_metrics_authorization in Yandex.Metrics 6

Same name and namespace in other branches
  1. 7 yandex_metrics.module \yandex_metrics_authorization()

Menu callback; the application authorization form.

1 string reference to 'yandex_metrics_authorization'
yandex_metrics_menu in ./yandex_metrics.module
Implementation of hook_menu().

File

./yandex_metrics.module, line 678
The main code of Yandex.Metrics module.

Code

function yandex_metrics_authorization() {
  $authorisation_token = variable_get('yandex_metrics_auth_token', '');
  if (!empty($authorisation_token)) {
    $authorization_status_text = '<span style="color:green;">' . t('The application is already authorized.') . '</span>';
  }
  else {
    $authorization_status_text = '<span style="color:red;">' . t('The application is not authorized yet.') . '</span>';
  }
  $form['yandex_metrics_auth_text'] = array(
    '#value' => $authorization_status_text,
    '#type' => 'item',
  );
  $form['yandex_metrics_client_id'] = array(
    '#default_value' => variable_get('yandex_metrics_client_id', ''),
    '#title' => t('Client ID'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#description' => t('Enter your application client ID in this field.'),
  );
  $form['yandex_metrics_client_secret'] = array(
    '#default_value' => variable_get('yandex_metrics_client_secret', ''),
    '#title' => t('Client Secret'),
    '#type' => 'textfield',
    '#description' => t('Enter your application secret in this field.'),
  );
  $form['authorize'] = array(
    '#type' => 'submit',
    '#value' => !empty($authorisation_token) ? t('Re-Authorize Application') : t('Authorize Application'),
  );
  return $form;
}