You are here

function media_wysiwyg_update_7204 in D7 Media 7.2

Same name and namespace in other branches
  1. 7.4 modules/media_wysiwyg/media_wysiwyg.install \media_wysiwyg_update_7204()
  2. 7.3 modules/media_wysiwyg/media_wysiwyg.install \media_wysiwyg_update_7204()

Whitelists certain fields for WYSIWYG overriding.

1 call to media_wysiwyg_update_7204()
media_wysiwyg_install in modules/media_wysiwyg/media_wysiwyg.install
Implements hook_install().

File

modules/media_wysiwyg/media_wysiwyg.install, line 136
Install, update and uninstall functions for the Media WYSIWYG module.

Code

function media_wysiwyg_update_7204() {
  $instances = field_read_instances(array(
    'entity_type' => 'file',
  ));
  $updated = array();
  $set_to_default = array();
  foreach ($instances as $instance) {
    $field_info = field_info_field($instance['field_name']);
    $allowed_field_types = variable_get('media_wysiwyg_wysiwyg_override_field_types', array(
      'text',
      'text_long',
    ));
    if (in_array($field_info['type'], $allowed_field_types)) {
      if (!isset($instance['settings']['wysiwyg_override'])) {
        $instance['settings']['wysiwyg_override'] = 1;
        field_update_instance($instance);
        $set_to_default[] = $instance['field_name'];
      }
    }
    elseif (isset($instance['settings']['wysiwyg_override'])) {
      unset($instance['settings']['wysiwyg_override']);
      field_update_instance($instance);
      $updated[] = $instance['field_name'];
    }
  }
  if (count($updated) || count($set_to_default)) {
    $updated_string = implode(', ', $updated);
    $default_string = implode(', ', $set_to_default);
    return t("Updated the following field instances: @updated_string so they can't be overridden when the file is inserted in the WYSIWYG. Updated the following fields @default_string so that they continue to show up when a file is inserted.", array(
      '@updated_string' => $updated_string,
      '@default_string' => $default_string,
    ));
  }
}