Code coverage for /20081101/modules/node/node.install

Line #Times calledCode
1
<?php
2
// $Id: node.install,v 1.7 2008/10/08 03:27:56 webchick Exp $
3
4
/**
5
 * Implementation of hook_schema().
6
 */
712
function node_schema() {
8134
  $schema['node'] = array(
9134
    'description' => t('The base table for nodes.'),
10
    'fields' => array(
11
      'nid' => array(
12134
        'description' => t('The primary identifier for a node.'),
13134
        'type' => 'serial',
14134
        'unsigned' => TRUE,
15134
        'not null' => TRUE,
16134
      ),
17
      'vid' => array(
18134
        'description' => t('The current {node_revisions}.vid version
identifier.'),
19134
        'type' => 'int',
20134
        'unsigned' => TRUE,
21134
        'not null' => TRUE,
22134
        'default' => 0,
23134
      ),
24
      'type' => array(
25134
        'description' => t('The {node_type}.type of this node.'),
26134
        'type' => 'varchar',
27134
        'length' => 32,
28134
        'not null' => TRUE,
29134
        'default' => '',
30134
      ),
31
      'language' => array(
32134
        'description' => t('The {languages}.language of this node.'),
33134
        'type' => 'varchar',
34134
        'length' => 12,
35134
        'not null' => TRUE,
36134
        'default' => '',
37134
      ),
38
      'title' => array(
39134
        'description' => t('The title of this node, always treated as
non-markup plain text.'),
40134
        'type' => 'varchar',
41134
        'length' => 255,
42134
        'not null' => TRUE,
43134
        'default' => '',
44134
      ),
45
      'uid' => array(
46134
        'description' => t('The {users}.uid that owns this node; initially,
this is the user that created it.'),
47134
        'type' => 'int',
48134
        'not null' => TRUE,
49134
        'default' => 0,
50134
      ),
51
      'status' => array(
52134
        'description' => t('Boolean indicating whether the node is
published (visible to non-administrators).'),
53134
        'type' => 'int',
54134
        'not null' => TRUE,
55134
        'default' => 1,
56134
      ),
57
      'created' => array(
58134
        'description' => t('The Unix timestamp when the node was
created.'),
59134
        'type' => 'int',
60134
        'not null' => TRUE,
61134
        'default' => 0,
62134
      ),
63
      'changed' => array(
64134
        'description' => t('The Unix timestamp when the node was most
recently saved.'),
65134
        'type' => 'int',
66134
        'not null' => TRUE,
67134
        'default' => 0,
68134
      ),
69
      'comment' => array(
70134
        'description' => t('Whether comments are allowed on this node: 0 =
no, 1 = read only, 2 = read/write.'),
71134
        'type' => 'int',
72134
        'not null' => TRUE,
73134
        'default' => 0,
74134
      ),
75
      'promote' => array(
76134
        'description' => t('Boolean indicating whether the node should be
displayed on the front page.'),
77134
        'type' => 'int',
78134
        'not null' => TRUE,
79134
        'default' => 0,
80134
      ),
81
      'moderate' => array(
82134
        'description' => t('Previously, a boolean indicating whether the
node was "in moderation"; mostly no longer used.'),
83134
        'type' => 'int',
84134
        'not null' => TRUE,
85134
        'default' => 0,
86134
      ),
87
      'sticky' => array(
88134
        'description' => t('Boolean indicating whether the node should be
displayed at the top of lists in which it appears.'),
89134
        'type' => 'int',
90134
        'not null' => TRUE,
91134
        'default' => 0,
92134
      ),
93
      'tnid' => array(
94134
        'description' => t('The translation set id for this node, which
equals the node id of the source post in each set.'),
95134
        'type' => 'int',
96134
        'unsigned' => TRUE,
97134
        'not null' => TRUE,
98134
        'default' => 0,
99134
      ),
100
      'translate' => array(
101134
        'description' => t('A boolean indicating whether this translation
page needs to be updated.'),
102134
        'type' => 'int',
103134
        'not null' => TRUE,
104134
        'default' => 0,
105134
      ),
106134
    ),
107
    'indexes' => array(
108134
      'node_changed'        => array('changed'),
109134
      'node_created'        => array('created'),
110134
      'node_moderate'       => array('moderate'),
111134
      'node_promote_status' => array('promote', 'status'),
112134
      'node_status_type'    => array('status', 'type', 'nid'),
113134
      'node_title_type'     => array('title', array('type', 4)),
114134
      'node_type'           => array(array('type', 4)),
115134
      'uid'                 => array('uid'),
116134
      'tnid'                => array('tnid'),
117134
      'translate'           => array('translate'),
118134
    ),
119
    'unique keys' => array(
120134
      'vid' => array('vid'),
121134
    ),
122134
    'primary key' => array('nid'),
123
  );
124
125134
  $schema['node_access'] = array(
126134
    'description' => t('Identifies which realm/grant pairs a user must
possess in order to view, update, or delete specific nodes.'),
127
    'fields' => array(
128
      'nid' => array(
129134
        'description' => t('The {node}.nid this record affects.'),
130134
        'type' => 'int',
131134
        'unsigned' => TRUE,
132134
        'not null' => TRUE,
133134
        'default' => 0,
134134
      ),
135
      'gid' => array(
136134
        'description' => t("The grant ID a user must possess in the
specified realm to gain this row's privileges on the node."),
137134
        'type' => 'int',
138134
        'unsigned' => TRUE,
139134
        'not null' => TRUE,
140134
        'default' => 0,
141134
      ),
142
      'realm' => array(
143134
        'description' => t('The realm in which the user must possess the
grant ID. Each node access node can define one or more realms.'),
144134
        'type' => 'varchar',
145134
        'length' => 255,
146134
        'not null' => TRUE,
147134
        'default' => '',
148134
      ),
149
      'grant_view' => array(
150134
        'description' => t('Boolean indicating whether a user with the
realm/grant pair can view this node.'),
151134
        'type' => 'int',
152134
        'unsigned' => TRUE,
153134
        'not null' => TRUE,
154134
        'default' => 0,
155134
        'size' => 'tiny',
156134
      ),
157
      'grant_update' => array(
158134
        'description' => t('Boolean indicating whether a user with the
realm/grant pair can edit this node.'),
159134
        'type' => 'int',
160134
        'unsigned' => TRUE,
161134
        'not null' => TRUE,
162134
        'default' => 0,
163134
        'size' => 'tiny',
164134
      ),
165
      'grant_delete' => array(
166134
        'description' => t('Boolean indicating whether a user with the
realm/grant pair can delete this node.'),
167134
        'type' => 'int',
168134
        'unsigned' => TRUE,
169134
        'not null' => TRUE,
170134
        'default' => 0,
171134
        'size' => 'tiny',
172134
      ),
173134
    ),
174134
    'primary key' => array('nid', 'gid', 'realm'),
175
  );
176
177134
  $schema['node_counter'] = array(
178134
    'description' => t('Access statistics for {node}s.'),
179
    'fields' => array(
180
      'nid' => array(
181134
        'description' => t('The {node}.nid for these statistics.'),
182134
        'type' => 'int',
183134
        'not null' => TRUE,
184134
        'default' => 0,
185134
      ),
186
      'totalcount' => array(
187134
        'description' => t('The total number of times the {node} has been
viewed.'),
188134
        'type' => 'int',
189134
        'unsigned' => TRUE,
190134
        'not null' => TRUE,
191134
        'default' => 0,
192134
        'size' => 'big',
193134
      ),
194
      'daycount' => array(
195134
        'description' => t('The total number of times the {node} has been
viewed today.'),
196134
        'type' => 'int',
197134
        'unsigned' => TRUE,
198134
        'not null' => TRUE,
199134
        'default' => 0,
200134
        'size' => 'medium',
201134
      ),
202
      'timestamp' => array(
203134
        'description' => t('The most recent time the {node} has been
viewed.'),
204134
        'type' => 'int',
205134
        'unsigned' => TRUE,
206134
        'not null' => TRUE,
207134
        'default' => 0,
208134
      ),
209134
    ),
210134
    'primary key' => array('nid'),
211
  );
212
213134
  $schema['node_revisions'] = array(
214134
    'description' => t('Stores information about each saved version of a
{node}.'),
215
    'fields' => array(
216
      'nid' => array(
217134
        'description' => t('The {node} this version belongs to.'),
218134
        'type' => 'int',
219134
        'unsigned' => TRUE,
220134
        'not null' => TRUE,
221134
        'default' => 0,
222134
      ),
223
      'vid' => array(
224134
        'description' => t('The primary identifier for this version.'),
225134
        'type' => 'serial',
226134
        'unsigned' => TRUE,
227134
        'not null' => TRUE,
228134
      ),
229
      'uid' => array(
230134
        'description' => t('The {users}.uid that created this version.'),
231134
        'type' => 'int',
232134
        'not null' => TRUE,
233134
        'default' => 0,
234134
      ),
235
      'title' => array(
236134
        'description' => t('The title of this version.'),
237134
        'type' => 'varchar',
238134
        'length' => 255,
239134
        'not null' => TRUE,
240134
        'default' => '',
241134
      ),
242
      'body' => array(
243134
        'description' => t('The body of this version.'),
244134
        'type' => 'text',
245134
        'not null' => TRUE,
246134
        'size' => 'big',
247134
      ),
248
      'teaser' => array(
249134
        'description' => t('The teaser of this version.'),
250134
        'type' => 'text',
251134
        'not null' => TRUE,
252134
        'size' => 'big',
253134
      ),
254
      'log' => array(
255134
        'description' => t('The log entry explaining the changes in this
version.'),
256134
        'type' => 'text',
257134
        'not null' => TRUE,
258134
        'size' => 'big',
259134
      ),
260
      'timestamp' => array(
261134
        'description' => t('A Unix timestamp indicating when this version
was created.'),
262134
        'type' => 'int',
263134
        'not null' => TRUE,
264134
        'default' => 0,
265134
      ),
266
      'format' => array(
267134
        'description' => t("The input format used by this version's
body."),
268134
        'type' => 'int',
269134
        'not null' => TRUE,
270134
        'default' => 0,
271134
      ),
272134
    ),
273
    'indexes' => array(
274134
      'nid' => array('nid'),
275134
      'uid' => array('uid'),
276134
    ),
277134
    'primary key' => array('vid'),
278
  );
279
280134
  $schema['node_type'] = array(
281134
    'description' => t('Stores information about all defined {node}
types.'),
282
    'fields' => array(
283
      'type' => array(
284134
        'description' => t('The machine-readable name of this type.'),
285134
        'type' => 'varchar',
286134
        'length' => 32,
287134
        'not null' => TRUE,
288134
      ),
289
      'name' => array(
290134
        'description' => t('The human-readable name of this type.'),
291134
        'type' => 'varchar',
292134
        'length' => 255,
293134
        'not null' => TRUE,
294134
        'default' => '',
295134
      ),
296
      'base' => array(
297134
        'description' => t('The base string used to construct callbacks
corresponding to this node type.'),
298134
        'type' => 'varchar',
299134
        'length' => 255,
300134
        'not null' => TRUE,
301134
      ),
302
      'description' => array(
303134
        'description' => t('A brief description of this type.'),
304134
        'type' => 'text',
305134
        'not null' => TRUE,
306134
        'size' => 'medium',
307134
      ),
308
      'help' => array(
309134
        'description' => t('Help information shown to the user when
creating a {node} of this type.'),
310134
        'type' => 'text',
311134
        'not null' => TRUE,
312134
        'size' => 'medium',
313134
      ),
314
      'has_title' => array(
315134
        'description' => t('Boolean indicating whether this type uses the
{node}.title field.'),
316134
        'type' => 'int',
317134
        'unsigned' => TRUE,
318134
        'not null' => TRUE,
319134
        'size' => 'tiny',
320134
      ),
321
      'title_label' => array(
322134
        'description' => t('The label displayed for the title field on the
edit form.'),
323134
        'type' => 'varchar',
324134
        'length' => 255,
325134
        'not null' => TRUE,
326134
        'default' => '',
327134
      ),
328
      'has_body' => array(
329134
        'description' => t('Boolean indicating whether this type uses the
{node_revisions}.body field.'),
330134
        'type' => 'int',
331134
        'unsigned' => TRUE,
332134
        'not null' => TRUE,
333134
        'size' => 'tiny',
334134
      ),
335
      'body_label' => array(
336134
        'description' => t('The label displayed for the body field on the
edit form.'),
337134
        'type' => 'varchar',
338134
        'length' => 255,
339134
        'not null' => TRUE,
340134
        'default' => '',
341134
      ),
342
      'min_word_count' => array(
343134
        'description' => t('The minimum number of words the body must
contain.'),
344134
        'type' => 'int',
345134
        'unsigned' => TRUE,
346134
        'not null' => TRUE,
347134
        'size' => 'small',
348134
      ),
349
      'custom' => array(
350134
        'description' => t('A boolean indicating whether this type is
defined by a module (FALSE) or by a user via a module like the Content
Construction Kit (TRUE).'),
351134
        'type' => 'int',
352134
        'not null' => TRUE,
353134
        'default' => 0,
354134
        'size' => 'tiny',
355134
      ),
356
      'modified' => array(
357134
        'description' => t('A boolean indicating whether this type has been
modified by an administrator; currently not used in any way.'),
358134
        'type' => 'int',
359134
        'not null' => TRUE,
360134
        'default' => 0,
361134
        'size' => 'tiny',
362134
      ),
363
      'locked' => array(
364134
        'description' => t('A boolean indicating whether the administrator
can change the machine name of this type.'),
365134
        'type' => 'int',
366134
        'not null' => TRUE,
367134
        'default' => 0,
368134
        'size' => 'tiny',
369134
      ),
370
      'orig_type' => array(
371134
        'description' => t('The original machine-readable name of this node
type. This may be different from the current type name if the locked field
is 0.'),
372134
        'type' => 'varchar',
373134
        'length' => 255,
374134
        'not null' => TRUE,
375134
        'default' => '',
376134
      ),
377134
    ),
378134
    'primary key' => array('type'),
379
  );
380
381134
  return $schema;
3820
}
383
384
/**
385
 * Drupal 6.x to 7.x updates
386
 */
387
388
/**
389
 * Fix node type 'module' attribute to avoid name-space conflicts.
390
 */
39112
function node_update_7000() {
3920
  $ret = array();
393
3940
  $ret[] = update_sql("UPDATE {node_type} SET module = 'node_content' WHERE
module = 'node'");
3950
  db_change_field($ret, 'node_type', 'module', 'base', array('type' =>
'varchar', 'length' => 255, 'not null' => TRUE));
396
3970
  return $ret;
3980
}
399
400
/**
401
 * End of 6.x to 7.x updates
402
 */
40312