Code coverage for /20081101/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
 */
712
function filter_schema() {
8134
  $schema['filters'] = array(
9134
    'description' => t('Table that maps filters (HTML corrector) to input
formats (Filtered HTML).'),
10
    'fields' => array(
11
      'fid' => array(
12134
        'type' => 'serial',
13134
        'not null' => TRUE,
14134
        'description' => t('Primary Key: Auto-incrementing filter ID.'),
15134
      ),
16
      'format' => array(
17134
        'type' => 'int',
18134
        'not null' => TRUE,
19134
        'default' => 0,
20134
        'description' => t('Foreign key: The {filter_formats}.format to
which this filter is assigned.'),
21134
      ),
22
      'module' => array(
23134
        'type' => 'varchar',
24134
        'length' => 64,
25134
        'not null' => TRUE,
26134
        'default' => '',
27134
        'description' => t('The origin module of the filter.'),
28134
      ),
29
      'delta' => array(
30134
        'type' => 'int',
31134
        'not null' => TRUE,
32134
        'default' => 0,
33134
        'size' => 'tiny',
34134
        'description' => t('ID to identify which filter within module is
being referenced.'),
35134
      ),
36
      'weight' => array(
37134
        'type' => 'int',
38134
        'not null' => TRUE,
39134
        'default' => 0,
40134
        'size' => 'tiny',
41134
        'description' => t('Weight of filter within format.'),
42
      )
43134
    ),
44134
    'primary key' => array('fid'),
45
    'unique keys' => array(
46134
      'fmd' => array('format', 'module', 'delta'),
47134
    ),
48
    'indexes' => array(
49134
      'list' => array('format', 'weight', 'module', 'delta'),
50134
    ),
51
  );
52134
  $schema['filter_formats'] = array(
53134
    'description' => t('Stores input formats: custom groupings of filters,
such as Filtered HTML.'),
54
    'fields' => array(
55
      'format' => array(
56134
        'type' => 'serial',
57134
        'not null' => TRUE,
58134
        'description' => t('Primary Key: Unique ID for format.'),
59134
      ),
60
      'name' => array(
61134
        'type' => 'varchar',
62134
        'length' => 255,
63134
        'not null' => TRUE,
64134
        'default' => '',
65134
        'description' => t('Name of the input format (Filtered HTML).'),
66134
      ),
67
      'roles' => array(
68134
        'type' => 'varchar',
69134
        'length' => 255,
70134
        'not null' => TRUE,
71134
        'default' => '',
72134
        'description' => t('A comma-separated string of roles; references
{role}.rid.'), // This is bad since you can't use joins, nor index.
73134
      ),
74
      'cache' => array(
75134
        'type' => 'int',
76134
        'not null' => TRUE,
77134
        'default' => 0,
78134
        'size' => 'tiny',
79134
        'description' => t('Flag to indicate whether format is cachable. (1
= cachable, 0 = not cachable)'),
80134
      ),
81
      'weight' => array(
82134
        'type' => 'int',
83134
        'not null' => TRUE,
84134
        'default' => 0,
85134
        'size' => 'tiny',
86134
        'description' => t('Weight of input format to use when listing.'),
87
      )
88134
    ),
89134
    'primary key' => array('format'),
90
    'unique keys' => array(
91134
      'name' => array('name'),
92134
    ),
93
  );
94
95134
  $schema['cache_filter'] = drupal_get_schema_unprocessed('system',
'cache');
96134
  $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
98134
  return $schema;
990
}
100
101
/**
102
 * Add a weight column to the filter formats table.
103
 */
10412
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
 */
11312
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
}
12512