You are here

function oauth_common_permission in OAuth 1.0 7.4

Same name and namespace in other branches
  1. 7.3 oauth_common.module \oauth_common_permission()

Implements hook_permission().

File

./oauth_common.module, line 35

Code

function oauth_common_permission() {
  $permissions = array(
    'oauth authorize any consumers' => array(
      'title' => t('Authorize any OAuth consumers'),
      'restrict access' => TRUE,
    ),
    'oauth register any consumers' => array(
      'title' => t('Register any OAuth consumers'),
      'restrict access' => TRUE,
    ),
    'administer oauth' => array(
      'title' => t('Administer OAuth'),
      'restrict access' => TRUE,
    ),
    'administer consumers' => array(
      'title' => t('Administer OAuth consumers'),
      'restrict access' => TRUE,
    ),
  );

  // Add seperate permissions for creating and
  // authorizing consumers in each context.
  foreach (oauth_common_context_list() as $name => $title) {
    $permissions[sprintf('oauth register consumers in %s', $name)] = array(
      'title' => t('Register OAuth consumers in %context', array(
        '%context' => $title,
      )),
    );
    $permissions[sprintf('oauth authorize consumers in %s', $name)] = array(
      'title' => t('Authorize OAuth consumers in %context', array(
        '%context' => $title,
      )),
    );
  }
  return $permissions;
}