function abt_form_node_form_alter in Access By Term 7
Implements hook_form_BASE_FORM_ID_alter().
Here we tell users if a field is beeing used for access control. Even which aspect of access control the field is defining (view,update,delete).
Also prevents users from editing abt tags if they don't have apropriate permissions.
File
- ./
abt.module, line 254 - abt.module Module for controling access by using user->term<-node relationship.
Code
function abt_form_node_form_alter(&$form, &$form_state, $form_id) {
$access_map = field_read_fields(array(
'module' => 'taxonomy',
));
foreach ($access_map as $field_name => $realm) {
if (isset($realm['settings']['abt_map'])) {
$field =& $form[$field_name];
$view = $realm['settings']['abt_map']['ctrl_view_access'] >= ABT_CONTROL_DEFAULT_RESTRICT ? t('view') . ' ' : '';
$update = $realm['settings']['abt_map']['ctrl_update_access'] >= ABT_CONTROL_DEFAULT_RESTRICT ? t('update') . ' ' : '';
$delete = $realm['settings']['abt_map']['ctrl_delete_access'] >= ABT_CONTROL_DEFAULT_RESTRICT ? t('delete') . ' ' : '';
$msg = str_replace(' ', ', ', trim($view . $update . $delete));
$msg = !empty($msg) ? ' <em>' . t('(Access control enabled for: @msg)', array(
'@msg' => $msg,
)) . '</em>' : '';
$field[$field['#language']]['#title'] = $field[$field['#language']]['#title'] . $msg;
}
}
// Remove the abt field if needed.
if (!user_access('allow edit abt field content in node')) {
$form = abt_remove_fields($form);
}
}