You are here

function access_scheme_info in Access Control Kit 7

Returns information on available access scheme types.

Parameters

string $type: (optional) A scheme type.

Return value

array|false The information array for the requested $type, or FALSE if not found. If $type is omitted, returns information for all available types in an array indexed by type. Type information is returned as an associative array with the following keys:

  • label: The human-readable name of the scheme type.
  • data_type: The data type of the realm values. Valid data types are 'boolean', 'integer', 'float' and 'text'.
  • description: (optional) A translated string describing the scheme type.
  • realms callback: The name of the function that provides the realm list.
  • settings callback: (optional) The name of the function that provides the scheme type's settings form.
  • type: The scheme type.
  • module: The module that provides the scheme type.
  • include file: (optional) The full pathname of a file that should be included before executing the callback functions.

See also

hook_access_scheme_info()

hook_access_scheme_info_alter()

6 calls to access_scheme_info()
AccessPluginTest::testSchemeInfo in ./access.test
Check that scheme types are defined correctly.
AccessSchemeEntityController::attachLoad in ./access_scheme_entity_controller.inc
Overrides DrupalDefaultEntityController::attachLoad().
access_access_scheme_presave in ./access.access.inc
Implements hook_access_scheme_presave().
access_scheme_add_list in ./access_schemes.admin.inc
Menu page callback; the add access scheme list page.
access_scheme_type_load in ./access.module
Loads the info for a scheme type from a URL-friendly argument.

... See full list

3 string references to 'access_scheme_info'
access_hook_info in ./access.module
Implements hook_hook_info().
access_info_cache_clear in ./access.module
Clears cached ACK API information.
access_update_7105 in ./access.install
Convert access control kit fields to standard list fields.

File

./access.module, line 470
The access control kit module.

Code

function access_scheme_info($type = NULL) {
  $info =& drupal_static(__FUNCTION__, array());
  if (empty($info)) {
    $cache = cache_get('access_scheme_info');
    if ($cache) {
      $info = $cache->data;
    }
    else {
      foreach (module_implements('access_scheme_info') as $module) {
        $module_info = module_invoke($module, 'access_scheme_info');
        if ($module_info) {
          foreach ($module_info as $type_name => $type_info) {

            // Merge in default values.
            $type_info += array(
              'label' => '',
              'data_type' => '',
              'description' => '',
              'realms callback' => '',
              'settings callback' => '',
              'file' => '',
              'file path' => '',
            );

            // Set inferred values.
            $type_info['type'] = $type_name;
            $type_info['module'] = $module;
            $info[$type_name] = $type_info;
          }
        }
      }
      drupal_alter('access_scheme_info', $info);

      // Calculate the include file paths for the callbacks, if needed.
      foreach ($info as $type_name => $type_info) {
        if (!empty($type_info['file'])) {
          $file_path = empty($type_info['file path']) ? drupal_get_path('module', $type_info['module']) : $type_info['file path'];
          $info[$type_name]['include file'] = $file_path . '/' . $type_info['file'];
        }
        else {
          $info[$type_name]['include file'] = '';
        }
        unset($info[$type_name]['file']);
        unset($info[$type_name]['file path']);
      }
      cache_set('access_scheme_info', $info);
    }
  }
  if (isset($type)) {
    return isset($info[$type]) ? $info[$type] : FALSE;
  }
  return $info;
}