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

Contents of /contributions/modules/casetracker/casetracker.install

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


Revision 1.35 - (show annotations) (download) (as text)
Tue Feb 10 22:33:33 2009 UTC (9 months, 2 weeks ago) by jmiccolis
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.34: +13 -15 lines
File MIME type: text/x-php
Adding initial case states back into .install
Adding missing ID tags, and other minor code cleanup
1 <?php
2 // $Id: casetracker.install,v 1.34 2009/02/09 23:22:58 jmiccolis Exp $
3
4 /**
5 * Implementation of hook_schema().
6 */
7 function casetracker_schema() {
8 $schema['casetracker_case'] = array(
9 'fields' => array(
10 'nid' => array(
11 'type' => 'int',
12 'not null' => TRUE,
13 'default' => 0,
14 ),
15 'vid' => array(
16 'type' => 'int',
17 'not null' => TRUE,
18 'default' => 0,
19 ),
20 'pid' => array(
21 'type' => 'int',
22 'not null' => TRUE,
23 'default' => 0,
24 ),
25 'case_number' => array(
26 'type' => 'int',
27 'not null' => TRUE,
28 'default' => 0,
29 ),
30 'assign_to' => array(
31 'type' => 'int',
32 'not null' => TRUE,
33 'default' => 0,
34 ),
35 'case_priority_id' => array(
36 'type' => 'int',
37 'not null' => TRUE,
38 'default' => 0,
39 ),
40 'case_type_id' => array(
41 'type' => 'int',
42 'not null' => TRUE,
43 'default' => 0,
44 ),
45 'case_status_id' => array(
46 'type' => 'int',
47 'not null' => TRUE,
48 'default' => 0,
49 ),
50 ),
51 'indexes' => array(
52 'nid' => array('nid'),
53 'p_id' => array('pid'),
54 ),
55 'primary key' => array('vid'),
56 );
57
58 $schema['casetracker_case_states'] = array(
59 'fields' => array(
60 'csid' => array(
61 'type' => 'serial',
62 'size' => 'tiny',
63 'not null' => TRUE,
64 ),
65 'case_state_name' => array(
66 'type' => 'varchar',
67 'length' => 255,
68 'not null' => TRUE,
69 'default' => '',
70 ),
71 'case_state_realm' => array(
72 'type' => 'varchar',
73 'length' => 255,
74 'not null' => TRUE,
75 'default' => '',
76 ),
77 'weight' => array(
78 'type' => 'int',
79 'size' => 'tiny',
80 'not null' => TRUE,
81 'default' => 0,
82 ),
83 ),
84 'indexes' => array(
85 'weight' => array('weight'),
86 ),
87 'primary key' => array('csid'),
88 );
89
90 $schema['casetracker_comment_status'] = array(
91 'fields' => array(
92 'cid' => array(
93 'type' => 'int',
94 'not null' => TRUE,
95 'default' => 0,
96 ),
97 'pid' => array(
98 'type' => 'int',
99 'not null' => TRUE,
100 'default' => 0,
101 ),
102 'title' => array(
103 'type' => 'varchar',
104 'length' => 250,
105 'not null' => FALSE,
106 ),
107 'assign_to' => array(
108 'type' => 'int',
109 'not null' => TRUE,
110 'default' => 0,
111 ),
112 'case_priority_id' => array(
113 'type' => 'int',
114 'not null' => TRUE,
115 'default' => 0,
116 ),
117 'case_type_id' => array(
118 'type' => 'int',
119 'not null' => TRUE,
120 'default' => 0,
121 ),
122 'case_status_id' => array(
123 'type' => 'int',
124 'not null' => TRUE,
125 'default' => 0,
126 ),
127 'state' => array(
128 'type' => 'int',
129 'not null' => TRUE,
130 'default' => 0,
131 ),
132 ),
133 );
134
135 return $schema;
136 }
137
138 /**
139 * Implementation of hook_install().
140 *
141 * Database schema last updated 2007-11 by zero2one.
142 *
143 * casetracker_case:
144 * nid: corresponding node ID of this case item.
145 * vid: corresponding revision ID of the node ID.
146 * pid: the project ID this case has been assigned to.
147 * case_number: the case number of this node (namespaced per projects).
148 * assign_to: the user ID this case has been assigned to.
149 * case_priority_id: the priority ID this case has been set to.
150 * case_type_id: the type ID this case has been set to.
151 * case_status_id: the status ID this case has been set to.
152 *
153 * casetracker_case_states:
154 * csid: the unique ID of this case state.
155 * case_state_name: the name of this case state.
156 * case_state_realm: the realm ('priority', etc.) of this state.
157 * weight: the weight of an case (order for display purpose).
158 *
159 * casetracker_comment_status:
160 * cid: comment ID as defined by core comment table.
161 * pid: the project ID (before or after) of this comment/case.
162 * title: the case title (before or after) of this comment/case.
163 * assign_to: the user ID (before or after) of this comment/case.
164 * case_priority_id: the priority ID (before or after) of this comment/case.
165 * case_type_id: the case ID (before or after) of this comment/case.
166 * case_status_id: the status ID (before or after) of this comment/case.
167 * state: if 0, this is data for "before" the comment; 1 is "after".
168 *
169 */
170 function casetracker_install() {
171 // Create tables.
172 drupal_install_schema('casetracker');
173
174 // Create default case states.
175 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('High', 'priority', -1)");
176 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('Normal', 'priority', 0)");
177 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('Low', 'priority', 1)");
178 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('Open', 'status', 0)");
179 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('Resolved', 'status', 1)");
180 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('Deferred', 'status', 2)");
181 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('Duplicate', 'status', 3)");
182 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('Closed', 'status', 4)");
183 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('Bug', 'type', 0)");
184 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('Feature Request', 'type', 1)");
185 db_query("INSERT INTO {casetracker_case_states} (case_state_name, case_state_realm, weight) VALUES ('General Task', 'type', 2)");
186 }
187
188 /**
189 * Implementation of hook_uninstall().
190 */
191 function casetracker_uninstall() {
192 // Remove tables.
193 drupal_uninstall_schema('casetracker');
194
195 variable_del('casetracker_default_assign_to');
196 variable_del('casetracker_default_case_priority');
197 variable_del('casetracker_default_case_state');
198 variable_del('casetracker_default_case_type');
199 variable_del('casetracker_project_node_types');
200 variable_del('casetracker_case_node_types');
201 variable_del('casetracker_current_case_numbers');
202 variable_del('casetracker_current_project_number');
203 }
204
205 /**
206 * Implementation of hook_update_N
207 */
208 function casetracker_update_6001() {
209 variable_del('casetracker_current_project_number');
210 variable_del('casetracker_current_case_numbers');
211 }

  ViewVC Help
Powered by ViewVC 1.1.2