r844: Removing the complex joins for bugs by caching user information on
[bugdar.git] / index.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
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 [#]gpl[#] of the License.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 $fetchtemplates = array(
23 'trackerhome',
24 'trackerhome_bits',
25 'pagenav',
26 'pagenav_bit'
27 );
28
29 define('SVN', '$Id$');
30
31 $focus['index'] = 'focus';
32
33 require_once('./global.php');
34 require_once('./includes/class_pagination.php');
35
36 if (!can_perform('canviewbugs'))
37 {
38 $message->error_permission();
39 }
40
41 // ###################################################################
42
43 $pagination = new Pagination('p', 'pp');
44 $count = $db->query_first("
45 SELECT COUNT(*) AS count
46 FROM " . TABLE_PREFIX . "bug
47 WHERE (!hidden OR (hidden AND productid IN (" . fetch_on_bits('canviewhidden') . ")))
48 AND productid IN (" . fetch_on_bits('canviewbugs') . ")"
49 );
50
51 $pagination->total = $count['count'];
52 $pagination->split_pages();
53
54 $bugs_fetch = $db->query("
55 SELECT * FROM " . TABLE_PREFIX . "bug
56 WHERE productid IN (" . fetch_on_bits('canviewbugs') . ")
57 AND (!hidden OR (hidden AND productid IN (" . fetch_on_bits('canviewhidden') . ")))
58 ORDER BY " . (can_perform('canviewhidden') ? "lastposttime" : "hiddenlastposttime") . " DESC
59 LIMIT " . $pagination->fetch_limit($pagination->page - 1) . ", " . $pagination->perpage
60 );
61
62 while ($bug = $db->fetch_array($bugs_fetch))
63 {
64 $funct->exec_swap_bg($stylevar['alt_colour'], '');
65 $bug['bgcolour'] = ($bugsys->userinfo['showcolours'] ? $bugsys->datastore['status']["$bug[status]"]['color'] : $funct->bgcolour);
66 $bug['product'] = $bugsys->datastore['product']["$bug[productid]"]['title'];
67 $bug['version'] = $bugsys->datastore['version']["$bug[versionid]"]['version'];
68 $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
69 $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
70 $bug['priority'] = $bugsys->datastore['priority']["$bug[priority]"]['priority'];
71 $bug['severity'] = $bugsys->datastore['severity']["$bug[severity]"]['severity'];
72
73 $bug['hiddendisplay'] = ((!can_perform('canviewhidden', $bug['productid']) AND $bug['hiddenlastposttime']) ? true : false);
74
75 $bug['lastposttime'] = ($bug['hiddendisplay'] ? $bug['hiddenlastposttime'] : $bug['lastposttime']);
76 $bug['lastpost'] = ($bug['hiddendisplay'] ? $bug['hiddenlastpostbyname'] : $bug['lastpostbyname']);
77
78 $bug['lastposttime'] = $datef->format($bugsys->options['dateformat'], $bug['lastposttime']);
79
80 eval('$bugs .= "' . $template->fetch('trackerhome_bits') . '";');
81 }
82
83 $db->free_result($bugs_fetch);
84
85 $show['pagenav'] = (($pagination->pagecount > 1) ? true : false);
86 $pagenav = $pagination->construct_page_nav('index.php');
87
88 eval('$template->flush("' . $template->fetch('trackerhome') . '");');
89
90 /*=====================================================================*\
91 || ###################################################################
92 || # $HeadURL$
93 || # $Id$
94 || ###################################################################
95 \*=====================================================================*/
96 ?>