r525: Got base of new per-product permissions
[bugdar.git] / includes / functions_datastore.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]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 fetch_user_display_name($user);
147 $devs["$user[userid]"] = $user;
148 }
149
150 $bugsys->db->query("
151 ### replacing developer / assign to cache ###
152 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
153 VALUES ('assignto', '" . $bugsys->escape(serialize($devs)) . "')"
154 );
155
156 $bugsys->datastore['assignto'] = $devs;
157 }
158
159 // ##################### Start build_resolutions #####################
160 function build_resolutions()
161 {
162 global $bugsys;
163
164 $resolutions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "resolution ORDER BY displayorder ASC");
165 while ($resolution = $bugsys->db->fetch_array($resolutions))
166 {
167 $tempstore["$resolution[resolutionid]"] = $resolution;
168 }
169
170 $bugsys->db->query("
171 ### replacing resolution cache ###
172 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
173 VALUES ('resolution', '" . $bugsys->escape(serialize($tempstore)) . "')"
174 );
175
176 $bugsys->datastore['resolution'] = $tempstore;
177 }
178
179 // ####################### Start build_versions ######################
180 function build_versions()
181 {
182 global $bugsys;
183
184 $versions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC");
185 while ($version = $bugsys->db->fetch_array($versions))
186 {
187 $tempstore["$version[versionid]"] = $version;
188 }
189
190 $bugsys->db->query("
191 ### replacing version cache ###
192 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
193 VALUES ('version', '" . $bugsys->escape(serialize($tempstore)) . "')"
194 );
195
196 $bugsys->datastore['version'] = $tempstore;
197 }
198
199 // ####################### Start build_products ######################
200 function build_products()
201 {
202 global $bugsys;
203
204 $products = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC");
205 while ($product = $bugsys->db->fetch_array($products))
206 {
207 $tempstore["$product[productid]"] = $product;
208 }
209
210 $bugsys->db->query("
211 ### replacing product / component cache ###
212 REPLACE INTO " . TABLE_PREFIX . "datastore (title, data)
213 VALUES ('product', '" . $bugsys->escape(serialize($tempstore)) . "')"
214 );
215
216 $bugsys->datastore['product'] = $tempstore;
217 }
218
219 // ##################### Start build_permissions #####################
220 function build_permissions()
221 {
222 global $bugsys;
223
224 // first cache all the global permissions
225 }
226
227 /*=====================================================================*\
228 || ###################################################################
229 || # $HeadURL$
230 || # $Id$
231 || ###################################################################
232 \*=====================================================================*/
233 ?>