function social_core_filter_process_format in Open Social 8.6
Same name and namespace in other branches
- 8.9 modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 8 modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 8.2 modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 8.3 modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 8.4 modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 8.5 modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 8.7 modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 8.8 modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 10.3.x modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 10.0.x modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 10.1.x modules/social_features/social_core/social_core.module \social_core_filter_process_format()
- 10.2.x modules/social_features/social_core/social_core.module \social_core_filter_process_format()
Remove ability of selecting format if full_html is available.
@todo Instead of defining the list of fields it would be better to add a separate Setting to all text_format fields, allowing to select whether to show format selector or not.
1 string reference to 'social_core_filter_process_format'
- social_core_element_info_alter in modules/
social_features/ social_core/ social_core.module - Implements hook_element_info_alter().
File
- modules/
social_features/ social_core/ social_core.module, line 408 - The Social core module.
Code
function social_core_filter_process_format($element) {
// Only fields listed here will have text format settings disabled.
$full_html_field_ids = [
'edit-body-0',
'edit-field-profile-self-introduction-0',
'edit-field-group-description-0',
];
$full_html = FilterFormat::load('full_html');
$permission_name = $full_html
->getPermissionName();
$account = \Drupal::currentUser();
if ($element['#type'] == 'text_format' && $element['#format'] == 'full_html' && !$account
->hasPermission($permission_name)) {
$element['#format'] = 'basic_html';
$element['value']['#format'] = 'basic_html';
$element['format']['format']['#default_value'] = 'basic_html';
$element['format']['format']['#value'] = 'basic_html';
$element['value']['#disabled'] = FALSE;
$element['format']['format']['#access'] = FALSE;
$element['format']['#access'] = TRUE;
$key = array_search('filter_form_access_denied', $element['value']['#pre_render']);
if (isset($element['value']['#pre_render'][$key])) {
unset($element['value']['#pre_render'][$key]);
}
}
elseif ($element['#type'] == 'text_format' && $account
->hasPermission($permission_name) && in_array($element['#id'], $full_html_field_ids)) {
$element['#format'] = 'full_html';
$element['format']['format']['#access'] = FALSE;
$element['format']['format']['#value'] = 'full_html';
$element['format']['help']['#access'] = FALSE;
$element['format']['format']['#options'] = [
'full_html' => 'Full HTML',
];
}
return $element;
}