You are here

function access_access_scheme_info in Access Control Kit 7

Implements hook_access_scheme_info().

File

./access.access.inc, line 11
Access control kit API hook implementations to integrate with core modules.

Code

function access_access_scheme_info() {
  $info['boolean'] = array(
    'label' => t('Boolean'),
    'data_type' => 'boolean',
    'description' => t('A <em>boolean</em> scheme controls access based on a true/false value (or yes/no, checked/unchecked, etc.). For example, you could grant access to content based on the "sticky" property, or to user profiles based on the value of a boolean field provided by the list module.'),
    'realms callback' => 'access_scheme_boolean_realms',
    'file' => 'callbacks/access.boolean.inc',
  );
  foreach (array(
    'integer',
    'float',
    'text',
  ) as $data_type) {

    // See if a list field exists of this type.
    $field_type = 'list_' . $data_type;
    $fields = field_read_fields(array(
      'type' => $field_type,
    ));

    // Don't include other realm fields.
    foreach ($fields as $field_name => $field) {
      if (!empty($field['settings']['allowed_values_function']) && $field['settings']['allowed_values_function'] == '_access_field_allowed_values') {
        unset($fields[$field_name]);
      }
    }
    if (!empty($fields)) {
      $info[$field_type] = array(
        'data_type' => $data_type,
        'realms callback' => 'access_scheme_list_field_realms',
        'settings callback' => 'access_scheme_list_field_settings',
        'file' => 'callbacks/access.list.inc',
      );
      switch ($data_type) {
        case 'integer':
          $info[$field_type]['label'] = t('List (integer) field');
          $info[$field_type]['description'] = t('A <em>list (integer) field</em> scheme controls access based on the value of an integer field provided by the list module. The allowed values list of the selected field will become the access realms for the site, and you will be able to grant access based on the value of that field to any ACK-supported fieldable entity that uses the field. ACK modules that support non-fieldable objects (such as the ACK menu module, for menu links) may also provide the ability to map those objects to a list value.');
          break;
        case 'float':
          $info[$field_type]['label'] = t('List (float) field');
          $info[$field_type]['description'] = t('A <em>list (float) field</em> scheme controls access based on the value of a float field provided by the list module. The allowed values list of the selected field will become the access realms for the site, and you will be able to grant access based on the value of that field to any ACK-supported fieldable entity that uses the field. ACK modules that support non-fieldable objects (such as the ACK menu module, for menu links) may also provide the ability to map those objects to a list value.');
          break;
        case 'text':
          $info[$field_type]['label'] = t('List (text) field');
          $info[$field_type]['description'] = t('A <em>list (text) field</em> scheme controls access based on the value of a text field provided by the list module. The allowed values list of the selected field will become the access realms for the site, and you will be able to grant access based on the value of that field to any ACK-supported fieldable entity that uses the field. ACK modules that support non-fieldable objects (such as the ACK menu module, for menu links) may also provide the ability to map those objects to a list value.');
          break;
      }
    }
  }
  if (module_exists('taxonomy')) {

    // See if any vocabularies exist.
    $exists = db_select('taxonomy_vocabulary', 't')
      ->fields('t', array(
      'vid',
    ))
      ->range(0, 1)
      ->execute()
      ->fetchField();
    if ($exists) {
      $info['taxonomy_term'] = array(
        'label' => t('Taxonomy'),
        'data_type' => 'integer',
        // @todo Support cascading hierarchical privileges as an option.
        'description' => t('A <em>taxonomy</em> scheme controls access based on the terms of a selected vocabulary. You will be able to grant access to any ACK-supported fieldable entity based on the terms associated with that entity through a taxonomy term reference field. ACK modules that support non-fieldable objects (such as the ACK menu module, for menu links) may also provide the ability to map those objects to a term.'),
        'realms callback' => 'access_scheme_taxonomy_term_realms',
        'settings callback' => 'access_scheme_taxonomy_term_settings',
        'file' => 'callbacks/access.taxonomy.inc',
      );
    }
  }
  $info['user'] = array(
    'label' => t('User account'),
    'data_type' => 'integer',
    'description' => t('A <em>user account</em> scheme controls access to ACK-supported objects based on the users associated with those objects. For example, you could grant User A access to all content authored by User B.'),
    'realms callback' => 'access_scheme_user_realms',
    'file' => 'callbacks/access.user.inc',
  );
  return $info;
}