|
From: Benjamin C. <bc...@us...> - 2002-03-02 18:48:33
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv19586
Modified Files:
index.php
Log Message:
A new look, and restrict project summary data to the visible projects for the user
Index: index.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/index.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- index.php 23 Jan 2002 14:41:10 -0000 1.15
+++ index.php 2 Mar 2002 18:48:30 -0000 1.16
@@ -29,9 +29,11 @@
));
$t->set_block('content', 'statsblock', 'sblock');
$t->set_block('statsblock','row','rows');
+$t->set_block('content', 'recentrow', 'recentrows');
+$t->set_block('content', 'closerow', 'closerows');
$t->set_var('TITLE',$TITLE['home']);
-function grab_data() {
+function grab_data($restricted_projects) {
global $q;
// Grab the legend
@@ -41,7 +43,8 @@
}
// Grab the data
- $q->query("select status_id, count(status_id) as count from ".TBL_BUG." group by status_id");
+ $q->query("select status_id, count(status_id) as count from ".TBL_BUG.
+ " where project_id not in ($restricted_projects) group by status_id");
while ($row = $q->grab()) {
$stats[$row['status_id']]['count'] = $row['count'];
}
@@ -49,12 +52,12 @@
return $stats;
}
-function build_image() {
+function build_image($restricted_projects) {
error_reporting(0); // Force this, just in case
include_once JPGRAPH_PATH.'jpgraph.php';
include_once JPGRAPH_PATH.'jpgraph_pie.php';
- $stats = grab_data();
+ $stats = grab_data($restricted_projects);
$totalbugs = 0;
foreach ($stats as $statid => $stat) {
if ($stat['count']) {
@@ -89,11 +92,22 @@
"<img align=\"right\" src=\"jpgimages/".GenImgName()."\" ISMAP USEMAP=\"#myimagemap\" border=0>";
}
+// Check to see if we have bugs from projects that shouldn't be visible to the user
+$restricted_projects = '0';
+if (!$perm->have_perm('Admin')) {
+ $matching_projects = delimit_list(',',
+ $q->grab_field_set("select project_id from ".TBL_PROJECT_GROUP.
+ " where group_id not in (".delimit_list(',', $auth->auth['group_ids']).")"));
+ if ($matching_projects) {
+ $restricted_projects .= ",$matching_projects";
+ }
+}
+// Show the overall bug stats
if (USE_JPGRAPH) {
- $t->set_var('sblock', build_image());
+ $t->set_var('sblock', build_image($restricted_projects));
} else {
- $stats = grab_data();
+ $stats = grab_data($restricted_projects);
$total = 0;
foreach ($stats as $statid => $stat) {
$t->set_var(array(
@@ -112,6 +126,38 @@
$t->parse('rows','row',true);
$t->parse('sblock', 'statsblock', true);
}
+
+// Show the recently added and closed bugs
+$q->query("select bug_id, title from ".TBL_BUG.
+ " where project_id not in ($restricted_projects)".
+ ' order by created_date desc limit 5');
+if (!$q->num_rows()) {
+ $t->set_var('recentrows', $STRING['nobugs']);
+} else {
+ while (list($bugid, $title) = $q->grab()) {
+ $t->set_var(array(
+ 'title' => stripslashes($title),
+ 'bugid' => $bugid
+ ));
+ $t->parse('recentrows', 'recentrow', true);
+ }
+}
+$q->query('select b.bug_id, title from '.TBL_BUG.' b, '.TBL_BUG_HISTORY.
+ " h where project_id not in ($restricted_projects) and b.bug_id = h.bug_id".
+ " and changed_field = 'Status' and new_value = 'Closed'".
+ ' order by h.created_date desc limit 5');
+if (!$q->num_rows()) {
+ $t->set_var('closerows', $STRING['nobugs']);
+} else {
+ while (list($bugid, $title) = $q->grab()) {
+ $t->set_var(array(
+ 'title' => stripslashes($title),
+ 'bugid' => $bugid
+ ));
+ $t->parse('closerows', 'closerow', true);
+ }
+}
+
$t->pparse('main',array('content','wrap','main'));
|