2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2004-2008 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()
25 $languages = BSApp
::$db->query("SELECT * FROM " . TABLE_PREFIX
. "language");
26 foreach ($languages as $language)
28 $tempstore["$language[languageid]"] = $language;
32 ### replacing the language cache ###
33 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
34 VALUES ('language', '" . BSApp
::$input->escape(serialize($tempstore)) . "')"
37 bugdar
::$datastore['language'] = $tempstore;
40 // ####################### Start build_settings ######################
41 function build_settings()
43 $settings = BSApp
::$db->query("SELECT * FROM " . TABLE_PREFIX
. "setting");
44 foreach ($settings as $setting)
46 $options["$setting[varname]"] = $setting['value'];
50 ### replacing the setting cache ###
51 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
52 VALUES ('setting', '" . BSApp
::$input->escape(serialize($options)) . "')"
55 bugdar
::$datastore['setting'] = $options;
58 // ###################### Start build_usergroups #####################
59 function build_usergroups()
61 $usergroups = BSApp
::$db->query("SELECT * FROM " . TABLE_PREFIX
. "usergroup");
62 foreach ($usergroups as $usergroup)
64 $groups["$usergroup[usergroupid]"] = $usergroup;
68 ### replacing usergroup cache ###
69 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
70 VALUES ('usergroup', '" . BSApp
::$input->escape(serialize($groups)) . "')"
73 bugdar
::$datastore['usergroup'] = $groups;
76 // ####################### Start build_statuses ######################
77 function build_statuses()
79 $statuses = BSApp
::$db->query("SELECT * FROM " . TABLE_PREFIX
. "status ORDER BY displayorder ASC");
80 foreach ($statuses as $status)
82 $tempstore["$status[statusid]"] = $status;
86 ### replacing status cache ###
87 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
88 VALUES ('status', '" . BSApp
::$input->escape(serialize($tempstore)) . "')"
91 bugdar
::$datastore['status'] = $tempstore;
94 // ###################### Start build_severities #####################
95 function build_severities()
97 $severities = BSApp
::$db->query("SELECT * FROM " . TABLE_PREFIX
. "severity ORDER BY displayorder ASC");
98 foreach ($severities as $severity)
100 $tempstore["$severity[severityid]"] = $severity;
104 ### replacing severity cache ###
105 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
106 VALUES ('severity', '" . BSApp
::$input->escape(serialize($tempstore)) . "')"
109 bugdar
::$datastore['severity'] = $tempstore;
112 // ###################### Start build_priorities #####################
113 function build_priorities()
115 $priorities = BSApp
::$db->query("SELECT * FROM " . TABLE_PREFIX
. "priority ORDER BY displayorder ASC");
116 foreach ($priorities as $priority)
118 $tempstore["$priority[priorityid]"] = $priority;
122 ### replacing priority cache ###
123 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
124 VALUES ('priority', '" . BSApp
::$input->escape(serialize($tempstore)) . "')"
127 bugdar
::$datastore['priority'] = $tempstore;
130 // ###################### Start build_assignedto #####################
131 function build_assignedto()
133 // determine the groups that are assignable
134 $ids = $exprs = array();
135 foreach (bugdar
::$datastore['usergroup'] AS $id => $group)
137 if ($group['permissions'] & bugdar
::$permissions['canbeassignedto'])
140 $exprs[] = "FIND_IN_SET($id, groupids)";
144 $ids = implode(',', $ids);
145 $exprs = implode(' OR ', $exprs);
146 $users = BSApp
::$db->query("
147 SELECT email, displayname, userid, showemail
148 FROM " . TABLE_PREFIX
. "user AS user
149 WHERE usergroupid IN ($ids) OR $exprs"
151 foreach ($users as $user)
153 $devs["$user[userid
]"] = $user;
157 ### replacing developer / assign to cache ###
158 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
159 VALUES ('assignto', '" . BSApp::$input->escape(serialize($devs)) . "')"
162 bugdar::$datastore['assignto'] = $devs;
165 // ##################### Start build_resolutions #####################
166 function build_resolutions()
168 $resolutions = BSApp::$db->query("SELECT
* FROM
" . TABLE_PREFIX . "resolution ORDER BY displayorder ASC
");
169 foreach ($resolutions as $resolution)
171 $tempstore["$resolution[resolutionid
]"] = $resolution;
175 ### replacing resolution cache ###
176 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
177 VALUES ('resolution', '" . BSApp::$input->escape(serialize($tempstore)) . "')"
180 bugdar::$datastore['resolution'] = $tempstore;
183 // ####################### Start build_versions ######################
184 function build_versions()
186 $versions = BSApp::$db->query("SELECT
* FROM
" . TABLE_PREFIX . "version ORDER BY displayorder ASC
");
187 foreach ($versions as $version)
189 $tempstore["$version[versionid
]"] = $version;
193 ### replacing version cache ###
194 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
195 VALUES ('version', '" . BSApp::$input->escape(serialize($tempstore)) . "')"
198 bugdar::$datastore['version'] = $tempstore;
201 // ####################### Start build_products ######################
202 function build_products()
204 $products = BSApp::$db->query("SELECT
* FROM
" . TABLE_PREFIX . "product ORDER BY displayorder ASC
");
205 foreach ($products as $product)
207 if ($product['parentid'])
209 $tempstore['component']["$product[productid
]"] = $product;
213 $tempstore['product']["$product[productid
]"] = $product;
218 ### replacing product / component cache ###
219 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
221 ('product', '" . BSApp::$input->escape(serialize($tempstore['product
'])) . "'),
222 ('component', '" . BSApp::$input->escape(serialize($tempstore['component
'])) . "')"
225 bugdar::$datastore['product'] = $tempstore['product'];
226 bugdar::$datastore['component'] = $tempstore['component'];
229 // ##################### Start build_permissions #####################
230 function build_permissions()
232 $permissions = BSApp::$db->query("SELECT
* FROM
" . TABLE_PREFIX . "permission ORDER BY usergroupid
, productid
");
233 foreach ($permissions as $permission)
235 $tempstore["$permission[usergroupid
]"]["$permission[productid
]"] = $permission['mask'];
239 ### replacing permissions cache ###
240 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
241 VALUES ('permission', '" . BSApp::$input->escape(serialize($tempstore)) . "')"
244 bugdar::$datastore['permission'] = $tempstore;
247 // ##################### Start build_automations ####################
248 function build_automations()
250 $automations = BSApp::$db->query("SELECT
* FROM
" . TABLE_PREFIX . "automation ORDER BY name ASC
");
251 foreach ($automations as $automation)
253 $actions["$automation[actionid
]"] = $automation;
257 ### replacing automation cache ###
258 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
259 VALUES ('automation', '" . BSApp::$input->escape(serialize($actions)) . "')"
262 bugdar::$datastore['automation'] = $actions;
265 // ###################### Start build_user_help ######################
266 function build_user_help()
268 // custom field descriptions
269 $descriptions = BSApp::$db->query("SELECT fieldid
, name
, description FROM
" . TABLE_PREFIX . "bugfield
");
270 foreach ($descriptions as $field)
272 $help["field
$field[fieldid
]"] = array('title' => $field['name'], 'body' => $field['description']);
275 // standard help texts
276 $texts = BSApp::$db->query("SELECT
* FROM
" . TABLE_PREFIX . "fieldhelp
");
277 foreach ($texts as $field)
279 $help["$field[keystring
]"] = $field;
283 ### replacing user help cache ###
284 REPLACE INTO
" . TABLE_PREFIX . "datastore (title
, data
)
285 VALUES ('help', '" . BSApp::$input->escape(serialize($help)) . "')"
288 bugdar::$datastore['help'] = $help;