2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©2002-2007 Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 // ###################### Start build_languages ######################
23 function build_languages()
27 $languages = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "language");
28 foreach ($languages as $language)
30 $tempstore["$language[languageid]"] = $language;
34 ### replacing the language cache ###
35 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
36 VALUES ('language', '" . $bugsys->escape(serialize($tempstore)) . "')"
39 bugdar
::$datastore['language'] = $tempstore;
42 // ####################### Start build_settings ######################
43 function build_settings()
47 $settings = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "setting");
48 foreach ($settings as $setting)
50 $options["$setting[varname]"] = $setting['value'];
54 ### replacing the setting cache ###
55 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
56 VALUES ('setting', '" . $bugsys->escape(serialize($options)) . "')"
59 bugdar
::$datastore['setting'] = $options;
62 // ###################### Start build_usergroups #####################
63 function build_usergroups()
67 $usergroups = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "usergroup");
68 foreach ($usergroups as $usergroup)
70 $groups["$usergroup[usergroupid]"] = $usergroup;
74 ### replacing usergroup cache ###
75 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
76 VALUES ('usergroup', '" . $bugsys->escape(serialize($groups)) . "')"
79 bugdar
::$datastore['usergroup'] = $groups;
82 // ####################### Start build_statuses ######################
83 function build_statuses()
87 $statuses = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "status ORDER BY displayorder ASC");
88 foreach ($statuses as $status)
90 $tempstore["$status[statusid]"] = $status;
94 ### replacing status cache ###
95 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
96 VALUES ('status', '" . $bugsys->escape(serialize($tempstore)) . "')"
99 bugdar
::$datastore['status'] = $tempstore;
102 // ###################### Start build_severities #####################
103 function build_severities()
107 $severities = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "severity ORDER BY displayorder ASC");
108 foreach ($severities as $severity)
110 $tempstore["$severity[severityid]"] = $severity;
114 ### replacing severity cache ###
115 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
116 VALUES ('severity', '" . $bugsys->escape(serialize($tempstore)) . "')"
119 bugdar
::$datastore['severity'] = $tempstore;
122 // ###################### Start build_priorities #####################
123 function build_priorities()
127 $priorities = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "priority ORDER BY displayorder ASC");
128 foreach ($priorities as $priority)
130 $tempstore["$priority[priorityid]"] = $priority;
134 ### replacing priority cache ###
135 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
136 VALUES ('priority', '" . $bugsys->escape(serialize($tempstore)) . "')"
139 bugdar
::$datastore['priority'] = $tempstore;
142 // ###################### Start build_assignedto #####################
143 function build_assignedto()
147 // determine the groups that are assignable
148 $ids = $exprs = array();
149 foreach (bugdar
::$datastore['usergroup'] AS $id => $group)
151 if ($group['permissions'] & $bugsys->permissions
['canbeassignedto'])
154 $exprs[] = "FIND_IN_SET($id, groupids)";
158 $ids = implode(',', $ids);
159 $exprs = implode(' OR ', $exprs);
160 $users = $bugsys->db
->query("
161 SELECT email, displayname, userid, showemail
162 FROM " . TABLE_PREFIX
. "user AS user
163 WHERE usergroupid IN ($ids) OR $exprs"
165 foreach ($users as $user)
167 $devs["$user[userid
]"] = $user;
171 ### replacing developer / assign to cache ###
172 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
173 VALUES ('assignto', '" . $bugsys->escape(serialize($devs)) . "')"
176 bugdar::$datastore['assignto'] = $devs;
179 // ##################### Start build_resolutions #####################
180 function build_resolutions()
184 $resolutions = $bugsys->db->query("SELECT
* FROM
" . TABLE_PREFIX . "resolution ORDER BY displayorder ASC
");
185 foreach ($resolutions as $resolution)
187 $tempstore["$resolution[resolutionid
]"] = $resolution;
191 ### replacing resolution cache ###
192 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
193 VALUES ('resolution', '" . $bugsys->escape(serialize($tempstore)) . "')"
196 bugdar::$datastore['resolution'] = $tempstore;
199 // ####################### Start build_versions ######################
200 function build_versions()
204 $versions = $bugsys->db->query("SELECT
* FROM
" . TABLE_PREFIX . "version ORDER BY displayorder ASC
");
205 foreach ($versions as $version)
207 $tempstore["$version[versionid
]"] = $version;
211 ### replacing version cache ###
212 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
213 VALUES ('version', '" . $bugsys->escape(serialize($tempstore)) . "')"
216 bugdar::$datastore['version'] = $tempstore;
219 // ####################### Start build_products ######################
220 function build_products()
224 $products = $bugsys->db->query("SELECT
* FROM
" . TABLE_PREFIX . "product ORDER BY displayorder ASC
");
225 foreach ($products as $product)
227 if ($product['parentid'])
229 $tempstore['component']["$product[productid
]"] = $product;
233 $tempstore['product']["$product[productid
]"] = $product;
238 ### replacing product / component cache ###
239 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
241 ('product', '" . $bugsys->escape(serialize($tempstore['product
'])) . "'),
242 ('component', '" . $bugsys->escape(serialize($tempstore['component
'])) . "')"
245 bugdar::$datastore['product'] = $tempstore['product'];
246 bugdar::$datastore['component'] = $tempstore['component'];
249 // ##################### Start build_permissions #####################
250 function build_permissions()
254 $permissions = $bugsys->db->query("SELECT
* FROM
" . TABLE_PREFIX . "permission ORDER BY usergroupid
, productid
");
255 foreach ($permissions as $permission)
257 $tempstore["$permission[usergroupid
]"]["$permission[productid
]"] = $permission['mask'];
261 ### replacing permissions cache ###
262 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
263 VALUES ('permission', '" . $bugsys->escape(serialize($tempstore)) . "')"
266 bugdar::$datastore['permission'] = $tempstore;
269 // ##################### Start build_automations ####################
270 function build_automations()
274 $automations = $bugsys->db->query("SELECT
* FROM
" . TABLE_PREFIX . "automation ORDER BY name ASC
");
275 foreach ($automations as $automation)
277 $actions["$automation[actionid
]"] = $automation;
281 ### replacing automation cache ###
282 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
283 VALUES ('automation', '" . $bugsys->escape(serialize($actions)) . "')"
286 bugdar::$datastore['automation'] = $actions;
289 // ###################### Start build_user_help ######################
290 function build_user_help()
294 // custom field descriptions
295 $descriptions = $bugsys->db->query("SELECT fieldid
, name
, description FROM
" . TABLE_PREFIX . "bugfield
");
296 foreach ($descriptions as $field)
298 $help["field
$field[fieldid
]"] = array('title' => $field['name'], 'body' => $field['description']);
301 // standard help texts
302 $texts = $bugsys->db->query("SELECT
* FROM
" . TABLE_PREFIX . "fieldhelp
");
303 foreach ($texts as $field)
305 $help["$field[keystring
]"] = $field;
309 ### replacing user help cache ###
310 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
311 VALUES ('help', '" . $bugsys->escape(serialize($help)) . "')"
314 bugdar::$datastore['help'] = $help;
317 /*=====================================================================*\
318 || ###################################################################
321 || ###################################################################
322 \*=====================================================================*/