You are here

function _opening_hours_openings_hours_field_setup in Opening hours 7

Setup field settings for opening hours extra field.

When we add the extra field we don't want it enabled on existing node types as it may conflict with existing implementations.

1 call to _opening_hours_openings_hours_field_setup()
opening_hours_update_7002 in ./opening_hours.install
Implements hook_update_N().

File

./opening_hours.install, line 157
Database schema, installation and upgrade hooks for the opening hours module.

Code

function _opening_hours_openings_hours_field_setup() {
  $field_machine_name = 'opening_hours_week';
  $info = entity_get_info('node');
  $view_modes = array_merge(array(
    'default',
  ), array_keys($info['view modes']));
  $node_types = node_type_get_types();
  foreach ($node_types as $node_type) {
    if (variable_get('opening_hours_enabled_' . $node_type->type, FALSE)) {
      $settings = field_bundle_settings('node', $node_type->type);
      foreach ($view_modes as $view_mode) {
        $settings['extra_fields']['display'][$field_machine_name][$view_mode] = array(
          'visible' => FALSE,
          'weight' => 0,
          'label' => 'above',
        );
      }
      field_bundle_settings('node', $node_type->type, $settings);
    }
  }
}