function _field_permissions_field_settings_alter in Field Permissions 6
Implementation of hook_field_settings_alter().
1 call to _field_permissions_field_settings_alter()
- field_permissions_field_settings_alter in ./
field_permissions.module - Implementation of hook_field_settings_alter().
File
- includes/
admin.inc, line 93 - Administrative interface for the Field Permissions module.
Code
function _field_permissions_field_settings_alter(&$settings, $op, $field) {
switch ($op) {
case 'form':
$field_permissions = array();
foreach (field_permissions_list($field['widget']['label']) as $permission_type => $permission_info) {
$field_permissions[$permission_type] = $permission_info['description'];
}
$settings['field_permissions'] = array(
'#title' => t('Field permissions'),
'#type' => 'checkboxes',
'#checkall' => TRUE,
'#options' => $field_permissions,
'#default_value' => isset($field['field_permissions']) && is_array($field['field_permissions']) ? array_filter($field['field_permissions']) : array(),
'#description' => t('Use these options to enable role based permissions for this field.
When permissions are enabled, access to this field is denied by default and explicit permissions should be granted to the proper user roles from the <a href="@admin-permissions">permissions administration</a> page.
On the other hand, when these options are disabled, field permissions are inherited from node view and/or edit permissions. In example, users allowed to view a particular node will also be able to view this field, and so on.', array(
'@admin-permissions' => url('admin/user/permissions'),
)),
'#weight' => -1,
);
// Hide the option to non-privileged users.
if (!user_access('administer field permissions')) {
$settings['field_permissions']['#type'] = 'value';
$settings['field_permissions']['#value'] = $settings['field_permissions']['#default_value'];
}
break;
case 'save':
$settings[] = 'field_permissions';
break;
}
}