|
From: Benjamin C. <bc...@us...> - 2001-12-08 14:55:46
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv11375
Modified Files:
CHANGELOG include.php query.php
Log Message:
Project visibility based on user groups
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/phpbt/phpbt/CHANGELOG,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- CHANGELOG 2001/12/05 14:00:14 1.32
+++ CHANGELOG 2001/12/08 14:55:42 1.33
@@ -11,6 +11,8 @@
the configuration page.
: Multiple bugs related to the bug query page fixed.
: Fixed a rendering problem with bug comments.
+: Added the ability to create user groups and restrict project visibility based
+ on those groups.
-- 0.5.1 -- 11 Nov 2001
: Fixed a bug (introduced in 0.5.0) with severity color not being pulled in
Index: include.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/include.php,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- include.php 2001/12/06 14:28:31 1.80
+++ include.php 2001/12/08 14:55:42 1.81
@@ -236,7 +236,7 @@
///
/// Build a select box with the item matching $value selected
function build_select($box, $value = '', $project = 0) {
- global $q, $select;
+ global $q, $select, $perm, $auth;
//create hash to map tablenames
$cfgDatabase = array(
@@ -257,7 +257,13 @@
'severity' => $querystart.' where sort_order > 0 order by sort_order',
'status' => $querystart.' where sort_order > 0 order by sort_order',
'resolution' => $querystart.' where sort_order > 0 order by sort_order',
- 'project' => $querystart." where active > 0 order by {$box}_name",
+ 'project' => $perm->have_perm('Admin')
+ ? $querystart." where active > 0 order by {$box}_name"
+ : "select p.{$box}_id, {$box}_name from $cfgDatabase[$box] 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, p.project_name order by project_name',
'component' => $querystart." where project_id = $project order by {$box}_name",
'version' => $querystart." where project_id = $project order by {$box}_name"
);
Index: query.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/query.php,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- query.php 2001/12/08 14:28:16 1.46
+++ query.php 2001/12/08 14:55:42 1.47
@@ -33,7 +33,8 @@
}
function show_query() {
- global $q, $t, $status, $resolution, $os, $priority, $severity, $TITLE, $u;
+ global $q, $t, $status, $resolution, $os, $priority, $severity, $TITLE, $u,
+ $perm, $auth;
$nq = new dbclass;
$js = '';
@@ -43,8 +44,16 @@
$t->set_block('savequeryblock','row','rows');
// Build the javascript-powered select boxes
- $q->query("select project_id, project_name from ".TBL_PROJECT.
- " where active = 1 order by project_name");
+ if ($perm->have_perm('Admin')) {
+ $q->query("select project_id, project_name from ".TBL_PROJECT.
+ " where active = 1 order by project_name");
+ } else {
+ $q->query('select p.project_id, project_name from '.TBL_PROJECT.
+ ' p left join '.TBL_PROJECT_GROUP.' pg using(project_id)
+ where active = 1 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 order by project_name');
+ }
while (list($pid, $pname) = $q->grab()) {
// Version array
$js .= "versions['$pname'] = new Array(new Array('','All'),";
@@ -101,7 +110,7 @@
}
function build_query($assignedto, $reportedby, $open) {
- global $q, $auth, $_gv;
+ global $q, $auth, $_gv, $perm, $auth;
foreach ($_gv as $k => $v) { $$k = $v; }
@@ -156,6 +165,13 @@
if ($versions) $proj[] = "b.version_id = $versions";
if ($components) $proj[] = "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')).
+ ')';
}
}
|