function social_group_get_allowed_visibility_options_per_group_type in Open Social 8.5
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 8 modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 8.2 modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 8.3 modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 8.4 modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 8.6 modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 8.7 modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 8.8 modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 10.3.x modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 10.0.x modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 10.1.x modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
- 10.2.x modules/social_features/social_group/social_group.module \social_group_get_allowed_visibility_options_per_group_type()
Get the allowed visibility options for a given group type.
Parameters
string|null $group_type_id: The group type. Can be NULL to get visibility when it is not in a group.
\Drupal\Core\Session\AccountInterface|null $account: The account object that may have impact on the visibility options.
Return value
array An array of visibility options for the given group type.
3 calls to social_group_get_allowed_visibility_options_per_group_type()
- PostForm::configureVisibilityField in modules/
social_features/ social_post/ src/ Form/ PostForm.php - Configures the allows values for the visiblity field.
- SocialGroupSelectorWidget::validateGroupSelection in modules/
social_features/ social_group/ src/ Plugin/ Field/ FieldWidget/ SocialGroupSelectorWidget.php - Validate the group selection and change the visibility settings.
- social_group_field_widget_form_alter in modules/
social_features/ social_group/ social_group.module - Alter the visibility field within groups.
File
- modules/
social_features/ social_group/ social_group.module, line 1404 - The Social group module.
Code
function social_group_get_allowed_visibility_options_per_group_type($group_type_id, AccountInterface $account = NULL, $entity = NULL) {
// Get the logged in user.
if ($account === NULL) {
$account = \Drupal::currentUser();
}
$visibility_options = [];
$visibility_options['public'] = FALSE;
$visibility_options['community'] = TRUE;
$visibility_options['group'] = FALSE;
switch ($group_type_id) {
case 'closed_group':
$visibility_options['community'] = FALSE;
$visibility_options['group'] = TRUE;
break;
case 'public_group':
$visibility_options['public'] = TRUE;
$visibility_options['community'] = FALSE;
break;
case 'open_group':
$visibility_options['public'] = FALSE;
$visibility_options['community'] = TRUE;
$visibility_options['group'] = FALSE;
break;
default:
$config = \Drupal::config('entity_access_by_field.settings');
$visibility_options['public'] = TRUE;
if ($config
->get('disable_public_visibility') === 1 && !$account
->hasPermission('override disabled public visibility')) {
// This is a new entity.
if (!$entity) {
$visibility_options['public'] = FALSE;
}
else {
/** @var \Drupal\node\Entity\Node $entity */
$current_visibility = $entity
->get('field_content_visibility')
->getString();
if ($current_visibility !== 'public') {
$visibility_options['public'] = FALSE;
}
}
}
$visibility_options['community'] = TRUE;
$visibility_options['group'] = FALSE;
break;
}
return $visibility_options;
}