<?php
/*=====================================================================*\
-|| ################################################################### ||
-|| # [#]app[#] [#]version[#]
-|| # --------------------------------------------------------------- # ||
-|| # All parts of this file are ©2003-[#]year[#] Iris Studios, Inc. No # ||
-|| # part of this file may be reproduced in any way: part or whole. # ||
-|| # --------------------------------------------------------------- # ||
-|| # ©2003 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
-|| ################################################################### ||
+|| ###################################################################
+|| # Bugdar
+|| # Copyright (c)2004-2009 Blue Static
+|| #
+|| # This program is free software; you can redistribute it and/or modify
+|| # it under the terms of the GNU General Public License as published by
+|| # the Free Software Foundation; version 2 of the License.
+|| #
+|| # This program is distributed in the hope that it will be useful, but
+|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+|| # more details.
+|| #
+|| # You should have received a copy of the GNU General Public License along
+|| # with this program; if not, write to the Free Software Foundation, Inc.,
+|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+|| ###################################################################
\*=====================================================================*/
+$fetchtemplates = array(
+ 'trackerhome',
+ 'trackerhome_bits',
+ 'list_head',
+ 'pagenav',
+ 'pagenav_bit'
+);
+
+
+$focus['index'] = 'focus';
+
require_once('./global.php');
+require_once('./includes/class_sort.php');
if (!can_perform('canviewbugs'))
{
- echo 'no permission';
- exit;
+ $message->errorPermission();
}
-// ###################################################################
+$sort = new ListSorter('index');
-// #*# pagination needs to be done here
+require_once 'includes/pagination.php';
+$pagination = new Pagination();
+$pagination->processIncomingData();
+
+// ###################################################################
-$bugs = $DB_sql->query("
- SELECT bug.*, user1.displayname AS firstreport, user2.displayname AS lastpost
- FROM " . TABLE_PREFIX . "bug AS bug
- LEFT JOIN user AS user1
- ON (bug.userid = user1.userid)
- LEFT JOIN user AS user2
- ON (bug.lastpostby = user2.userid)
- ORDER BY bug.lastposttime DESC"
+$count = $db->queryFirst("
+ SELECT COUNT(*) AS count
+ FROM " . TABLE_PREFIX . "bug
+ 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') . "))" : "") . ")
+ AND product IN (" . fetch_on_bits('canviewbugs') . ")" . ((bugdar::$options['hidestatuses'] OR isset(bugdar::$userinfo['hidestatuses'])) ? "
+ AND status NOT IN (" . (bugdar::$userinfo['hidestatuses'] != '' ? bugdar::$userinfo['hidestatuses'] : bugdar::$options['hidestatuses']) . ")" : "")
);
-echo '<table border="1" cellspacing="2" cellpadding="4" width="100%"><tr style="background-color:#EEEEEE">';
-echo '<td>Bug ID</td><td>Title</td><td>Reporter</td><td>Product/Version</td><td>Status/Resolution</td><td>Last Post</td></tr>';
+if (!$count['count'])
+{
+ $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.'));
+}
+
+$pagination->setTotal($count['count']);
+$pagination->splitPages();
+$bugs_fetch = $db->query($sort->fetchSqlQuery(null, $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage()));
-while ($bug = $DB_sql->fetch_array($bugs))
+foreach ($bugs_fetch as $bug)
{
- echo "<tr>";
- echo "<td>$bug[bugid]</td>";
- echo "<td><a href=\"showreport.php?bugid=$bug[bugid]\">$bug[summary]</a></td>";
- echo "<td>$bug[firstreport]</td>";
- echo "<td>" . $bugsys->datastore['product']["$bug[productid]"]['title'] . '/' . $bugsys->datastore['version']["$bug[versionid]"]['version'] . "</td>";
- echo "<td>" . $bugsys->datastore['status']["$bug[status]"]['status'] . '/' . $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'] . "</td>";
- echo "<td>" . datelike('standard', $bug['lastposttime']) . ' by ' . $bug['lastpost'] . "</td>";
- echo "</tr>";
+ BSFunctions::swap_css_classes('altcolor', '');
+ $bug = ProcessBugDataForDisplay($bug, BSFunctions::$cssClass);
+ $bugs .= $sort->constructRow($bug);
}
-echo '</table>';
+$bugs_fetch->free();
-echo '[<a href="newreport.php?">New Report</a>]';
+$columnHeads = $sort->constructColumnHeaders(true, 'p=' . $pagination->page . '&pp=' . $pagination->perpage);
+$show['pagenav'] = ($pagination->getPageCount() > 1);
+
+$tpl = new BSTemplate('trackerhome');
+$tpl->vars = array(
+ 'columnHeads' => $columnHeads,
+ 'bugs' => $bugs,
+ 'pagenav' => $pagination->constructPageNav($sort->fetchSortLink($sort->sortkey))
+);
+$tpl->evaluate()->flush();
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
?>
\ No newline at end of file