You are here

function template_preprocess_access_grant in Access Control Kit 7

Process variables for access-grant.tpl.php.

The $variables array contains the following arguments:

  • $access_grant

See also

access-grant.tpl.php

File

./access.pages.inc, line 23
Page callbacks for the access control kit module.

Code

function template_preprocess_access_grant(&$variables) {
  $grant = $variables['elements']['#access_grant'];
  $variables['grant'] = $grant;

  // Place the renderable elements in the $content variable.
  foreach (element_children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }

  // Add variables for each attached field.
  field_attach_preprocess('access_grant', $grant, $variables['elements'], $variables);

  // Add helper variables for the access realm field, since the name is dynamic.
  $scheme = access_scheme_machine_name_load($grant->scheme);
  $field_name = $scheme->realm_field['field_name'];
  $variables['realm_field_name'] = $field_name;
  $variables['realms'] = empty($variables[$field_name]) ? array() : $variables[$field_name];

  // Add a class to identify the scheme.
  $variables['classes_array'][] = drupal_html_class('access-grant-' . $grant->scheme);

  // Allow per scheme templates.
  $variables['theme_hook_suggestions'][] = 'access_grant__' . $grant->scheme;
}