r212: Fixed a problem where the last post would be off if we did not have permission...
[bugdar.git] / index.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 $fetchtemplates = array(
14 'TRACKERHOME',
15 'trackerhome_bits'
16 );
17
18 require_once('./global.php');
19
20 if (!can_perform('canviewbugs'))
21 {
22 $message->error_permission();
23 }
24
25 // ###################################################################
26
27 // #*# pagination needs to be done here
28
29 $bugs_fetch = $db->query("
30 SELECT bug.*, user1.displayname AS firstreport, user2.displayname AS lastpost, user3.displayname AS hiddenlastpost
31 FROM " . TABLE_PREFIX . "bug AS bug
32 LEFT JOIN user AS user1
33 ON (bug.userid = user1.userid)
34 LEFT JOIN user AS user2
35 ON (bug.lastpostby = user2.userid)
36 LEFT JOIN user AS user3
37 ON (bug.hiddenlastpostby = user3.userid)" . ((!can_perform('canviewhidden')) ? "
38 WHERE !hidden" : "") . "
39 ORDER BY bug." . ((can_perform('canviewhidden')) ? "lastposttime" : "hiddenlastposttime") . " DESC"
40 );
41
42 while ($bug = $db->fetch_array($bugs_fetch))
43 {
44 $bug['bgcolour'] = $bugsys->datastore['status']["$bug[status]"]['color'];
45 $bug['product'] = $bugsys->datastore['product']["$bug[productid]"]['title'];
46 $bug['version'] = $bugsys->datastore['version']["$bug[versionid]"]['version'];
47 $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status'];
48 $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution'];
49
50 $bug['hiddendisplay'] = ((!can_perform('canviewhidden') AND $bug['hiddenlastposttime']) ? true : false);
51
52 $bug['lastposttime'] = (($bug['hiddendisplay']) ? $bug['hiddenlastposttime'] : $bug['lastposttime']);
53 $bug['lastpost'] = (($bug['hiddendisplay']) ? $bug['hiddenlastpost'] : $bug['lastpost']);
54
55 $bug['lastpostinfo'] = datelike('standard', $bug['lastposttime']) . ' by ' . $bug['lastpost'];
56
57 eval('$bugs .= "' . $template->fetch('trackerhome_bits') . '";');
58 }
59
60 $db->free_result($bugs_fetch);
61
62 $show['newreport'] = ((can_perform('cansubmitbugs')) ? true : false);
63
64 eval('$template->flush("' . $template->fetch('TRACKERHOME') . '");');
65
66 /*=====================================================================*\
67 || ###################################################################
68 || # $HeadURL$
69 || # $Id$
70 || ###################################################################
71 \*=====================================================================*/
72 ?>