function access_schema in Access Control Kit 7
Implements hook_schema().
File
- ./
access.install, line 11 - Install, update and uninstall functions for the access control kit module.
Code
function access_schema() {
// The access grant (entity) table.
$schema['access_grant'] = array(
'description' => 'The base table for access grants. Each combination of uid, rid and scheme must be unique.',
'fields' => array(
'gid' => array(
'description' => 'The primary identifier for an access grant.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The {users}.uid of the user granted access.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'rid' => array(
'description' => 'The {role}.rid of the role assigned by this grant.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'scheme' => array(
'description' => 'The {access_scheme}.machine_name of this grant.',
'type' => 'varchar',
'length' => 28,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array(
'gid',
),
'unique keys' => array(
'uid_rid_scheme' => array(
'uid',
'rid',
'scheme',
),
),
'indexes' => array(
'uid' => array(
'uid',
),
'scheme' => array(
array(
'scheme',
4,
),
),
),
'foreign keys' => array(
'grant_user' => array(
'table' => 'users',
'columns' => array(
'uid' => 'uid',
),
),
'grant_role' => array(
'table' => 'role',
'columns' => array(
'rid' => 'rid',
),
),
'grant_scheme' => array(
'table' => 'access_scheme',
'columns' => array(
'scheme' => 'machine_name',
),
),
),
);
// The access scheme (bundle/entity) table.
$schema['access_scheme'] = array(
'description' => 'Stores information about all defined {access_grant} schemes.',
'fields' => array(
'sid' => array(
'description' => 'The scheme ID.',
'type' => 'serial',
'not null' => TRUE,
),
'machine_name' => array(
'description' => 'The machine-readable name of this scheme.',
'type' => 'varchar',
'length' => 28,
'not null' => TRUE,
),
'name' => array(
'description' => 'The human-readable name of this scheme.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'type' => array(
'description' => 'The scheme type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'realm_field_name' => array(
'description' => 'The name of the field attached to grants in this scheme that determines the realm values.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'A brief description of this access scheme.',
'type' => 'text',
'not null' => FALSE,
),
'settings' => array(
'description' => 'Serialized data containing settings specific to the scheme type.',
'type' => 'blob',
'size' => 'big',
'serialize' => TRUE,
),
),
'primary key' => array(
'sid',
),
'unique keys' => array(
'machine_name' => array(
'machine_name',
),
),
);
// The access handler table.
$schema['access_handler'] = array(
'description' => 'Attaches object access handlers to {access_scheme} schemes.',
'fields' => array(
'scheme' => array(
'description' => 'The {access_scheme}.machine_name to which this handler is attached.',
'type' => 'varchar',
'length' => 28,
'not null' => TRUE,
'default' => '',
),
'object_type' => array(
'description' => 'The type of Drupal object (for example, node, taxonomy_term, etc.) that this handler manages. Only one handler is permitted per object type per scheme.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'handler' => array(
'description' => 'The name of the access handler class.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'module' => array(
'description' => 'The module that implements the handler.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'settings' => array(
'description' => 'Serialized data containing the handler settings, as defined by the implementing module.',
'type' => 'blob',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
),
'primary key' => array(
'scheme',
'object_type',
),
'foreign keys' => array(
'handler_scheme' => array(
'table' => 'access_scheme',
'columns' => array(
'scheme' => 'machine_name',
),
),
),
'indexes' => array(
'scheme' => array(
array(
'scheme',
4,
),
),
),
);
return $schema;
}