From 6265788d2769ec4cd2e7c76b68c4c3482d0a74fe Mon Sep 17 00:00:00 2001 From: Ronald te Brake Date: Tue, 2 May 2017 11:46:36 +0200 Subject: [PATCH 1/2] #2842079 by ronaldtebrake - dont hide the public visibility disable it rather so users get feedback and we dont set the default every single time --- .../entity_access_by_field.module | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/custom/entity_access_by_field/entity_access_by_field.module b/modules/custom/entity_access_by_field/entity_access_by_field.module index 9df7941787e..9559a0f8265 100644 --- a/modules/custom/entity_access_by_field/entity_access_by_field.module +++ b/modules/custom/entity_access_by_field/entity_access_by_field.module @@ -173,14 +173,17 @@ function entity_access_by_field_form_alter(&$form, \Drupal\Core\Form\FormStateIn // This is for nodes. if (isset($form['field_content_visibility'])) { // Some vars for easier reading. - $field = &$form['field_content_visibility']; $widget = &$form['field_content_visibility']['widget']; - $options = &$form['field_content_visibility']['widget']['#options']; + $route_name = \Drupal::routeMatch()->getRouteName(); // Remove the public option. - unset($options['public']); - // Check if the public options is currently selected. - if ($widget['#default_value'] === 'public') { + $widget['#disabled'] = TRUE; + // Check if the public options is selected on node add. Than we + // change it to community. Just to make sure LU will always have + // community selected on creating new nodes. On node edit we don't + // want this behavior because SM can change the visibility. + $widget['#title'] = t('The visibility settings have been disabled. In order to change the visibility, please contact a site manager.')->render(); + if ($route_name == 'node.add' && $widget['#default_value'] === 'public') { // Set the default value to community. $widget['#default_value'] = 'community'; } From 032d7b8b8a070da87f3135a89fb780d4ca273af1 Mon Sep 17 00:00:00 2001 From: Ronald te Brake Date: Tue, 2 May 2017 12:00:23 +0200 Subject: [PATCH 2/2] #2842079 by ronaldtebrake - dont hide the public visibility disable it rather so users get feedback and we dont set the default every single time --- .../custom/entity_access_by_field/entity_access_by_field.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/custom/entity_access_by_field/entity_access_by_field.module b/modules/custom/entity_access_by_field/entity_access_by_field.module index 9559a0f8265..db94cdb5001 100644 --- a/modules/custom/entity_access_by_field/entity_access_by_field.module +++ b/modules/custom/entity_access_by_field/entity_access_by_field.module @@ -182,7 +182,7 @@ function entity_access_by_field_form_alter(&$form, \Drupal\Core\Form\FormStateIn // change it to community. Just to make sure LU will always have // community selected on creating new nodes. On node edit we don't // want this behavior because SM can change the visibility. - $widget['#title'] = t('The visibility settings have been disabled. In order to change the visibility, please contact a site manager.')->render(); + $widget['#title'] = t('The visibility setting has been disabled. In order to change the visibility, please contact a site manager.')->render(); if ($route_name == 'node.add' && $widget['#default_value'] === 'public') { // Set the default value to community. $widget['#default_value'] = 'community';