r665: Renaming product from "BugStrike" to "Bugdar"
[bugdar.git] / includes / functions_datastore.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 // ###################### Start build_languages ######################
14 function build_languages()
15 {
16 global $bugsys;
17
18 $languages = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "language");
19 while ($language = $bugsys->db->fetch_array($languages))
20 {
21 $tempstore["$language[languageid]"] = $language;
22 }
23
24 $bugsys->db->query("
25 ### replacing the language cache ###
26 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
27 VALUES ('language', '" . $bugsys->escape(serialize($tempstore)) . "')"
28 );
29
30 $bugsys->datastore['language'] = $tempstore;
31 }
32
33 // ####################### Start build_settings ######################
34 function build_settings()
35 {
36 global $bugsys;
37
38 $settings = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "setting");
39 while ($setting = $bugsys->db->fetch_array($settings))
40 {
41 $options["$setting[varname]"] = $setting['value'];
42 }
43
44 $bugsys->db->query("
45 ### replacing the setting cache ###
46 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
47 VALUES ('setting', '" . $bugsys->escape(serialize($options)) . "')"
48 );
49
50 $bugsys->datastore['setting'] = $options;
51 }
52
53 // ###################### Start build_usergroups #####################
54 function build_usergroups()
55 {
56 global $bugsys;
57
58 $usergroups = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "usergroup");
59 while ($usergroup = $bugsys->db->fetch_array($usergroups))
60 {
61 $groups["$usergroup[usergroupid]"] = $usergroup;
62 }
63
64 $bugsys->db->query("
65 ### replacing usergroup cache ###
66 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
67 VALUES ('usergroup', '" . $bugsys->escape(serialize($groups)) . "')"
68 );
69
70 $bugsys->datastore['usergroup'] = $groups;
71 }
72
73 // ####################### Start build_statuses ######################
74 function build_statuses()
75 {
76 global $bugsys;
77
78 $statuses = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "status ORDER BY displayorder ASC");
79 while ($status = $bugsys->db->fetch_array($statuses))
80 {
81 $tempstore["$status[statusid]"] = $status;
82 }
83
84 $bugsys->db->query("
85 ### replacing status cache ###
86 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
87 VALUES ('status', '" . $bugsys->escape(serialize($tempstore)) . "')"
88 );
89
90 $bugsys->datastore['status'] = $tempstore;
91 }
92
93 // ###################### Start build_severities #####################
94 function build_severities()
95 {
96 global $bugsys;
97
98 $severities = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "severity ORDER BY displayorder ASC");
99 while ($severity = $bugsys->db->fetch_array($severities))
100 {
101 $tempstore["$severity[severityid]"] = $severity;
102 }
103
104 $bugsys->db->query("
105 ### replacing severity cache ###
106 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
107 VALUES ('severity', '" . $bugsys->escape(serialize($tempstore)) . "')"
108 );
109
110 $bugsys->datastore['severity'] = $tempstore;
111 }
112
113 // ###################### Start build_priorities #####################
114 function build_priorities()
115 {
116 global $bugsys;
117
118 $priorities = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "priority ORDER BY displayorder ASC");
119 while ($priority = $bugsys->db->fetch_array($priorities))
120 {
121 $tempstore["$priority[priorityid]"] = $priority;
122 }
123
124 $bugsys->db->query("
125 ### replacing priority cache ###
126 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
127 VALUES ('priority', '" . $bugsys->escape(serialize($tempstore)) . "')"
128 );
129
130 $bugsys->datastore['priority'] = $tempstore;
131 }
132
133 // ###################### Start build_assignedto #####################
134 function build_assignedto()
135 {
136 global $bugsys;
137
138 $users = $bugsys->db->query("
139 SELECT user.email, user.displayname, user.userid, user.showemail
140 FROM " . TABLE_PREFIX . "user AS user
141 LEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup ON (user.usergroupid = usergroup.usergroupid)
142 WHERE (usergroup.permissions & " . CANBEASSIGNEDTO . ")"
143 );
144 while ($user = $bugsys->db->fetch_array($users))
145 {
146 $devs["$user[userid]"] = $user;
147 }
148
149 $bugsys->db->query("
150 ### replacing developer / assign to cache ###
151 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
152 VALUES ('assignto', '" . $bugsys->escape(serialize($devs)) . "')"
153 );
154
155 $bugsys->datastore['assignto'] = $devs;
156 }
157
158 // ##################### Start build_resolutions #####################
159 function build_resolutions()
160 {
161 global $bugsys;
162
163 $resolutions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "resolution ORDER BY displayorder ASC");
164 while ($resolution = $bugsys->db->fetch_array($resolutions))
165 {
166 $tempstore["$resolution[resolutionid]"] = $resolution;
167 }
168
169 $bugsys->db->query("
170 ### replacing resolution cache ###
171 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
172 VALUES ('resolution', '" . $bugsys->escape(serialize($tempstore)) . "')"
173 );
174
175 $bugsys->datastore['resolution'] = $tempstore;
176 }
177
178 // ####################### Start build_versions ######################
179 function build_versions()
180 {
181 global $bugsys;
182
183 $versions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC");
184 while ($version = $bugsys->db->fetch_array($versions))
185 {
186 $tempstore["$version[versionid]"] = $version;
187 }
188
189 $bugsys->db->query("
190 ### replacing version cache ###
191 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
192 VALUES ('version', '" . $bugsys->escape(serialize($tempstore)) . "')"
193 );
194
195 $bugsys->datastore['version'] = $tempstore;
196 }
197
198 // ####################### Start build_products ######################
199 function build_products()
200 {
201 global $bugsys;
202
203 $products = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC");
204 while ($product = $bugsys->db->fetch_array($products))
205 {
206 $tempstore["$product[productid]"] = $product;
207 }
208
209 $bugsys->db->query("
210 ### replacing product / component cache ###
211 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
212 VALUES ('product', '" . $bugsys->escape(serialize($tempstore)) . "')"
213 );
214
215 $bugsys->datastore['product'] = $tempstore;
216 }
217
218 // ##################### Start build_permissions #####################
219 function build_permissions()
220 {
221 global $bugsys;
222
223 $permissions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "permission ORDER BY usergroupid, productid");
224 while ($permission = $bugsys->db->fetch_array($permissions))
225 {
226 $tempstore["$permission[usergroupid]"]["$permission[productid]"] = $permission['mask'];
227 }
228
229 $bugsys->db->query("
230 ### replacing permissions cache ###
231 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
232 VALUES ('permission', '" . $bugsys->escape(serialize($tempstore)) . "')"
233 );
234
235 $bugsys->datastore['permission'] = $tempstore;
236 }
237
238 // ##################### Start build_auto_actions ####################
239 function build_auto_actions()
240 {
241 global $bugsys;
242
243 $autoactions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "autoaction ORDER BY name ASC");
244 while ($autoaction = $bugsys->db->fetch_array($autoactions))
245 {
246 $actions["$autoaction[actionid]"] = $autoaction;
247 }
248
249 $bugsys->db->query("
250 ### replacing auto action cache ###
251 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
252 VALUES ('autoaction', '" . $bugsys->escape(serialize($actions)) . "')"
253 );
254
255 $bugsys->datastore['autoaction'] = $actions;
256 }
257
258 // ###################### Start build_user_help ######################
259 function build_user_help()
260 {
261 global $bugsys;
262
263 // custom field descriptions
264 $descriptions = $bugsys->db->query("SELECT fieldid, name, description FROM " . TABLE_PREFIX . "bugfield");
265 while ($field = $bugsys->db->fetch_array($descriptions))
266 {
267 $help["field$field[fieldid]"] = array('title' => $field['name'], 'body' => $field['description']);
268 }
269
270 // standard help texts
271 $texts = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp");
272 while ($field = $bugsys->db->fetch_array($texts))
273 {
274 $help["$field[keystring]"] = $field;
275 }
276
277 $bugsys->db->query("
278 ### replacing user help cache ###
279 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
280 VALUES ('help', '" . $bugsys->escape(serialize($help)) . "')"
281 );
282
283 $bugsys->datastore['help'] = $help;
284 }
285
286 /*=====================================================================*\
287 || ###################################################################
288 || # $HeadURL$
289 || # $Id$
290 || ###################################################################
291 \*=====================================================================*/
292 ?>