You are here

function access_access_scheme_insert in Access Control Kit 7

Implements hook_access_scheme_insert().

1 call to access_access_scheme_insert()
access_access_scheme_update in ./access.access.inc
Implements hook_access_scheme_update().

File

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

Code

function access_access_scheme_insert($scheme) {

  // Create the realm field instance.
  $instance = field_info_instance('access_grant', $scheme->realm_field_name, $scheme->machine_name);
  if (empty($instance)) {
    $instance = array(
      'field_name' => $scheme->realm_field_name,
      'entity_type' => 'access_grant',
      'bundle' => $scheme->machine_name,
      'label' => check_plain($scheme->name),
      'description' => filter_xss($scheme->description),
      'required' => TRUE,
      'widget' => array(
        'type' => 'options_buttons',
        'settings' => array(),
      ),
    );
    field_create_instance($instance);
  }

  // Save the roles.
  if (empty($scheme->roles)) {
    $scheme->roles = array();
  }
  variable_set('access_scheme_roles_' . $scheme->machine_name, $scheme->roles);
}