Switch the 'modify' code of admin/field.php to use templates
[bugdar.git] / index.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2004-2009 Blue Static
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 2 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 'list_head',
26 'pagenav',
27 'pagenav_bit'
28 );
29
30
31 $focus['index'] = 'focus';
32
33 require_once('./global.php');
34 require_once('./includes/class_sort.php');
35
36 if (!can_perform('canviewbugs'))
37 {
38 $message->errorPermission();
39 }
40
41 $sort = new ListSorter('index');
42
43 require_once 'includes/pagination.php';
44 $pagination = new Pagination();
45 $pagination->processIncomingData();
46
47 // ###################################################################
48
49 $count = $db->queryFirst("
50 SELECT COUNT(*) AS count
51 FROM " . TABLE_PREFIX . "bug
52 WHERE (!hidden OR (hidden AND product IN (" . fetch_on_bits('canviewhidden') . "))" . (can_perform('canviewownhidden') ? " OR (hidden AND userid = " . bugdar::$userinfo['userid'] . " AND product IN (" . fetch_on_bits('canviewownhidden') . "))" : "") . ")
53 AND product IN (" . fetch_on_bits('canviewbugs') . ")" . ((bugdar::$options['hidestatuses'] OR isset(bugdar::$userinfo['hidestatuses'])) ? "
54 AND status NOT IN (" . (bugdar::$userinfo['hidestatuses'] != '' ? bugdar::$userinfo['hidestatuses'] : bugdar::$options['hidestatuses']) . ")" : "")
55 );
56
57 if (!$count['count'])
58 {
59 $message->error(T('There are no bugs to display. This could be because you do not have permission to view bugs, or there may be none in the database.'));
60 }
61
62 $pagination->setTotal($count['count']);
63 $pagination->splitPages();
64
65 $bugs_fetch = $db->query($sort->fetchSqlQuery(null, $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage()));
66
67 foreach ($bugs_fetch as $bug)
68 {
69 BSFunctions::swap_css_classes('altcolor', '');
70 $bug = ProcessBugDataForDisplay($bug, BSFunctions::$cssClass);
71 $bugs .= $sort->constructRow($bug);
72 }
73
74 $bugs_fetch->free();
75
76 $columnHeads = $sort->constructColumnHeaders(true, 'p=' . $pagination->page . '&amp;pp=' . $pagination->perpage);
77 $show['pagenav'] = ($pagination->getPageCount() > 1);
78
79 $tpl = new BSTemplate('trackerhome');
80 $tpl->vars = array(
81 'columnHeads' => $columnHeads,
82 'bugs' => $bugs,
83 'pagenav' => $pagination->constructPageNav($sort->fetchSortLink($sort->sortkey))
84 );
85 $tpl->evaluate()->flush();
86
87 ?>