You are here

function _services_oauth_controller_settings in Services 6.3

Same name and namespace in other branches
  1. 7.3 auth/services_oauth/services_oauth.inc \_services_oauth_controller_settings()
1 string reference to '_services_oauth_controller_settings'
services_oauth_services_authentication_info in auth/services_oauth/services_oauth.module
Implementation of hook_services_authentication().

File

auth/services_oauth/services_oauth.inc, line 161
Include file for services_oauth module.

Code

function _services_oauth_controller_settings($settings, $controller, $endpoint, $class, $name) {
  $form = array();
  $cc = array(
    'credentials' => '',
    'authorization' => '',
  );
  if (!empty($controller['endpoint']['services_oauth'])) {
    $cc = $controller['endpoint']['services_oauth'] + $cc;
  }
  $auth_levels = array();
  if (is_array($settings)) {
    $context = oauth_common_context_load($settings['oauth_context']);
  }
  else {
    $context = new StdClass();
  }
  if (isset($context->authorization_levels)) {
    foreach ($context->authorization_levels as $name => $level) {
      $auth_levels[$name] = t($level['title']);
    }
  }
  $form['credentials'] = array(
    '#type' => 'select',
    '#options' => array(
      '' => t('Default'),
      'none' => t('None'),
      'unsigned_consumer' => t('Unsigned with consumer key'),
      'consumer' => t('Consumer key'),
      'token' => t('Consumer key and access token'),
    ),
    '#default_value' => $cc['credentials'],
    '#title' => t('Required authentication'),
    '#description' => t('Authorization levels will <em>not</em> be applied if the consumer isn\'t required to supply a access token.'),
  );
  $form['authorization'] = array(
    '#type' => 'select',
    '#options' => array(
      '' => t('Default'),
    ) + $auth_levels,
    '#default_value' => $cc['authorization'],
    '#title' => t('Required authorization'),
  );
  return $form;
}