You are here

function editor_install in Editor 7

Implements hook_install().

File

./editor.install, line 30
Install, update and uninstall functions for the Editor module.

Code

function editor_install() {
  $schema = array();
  editor_schema_alter($schema);
  $spec = $schema['filter_format']['fields']['editor'];

  // If another module has added a {filter_format}.editor field, change it to
  // the expected specification. Otherwise, add it.
  if (db_field_exists('filter_format', 'editor')) {

    // Indexes using a field being changed must be dropped prior to calling
    // db_change_field(). However, the database API doesn't provide a way to do
    // this without knowing what the old indexes are. Therefore, it is the
    // responsibility of the module that added them to drop them prior to
    // allowing this module to be installed.
    db_change_field('filter_format', 'editor', 'editor', $spec);
  }
  else {
    db_add_field('filter_format', 'editor', $spec);
  }
  $spec = $schema['filter_format']['fields']['editor_settings'];

  // If another module has added a {filter_format}.editor_settings field, change
  // it to the expected specification. Otherwise, add it.
  if (db_field_exists('filter_format', 'editor_settings')) {

    // Indexes using a field being changed must be dropped prior to calling
    // db_change_field(). However, the database API doesn't provide a way to do
    // this without knowing what the old indexes are. Therefore, it is the
    // responsibility of the module that added them to drop them prior to
    // allowing this module to be installed.
    db_change_field('filter_format', 'editor_settings', 'editor_settings', $spec);
  }
  else {
    db_add_field('filter_format', 'editor_settings', $spec);
  }
}