You are here

function yandex_metrics_authorization_submit in Yandex.Metrics 7

Same name and namespace in other branches
  1. 6 yandex_metrics.module \yandex_metrics_authorization_submit()

Implementation of hook_submit for yandex_metrics_authorization form.

_state

Parameters

array $form:

File

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

Code

function yandex_metrics_authorization_submit($form, &$form_state) {
  variable_set('yandex_metrics_client_id', $form_state['values']['yandex_metrics_client_id']);
  variable_set('yandex_metrics_client_secret', $form_state['values']['yandex_metrics_client_secret']);
  $client_id = variable_get('yandex_metrics_client_id', '');
  if (empty($client_id)) {
    drupal_set_message(t("Please set Client ID first."));
    return;
  }
  $request_url = 'https://oauth.yandex.ru/authorize';
  $params = array(
    'response_type' => 'code',
    'client_id' => $client_id,
  );

  // Check for the overlay.
  if (module_exists('overlay') && overlay_get_mode() == 'child') {
    overlay_close_dialog($request_url, array(
      'query' => $params,
      'external' => TRUE,
    ));
    overlay_deliver_empty_page();
  }
  else {
    drupal_goto($request_url, array(
      'query' => $params,
    ));
  }
}