function access_access_scheme_presave in Access Control Kit 7
Implements hook_access_scheme_presave().
File
- ./
access.access.inc, line 103 - Access control kit API hook implementations to integrate with core modules.
Code
function access_access_scheme_presave($scheme) {
// Prevent a blank realm_field_name property.
if (empty($scheme->realm_field_name)) {
$scheme->realm_field_name = 'ack_' . $scheme->machine_name;
}
// Make sure we have the scheme type definition on the object.
if (empty($scheme->info)) {
$scheme->info = access_scheme_info($scheme->type);
}
if (!empty($scheme->info)) {
// If the realm field doesn't exist, create it.
$field = field_info_field($scheme->realm_field_name);
if (empty($field)) {
$field = array(
'field_name' => $scheme->realm_field_name,
'type' => 'list_' . $scheme->info['data_type'],
'entity_types' => array(
'access_grant',
),
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'locked' => TRUE,
'settings' => array(
'allowed_values' => array(),
'allowed_values_function' => '_access_field_allowed_values',
),
);
field_create_field($field);
}
}
}