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

Contents of /contributions/modules/versioncontrol_project/versioncontrol_project.install

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


Revision 1.25 - (show annotations) (download) (as text)
Mon Jun 1 13:23:32 2009 UTC (5 months, 3 weeks ago) by jpetso
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-RC2, HEAD
Changes since 1.24: +51 -3 lines
File MIME type: text/x-php
Port of #371969 by dww, adapted and extended for cross-VCS purposes:
Provide blocks for maintainer and developer commit information.
1 <?php
2 // $Id: versioncontrol_project.install,v 1.24 2009/05/31 17:32:33 jpetso Exp $
3 /**
4 * @file
5 * Version Control / Project Node integration - Integrates project nodes
6 * (provided by the Project module) with version control systems supported
7 * by the Version Control API.
8 *
9 * Copyright 2006 by Karthik ("Zen", http://drupal.org/user/21209)
10 * Copyright 2006, 2007, 2009 by Derek Wright ("dww", http://drupal.org/user/46549)
11 * Copyright 2007, 2009 by Jakob Petsovits ("jpetso", http://drupal.org/user/56020)
12 */
13
14 /**
15 * Implementation of hook_schema().
16 */
17 function versioncontrol_project_schema() {
18 $schema['versioncontrol_project_projects'] = array(
19 'description' => 'This table associates a project (given as node id) with a directory location in a version controlled repository.',
20 'fields' => array(
21 'nid' => array(
22 'description' => 'The {node}.nid identifier of the project node.',
23 'type' => 'int',
24 'unsigned' => TRUE,
25 'not null' => TRUE,
26 'default' => 0,
27 ),
28 'repo_id' => array(
29 'description' => 'The {versioncontrol_repositories}.repo_id identifier of the repository where the project directory is located.',
30 'type' => 'int',
31 'unsigned' => TRUE,
32 'not null' => TRUE,
33 'default' => 0,
34 ),
35 'directory' => array(
36 'description' => 'The path of the project directory relative to the repository root, in the same format as {versioncontrol_item_revisions}.path (which means it starts with a slash and does not end with one).',
37 'type' => 'varchar',
38 'length' => 255,
39 'not null' => TRUE,
40 'default' => '',
41 ),
42 ),
43 'indexes' => array(
44 'repo_id_directory' => array('repo_id', 'directory'),
45 ),
46 'primary key' => array('nid'),
47 );
48
49 $schema['versioncontrol_project_comaintainers'] = array(
50 'description' => 'The list of project co-maintainers. The actual maintainer is the node owner and not stored in here, (s)he will be retrieved from {node}.uid rather than from this table.',
51 'fields' => array(
52 'nid' => array(
53 'description' => 'The {node}.nid identifier of the project node where the user in {versioncontrol_project_comaintainers}.uid is listed as co-maintainer.',
54 'type' => 'int',
55 'unsigned' => TRUE,
56 'not null' => TRUE,
57 'default' => 0,
58 ),
59 'uid' => array(
60 'description' => 'The Drupal user id (referring to {users}.uid) of the co-maintainer.',
61 'type' => 'int',
62 'unsigned' => TRUE,
63 'not null' => TRUE,
64 'default' => 0,
65 ),
66 ),
67 'primary key' => array('nid', 'uid'),
68 );
69
70 $schema['versioncontrol_project_items'] = array(
71 'description' => 'An association of repository items in {versioncontrol_item_revisions} to projects in {versioncontrol_project_projects}.',
72 'fields' => array(
73 'item_revision_id' => array(
74 'description' => 'The {versioncontrol_item_revisions}.item_revision_id identifier that belongs to the project.',
75 'type' => 'int',
76 'unsigned' => TRUE,
77 'not null' => TRUE,
78 'default' => 0,
79 ),
80 'nid' => array(
81 'description' => 'The {node}.nid identifier of the project node that the item belongs to. VERSIONCONTROL_PROJECT_NID_NONE (== 0) for items which do not belong to any project. VERSIONCONTROL_PROJECT_NID_NONE and actual (positive) nids are mutually exclusive for any given item_revision_id.',
82 'type' => 'int',
83 'unsigned' => TRUE,
84 'not null' => TRUE,
85 'default' => 0,
86 ),
87 ),
88 'primary key' => array('item_revision_id', 'nid'),
89 );
90
91 $schema['versioncontrol_project_operations'] = array(
92 'description' => 'An association of operations in {versioncontrol_operations} to projects in {versioncontrol_project_projects}. This is just a cache built out of {versioncontrol_project_items}, for more efficient joins in repository queries, and unlike {versioncontrol_project_items} does not contain items with nid == VERSIONCONTROL_PROJECT_NID_NONE.',
93 'fields' => array(
94 'vc_op_id' => array(
95 'description' => 'The {versioncontrol_operations}.vc_op_id identifier that is related to the project.',
96 'type' => 'int',
97 'unsigned' => TRUE,
98 'not null' => TRUE,
99 'default' => 0,
100 ),
101 'nid' => array(
102 'description' => 'The {node}.nid identifier of the project node that the operation took place in.',
103 'type' => 'int',
104 'unsigned' => TRUE,
105 'not null' => TRUE,
106 'default' => 0,
107 ),
108 ),
109 'primary key' => array('vc_op_id', 'nid'),
110 );
111
112 $schema['versioncontrol_project_cache_block'] = array(
113 'description' => t('Cache for project-node-specific blocks that cannot rely on the normal block cache.'),
114 'fields' => array(
115 'cid' => array(
116 'description' => 'Primary Key: Unique cache ID.',
117 'type' => 'varchar',
118 'length' => 255,
119 'not null' => TRUE,
120 'default' => '',
121 ),
122 'data' => array(
123 'description' => 'A collection of data to cache.',
124 'type' => 'blob',
125 'not null' => FALSE,
126 'size' => 'big',
127 ),
128 ),
129 'primary key' => array('cid'),
130 );
131
132 return $schema;
133 }
134
135 /**
136 * Implementation of hook_install().
137 */
138 function versioncontrol_project_install() {
139 // Create tables.
140 drupal_install_schema('versioncontrol_project');
141 }
142
143 /**
144 * Implementation of hook_enable().
145 */
146 function versioncontrol_project_enable() {
147 require_once(drupal_get_path('module', 'versioncontrol_project') .'/versioncontrol_project.module');
148
149 // Check to make sure all existing projects are entered in the
150 // {versioncontrol_project_projects} table, and add if not.
151 $vc_projects = array();
152 $projects = array();
153 $current_vc_projects = db_query("SELECT nid FROM {versioncontrol_project_projects}");
154 while ($vc_project = db_fetch_object($current_vc_projects)) {
155 $vc_projects[] = $vc_project->nid;
156 }
157 $projects = db_query("SELECT nid FROM {node} WHERE type = 'project_project'");
158 while ($project = db_fetch_array($projects)) {
159 if (!in_array($project['nid'], $vc_projects)) {
160 $project['repo_id'] = 0;
161 versioncontrol_project_set_project($project);
162 }
163 }
164
165 _versioncontrol_project_write_missing_item_associations();
166 }
167
168 /**
169 * Implementation of hook_uninstall().
170 */
171 function versioncontrol_project_uninstall() {
172 // Remove variables.
173 db_query("DELETE FROM {variable} WHERE name LIKE 'versioncontrol_project_directory_tid_%'");
174 $variables = array(
175 'versioncontrol_project_restrict_commits',
176 'versioncontrol_project_restrict_creation',
177 'versioncontrol_project_dir_validate_by_type',
178 'versioncontrol_project_validate_by_short_name',
179 'versioncontrol_project_developers_block_length',
180 'versioncontrol_project_maintainers_block_length',
181 );
182 foreach ($variables as $variable) {
183 variable_del($variable);
184 }
185
186 // Remove tables.
187 drupal_uninstall_schema('versioncontrol_project');
188 }
189
190
191 // Update functions. To be named versioncontrol_project_update_xyzz(), where x
192 // is the major version of Drupal core, y is the major version of this module
193 // for this version of Drupal core, and zz is a consecutive number.
194
195 // versioncontrol_project_update_2() was the last update on Drupal 5.x (-2.x).
196
197 /**
198 * Update 6100: Add the project/item association table and the related
199 * project/operation association cache built out of the former.
200 */
201 function versioncontrol_project_update_6100() {
202 $ret = array();
203
204 $project_item_table = array(
205 'fields' => array(
206 'item_revision_id' => array(
207 'type' => 'int',
208 'unsigned' => TRUE,
209 'not null' => TRUE,
210 'default' => 0,
211 ),
212 'nid' => array(
213 'type' => 'int',
214 'unsigned' => TRUE,
215 'not null' => TRUE,
216 'default' => 0,
217 ),
218 ),
219 'primary key' => array('item_revision_id', 'nid'),
220 );
221 $project_operations_table = array(
222 'fields' => array(
223 'vc_op_id' => array(
224 'type' => 'int',
225 'unsigned' => TRUE,
226 'not null' => TRUE,
227 'default' => 0,
228 ),
229 'nid' => array(
230 'type' => 'int',
231 'unsigned' => TRUE,
232 'not null' => TRUE,
233 'default' => 0,
234 ),
235 ),
236 'primary key' => array('vc_op_id', 'nid'),
237 );
238
239 db_create_table($ret, 'versioncontrol_project_items', $project_item_table);
240 db_create_table($ret, 'versioncontrol_project_operations', $project_operations_table);
241
242 require_once(drupal_get_path('module', 'versioncontrol_project') .'/versioncontrol_project.module');
243 _versioncontrol_project_write_missing_item_associations();
244 $ret[] = array(
245 'success' => TRUE,
246 'query' => t('Countless queries (probably), inserting project associations into {versioncontrol_project_items} and {versioncontrol_project_operations}.'),
247 );
248
249 return $ret;
250 }
251
252 /**
253 * Update 6101 (from 6.x-1.0-rc1 to rc2):
254 * String deltas for the "active developers" block.
255 */
256 function versioncontrol_project_update_6101() {
257 $ret = array();
258 $ret[] = update_sql("
259 UPDATE {blocks} SET delta = 'site_active_projects'
260 WHERE delta = '0' AND module = 'versioncontrol_project'");
261 return $ret;
262 }
263
264 /**
265 * Update 6102 (from 6.x-1.0-rc1 to rc2):
266 * Add the {versioncontrol_project_cache_block} table for the maintainers block.
267 */
268 function versioncontrol_project_update_6102() {
269 $ret = array();
270 $table = array(
271 'fields' => array(
272 'cid' => array(
273 'type' => 'varchar',
274 'length' => 255,
275 'not null' => TRUE,
276 'default' => '',
277 ),
278 'data' => array(
279 'type' => 'blob',
280 'not null' => FALSE,
281 'size' => 'big',
282 ),
283 ),
284 'primary key' => array('cid'),
285 );
286 db_create_table($ret, 'versioncontrol_project_cache_block', $table);
287 return $ret;
288 }

  ViewVC Help
Powered by ViewVC 1.1.2