2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)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 while ($language = $bugsys->db
->fetch_array($languages))
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 while ($setting = $bugsys->db
->fetch_array($settings))
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 while ($usergroup = $bugsys->db
->fetch_array($usergroups))
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_assignedto #####################
83 function build_assignedto()
87 // determine the groups that are assignable
88 $ids = $exprs = array();
89 foreach (Bugdar
::$datastore['usergroup'] AS $id => $group)
91 if ($group['permissions'] & $bugsys->permissions
['canbeassignedto'])
94 $exprs[] = "FIND_IN_SET($id, groupids)";
98 $ids = implode(',', $ids);
99 $exprs = implode(' OR ', $exprs);
100 $users = $bugsys->db
->query("
101 SELECT email, displayname, userid, showemail
102 FROM " . TABLE_PREFIX
. "user AS user
103 WHERE usergroupid IN ($ids) OR $exprs"
105 while ($user = $bugsys->db
->fetch_array($users))
107 $devs["$user[userid]"] = $user;
111 ### replacing developer / assign to cache ###
112 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
113 VALUES ('assignto', '" . $bugsys->escape(serialize($devs)) . "')"
116 Bugdar
::$datastore['assignto'] = $devs;
119 // ####################### Start build_versions ######################
120 function build_versions()
124 $versions = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "version ORDER BY displayorder ASC");
125 while ($version = $bugsys->db
->fetch_array($versions))
127 $tempstore["$version[versionid]"] = $version;
131 ### replacing version cache ###
132 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
133 VALUES ('version', '" . $bugsys->escape(serialize($tempstore)) . "')"
136 Bugdar
::$datastore['version'] = $tempstore;
139 // ####################### Start build_products ######################
140 function build_products()
144 $products = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "product ORDER BY displayorder ASC");
145 while ($product = $bugsys->db
->fetch_array($products))
147 if ($product['parentid'])
149 $tempstore['component']["$product[productid]"] = $product;
153 $tempstore['product']["$product[productid]"] = $product;
158 ### replacing product / component cache ###
159 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
161 ('product', '" . $bugsys->escape(serialize($tempstore['product'])) . "'),
162 ('component', '" . $bugsys->escape(serialize($tempstore['component'])) . "')"
165 Bugdar
::$datastore['product'] = $tempstore['product'];
166 Bugdar
::$datastore['component'] = $tempstore['component'];
169 // ##################### Start build_permissions #####################
170 function build_permissions()
174 $permissions = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "permission ORDER BY usergroupid, productid");
175 while ($permission = $bugsys->db
->fetch_array($permissions))
177 $tempstore["$permission[usergroupid]"]["$permission[productid]"] = $permission['mask'];
181 ### replacing permissions cache ###
182 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
183 VALUES ('permission', '" . $bugsys->escape(serialize($tempstore)) . "')"
186 Bugdar
::$datastore['permission'] = $tempstore;
189 // ##################### Start build_automations ####################
190 function build_automations()
194 $automations = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "automation ORDER BY name ASC");
195 while ($automation = $bugsys->db
->fetch_array($automations))
197 $actions["$automation[actionid]"] = $automation;
201 ### replacing automation cache ###
202 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
203 VALUES ('automation', '" . $bugsys->escape(serialize($actions)) . "')"
206 Bugdar
::$datastore['automation'] = $actions;
209 // ###################### Start build_user_help ######################
210 function build_user_help()
214 // custom field descriptions
215 $descriptions = $bugsys->db
->query("SELECT fieldid, name, description FROM " . TABLE_PREFIX
. "bugfield");
216 while ($field = $bugsys->db
->fetch_array($descriptions))
218 $help["field$field[fieldid]"] = array('title' => $field['name'], 'body' => $field['description']);
221 // standard help texts
222 $texts = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp");
223 while ($field = $bugsys->db
->fetch_array($texts))
225 $help["$field[keystring]"] = $field;
229 ### replacing user help cache ###
230 REPLACE INTO " . TABLE_PREFIX
. "datastore (title, data)
231 VALUES ('help', '" . $bugsys->escape(serialize($help)) . "')"
234 Bugdar
::$datastore['help'] = $help;