You are here

function access_scheme_form_submit_build_scheme in Access Control Kit 7

Updates the form state's scheme entity by processing the submitted values.

This is the default builder function for the access scheme form. It is called during the "Save" submit handler to retrieve the entity to save. This function can also be called by a "Next" button of a wizard to update the form state with the current step's values before proceeding to the next step.

Return value

object The updated access scheme.

See also

access_scheme_form()

1 call to access_scheme_form_submit_build_scheme()
access_scheme_form_submit in ./access_schemes.admin.inc
Form submission handler for access_scheme_form().

File

./access_schemes.admin.inc, line 395
Access schemes administrative UI for the access control kit module.

Code

function access_scheme_form_submit_build_scheme($form, &$form_state) {
  $scheme = $form_state['scheme'];
  entity_form_submit_build_entity('access_scheme', $scheme, $form, $form_state);

  // Format the selected roles as rid => role_name.
  $roles = user_roles(TRUE);
  unset($roles[DRUPAL_AUTHENTICATED_RID]);
  $scheme->roles = array_filter($scheme->roles);
  $scheme->roles = array_intersect_key($roles, $scheme->roles);

  // Attach the handlers.
  if (isset($scheme->handlers)) {
    foreach ($scheme->handlers as $object_type => $handler_values) {

      // Check whether the handler element was set to "not managed."
      if (empty($handler_values['handler'])) {
        $scheme->handlers[$object_type] = NULL;
      }
      else {
        $handler = $handler_values['handler'];
        $settings = isset($handler_values[$handler]) ? $handler_values[$handler] : array();
        entity_get_controller('access_scheme')
          ->attachHandler($scheme, $object_type, $handler, $settings);
      }
    }
  }
  return $scheme;
}