yandex_services_auth.module in Yandex Services Authorization API 8
Same filename and directory in other branches
Main file for the Yandex Services Authorization API module.
File
yandex_services_auth.moduleView source
<?php
/**
* @file
* Main file for the Yandex Services Authorization API module.
*/
/**
* Implements hook_menu().
*/
function yandex_services_auth_menu() {
$items = array();
$items['admin/config/system/yandex_services_auth'] = array(
'title' => 'Yandex Services Authorization',
'description' => 'Authorize your site to utilize Yandex services.',
'route_name' => 'yandex_services_auth.authorization_form',
);
$items['yandex_services_auth/oauth'] = array(
'route_name' => 'yandex_services_auth.oauth_callback',
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* API function to return information for other modules.
*
* @param string $value
* - client_id
* - client_secret
* - token
*/
function yandex_services_auth_info($value = 'token') {
switch ($value) {
case 'client_id':
return \Drupal::state()
->get('yandex_services_auth_client_id');
case 'client_secret':
return \Drupal::state()
->get('yandex_services_auth_client_secret');
case 'token':
default:
return \Drupal::state()
->get('yandex_services_auth_token');
}
}
/**
* Implements hook_help().
*/
function yandex_services_auth_help($path, $arg) {
switch ($path) {
case 'admin/help#yandex_services_auth':
$output = '';
$output .= '<h3>' . t('Overview') . '</h3>';
$output .= '<p>' . t('This project is the common authorization API for all Yandex services which support Yandex OAuth method.') . '</p>';
$output .= '<dl>';
$output .= '<dt><b>' . t('Authorization') . '</b></dt>';
$output .= '<dt>' . t('To authorize your site you should register Yandex application at !app_register_link. Then enter your application Client ID and Client Secret in the appropriate fields on !settings_page. The list of your Yandex applications is located !app_list_link.', array(
'!app_register_link' => l('https://oauth.yandex.ru/client/new', 'https://oauth.yandex.ru/client/new', array(
'attributes' => array(
'target' => '_blank',
),
)),
'!app_list_link' => l(t('here'), 'https://oauth.yandex.ru/client/my', array(
'attributes' => array(
'target' => '_blank',
),
)),
'!settings_page' => l(t('the module settings page'), 'admin/config/system/yandex_services_auth'),
)) . '</dt>';
$output .= '</dl>';
return $output;
case 'admin/config/system/yandex_services_auth':
$output = '<p>' . t('To authorize your site you should register Yandex application at !app_register_link. Then enter your application Client ID and Client Secret in the appropriate fields on this page. The list of your Yandex applications is located !app_list_link.', array(
'!app_register_link' => l('https://oauth.yandex.ru/client/new', 'https://oauth.yandex.ru/client/new', array(
'attributes' => array(
'target' => '_blank',
),
)),
'!app_list_link' => l(t('here'), 'https://oauth.yandex.ru/client/my', array(
'attributes' => array(
'target' => '_blank',
),
)),
'@reports-url' => url('admin/reports/yandex_metrics_summary'),
)) . '</p>';
$output .= '<p>' . t('Your Yandex application Callback URI: @callback-uri', array(
'@callback-uri' => url('yandex_services_auth/oauth', array(
'absolute' => TRUE,
)),
)) . '</p>';
return $output;
}
}
Functions
Name | Description |
---|---|
yandex_services_auth_help | Implements hook_help(). |
yandex_services_auth_info | API function to return information for other modules. |
yandex_services_auth_menu | Implements hook_menu(). |