2007-10-05 16:07:22 +00:00
<?php
// $Id$
2009-05-13 19:42:18 +00:00
/**
* @file
* Install, update and uninstall functions for the filter module.
*/
2007-10-05 16:07:22 +00:00
/**
* Implementation of hook_schema().
*/
function filter_schema() {
2008-12-03 16:32:22 +00:00
$schema['filter'] = array(
2009-01-21 16:58:42 +00:00
'description' => 'Table that maps filters (HTML corrector) to text formats (Filtered HTML).',
2007-10-05 16:07:22 +00:00
'fields' => array(
2007-10-10 11:39:35 +00:00
'fid' => array(
'type' => 'serial',
'not null' => TRUE,
2008-11-15 13:01:11 +00:00
'description' => 'Primary Key: Auto-incrementing filter ID.',
2007-10-10 11:39:35 +00:00
),
'format' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
2008-12-03 16:32:22 +00:00
'description' => 'Foreign key: The {filter_format}.format to which this filter is assigned.',
2007-10-10 11:39:35 +00:00
),
'module' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
2008-11-15 13:01:11 +00:00
'description' => 'The origin module of the filter.',
2007-10-10 11:39:35 +00:00
),
'delta' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
2008-11-15 13:01:11 +00:00
'description' => 'ID to identify which filter within module is being referenced.',
2007-10-10 11:39:35 +00:00
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
2008-11-15 13:01:11 +00:00
'description' => 'Weight of filter within format.',
2007-10-10 11:39:35 +00:00
)
2007-10-05 16:07:22 +00:00
),
'primary key' => array('fid'),
2007-12-18 12:59:22 +00:00
'unique keys' => array(
'fmd' => array('format', 'module', 'delta'),
),
'indexes' => array(
'list' => array('format', 'weight', 'module', 'delta'),
),
2007-10-05 16:07:22 +00:00
);
2008-12-03 16:32:22 +00:00
$schema['filter_format'] = array(
2009-01-21 16:58:42 +00:00
'description' => 'Stores text formats: custom groupings of filters, such as Filtered HTML.',
2007-10-05 16:07:22 +00:00
'fields' => array(
2007-10-10 11:39:35 +00:00
'format' => array(
'type' => 'serial',
'not null' => TRUE,
2008-11-15 13:01:11 +00:00
'description' => 'Primary Key: Unique ID for format.',
2007-10-10 11:39:35 +00:00
),
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
2009-01-21 16:58:42 +00:00
'description' => 'Name of the text format (Filtered HTML).',
2007-10-10 11:39:35 +00:00
),
'roles' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
2008-11-15 13:01:11 +00:00
'description' => 'A comma-separated string of roles; references {role}.rid.', // This is bad since you can't use joins, nor index.
2007-10-10 11:39:35 +00:00
),
'cache' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
2008-11-15 13:01:11 +00:00
'description' => 'Flag to indicate whether format is cachable. (1 = cachable, 0 = not cachable)',
2007-10-10 11:39:35 +00:00
),
2008-02-19 14:07:21 +00:00
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
2009-01-21 16:58:42 +00:00
'description' => 'Weight of text format to use when listing.',
2008-02-19 14:07:21 +00:00
)
2007-10-05 16:07:22 +00:00
),
'primary key' => array('format'),
2008-03-15 12:31:29 +00:00
'unique keys' => array(
'name' => array('name'),
),
2007-10-05 16:07:22 +00:00
);
$schema['cache_filter'] = drupal_get_schema_unprocessed('system', 'cache');
2009-01-21 16:58:42 +00:00
$schema['cache_filter']['description'] = 'Cache table for the Filter module to store already filtered pieces of text, identified by text format and md5 hash of the text.';
2007-10-05 16:07:22 +00:00
return $schema;
}
2008-02-19 14:07:21 +00:00
/**
* Add a weight column to the filter formats table.
*/
function filter_update_7000() {
$ret = array();
db_add_field($ret, 'filter_formats', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
return $ret;
}
2008-04-11 02:55:55 +00:00
/**
* Break out "escape HTML filter" option to its own filter.
*/
function filter_update_7001() {
$ret = array();
$result = db_query("SELECT format FROM {filter_formats}");
2009-04-25 18:01:10 +00:00
foreach ($result as $format) {
2008-04-11 02:55:55 +00:00
// Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE = 2.
2008-04-14 17:48:46 +00:00
if (variable_get('filter_html_' . $format->format, 1) == 2) {
$ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (" . $format->format . ", 'filter', 4, 0)");
2008-04-11 02:55:55 +00:00
}
2008-04-14 17:48:46 +00:00
variable_del('filter_html_' . $format->format);
2008-04-11 02:55:55 +00:00
}
return $ret;
}
2008-12-03 16:32:22 +00:00
/**
* Rename {filters} table to {filter} and {filter_formats} table to {filter_format}.
*/
function filter_update_7002() {
$ret = array();
db_rename_table($ret, 'filters', 'filter');
db_rename_table($ret, 'filter_formats', 'filter_format');
return $ret;
}