source: trunk/Upload/includes/functions/func_rebuild.php @ 74

Revision 74, 9.6 KB checked in by someotherguy, 3 years ago (diff)

Begin re-coding user-side.

Line 
1<?php
2
3/*
4#======================================================
5|    <#TAG_NAME_TAG#>
6|    =====================================
7|    <#TAG_DEVELOPERS_TAG#>
8|    <#TAG_COPYRIGHT_TAG#>
9|    <#TAG_URL_TAG#>
10|    =====================================
11|    Email: <#TAG_EMAIL_TAG#>
12#======================================================
13|    @ Version: <#TAG_VER_HUMAN_TAG#>
14|    @ Version Int: <#TAG_VER_INT_TAG#>
15|    @ Version Num: <#TAG_VER_NUM_TAG#>
16|    @ Build: <#TAG_VER_BUILD_TAG#>
17#======================================================
18|    | Functions: Rebuild
19#======================================================
20*/
21
22class td_func_rebuild {
23
24        #=======================================
25        # @ Rebuild Settings Cache
26        #=======================================
27
28        public function settings_cache()
29    {
30        $to_cache = array();
31
32        $this->trellis->db->construct( array(
33                                                                                         'select'       => array( 'cf_key', 'cf_group', 'cf_value' ),
34                                                                                         'from'     => 'settings',
35                                                                                         'where'        => array( 'cf_cache', '=', 1 ),
36                                      )      );
37
38                $this->trellis->db->execute();
39
40                while ( $cf = $this->trellis->db->fetch_row() )
41                {
42                        $to_cache[ $cf['cf_group'] ][ $cf['cf_key'] ] = $cf['cf_value'];
43                }
44
45                $this->trellis->cache->add( 'settings', $to_cache, 1 );
46    }
47
48        #=======================================
49        # @ Rebuild Departments Cache
50        #=======================================
51
52        public function departs_cache()
53    {
54        $to_cache = array();
55
56        $this->trellis->db->construct( array(
57                                                                                         'select'       => array( 'id', 'name', 'description', 'assign_auto', 'assign_move', 'escalate_enable', 'escalate_wait', 'escalate_depart', 'escalate_assign', 'close_auto', 'allow_attach', 'close_own', 'reopen_own', 'position' ),
58                                                                                         'from'     => 'departments',
59                                                                                         'order'        => array( 'position' => 'asc' ),
60                                      )      );
61
62                $this->trellis->db->execute();
63
64                while ( $d = $this->trellis->db->fetch_row() )
65                {
66                        $to_cache[ $d['id'] ] = $d;
67                }
68
69                $this->trellis->cache->add( 'departs', $to_cache, 1 );
70    }
71
72        #=======================================
73        # @ Rebuild Categories Cache
74        #=======================================
75
76        public function categories_cache()
77    {
78        $to_cache = array();
79
80        $this->trellis->db->construct( array(
81                                                                                         'select'       => 'all',
82                                                                                         'from'     => 'categories',
83                                      )      );
84
85                $this->trellis->db->execute();
86
87                while ( $c = $this->trellis->db->fetch_row() )
88                {
89                        $to_cache[ $c['id'] ] = $c;
90                }
91                $this->trellis->cache->add( 'categories', $to_cache, 1 );
92    }
93
94        #=======================================
95        # @ Rebuild Groups Cache
96        #=======================================
97
98        public function groups_cache()
99    {
100        $to_cache = array();
101
102        $this->trellis->db->construct( array(
103                                                                                         'select'       => array( 'g_id', 'g_name', 'g_acp_access' ),
104                                                                                         'from'     => 'groups',
105                                      )      );
106
107                $this->trellis->db->execute();
108
109                while ( $g = $this->trellis->db->fetch_row() )
110                {
111                        $to_cache[ $g['g_id'] ] = $g;
112                }
113
114                $this->trellis->cache->add( 'groups', $to_cache, 1 );
115    }
116
117        #=======================================
118        # @ Rebuild News Cache
119        #=======================================
120
121        public function news_cache($limit=0)
122    {
123        $to_cache = array();
124
125        if ( ! $limit ) $limit = $this->trellis->cache->data['settings']['news']['dashboard_amount'];
126
127        $this->trellis->db->construct( array(
128                                                                                         'select'       => array( 'id', 'title', 'excerpt', 'date' ),
129                                                                                         'from'     => 'news',
130                                                                                         'order'        => array( 'date' => 'desc' ),
131                                                                                         'limit'        => array( 0, $limit ),
132                                      )      );
133
134                $this->trellis->db->execute();
135
136                while ( $a = $this->trellis->db->fetch_row() )
137                {
138                        $to_cache[ $a['id'] ] = $a;
139                }
140
141                $this->trellis->cache->add( 'news', $to_cache, 1 );
142    }
143
144        #=======================================
145        # @ Rebuild Languages Cache
146        #=======================================
147
148        public function langs_cache()
149    {
150        $to_cache = array();
151
152        $this->trellis->db->construct( array(
153                                                                                         'select'       => 'all',
154                                                                                         'from'     => 'languages',
155                                      )      );
156
157                $this->trellis->db->execute();
158
159                while ( $l = $this->trellis->db->fetch_row() )
160                {
161                        $to_cache[ $l['lkey'] ] = $l;
162
163                        if ( $l['default'] )
164                        {
165                                $this->trellis->cache->add( 'misc', array( 'default_lang' => $l['lkey'] ) );
166                        }
167                }
168
169                $this->trellis->cache->add( 'langs', $to_cache, 1 );
170    }
171
172        #=======================================
173        # @ Rebuild Skins Cache
174        #=======================================
175
176        public function skins_cache()
177    {
178        $to_cache = array();
179
180        $this->trellis->db->construct( array(
181                                                                                         'select'       => array( 'id', 'name', 'img_dir', 'users', 'default' ),
182                                                                                         'from'     => 'skins',
183                                      )      );
184
185                $this->trellis->db->execute();
186
187                while ( $s = $this->trellis->db->fetch_row() )
188                {
189                        $to_cache[ $s['id'] ] = $s;
190
191                        if ( $s['default'] )
192                        {
193                                $this->trellis->cache->add( 'misc', array( 'default_skin' => $s['id'] ) );
194                        }
195                }
196
197                $this->trellis->cache->add( 'skins', $to_cache, 1 );
198    }
199
200        #=======================================
201        # @ Rebuild Profile Fields Cache
202        #=======================================
203
204        public function pfields_cache()
205    {
206        $to_cache = array();
207
208        $this->trellis->db->construct( array(
209                                                                                         'select'       => 'all',
210                                                                                         'from'     => 'profile_fields',
211                                      )      );
212
213                $this->trellis->db->execute();
214
215                while ( $f = $this->trellis->db->fetch_row() )
216                {
217                        $to_cache[ $f['id'] ] = $f;
218                }
219
220                $this->trellis->cache->add( 'pfields', $to_cache, 1 );
221    }
222
223        #=======================================
224        # @ Rebuild Deparmtnet Fields Cache
225        #=======================================
226
227        public function dfields_cache()
228    {
229        $to_cache = array();
230
231        $this->trellis->db->construct( array(
232                                                                                         'select'       => 'all',
233                                                                                         'from'     => 'depart_fields',
234                                      )      );
235
236                $this->trellis->db->execute();
237
238                while ( $f = $this->trellis->db->fetch_row() )
239                {
240                        $to_cache[ $f['id'] ] = $f;
241                }
242
243                $this->trellis->cache->add( 'dfields', $to_cache, 1 );
244    }
245
246        #=======================================
247        # @ Rebuild Reply Templates Cache
248        #=======================================
249
250        public function rtemplates_cache()
251    {
252        $to_cache = array();
253
254        $this->trellis->db->construct( array(
255                                                                                         'select'       => array( 'id', 'name', 'description' ),
256                                                                                         'from'     => 'reply_templates',
257                                                                                         'order'        => array( 'position' => 'asc' ),
258                                      )      );
259
260                $this->trellis->db->execute();
261
262                while ( $rt = $this->trellis->db->fetch_row() )
263                {
264                        $to_cache[ $rt['id'] ] = $rt;
265                }
266
267                $this->trellis->cache->add( 'rtemplates', $to_cache, 1 );
268    }
269
270        #=======================================
271        # @ Rebuild Priorities Cache
272        #=======================================
273
274        public function priorities_cache()
275    {
276        $to_cache = array();
277
278        $this->trellis->db->construct( array(
279                                                                                         'select'       => 'all',
280                                                                                         'from'     => 'priorities',
281                                                                                         'order'        => array( 'position' => 'asc' ),
282                                      )      );
283
284                $this->trellis->db->execute();
285
286                while ( $p = $this->trellis->db->fetch_row() )
287                {
288                        $to_cache[ $p['id'] ] = $p;
289                }
290
291                $this->trellis->cache->add( 'priorities', $to_cache, 1 );
292    }
293
294        #=======================================
295        # @ Rebuild Flags Cache
296        #=======================================
297
298        public function flags_cache()
299    {
300        $to_cache = array();
301
302        $this->trellis->db->construct( array(
303                                                                                         'select'       => 'all',
304                                                                                         'from'     => 'flags',
305                                                                                         'order'        => array( 'position' => 'asc' ),
306                                      )      );
307
308                $this->trellis->db->execute();
309
310                while ( $f = $this->trellis->db->fetch_row() )
311                {
312                        $to_cache[ $f['id'] ] = $f;
313                }
314
315                $this->trellis->cache->add( 'flags', $to_cache, 1 );
316    }
317
318        #=======================================
319        # @ Rebuild Staff Cache
320        #=======================================
321
322        public function staff_cache()
323    {
324        $to_cache = array();
325
326        # TODO: Sub-groups
327
328        $this->trellis->db->construct( array(
329                                                                                         'select'       => array( 'u' => array( 'id', 'name' ), 'g' => array( 'g_acp_depart_perm' ) ),
330                                                                                         'from'     => array( 'u' => 'users' ),
331                                                                                         'join'     => array( array( 'from' => array( 'g' => 'groups' ), 'where' => array( 'u' => 'ugroup', '=', 'g' => 'g_id' ) ) ),
332                                                                                         'where'        => array( array( 'g' => 'g_acp_access' ), '=', 1 ),
333                                                                                         'order'        => array( 'name' => array( 'u' => 'desc' ) ),
334                                      )      );
335
336                $this->trellis->db->execute();
337
338                while ( $s = $this->trellis->db->fetch_row() )
339                {
340                        $to_cache[ $s['id'] ] = $s;
341                }
342
343                $this->trellis->cache->add( 'staff', $to_cache, 1 );
344    }
345
346        #=======================================
347        # @ Rebuild Statuses Cache
348        #=======================================
349
350        public function statuses_cache()
351    {
352        $to_cache = array();
353        $to_cache_defaults = array();
354
355        $this->trellis->db->construct( array(
356                                                                                         'select'       => 'all',
357                                                                                         'from'     => 'statuses',
358                                                                                         'order'        => array( 'position' => 'asc' ),
359                                      )      );
360
361                $this->trellis->db->execute();
362
363                while ( $s = $this->trellis->db->fetch_row() )
364                {
365                        $to_cache[ $s['id'] ] = $s;
366
367                        if ( $s['default'] ) $to_cache_defaults[ $s['type'] ] = $s['id'];
368                }
369
370                $this->trellis->cache->add( 'statuses', $to_cache, 1 );
371                $this->trellis->cache->add( 'status_defaults', $to_cache_defaults, 1 );
372    }
373
374}
375
376?>
Note: See TracBrowser for help on using the repository browser.