| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: project_issue.install,v 1.64 2009/08/21 22:51:31 dww Exp $ 3 4 /** 5 * Implementation of hook_schema(). 6 */ 7 function project_issue_schema() { 8 $schema['project_issue_projects'] = array( 9 'description' => 'Table containing per-project issue-related settings.', 10 'fields' => array( 11 'nid' => array( 12 'description' => 'Primary Key: The {project_projects}.nid of the project.', 13 'type' => 'int', 14 'unsigned' => 1, 15 'not null' => TRUE, 16 'default' => 0, 17 ), 18 'issues' => array( 19 'description' => 'Boolean value indicating whether or not issue-tracking is enabled for this project.', 20 'type' => 'int', 21 'size' => 'tiny', 22 'not null' => TRUE, 23 'default' => 0, 24 ), 25 'components' => array( 26 'description' => 'A serialized array defining the components for this project.', 27 'type' => 'text', 28 'not null' => FALSE, 29 ), 30 'default_component' => array( 31 'description' => 'The default component for new issues of this project, or an empty string if the user needs to select a component.', 32 'type' => 'varchar', 33 'length' => 255, 34 'not null' => TRUE, 35 'default' => '', 36 ), 37 'help' => array( 38 'description' => 'Submission guidelines for issues added to this project.', 39 'type' => 'text', 40 'not null' => FALSE, 41 ), 42 'mail_digest' => array( 43 'description' => 'E-mail address for the weekly critical issues report.', 44 'type' => 'varchar', 45 'length' => 255, 46 'not null' => TRUE, 47 'default' => '', 48 ), 49 'mail_copy' => array( 50 'description' => 'E-mail address to send a copy of all issues to.', 51 'type' => 'varchar', 52 'length' => 255, 53 'not null' => TRUE, 54 'default' => '', 55 ), 56 'mail_copy_filter' => array( 57 'description' => 'A serialized array containing the types of issues to include in the e-mail sent to {project_projects}.mail_copy.', 58 'type' => 'varchar', 59 'length' => 255, 60 'not null' => TRUE, 61 'default' => '', 62 ), 63 'mail_copy_filter_state' => array( 64 'description' => 'A serialized array containing the statuses to include in the e-mail sent to {project_projects}.mail_copy.', 65 'type' => 'varchar', 66 'length' => 255, 67 'not null' => TRUE, 68 'default' => '', 69 ), 70 'mail_reminder' => array( 71 'description' => 'Boolean indicating whether or not users with open issues should receive a monthly reminder.', 72 'type' => 'int', 73 'size' => 'tiny', 74 'not null' => TRUE, 75 'default' => 0, 76 ), 77 ), 78 'primary key' => array('nid'), 79 ); 80 81 $schema['project_issues'] = array( 82 'description' => 'The base table for issues.', 83 'fields' => array( 84 'nid' => array( 85 'description' => 'Primary Key: The {node}.nid of this project_issue node.', 86 'type' => 'int', 87 'unsigned' => 1, 88 'not null' => TRUE, 89 'default' => 0, 90 ), 91 'pid' => array( 92 'description' => 'The {project_projects}.nid of the project to which this issue belongs.', 93 'type' => 'int', 94 'unsigned' => 1, 95 'not null' => TRUE, 96 'default' => 0, 97 ), 98 'category' => array( 99 'description' => 'Category of the issue.', 100 'type' => 'varchar', 101 'length' => 255, 102 'not null' => TRUE, 103 'default' => '', 104 ), 105 'component' => array( 106 'description' => 'Component of the issue as defined per-project in {project_issue_projects}.components.', 107 'type' => 'varchar', 108 'length' => 255, 109 'not null' => TRUE, 110 'default' => '', 111 ), 112 'priority' => array( 113 'description' => 'The priority for this issue.', 114 'type' => 'int', 115 'size' => 'tiny', 116 'unsigned' => 1, 117 'not null' => TRUE, 118 'default' => 0, 119 ), 120 'rid' => array( 121 'description' => 'The {project_release_nodes}.rid (version identifier) for this issue (only used in conjunction with the project_release module).', 122 'type' => 'int', 123 'unsigned' => 1, 124 'not null' => TRUE, 125 'default' => 0, 126 ), 127 'assigned' => array( 128 'description' => 'The {users}.uid of the user to which this issue is currently assigned.', 129 'type' => 'int', 130 'unsigned' => 1, 131 'not null' => TRUE, 132 'default' => 0, 133 ), 134 'sid' => array( 135 'description' => 'Current {project_issue_state}.sid of this issue.', 136 'type' => 'int', 137 'unsigned' => 1, 138 'not null' => TRUE, 139 'default' => 0, 140 ), 141 'original_issue_data' => array( 142 'description' => 'A serialized object containing the original metadata values that were used when this issue was created.', 143 'type' => 'text', 144 'not null' => TRUE, 145 ), 146 'last_comment_id' => array( 147 'description' => '{comments}.cid of the most recent comment added to the issue. 0 if no comment has been added yet.', 148 'type' => 'int', 149 'not null' => TRUE, 150 'default' => 0, 151 ), 152 'db_lock' => array( 153 'description' => 'Row-lock indicator to prevent race conditions when determining sequential comment number (http://drupal.org/node/180866).', 154 'type' => 'int', 155 'size' => 'tiny', 156 'not null' => TRUE, 157 'default' => 0, 158 ), 159 ), 160 'indexes' => array( 161 'project_issues_pid' => array('pid'), 162 'project_issues_sid' => array('sid'), 163 'project_issues_nid_assigned' => array('nid', 'assigned'), 164 ), 165 'primary key' => array('nid'), 166 ); 167 168 $schema['project_issue_comments'] = array( 169 'description' => 'The base table for comments added to issues.', 170 'fields' => array( 171 'nid' => array( 172 'description' => 'References {project_issues}.nid, the issue to which this comment was added.', 173 'type' => 'int', 174 'not null' => FALSE, 175 ), 176 'cid' => array( 177 'description' => 'Primary Key: The {comments}.cid for this comment.', 178 'type' => 'int', 179 'not null' => FALSE, 180 ), 181 'rid' => array( 182 'description' => 'The {project_release_nodes}.rid (version identifier) after this comment was made (only used in conjunction with the project_release module).', 183 'type' => 'int', 184 'not null' => TRUE, 185 'default' => 0, 186 ), 187 'component' => array( 188 'description' => 'Component of the issue after this comment was made. Components are defined per-project in {project_issue_projects}.components.', 189 'type' => 'varchar', 190 'length' => 255, 191 'not null' => TRUE, 192 'default' => '', 193 ), 194 'category' => array( 195 'description' => 'Category of this issue after this comment was made.', 196 'type' => 'varchar', 197 'length' => 255, 198 'not null' => TRUE, 199 'default' => '', 200 ), 201 'priority' => array( 202 'description' => 'The priority for this issue after this comment was made.', 203 'type' => 'int', 204 'not null' => TRUE, 205 'default' => 0, 206 ), 207 'assigned' => array( 208 'description' => 'The {users}.uid of the user to which this issue was assigned after this comment was made.', 209 'type' => 'int', 210 'not null' => TRUE, 211 'default' => 0, 212 ), 213 'sid' => array( 214 'description' => 'The {project_issue_state}.sid of this issue after this comment was made.', 215 'type' => 'int', 216 'not null' => TRUE, 217 'default' => 0, 218 ), 219 'pid' => array( 220 'description' => 'The {project_projects}.nid of the project to which this issue belongs after this comment was made.', 221 'type' => 'int', 222 'unsigned' => 1, 223 'not null' => TRUE, 224 'default' => 0, 225 ), 226 'title' => array( 227 'description' => 'The title of the issue after this comment was made.', 228 'type' => 'varchar', 229 'length' => 255, 230 'not null' => TRUE, 231 ), 232 'timestamp' => array( 233 'description' => 'Timestamp for this comment.', 234 'type' => 'int', 235 'unsigned' => 1, 236 'not null' => TRUE, 237 ), 238 'comment_number' => array( 239 'description' => 'The sequential number for this comment in the issue.', 240 'type' => 'int', 241 'not null' => TRUE, 242 'default' => 0, 243 ), 244 ), 245 'primary key' => array('cid'), 246 'indexes' => array( 247 'nid_timestamp' => array('nid', 'timestamp'), 248 'comment_number' => array('comment_number'), 249 ), 250 ); 251 252 $schema['project_subscriptions'] = array( 253 'description' => 'Table keeping track of per-user project_issue subscriptions.', 254 'fields' => array( 255 'nid' => array( 256 'description' => '{project_projects}.nid of the project to which the user is subscribed.', 257 'type' => 'int', 258 'unsigned' => 1, 259 'not null' => TRUE, 260 'default' => 0, 261 ), 262 'uid' => array( 263 'description' => 'The {users}.uid for this subscriber.', 264 'type' => 'int', 265 'unsigned' => 1, 266 'not null' => TRUE, 267 'default' => 0, 268 ), 269 'level' => array( 270 'description' => 'The type of subscription for the project. Possible values are: 0 = not subscribed, 1 = subscribed to own issues or 2 = subscribed to all issues.', 271 'type' => 'int', 272 'size' => 'tiny', 273 'unsigned' => 1, 274 'not null' => TRUE, 275 'default' => 0, 276 ), 277 ), 278 'indexes' => array( 279 'project_subscriptions_nid_uid_level' => array('nid', 'uid', 'level'), 280 ), 281 ); 282 283 $schema['project_issue_state'] = array( 284 'description' => 'Table that holds all possible values for issue statuses.', 285 'fields' => array( 286 'sid' => array( 287 'description' => 'Primary Key: Unique id for this status.', 288 'type' => 'serial', 289 'unsigned' => 1, 290 'not null' => TRUE, 291 ), 292 'name' => array( 293 'description' => 'Display-friendly name for this status.', 294 'type' => 'varchar', 295 'length' => 64, 296 'not null' => TRUE, 297 'default' => '', 298 ), 299 'weight' => array( 300 'description' => 'Weight for this status, used when ordering statuses', 301 'type' => 'int', 302 'size' => 'tiny', 303 'not null' => TRUE, 304 'default' => 0, 305 ), 306 'author_has' => array( 307 'description' => 'Boolean indicating whether or not the author of an issue may use this issue status in that issue, regardless of the permissions controlling site-wide use of this status.', 308 'type' => 'int', 309 'size' => 'tiny', 310 'not null' => TRUE, 311 'default' => 0, 312 ), 313 'default_query' => array( 314 'description' => 'Boolean indicating whether or not issues with this status are included in default queries.', 315 'type' => 'int', 316 'size' => 'tiny', 317 'not null' => TRUE, 318 'default' => 0, 319 ), 320 ), 321 'primary key' => array('sid'), 322 ); 323 324 return $schema; 325 } 326 327 function project_issue_install() { 328 // We need to check this before we try to create the table, so that 329 // if it already exists, we don't attempt to insert our own values. 330 $project_issue_state_existed = db_table_exists('project_issue_state'); 331 332 // Create tables. 333 drupal_install_schema('project_issue'); 334 335 if (!$project_issue_state_existed) { 336 // sid, name, weight, author-can-set, in-default-queries 337 project_issue_init_state(1, 'active', -13, 0, 1); 338 project_issue_init_state(2, 'fixed', 1, 0, 1); 339 project_issue_init_state(3, 'duplicate', 4, 0, 0); 340 project_issue_init_state(4, 'postponed', 6, 0, 1); 341 project_issue_init_state(5, "won't fix", 9, 0, 0); 342 project_issue_init_state(6, 'by design', 11, 0, 0); 343 project_issue_init_state(7, 'closed', 13, 1, 0); 344 project_issue_init_state(8, 'needs review', -8, 0, 0); 345 project_issue_init_state(13, 'needs work', -6, 0, 0); 346 project_issue_init_state(14, 'ready to commit', -2, 0, 0); 347 348 // Since we're hacking in auto-increment values here, 349 // update the sequence value for Postgres -- ugly but necessary for now. 350 if ($GLOBALS['db_type'] == 'pgsql') { 351 db_query("SELECT setval('project_issue_state_sid_seq', 14)"); 352 } 353 } 354 355 project_issue_add_missing_projects(); 356 357 db_query("UPDATE {system} SET weight = 2 WHERE name = 'project_issue'"); 358 359 // Set up future followups to be read/write. 360 if (module_exists('comment')) { 361 variable_set('comment_project_issue', COMMENT_NODE_READ_WRITE); 362 } 363 // Enable file attachments for followups. 364 variable_set('comment_upload_project_issue', 1); 365 // Enable file attachments for issues. 366 variable_set('upload_project_issue', 1); 367 } 368 369 /** 370 * Implementation of hook_uninstall(). 371 */ 372 function project_issue_uninstall() { 373 // Remove tables. 374 drupal_uninstall_schema('project_issue'); 375 376 $variables = array( 377 'project_issue_default_state', 378 'project_directory_issues', 379 'project_reply_to', 380 'project_issue_digest_last', 381 'project_issue_cockpit_categories', 382 'project_issue_digest_interval', 383 'project_issue_reminder_last', 384 'project_issue_reminder_interval', 385 'project_issue_show_comment_signatures', 386 'project_issue_site_help', 387 'project_issue_invalid_releases', 388 'project_issue_followup_user', 389 'project_issue_hook_cron', 390 ); 391 foreach ($variables as $variable) { 392 variable_del($variable); 393 } 394 } 395 396 function project_issue_enable() { 397 project_issue_add_missing_projects(); 398 } 399 400 /** 401 * Initialize a given issue state in the database. 402 */ 403 function project_issue_init_state($sid, $name, $weight, $author, $query) { 404 db_query("INSERT INTO {project_issue_state} (sid, name, weight, author_has, default_query) VALUES (%d, '%s', %d, %d, %d)", $sid, $name, $weight, $author, $query); 405 } 406 407 /** 408 * Check for existing project nodes that do not have an entry in the 409 * {project_issue_projects} table, and add them. 410 * 411 */ 412 function project_issue_add_missing_projects() { 413 $projects = db_query("SELECT n.nid, pip.nid AS pip_nid FROM {node} n LEFT JOIN {project_issue_projects} pip ON n.nid = pip.nid WHERE n.type = 'project_project' AND pip.nid IS NULL"); 414 while ($project = db_fetch_object($projects)) { 415 db_query('INSERT INTO {project_issue_projects} (nid) VALUES (%d)', $project->nid); 416 } 417 } 418 419 /** 420 * Remove stale setting that's now provided by views. 421 */ 422 function project_issue_update_6000() { 423 variable_del('project_issues_per_page'); 424 return array(); 425 } 426 427 /** 428 * Add the 'default_component' field to {project_issue_projects}. 429 */ 430 function project_issue_update_6001() { 431 $ret = array(); 432 db_add_field($ret, 'project_issue_projects', 'default_component', 433 array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')); 434 return $ret; 435 } 436 437 /** 438 * Make {project_issue_comments}.cid the primary key for that table. 439 */ 440 function project_issue_update_6002() { 441 $ret = array(); 442 db_add_primary_key($ret, 'project_issue_comments', array('cid')); 443 if (empty($ret[0]['success'])) { 444 return array(array('success' => TRUE, 'query' => '<strong>' . t("It is safe to ignore warnings about 'Multiple primary key defined'.") . '</strong>')); 445 } 446 return $ret; 447 } 448
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |