Code coverage for /20080809/modules/filter/filter.install

Line #Times calledCode
1
<?php
2
// $Id: filter.install,v 1.9 2008/04/14 17:48:37 dries Exp $
3
4
/**
5
 * Implementation of hook_schema().
6
 */
780
function filter_schema() {
877
  $schema['filters'] = array(
977
    'description' => t('Table that maps filters (HTML corrector) to input
formats (Filtered HTML).'),
10
    'fields' => array(
11
      'fid' => array(
1277
        'type' => 'serial',
1377
        'not null' => TRUE,
1477
        'description' => t('Primary Key: Auto-incrementing filter ID.'),
1577
      ),
16
      'format' => array(
1777
        'type' => 'int',
1877
        'not null' => TRUE,
1977
        'default' => 0,
2077
        'description' => t('Foreign key: The {filter_formats}.format to
which this filter is assigned.'),
2177
      ),
22
      'module' => array(
2377
        'type' => 'varchar',
2477
        'length' => 64,
2577
        'not null' => TRUE,
2677
        'default' => '',
2777
        'description' => t('The origin module of the filter.'),
2877
      ),
29
      'delta' => array(
3077
        'type' => 'int',
3177
        'not null' => TRUE,
3277
        'default' => 0,
3377
        'size' => 'tiny',
3477
        'description' => t('ID to identify which filter within module is
being referenced.'),
3577
      ),
36
      'weight' => array(
3777
        'type' => 'int',
3877
        'not null' => TRUE,
3977
        'default' => 0,
4077
        'size' => 'tiny',
4177
        'description' => t('Weight of filter within format.'),
42
      )
4377
    ),
4477
    'primary key' => array('fid'),
45
    'unique keys' => array(
4677
      'fmd' => array('format', 'module', 'delta'),
4777
    ),
48
    'indexes' => array(
4977
      'list' => array('format', 'weight', 'module', 'delta'),
5077
    ),
51
  );
5277
  $schema['filter_formats'] = array(
5377
    'description' => t('Stores input formats: custom groupings of filters,
such as Filtered HTML.'),
54
    'fields' => array(
55
      'format' => array(
5677
        'type' => 'serial',
5777
        'not null' => TRUE,
5877
        'description' => t('Primary Key: Unique ID for format.'),
5977
      ),
60
      'name' => array(
6177
        'type' => 'varchar',
6277
        'length' => 255,
6377
        'not null' => TRUE,
6477
        'default' => '',
6577
        'description' => t('Name of the input format (Filtered HTML).'),
6677
      ),
67
      'roles' => array(
6877
        'type' => 'varchar',
6977
        'length' => 255,
7077
        'not null' => TRUE,
7177
        'default' => '',
7277
        'description' => t('A comma-separated string of roles; references
{role}.rid.'), // This is bad since you can't use joins, nor index.
7377
      ),
74
      'cache' => array(
7577
        'type' => 'int',
7677
        'not null' => TRUE,
7777
        'default' => 0,
7877
        'size' => 'tiny',
7977
        'description' => t('Flag to indicate whether format is cachable. (1
= cachable, 0 = not cachable)'),
8077
      ),
81
      'weight' => array(
8277
        'type' => 'int',
8377
        'not null' => TRUE,
8477
        'default' => 0,
8577
        'size' => 'tiny',
8677
        'description' => t('Weight of input format to use when listing.'),
87
      )
8877
    ),
8977
    'primary key' => array('format'),
90
    'unique keys' => array(
9177
      'name' => array('name'),
9277
    ),
93
  );
94
9577
  $schema['cache_filter'] = drupal_get_schema_unprocessed('system',
'cache');
9677
  $schema['cache_filter']['description'] = t('Cache table for the Filter
module to store already filtered pieces of text, identified by input format
and md5 hash of the text.');
97
9877
  return $schema;
990
}
100
101
/**
102
 * Add a weight column to the filter formats table.
103
 */
10480
function filter_update_7000() {
1050
  $ret = array();
1060
  db_add_field($ret, 'filter_formats', 'weight', array('type' => 'int',
'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
1070
  return $ret;
1080
}
109
110
/**
111
 * Break out "escape HTML filter" option to its own filter.
112
 */
11380
function filter_update_7001() {
1140
  $ret = array();
1150
  $result = db_query("SELECT format FROM {filter_formats}");
1160
  while ($format = db_fetch_object($result)) {
117
    // Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE =
2.
1180
    if (variable_get('filter_html_' . $format->format, 1) == 2) {
1190
      $ret[] = update_sql("INSERT INTO {filters} (format, module, delta,
weight) VALUES (" . $format->format . ", 'filter', 4, 0)");
1200
    }
1210
    variable_del('filter_html_' . $format->format);
1220
  }
1230
  return $ret;
1240
}
12580