r939: Making the sort order cross pages
[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 require_once('./includes/class_sort.php');
36
37 if (!can_perform('canviewbugs'))
38 {
39 $message->error_permission();
40 }
41
42 $sort = new ListSorter('index');
43
44 // ###################################################################
45
46 $pagination = new Pagination('p', 'pp');
47 $count = $db->query_first("
48 SELECT COUNT(*) AS count
49 FROM " . TABLE_PREFIX . "bug
50 WHERE (!hidden OR (hidden AND product IN (" . fetch_on_bits('canviewhidden') . ")))
51 AND product IN (" . fetch_on_bits('canviewbugs') . ")" . (($bugsys->options['hidestatuses'] OR isset($bugsys->userinfo['hidestatuses'])) ? "
52 AND status NOT IN (" . (isset($bugsys->userinfo['hidestatuses']) ? $bugsys->userinfo['hidestatuses'] : $bugsys->options['hidestatuses']) . ")" : "")
53 );
54
55 $pagination->total = $count['count'];
56 $pagination->split_pages();
57
58 $bugs_fetch = $db->query($sort->fetch_sql_query(null, $pagination->fetch_limit($pagination->page - 1) . ", " . $pagination->perpage));
59
60 while ($bug = $db->fetch_array($bugs_fetch))
61 {
62 $funct->exec_swap_bg($stylevar['alt_colour'], '');
63 $bug['bgcolour'] = ($bugsys->userinfo['showcolours'] ? $bugsys->datastore['status']["$bug[status]"]['color'] : $funct->bgcolour);
64 $bug['product'] = $bugsys->datastore['product']["$bug[product]"]['title'];
65 $bug['version'] = $bugsys->datastore['version']["$bug[version]"]['version'];
66 $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
67 $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
68 $bug['priority'] = $bugsys->datastore['priority']["$bug[priority]"]['priority'];
69 $bug['severity'] = $bugsys->datastore['severity']["$bug[severity]"]['severity'];
70
71 $bug['hiddendisplay'] = ((!can_perform('canviewhidden', $bug['productid']) AND $bug['hiddenlastposttime']) ? true : false);
72
73 $bug['lastposttime'] = ($bug['hiddendisplay'] ? $bug['hiddenlastposttime'] : $bug['lastposttime']);
74 $bug['lastpost'] = ($bug['hiddendisplay'] ? $bug['hiddenlastpostbyname'] : $bug['lastpostbyname']);
75
76 $bug['lastposttime'] = $datef->format($bugsys->options['dateformat'], $bug['lastposttime']);
77
78 eval('$bugs .= "' . $template->fetch('trackerhome_bits') . '";');
79 }
80
81 $db->free_result($bugs_fetch);
82
83 $order = $sort->fetch_display_array('p=' . $pagination->page . '&amp;pp=' . $pagination->perpage);
84 $show['pagenav'] = (($pagination->pagecount > 1) ? true : false);
85 $pagenav = $pagination->construct_page_nav($sort->fetch_sort_link($sort->sortkey));
86
87 eval('$template->flush("' . $template->fetch('trackerhome') . '");');
88
89 /*=====================================================================*\
90 || ###################################################################
91 || # $HeadURL$
92 || # $Id$
93 || ###################################################################
94 \*=====================================================================*/
95 ?>