/[drupal]/contributions/modules/skeleton/skeleton.install
ViewVC logotype

Contents of /contributions/modules/skeleton/skeleton.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Thu Mar 12 18:22:29 2009 UTC (8 months, 2 weeks ago) by deviantintegral
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-ALPHA1, HEAD
Changes since 1.5: +41 -3 lines
File MIME type: text/x-php
#351884: Add new pages to instantiated templates.
1 <?php
2
3 // $Id: skeleton.install,v 1.5 2009/01/07 17:38:58 deviantintegral Exp $
4
5 /**
6 * @file
7 * Installer for the skeleton module
8 */
9
10 /**
11 * Implementation of hook_install().
12 */
13 function skeleton_install() {
14 drupal_set_message(t('Installing the Skeleton module'));
15 $results = drupal_install_schema('skeleton');
16 $install_pass = TRUE;
17 foreach ($results as $result) {
18 if (!$result['success']) {
19 $install_pass = FALSE;
20 }
21 }
22 if ($install_pass) {
23 drupal_set_message('Installed the {skeleton}, {skeleton_data}, {skeleton_template}, and {skeleton_template_node} tables successfully.');
24 }
25 else {
26 drupal_set_message(t('The installation of the skeleton module was unsuccessful.'), 'error');
27 }
28 // set the module weight low for hook_form_alter()
29 db_query("UPDATE {system} SET weight = 20 WHERE name = 'skeleton'");
30 }
31
32 /**
33 * Implementation of hook_uninstall().
34 */
35 function skeleton_uninstall() {
36 // Remove tables.
37 drupal_uninstall_schema('skeleton');
38 }
39
40 /**
41 * Implementation of hook_schema().
42 */
43 function skeleton_schema() {
44 $schema = array();
45
46 $schema['skeleton'] = array(
47 'fields' => array(
48 'skeleton_id' => array('type' => 'serial', 'length' => 11),
49 'skeleton' => array('type' => 'varchar', 'length' => 80),
50 ),
51 'primary key' => array(
52 'skeleton_id',
53 ),
54 );
55
56 $schema['skeleton_data'] = array(
57 'fields' => array(
58 'skeleton_id' => array('type' => 'int', 'unsigned' => TRUE, 'length' => 11, 'not null' => TRUE, 'default' => 0),
59 'template_id' => array('type' => 'int', 'unsigned' => TRUE, 'length' => 11, 'not null' => TRUE, 'default' => 0),
60 'parent' => array('type' => 'int', 'unsigned' => TRUE, 'length' => 11, 'not null' => TRUE, 'default' => 0),
61 'weight' => array('type' => 'int', 'size' => 'small', 'length' => 6, 'not null' => TRUE, 'default' => 0),
62 ),
63 'primary key' => array(
64 'skeleton_id',
65 'template_id',
66 ),
67 );
68
69 $schema['skeleton_template'] = array(
70 'fields' => array(
71 'template_id' => array('type' => 'serial', 'length' => 11),
72 'template' => array('type' => 'varchar', 'length' => 80),
73 'node_type' => array('type' => 'varchar', 'length' => 80),
74 'node_data' => array('type' => 'blob', 'size' => 'big'),
75 ),
76 'primary key' => array(
77 'template_id',
78 ),
79 );
80
81 $schema['skeleton_token'] = array(
82 'fields' => array(
83 'token_id' => array('type' => 'serial', 'length' => 11),
84 'token' => array('type' => 'varchar', 'length' => 80),
85 'description' => array('type' => 'varchar', 'length' => 80),
86 ),
87 'primary key' => array(
88 'token_id',
89 ),
90 );
91
92 $schema['skeleton_template_node'] = array(
93 'fields' => array(
94 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
95 'skeleton_id' => array('type' => 'int', 'unsigned' => TRUE, 'length' => 11, 'not null' => TRUE),
96 'template_id' => array('type' => 'int', 'unsigned' => TRUE, 'length' => 11, 'not null' => TRUE),
97 'template_status' => array('type' => 'varchar', 'length' => '16', 'not null' => TRUE),
98 'tokens' => array('type' => 'blob', 'size' => 'big'),
99 ),
100 'primary key' => array(
101 'nid',
102 'template_id',
103 ),
104 );
105
106 return $schema;
107 }
108
109 /**
110 * Add a table for storing custom tokens and their descriptions.
111 */
112 function skeleton_update_6001() {
113 $ret = array();
114 $schema = array();
115 $schema['skeleton_token'] = array(
116 'fields' => array(
117 'token_id' => array('type' => 'serial', 'length' => 11),
118 'token' => array('type' => 'varchar', 'length' => 80),
119 'description' => array('type' => 'varchar', 'length' => 80),
120 ),
121 'primary key' => array(
122 'token_id',
123 ),
124 );
125 db_create_table($ret, 'skeleton_token', $schema['skeleton_token']);
126 return $ret;
127 }
128
129 /**
130 * Add a table for storing template id's and supplied tokens in instantiated nodes.
131 * @return unknown_type
132 */
133 function skeleton_update_6002() {
134 $ret = array();
135 $schema = array();
136 $schema['skeleton_template_node'] = array(
137 'fields' => array(
138 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
139 'skeleton_id' => array('type' => 'int', 'unsigned' => TRUE, 'length' => 11, 'not null' => TRUE),
140 'template_id' => array('type' => 'int', 'unsigned' => TRUE, 'length' => 11, 'not null' => TRUE),
141 'template_status' => array('type' => 'varchar', 'length' => '16', 'not null' => TRUE),
142 'tokens' => array('type' => 'blob', 'size' => 'big'),
143 ),
144 'primary key' => array(
145 'nid',
146 'template_id',
147 ),
148 );
149 db_create_table($ret, 'skeleton_template_node', $schema['skeleton_template_node']);
150 return $ret;
151 }

  ViewVC Help
Powered by ViewVC 1.1.2