|
From: Benjamin C. <bc...@us...> - 2002-03-05 22:14:03
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv17352
Modified Files:
bug.php query.php report.php
Log Message:
Use the new project restriction code
Index: bug.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/bug.php,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- bug.php 28 Feb 2002 18:21:30 -0000 1.81
+++ bug.php 5 Mar 2002 22:14:00 -0000 1.82
@@ -827,32 +827,27 @@
}
function show_projects() {
- global $me, $q, $t, $STRING, $TITLE, $perm, $auth;
+ global $me, $q, $t, $STRING, $TITLE, $perm, $auth, $restricted_projects, $_gv;
// Show only active projects with at least one component
if ($perm->have_perm('Admin')) { // Show admins all projects
- $q->query('select p.project_id, p.project_name, p.project_desc, p.created_date
- from '.TBL_PROJECT.' p, '.TBL_COMPONENT.
- ' c where p.active = 1 and p.project_id = c.project_id group by
- p.project_id, p.project_name, p.project_desc, p.created_date
- order by project_name');
+ $p_query = '';
} else { // Filter out projects that can't be seen by this user
- $q->query('select p.project_id, p.project_name, p.project_desc, p.created_date
- from '.TBL_PROJECT.' p left join '.TBL_PROJECT_GROUP.' pg
- using(project_id), '.TBL_COMPONENT.' c
- where p.active = 1 and p.project_id = c.project_id
- and (pg.project_id is null or pg.group_id in ('.
- delimit_list(',', $auth->auth['group_ids']).')) group by
- p.project_id, p.project_name, p.project_desc, p.created_date
- order by project_name');
+ $p_query = " and p.project_id not in ($restricted_projects)";
}
+ $q->query('select p.project_id, p.project_name, p.project_desc, p.created_date
+ from '.TBL_PROJECT.' p, '.TBL_COMPONENT.
+ ' c where p.active = 1 and p.project_id = c.project_id'.$p_query.
+ ' group by p.project_id, p.project_name, p.project_desc, p.created_date'.
+ ' order by project_name');
+
switch ($q->num_rows()) {
case 0 :
$t->set_var('rows',$STRING['noprojects']);
return;
case 1 :
$row = $q->grab();
- $project = $row['project_id'];
+ $_gv['project'] = $row['project_id'];
show_form();
break;
default :
Index: query.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/query.php,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- query.php 26 Jan 2002 17:18:36 -0000 1.57
+++ query.php 5 Mar 2002 22:14:00 -0000 1.58
@@ -73,7 +73,7 @@
}
function build_query($assignedto, $reportedby, $open) {
- global $q, $auth, $_gv, $perm, $auth;
+ global $q, $auth, $_gv, $perm, $restricted_projects;
foreach ($_gv as $k => $v) { $$k = $v; }
@@ -138,12 +138,7 @@
if ($components) $proj[] = "b.component_id = $components";
$query[] = '('.delimit_list(' and ',$proj).')';
} elseif (!$perm->have_perm('Admin')) { // Filter results from hidden projects
- $query[] = 'b.project_id in ('.
- delimit_list(',', $q->grab_field_set('select p.project_id
- from '.TBL_PROJECT.' p left join '.TBL_PROJECT_GROUP.' pg using(project_id)
- where active > 0 and (pg.project_id is null or pg.group_id in ('.
- delimit_list(',', $auth->auth['group_ids']).')) group by p.project_id')).
- ')';
+ $query[] = "b.project_id not in ($restricted_projects)";
}
}
Index: report.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/report.php,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- report.php 16 Jan 2002 11:12:33 -0000 1.18
+++ report.php 5 Mar 2002 22:14:00 -0000 1.19
@@ -25,7 +25,7 @@
include 'include.php';
function resolution_by_engineer($projectid = 0) {
- global $q, $t;
+ global $q, $t, $restricted_projects, $perm;
$t->set_block('content', 'row', 'rows');
$t->set_block('row', 'col', 'cols');
@@ -45,6 +45,8 @@
if ($projectid && is_numeric($projectid)) {
$projectquery = "where project_id = $projectid";
+ } elseif (!$perm->have_perm('Admin')) {
+ $projectquery = "where project_id not in ($restricted_projects)";
} else {
$projectquery = '';
}
|