<?php
/*=====================================================================*\
-|| ################################################################### ||
-|| # BugStrike [#]version[#]
-|| # --------------------------------------------------------------- # ||
-|| # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
-|| # This file may not be reproduced in any way without permission. # ||
-|| # --------------------------------------------------------------- # ||
-|| # User License Agreement at http://www.iris-studios.com/license/ # ||
-|| ################################################################### ||
+|| ###################################################################
+|| # 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'
+ '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_fetch = $db->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']) . ")" : "")
);
-while ($bug = $db->fetch_array($bugs_fetch))
+if (!$count['count'])
{
- $bug['product'] = $bugsys->datastore['product']["$bug[productid]"]['title'];
- $bug['version'] = $bugsys->datastore['version']["$bug[versionid]"]['version'];
- $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
- $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
- $bug['lastpostinfo'] = datelike('standard', $bug['lastposttime']) . ' by ' . $bug['lastpost'];
- eval('$bugs .= "' . $template->fetch('trackerhome_bits') . '";');
+ $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.'));
}
-$db->free_result($bugs_fetch);
+$pagination->setTotal($count['count']);
+$pagination->splitPages();
-$show['newreport'] = ((can_perform('cansubmitbugs')) ? true : false);
+$bugs_fetch = $db->query($sort->fetchSqlQuery(null, $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage()));
-eval('$template->flush("' . $template->fetch('TRACKERHOME') . '");');
+foreach ($bugs_fetch as $bug)
+{
+ BSFunctions::swap_css_classes('altcolor', '');
+ $bug = ProcessBugDataForDisplay($bug, BSFunctions::$cssClass);
+ $bugs .= $sort->constructRow($bug);
+}
+
+$bugs_fetch->free();
+
+$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