You are here

function social_event_an_enroll_node_update in Open Social 8.3

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_node_update()
  2. 8.4 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_node_update()
  3. 8.5 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_node_update()
  4. 8.6 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_node_update()
  5. 8.7 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_node_update()
  6. 8.8 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_node_update()
  7. 10.3.x modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_node_update()
  8. 10.0.x modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_node_update()
  9. 10.1.x modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_node_update()
  10. 10.2.x modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_node_update()

Implements hook_ENTIT_YTYPE_update().

Display warning if visibility was changed for already enabled AN enroll.

File

modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module, line 243
The Social event AN enroll module.

Code

function social_event_an_enroll_node_update(Node $node) {
  if ($node
    ->getType() === 'event') {
    $is_event_an_enroll = !empty($node
      ->get('field_event_an_enroll')->value);
    $new_visibility = $node
      ->get('field_content_visibility')
      ->getString();
    $old_visibility = $node->original
      ->get('field_content_visibility')
      ->getString();
    if ($is_event_an_enroll && $old_visibility == 'public' && $new_visibility != 'public') {
      drupal_set_message(t('Enrollment without account can only be enabled when the visibility of the event is Public.'), 'warning');
    }
  }
}