function tac_lite_form_alter in Taxonomy Access Control Lite 7
Implementation of hook_form_alter().
Parameters
$form: Nested array of form elements that comprise the form.
$form_state: A keyed array containing the current state of the form. The arguments that drupal_get_form() was originally called with are available in the array $form_state['build_info']['args'].
$form_id: String representing the name of the form itself. Typically this is the name of the function that generated the form.
File
- ./
tac_lite.module, line 381 - Control access to site content based on taxonomy, roles and users.
Code
function tac_lite_form_alter(&$form, &$form_state, $form_id) {
// Catch for the tac_lite category on the user edit form.
if ($form_id == 'user_profile_form') {
if ($form['#user_category'] == 'tac_lite') {
$vocabularies = taxonomy_get_vocabularies();
$vids = variable_get('tac_lite_categories', NULL);
if (count($vids)) {
for ($i = 1; $i <= variable_get('tac_lite_schemes', 1); $i++) {
$config = _tac_lite_config($i);
if ($config['name']) {
$perms = $config['perms'];
if ($config['term_visibility']) {
$perms[] = t('term visibility');
}
$form['tac_lite'][$config['realm']] = array(
'#type' => 'fieldset',
'#title' => $config['name'],
'#description' => t('This scheme controls %perms.', array(
'%perms' => implode(' and ', $perms),
)),
'#tree' => TRUE,
);
// Create a form element for each vocabulary
foreach ($vids as $vid) {
$v = $vocabularies[$vid];
// TODO: Should we be looking in form_state also for the default value?
// (Might only be necessary if we are adding in custom validation?)
$default_values = array();
if (!empty($form['#user']->data[$config['realm']])) {
if (isset($form['#user']->data[$config['realm']][$vid])) {
$default_values = $form['#user']->data[$config['realm']][$vid];
}
}
$form['tac_lite'][$config['realm']][$vid] = _tac_lite_term_select($v, $default_values);
$form['tac_lite'][$config['realm']][$vid]['#description'] = t('Grant permission to this user by selecting terms. Note that permissions are in addition to those granted based on user roles.');
}
}
}
$form['tac_lite'][0] = array(
'#type' => 'markup',
'#markup' => '<p>' . t('You may grant this user access based on the schemes and terms below. These permissions are in addition to <a href="!url">role based grants on scheme settings pages</a>.', array(
'!url' => url('admin/config/people/tac_lite/scheme_1'),
)) . "</p>\n",
'#weight' => -1,
);
}
else {
// TODO: Do we need to handle the situation where no vocabularies have been set up yet / none have been assigned to tac_lite?
}
return $form;
}
}
}