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 node module.
|
|
|
|
*/
|
|
|
|
|
2007-10-05 16:07:22 +00:00
|
|
|
/**
|
2009-12-04 16:49:48 +00:00
|
|
|
* Implements hook_schema().
|
2007-10-05 16:07:22 +00:00
|
|
|
*/
|
|
|
|
function node_schema() {
|
|
|
|
$schema['node'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The base table for nodes.',
|
2007-10-05 16:07:22 +00:00
|
|
|
'fields' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'nid' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The primary identifier for a node.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'serial',
|
|
|
|
'unsigned' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'not null' => TRUE,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'vid' => array(
|
2008-12-03 16:32:22 +00:00
|
|
|
'description' => 'The current {node_revision}.vid version identifier.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {node_type}.type of this node.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 32,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => '',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'language' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {languages}.language of this node.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 12,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => '',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'title' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The title of this node, always treated as non-markup plain text.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 255,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => '',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'uid' => array(
|
2009-02-26 07:30:29 +00:00
|
|
|
'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'status' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 1,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'created' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The Unix timestamp when the node was created.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'changed' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The Unix timestamp when the node was most recently saved.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'comment' => array(
|
2009-03-17 12:41:54 +00:00
|
|
|
'description' => 'Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write).',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'promote' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Boolean indicating whether the node should be displayed on the front page.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'sticky' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Boolean indicating whether the node should be displayed at the top of lists in which it appears.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'tnid' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The translation set id for this node, which equals the node id of the source post in each set.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'translate' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'A boolean indicating whether this translation page needs to be updated.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-05 16:07:22 +00:00
|
|
|
'indexes' => array(
|
|
|
|
'node_changed' => array('changed'),
|
|
|
|
'node_created' => array('created'),
|
2009-01-02 21:12:31 +00:00
|
|
|
'node_frontpage' => array('promote', 'status', 'sticky', 'created'),
|
2007-10-05 16:07:22 +00:00
|
|
|
'node_status_type' => array('status', 'type', 'nid'),
|
|
|
|
'node_title_type' => array('title', array('type', 4)),
|
|
|
|
'node_type' => array(array('type', 4)),
|
|
|
|
'uid' => array('uid'),
|
|
|
|
'tnid' => array('tnid'),
|
|
|
|
'translate' => array('translate'),
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-05 16:07:22 +00:00
|
|
|
'unique keys' => array(
|
2008-03-15 12:31:29 +00:00
|
|
|
'vid' => array('vid'),
|
|
|
|
),
|
2009-06-01 22:07:10 +00:00
|
|
|
'foreign keys' => array(
|
2010-08-22 13:55:53 +00:00
|
|
|
'node_revision' => array(
|
|
|
|
'table' => 'node_revision',
|
|
|
|
'columns' => array('vid' => 'vid'),
|
|
|
|
),
|
|
|
|
'node_author' => array(
|
|
|
|
'table' => 'users',
|
|
|
|
'columns' => array('uid' => 'uid'),
|
|
|
|
),
|
2009-06-01 22:07:10 +00:00
|
|
|
),
|
2007-10-05 16:07:22 +00:00
|
|
|
'primary key' => array('nid'),
|
2008-03-15 12:31:29 +00:00
|
|
|
);
|
2007-10-05 16:07:22 +00:00
|
|
|
|
|
|
|
$schema['node_access'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.',
|
2007-10-05 16:07:22 +00:00
|
|
|
'fields' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'nid' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {node}.nid this record affects.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'gid' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => "The grant ID a user must possess in the specified realm to gain this row's privileges on the node.",
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'realm' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The realm in which the user must possess the grant ID. Each node access node can define one or more realms.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 255,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => '',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'grant_view' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Boolean indicating whether a user with the realm/grant pair can view this node.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-03-15 12:31:29 +00:00
|
|
|
'size' => 'tiny',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'grant_update' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Boolean indicating whether a user with the realm/grant pair can edit this node.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-03-15 12:31:29 +00:00
|
|
|
'size' => 'tiny',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'grant_delete' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Boolean indicating whether a user with the realm/grant pair can delete this node.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-03-15 12:31:29 +00:00
|
|
|
'size' => 'tiny',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'primary key' => array('nid', 'gid', 'realm'),
|
2010-08-22 13:55:53 +00:00
|
|
|
'foreign keys' => array(
|
|
|
|
'affected_node' => array(
|
|
|
|
'table' => 'node',
|
|
|
|
'columns' => array('nid' => 'nid'),
|
|
|
|
),
|
|
|
|
),
|
2008-03-15 12:31:29 +00:00
|
|
|
);
|
2007-10-05 16:07:22 +00:00
|
|
|
|
2008-12-03 16:32:22 +00:00
|
|
|
$schema['node_revision'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Stores information about each saved version of a {node}.',
|
2007-10-05 16:07:22 +00:00
|
|
|
'fields' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'nid' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {node} this version belongs to.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'vid' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The primary identifier for this version.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'serial',
|
|
|
|
'unsigned' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'not null' => TRUE,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'uid' => array(
|
2009-02-26 07:30:29 +00:00
|
|
|
'description' => 'The {users}.uid that created this version.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'title' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The title of this version.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 255,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => '',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'log' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The log entry explaining the changes in this version.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'text',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'size' => 'big',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'timestamp' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'A Unix timestamp indicating when this version was created.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => 0,
|
|
|
|
),
|
2009-08-19 12:37:58 +00:00
|
|
|
'status' => array(
|
|
|
|
'description' => 'Boolean indicating whether the node (at the time of this revision) is published (visible to non-administrators).',
|
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 1,
|
|
|
|
),
|
|
|
|
'comment' => array(
|
|
|
|
'description' => 'Whether comments are allowed on this node (at the time of this revision): 0 = no, 1 = closed (read only), 2 = open (read/write).',
|
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
),
|
|
|
|
'promote' => array(
|
|
|
|
'description' => 'Boolean indicating whether the node (at the time of this revision) should be displayed on the front page.',
|
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
),
|
|
|
|
'sticky' => array(
|
|
|
|
'description' => 'Boolean indicating whether the node (at the time of this revision) should be displayed at the top of lists in which it appears.',
|
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
),
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-05 16:07:22 +00:00
|
|
|
'indexes' => array(
|
|
|
|
'nid' => array('nid'),
|
2008-03-15 12:31:29 +00:00
|
|
|
'uid' => array('uid'),
|
|
|
|
),
|
2007-10-05 16:07:22 +00:00
|
|
|
'primary key' => array('vid'),
|
2009-06-01 22:07:10 +00:00
|
|
|
'foreign keys' => array(
|
2010-08-22 13:55:53 +00:00
|
|
|
'versioned_node' => array(
|
|
|
|
'table' => 'node',
|
|
|
|
'columns' => array('nid' => 'nid'),
|
|
|
|
),
|
|
|
|
'version_author' => array(
|
|
|
|
'table' => 'users',
|
|
|
|
'columns' => array('uid' => 'uid'),
|
|
|
|
),
|
2009-06-01 22:07:10 +00:00
|
|
|
),
|
2008-03-15 12:31:29 +00:00
|
|
|
);
|
2007-10-05 16:07:22 +00:00
|
|
|
|
|
|
|
$schema['node_type'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Stores information about all defined {node} types.',
|
2007-10-05 16:07:22 +00:00
|
|
|
'fields' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The machine-readable name of this type.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 32,
|
2008-03-15 12:31:29 +00:00
|
|
|
'not null' => TRUE,
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'name' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The human-readable name of this type.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 255,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => '',
|
2009-10-16 19:06:25 +00:00
|
|
|
'translatable' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2008-10-08 03:27:56 +00:00
|
|
|
'base' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The base string used to construct callbacks corresponding to this node type.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 255,
|
2008-03-15 12:31:29 +00:00
|
|
|
'not null' => TRUE,
|
|
|
|
),
|
|
|
|
'description' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'A brief description of this type.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'text',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'size' => 'medium',
|
2009-10-16 19:06:25 +00:00
|
|
|
'translatable' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'help' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Help information shown to the user when creating a {node} of this type.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'text',
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'size' => 'medium',
|
2009-10-16 19:06:25 +00:00
|
|
|
'translatable' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'has_title' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Boolean indicating whether this type uses the {node}.title field.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'size' => 'tiny',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'title_label' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The label displayed for the title field on the edit form.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 255,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => '',
|
2009-10-16 19:06:25 +00:00
|
|
|
'translatable' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'custom' => array(
|
2009-08-19 22:46:05 +00:00
|
|
|
'description' => 'A boolean indicating whether this type is defined by a module (FALSE) or by a user via Add content type (TRUE).',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-03-15 12:31:29 +00:00
|
|
|
'size' => 'tiny',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'modified' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'A boolean indicating whether this type has been modified by an administrator; currently not used in any way.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-03-15 12:31:29 +00:00
|
|
|
'size' => 'tiny',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'locked' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'A boolean indicating whether the administrator can change the machine name of this type.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-03-15 12:31:29 +00:00
|
|
|
'size' => 'tiny',
|
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'orig_type' => array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0.',
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 255,
|
|
|
|
'not null' => TRUE,
|
2008-03-15 12:31:29 +00:00
|
|
|
'default' => '',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-05 16:07:22 +00:00
|
|
|
'primary key' => array('type'),
|
2008-03-15 12:31:29 +00:00
|
|
|
);
|
2007-10-05 16:07:22 +00:00
|
|
|
|
2010-03-28 11:16:29 +00:00
|
|
|
$schema['block_node_type'] = array(
|
|
|
|
'description' => 'Sets up display criteria for blocks based on content types',
|
|
|
|
'fields' => array(
|
|
|
|
'module' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 64,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'description' => "The block's origin module, from {block}.module.",
|
|
|
|
),
|
|
|
|
'delta' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 32,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'description' => "The block's unique delta within module, from {block}.delta.",
|
|
|
|
),
|
|
|
|
'type' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 32,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'description' => "The machine-readable name of this type from {node_type}.type.",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'primary key' => array('module', 'delta', 'type'),
|
|
|
|
'indexes' => array(
|
|
|
|
'type' => array('type'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2007-10-05 16:07:22 +00:00
|
|
|
return $schema;
|
|
|
|
}
|
2008-10-08 03:27:56 +00:00
|
|
|
|
2010-03-01 07:39:12 +00:00
|
|
|
/**
|
|
|
|
* Implements hook_install().
|
|
|
|
*/
|
|
|
|
function node_install() {
|
|
|
|
// Populate the node access table.
|
|
|
|
db_insert('node_access')
|
|
|
|
->fields(array(
|
|
|
|
'nid' => 0,
|
|
|
|
'gid' => 0,
|
|
|
|
'realm' => 'all',
|
|
|
|
'grant_view' => 1,
|
|
|
|
'grant_update' => 0,
|
|
|
|
'grant_delete' => 0,
|
|
|
|
))
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
|
2010-02-03 18:16:23 +00:00
|
|
|
/**
|
|
|
|
* Implements hook_update_dependencies().
|
|
|
|
*/
|
|
|
|
function node_update_dependencies() {
|
|
|
|
// Node update 7006 migrates node data to fields and therefore must run after
|
|
|
|
// the Field module has been enabled, but before upgrading field data.
|
|
|
|
$dependencies['node'][7006] = array(
|
|
|
|
'system' => 7049,
|
2010-09-28 03:30:37 +00:00
|
|
|
// It must also run after filter_update_7000() because it needs to query
|
|
|
|
// the list of existing text formats.
|
|
|
|
'filter' => 7000,
|
2010-02-03 18:16:23 +00:00
|
|
|
);
|
|
|
|
$dependencies['system'][7050] = array(
|
|
|
|
'node' => 7006,
|
|
|
|
);
|
|
|
|
return $dependencies;
|
|
|
|
}
|
|
|
|
|
2010-09-13 05:50:09 +00:00
|
|
|
/**
|
|
|
|
* Utility function: fetch the node types directly from the database.
|
|
|
|
*
|
|
|
|
* This function is valid for a database schema version 7000.
|
|
|
|
*
|
|
|
|
* @ingroup update-api-6.x-to-7.x
|
|
|
|
*/
|
|
|
|
function _update_7000_node_get_types() {
|
|
|
|
return db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ);
|
|
|
|
}
|
|
|
|
|
2008-10-08 03:27:56 +00:00
|
|
|
/**
|
2009-04-24 08:23:02 +00:00
|
|
|
* @defgroup updates-6.x-to-7.x System updates from 6.x to 7.x
|
|
|
|
* @{
|
2008-10-08 03:27:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fix node type 'module' attribute to avoid name-space conflicts.
|
|
|
|
*/
|
|
|
|
function node_update_7000() {
|
2009-09-29 15:13:57 +00:00
|
|
|
db_update('node_type')
|
|
|
|
->fields(array('module' => 'node_content'))
|
|
|
|
->condition('module', 'node')
|
|
|
|
->execute();
|
2010-01-09 22:07:57 +00:00
|
|
|
|
|
|
|
// Rename the module column to base.
|
|
|
|
db_change_field('node_type', 'module', 'base', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
|
2008-10-08 03:27:56 +00:00
|
|
|
}
|
|
|
|
|
2008-12-03 16:32:22 +00:00
|
|
|
/**
|
|
|
|
* Rename {node_revisions} table to {node_revision}.
|
|
|
|
*/
|
|
|
|
function node_update_7001() {
|
2009-09-29 15:13:57 +00:00
|
|
|
db_rename_table('node_revisions', 'node_revision');
|
2008-12-03 16:32:22 +00:00
|
|
|
}
|
|
|
|
|
2009-01-02 21:12:31 +00:00
|
|
|
/**
|
|
|
|
* Extend the node_promote_status index to include all fields required for the node page query.
|
|
|
|
*/
|
|
|
|
function node_update_7002() {
|
2009-09-29 15:13:57 +00:00
|
|
|
db_drop_index('node', 'node_promote_status');
|
|
|
|
db_add_index('node', 'node_frontpage', array('promote', 'status', 'sticky', 'created'));
|
2009-01-02 21:12:31 +00:00
|
|
|
}
|
|
|
|
|
2008-10-08 03:27:56 +00:00
|
|
|
/**
|
2009-04-24 08:23:02 +00:00
|
|
|
* Remove the node_counter if the statistics module is uninstalled.
|
|
|
|
*/
|
|
|
|
function node_update_7003() {
|
2009-04-25 14:01:05 +00:00
|
|
|
if (drupal_get_installed_schema_version('statistics') == SCHEMA_UNINSTALLED) {
|
2009-09-29 15:13:57 +00:00
|
|
|
db_drop_table('node_counter');
|
2009-04-24 08:23:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-05 05:28:28 +00:00
|
|
|
/**
|
|
|
|
* Extend the existing default preview and teaser settings to all node types.
|
|
|
|
*/
|
|
|
|
function node_update_7004() {
|
|
|
|
// Get original settings and all types.
|
|
|
|
$original_length = variable_get('teaser_length', 600);
|
|
|
|
$original_preview = variable_get('node_preview', 0);
|
|
|
|
|
|
|
|
// Map old preview setting to new values order.
|
|
|
|
$original_preview ? $original_preview = 2 : $original_preview = 1;
|
2009-09-17 03:12:41 +00:00
|
|
|
drupal_static_reset('_node_types_build');
|
2009-06-05 05:28:28 +00:00
|
|
|
|
|
|
|
// Apply original settings to all types.
|
2010-09-29 19:46:40 +00:00
|
|
|
foreach (_update_7000_node_get_types() as $type => $type_object) {
|
2009-06-05 05:28:28 +00:00
|
|
|
variable_set('teaser_length_' . $type, $original_length);
|
|
|
|
variable_set('node_preview_' . $type, $original_preview);
|
|
|
|
}
|
|
|
|
// Delete old variable but leave 'teaser_length' for aggregator module upgrade.
|
|
|
|
variable_del('node_preview');
|
|
|
|
}
|
|
|
|
|
2009-06-12 08:39:40 +00:00
|
|
|
/**
|
2009-08-31 16:24:15 +00:00
|
|
|
* Add status/comment/promote and sticky columns to the {node_revision} table.
|
2009-06-12 08:39:40 +00:00
|
|
|
*/
|
2009-08-19 12:37:58 +00:00
|
|
|
function node_update_7005() {
|
2010-09-28 02:30:32 +00:00
|
|
|
foreach (array('status', 'comment', 'promote', 'sticky') as $column) {
|
2009-09-29 15:13:57 +00:00
|
|
|
db_add_field('node_revision', $column, array(
|
2009-08-19 12:37:58 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-08-31 16:24:15 +00:00
|
|
|
* Convert body and teaser from node properties to fields, and migrate status/comment/promote and sticky columns to the {node_revision} table.
|
2009-08-19 12:37:58 +00:00
|
|
|
*/
|
2010-05-05 06:29:56 +00:00
|
|
|
function node_update_7006(&$sandbox) {
|
|
|
|
$sandbox['#finished'] = 0;
|
2009-06-12 08:39:40 +00:00
|
|
|
|
|
|
|
// Get node type info for every invocation.
|
2009-09-17 03:12:41 +00:00
|
|
|
drupal_static_reset('_node_types_build');
|
2009-06-12 08:39:40 +00:00
|
|
|
|
2010-05-05 06:29:56 +00:00
|
|
|
if (!isset($sandbox['total'])) {
|
2009-06-12 08:39:40 +00:00
|
|
|
// Initial invocation.
|
|
|
|
|
2010-09-29 19:46:40 +00:00
|
|
|
// First, create the body field.
|
|
|
|
$body_field = array(
|
|
|
|
'field_name' => 'body',
|
|
|
|
'type' => 'text_with_summary',
|
|
|
|
'module' => 'text',
|
|
|
|
'cardinality' => 1,
|
|
|
|
'entity_types' => array('node'),
|
|
|
|
'translatable' => TRUE,
|
|
|
|
);
|
|
|
|
_update_7000_field_create_field($body_field);
|
|
|
|
|
|
|
|
$default_trim_length = variable_get('teaser_length', 600);
|
|
|
|
|
2010-05-05 15:11:51 +00:00
|
|
|
// Get node type info, specifically the body field settings.
|
2010-09-29 19:46:40 +00:00
|
|
|
$node_types = _update_7000_node_get_types();
|
|
|
|
|
|
|
|
// Create default settings for orphan nodes.
|
2010-09-11 00:39:49 +00:00
|
|
|
$extra_types = db_query('SELECT DISTINCT type FROM {node} WHERE type NOT IN (:types)', array(':types' => array_keys($node_types)))->fetchCol();
|
|
|
|
foreach ($extra_types as $type) {
|
|
|
|
$type_object = new stdClass;
|
|
|
|
$type_object->type = $type;
|
|
|
|
// Always create a body. Querying node_revisions for a non-empty body
|
|
|
|
// would skip creating body fields for types that have a body but
|
|
|
|
// the nodes of that type so far had empty bodies.
|
|
|
|
$type_object->has_body = 1;
|
|
|
|
$type_object->body_label = 'Body';
|
|
|
|
$node_types[$type_object->type] = $type_object;
|
|
|
|
}
|
2010-05-05 15:11:51 +00:00
|
|
|
|
|
|
|
// Add body field instances for existing node types.
|
2010-09-11 00:39:49 +00:00
|
|
|
foreach ($node_types as $node_type) {
|
2010-05-05 15:11:51 +00:00
|
|
|
if ($node_type->has_body) {
|
2010-08-08 13:02:37 +00:00
|
|
|
$trim_length = variable_get('teaser_length_' . $node_type->type, $default_trim_length);
|
2010-09-29 19:46:40 +00:00
|
|
|
|
|
|
|
$instance = array(
|
|
|
|
'entity_type' => 'node',
|
|
|
|
'bundle' => $node_type->type,
|
|
|
|
'label' => $node_type->body_label,
|
|
|
|
'widget' => array(
|
|
|
|
'type' => 'text_textarea_with_summary',
|
|
|
|
'settings' => array(
|
|
|
|
'rows' => 20,
|
|
|
|
'summary_rows' => 5,
|
|
|
|
),
|
|
|
|
'weight' => -4,
|
|
|
|
'module' => 'text',
|
|
|
|
),
|
|
|
|
'settings' => array('display_summary' => TRUE),
|
|
|
|
'display' => array(
|
|
|
|
'default' => array(
|
|
|
|
'label' => 'hidden',
|
|
|
|
'type' => 'text_default',
|
|
|
|
),
|
|
|
|
'teaser' => array(
|
|
|
|
'label' => 'hidden',
|
|
|
|
'type' => 'text_summary_or_trimmed',
|
|
|
|
'trim_length' => $trim_length,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
_update_7000_field_create_instance($body_field, $instance);
|
2010-08-08 13:02:37 +00:00
|
|
|
variable_del('teaser_length_' . $node_type->type);
|
2009-06-12 08:39:40 +00:00
|
|
|
}
|
2010-08-08 13:02:37 +00:00
|
|
|
// Leave 'teaser_length' variable for aggregator module upgrade.
|
2010-05-05 15:11:51 +00:00
|
|
|
|
|
|
|
$sandbox['node_types_info'][$node_type->type] = array(
|
|
|
|
'has_body' => $node_type->has_body,
|
|
|
|
);
|
2009-06-12 08:39:40 +00:00
|
|
|
}
|
|
|
|
|
2010-09-28 03:30:37 +00:00
|
|
|
// Used below when updating the stored text format of each node body.
|
|
|
|
$sandbox['existing_text_formats'] = db_query("SELECT format FROM {filter_format}")->fetchCol();
|
|
|
|
|
2009-06-12 08:39:40 +00:00
|
|
|
// Initialize state for future calls.
|
2010-05-05 06:29:56 +00:00
|
|
|
$sandbox['last'] = 0;
|
|
|
|
$sandbox['count'] = 0;
|
2009-06-12 08:39:40 +00:00
|
|
|
|
|
|
|
$query = db_select('node', 'n');
|
|
|
|
$query->join('node_revision', 'nr', 'n.vid = nr.vid');
|
2010-05-05 06:29:56 +00:00
|
|
|
$sandbox['total'] = $query->countQuery()->execute()->fetchField();
|
2010-09-29 19:46:40 +00:00
|
|
|
|
|
|
|
$sandbox['body_field_id'] = $body_field['id'];
|
2009-06-12 08:39:40 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Subsequent invocations.
|
|
|
|
|
|
|
|
$found = FALSE;
|
2010-05-05 06:29:56 +00:00
|
|
|
if ($sandbox['total']) {
|
2009-06-12 08:39:40 +00:00
|
|
|
// Operate on every revision of every node (whee!), in batches.
|
2010-01-24 15:12:19 +00:00
|
|
|
$batch_size = 200;
|
|
|
|
$query = db_select('node_revision', 'nr');
|
|
|
|
$query->innerJoin('node', 'n', 'n.vid = nr.vid');
|
|
|
|
$query
|
|
|
|
->fields('nr', array('nid', 'vid', 'body', 'teaser', 'format'))
|
2010-04-28 05:14:33 +00:00
|
|
|
->fields('n', array('type', 'status', 'comment', 'promote', 'sticky', 'language'))
|
2010-05-05 06:29:56 +00:00
|
|
|
->condition('nr.vid', $sandbox['last'], '>')
|
2009-06-12 08:39:40 +00:00
|
|
|
->orderBy('nr.vid', 'ASC')
|
2010-01-24 15:12:19 +00:00
|
|
|
->range(0, $batch_size);
|
|
|
|
$revisions = $query->execute();
|
2009-06-12 08:39:40 +00:00
|
|
|
|
|
|
|
// Load each reversion of each node, set up 'body'
|
|
|
|
// appropriately, and save the node's field data. Note that
|
|
|
|
// node_load() will not return the body or teaser values from
|
|
|
|
// {node_revision} because those columns have been removed from the
|
|
|
|
// schema structure in memory (but not yet from the database),
|
|
|
|
// so we get the values from the explicit query of the table
|
|
|
|
// instead.
|
|
|
|
foreach ($revisions as $revision) {
|
|
|
|
$found = TRUE;
|
|
|
|
|
2010-05-05 06:55:25 +00:00
|
|
|
if ($sandbox['node_types_info'][$revision->type]['has_body']) {
|
2009-06-12 08:39:40 +00:00
|
|
|
$node = (object) array(
|
|
|
|
'nid' => $revision->nid,
|
|
|
|
'vid' => $revision->vid,
|
|
|
|
'type' => $revision->type,
|
|
|
|
);
|
2010-04-28 05:14:33 +00:00
|
|
|
// After node_update_7009() we will always have LANGUAGE_NONE as
|
|
|
|
// language neutral language code, but here we still have empty
|
|
|
|
// strings.
|
|
|
|
$langcode = empty($revision->language) ? LANGUAGE_NONE : $revision->language;
|
2009-06-12 08:39:40 +00:00
|
|
|
if (!empty($revision->teaser) && $revision->teaser != text_summary($revision->body)) {
|
2010-04-28 05:14:33 +00:00
|
|
|
$node->body[$langcode][0]['summary'] = $revision->teaser;
|
2009-06-12 08:39:40 +00:00
|
|
|
}
|
|
|
|
// Do this after text_summary() above.
|
|
|
|
$break = '<!--break-->';
|
|
|
|
if (substr($revision->body, 0, strlen($break)) == $break) {
|
|
|
|
$revision->body = substr($revision->body, strlen($break));
|
|
|
|
}
|
2010-04-28 05:14:33 +00:00
|
|
|
$node->body[$langcode][0]['value'] = $revision->body;
|
2010-09-28 03:30:37 +00:00
|
|
|
// Update the revision's text format for the changes to the Drupal 7
|
|
|
|
// filter system. This uses the same kind of logic that occurs, for
|
|
|
|
// example, in user_update_7010(), but we do this here rather than
|
|
|
|
// via a separate set of database queries, since we are already
|
|
|
|
// migrating the data.
|
|
|
|
if (empty($revision->body) && empty($revision->format)) {
|
|
|
|
$node->body[$langcode][0]['format'] = NULL;
|
|
|
|
}
|
|
|
|
elseif (!in_array($revision->format, $sandbox['existing_text_formats'])) {
|
|
|
|
$node->body[$langcode][0]['format'] = variable_get('filter_default_format', 1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$node->body[$langcode][0]['format'] = $revision->format;
|
|
|
|
}
|
2009-06-12 08:39:40 +00:00
|
|
|
// This is a core update and no contrib modules are enabled yet, so
|
|
|
|
// we can assume default field storage for a faster update.
|
2010-09-29 19:46:40 +00:00
|
|
|
_update_7000_field_sql_storage_write('node', $node->type, $node->nid, $node->vid, 'body', $node->body);
|
2009-06-12 08:39:40 +00:00
|
|
|
}
|
|
|
|
|
2009-08-19 12:37:58 +00:00
|
|
|
// Migrate the status columns to the {node_revision} table.
|
|
|
|
db_update('node_revision')
|
|
|
|
->fields(array(
|
|
|
|
'status' => $revision->status,
|
|
|
|
'comment' => $revision->comment,
|
|
|
|
'promote' => $revision->promote,
|
|
|
|
'sticky' => $revision->sticky,
|
|
|
|
))
|
|
|
|
->condition('vid', $revision->vid)
|
|
|
|
->execute();
|
|
|
|
|
2010-05-05 06:29:56 +00:00
|
|
|
$sandbox['last'] = $revision->vid;
|
|
|
|
$sandbox['count'] += 1;
|
2009-06-12 08:39:40 +00:00
|
|
|
}
|
|
|
|
|
2010-05-05 06:29:56 +00:00
|
|
|
$sandbox['#finished'] = min(0.99, $sandbox['count'] / $sandbox['total']);
|
2009-06-12 08:39:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$found) {
|
|
|
|
// All nodes are processed.
|
|
|
|
|
|
|
|
// Remove the now-obsolete body info from node_revision.
|
2009-09-29 15:13:57 +00:00
|
|
|
db_drop_field('node_revision', 'body');
|
|
|
|
db_drop_field('node_revision', 'teaser');
|
|
|
|
db_drop_field('node_revision', 'format');
|
2009-06-12 08:39:40 +00:00
|
|
|
|
2010-05-05 15:11:51 +00:00
|
|
|
// Remove node_type properties related to the former 'body'.
|
|
|
|
db_drop_field('node_type', 'has_body');
|
|
|
|
db_drop_field('node_type', 'body_label');
|
|
|
|
|
2009-06-12 08:39:40 +00:00
|
|
|
// We're done.
|
2010-05-05 06:29:56 +00:00
|
|
|
$sandbox['#finished'] = 1;
|
2009-06-12 08:39:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-27 19:26:31 +00:00
|
|
|
/**
|
|
|
|
* Remove column min_word_count.
|
|
|
|
*/
|
2009-08-19 12:37:58 +00:00
|
|
|
function node_update_7007() {
|
2009-09-29 15:13:57 +00:00
|
|
|
db_drop_field('node_type', 'min_word_count');
|
2009-07-27 19:26:31 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 07:58:50 +00:00
|
|
|
/**
|
|
|
|
* Split the 'administer nodes' permission from 'access content overview'.
|
|
|
|
*/
|
|
|
|
function node_update_7008() {
|
|
|
|
$roles = user_roles(FALSE, 'administer nodes');
|
|
|
|
foreach ($roles as $rid => $role) {
|
2010-09-29 19:46:40 +00:00
|
|
|
_update_7000_user_role_grant_permissions($rid, array('access content overview'), 'node');
|
2009-11-14 07:58:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-02 19:26:23 +00:00
|
|
|
/**
|
|
|
|
* Convert node languages from the empty string to LANGUAGE_NONE.
|
|
|
|
*/
|
|
|
|
function node_update_7009() {
|
|
|
|
db_update('node')
|
|
|
|
->fields(array('language' => LANGUAGE_NONE))
|
|
|
|
->condition('language', '')
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
|
2010-03-28 11:16:29 +00:00
|
|
|
/**
|
|
|
|
* Add the {block_node_type} table.
|
|
|
|
*/
|
|
|
|
function node_update_7010() {
|
|
|
|
$schema['block_node_type'] = array(
|
|
|
|
'description' => 'Sets up display criteria for blocks based on content types',
|
|
|
|
'fields' => array(
|
|
|
|
'module' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 64,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'description' => "The block's origin module, from {block}.module.",
|
|
|
|
),
|
|
|
|
'delta' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 32,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'description' => "The block's unique delta within module, from {block}.delta.",
|
|
|
|
),
|
|
|
|
'type' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 32,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'description' => "The machine-readable name of this type from {node_type}.type.",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'primary key' => array('module', 'delta', 'type'),
|
|
|
|
'indexes' => array(
|
|
|
|
'type' => array('type'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
db_create_table('block_node_type', $schema['block_node_type']);
|
|
|
|
}
|
|
|
|
|
2009-04-24 08:23:02 +00:00
|
|
|
/**
|
|
|
|
* @} End of "defgroup updates-6.x-to-7.x"
|
|
|
|
* The next series of updates should start at 8000.
|
2008-10-08 03:27:56 +00:00
|
|
|
*/
|