|
From: Benjamin C. <bc...@us...> - 2001-11-14 04:11:05
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv25957
Modified Files:
CHANGELOG bug.php query.php
Log Message:
Added Previous and Next links for moving to other bugs in the bug list from the bug display page. The links don't show up when searching with no query parameters, and I'm thinking that may be the way it should be
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/phpbt/phpbt/CHANGELOG,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- CHANGELOG 2001/11/12 03:16:20 1.28
+++ CHANGELOG 2001/11/14 04:11:02 1.29
@@ -1,3 +1,9 @@
+-- 0.6.0 --
+: Fixed a bug with old queries being retained when submitting a new query.
+: Moved session and auth classes into the package.
+: Added Previous and Next links for moving to other bugs in the bug list
+ from the bug display page.
+
-- 0.5.1 -- 11 Nov 2001
: Fixed a bug (introduced in 0.5.0) with severity color not being pulled in
with the bug list database query.
Index: bug.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/bug.php,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- bug.php 2001/11/13 03:53:00 1.58
+++ bug.php 2001/11/14 04:11:02 1.59
@@ -512,10 +512,58 @@
}
}
}
+
+///
+/// Grab the links for the previous and next bugs in the list
+function prev_next_links($bugid, $pos) {
+ global $q, $queryinfo;
+
+ if (!isset($queryinfo['query']) || !$queryinfo['query']) {
+ return array('', '');
+ }
+
+ $prevlink = $nextlink = '';
+ if ($pos) {
+ $offset = $pos - 1;
+ $limit = 2;
+ } else {
+ $offset = $pos;
+ $limit = 1;
+ }
+ $q->limit_query('select bug_id from '.TBL_BUG.' b
+ left join '.TBL_AUTH_USER.' owner on b.assigned_to = owner.user_id
+ left join '.TBL_AUTH_USER.' reporter on b.created_by = reporter.user_id
+ left join '.TBL_AUTH_USER.' lastmodifier on b.last_modified_by = lastmodifier.user_id
+ left join '.TBL_RESOLUTION.' resolution on b.resolution_id = resolution.resolution_id, '.
+ TBL_SEVERITY.' severity, '.TBL_STATUS.' status, '.TBL_OS.' os, '.
+ TBL_VERSION.' version, '.TBL_COMPONENT.' component, '.TBL_PROJECT.' project
+ where b.severity_id = severity.severity_id and b.status_id = status.status_id
+ and b.os_id = os.os_id and b.version_id = version.version_id
+ and b.component_id = component.component_id and b.project_id = project.project_id '.
+ "and {$queryinfo['query']} and bug_id <> $bugid
+ order by {$queryinfo['order']} {$queryinfo['sort']}", $limit, $offset);
+
+ $firstid = $q->grab_field();
+ $secondid = $q->grab_field();
+ if ($pos) {
+ if ($firstid) {
+ $prevlink = "<a href='bug.php?op=show&bugid=$firstid&pos=".($pos - 1).'\'>Previous</a>';
+ }
+ if ($secondid) {
+ $nextlink = "<a href='bug.php?op=show&bugid=$secondid&pos=".($pos + 1).'\'>Next</a>';
+ }
+ } else {
+ if ($firstid) {
+ $nextlink = "<a href='bug.php?op=show&bugid=$firstid&pos=".($pos + 1).'\'>Next</a>';
+ }
+ }
+
+ return array($prevlink, $nextlink);
+}
function show_bug($bugid = 0, $error = '') {
- global $q, $me, $t, $project, $STRING, $u, $perm;
+ global $q, $me, $t, $project, $STRING, $u, $perm, $_gv;
if (!ereg('^[0-9]+$',$bugid) or
!$row = $q->grab('select b.*, reporter.login as reporter, owner.login as owner, status_name, resolution_name
@@ -538,6 +586,8 @@
$t->set_block('content','crow','closerow');
$t->set_block('content','attrow','attrows');
$t->set_unknowns('remove');
+
+ list($prevlink, $nextlink) = prev_next_links($bugid, $_gv['pos']);
$t->set_var(array(
'statuserr' => $error['status'] ? $error['status'].'<br><br>' : '',
'bugid' => $bugid,
@@ -565,7 +615,10 @@
'cclist' => build_select('bug_cc', $bugid),
'submit' => $u == 'nobody' ? $STRING['logintomodify'] :
'<input type="submit" value="Submit">',
- 'developer_list' => build_select('owner')
+ 'developer_list' => build_select('owner'),
+ 'prevlink' => $prevlink,
+ 'nextlink' => $nextlink,
+ 'prevnextsep' => $prevlink && $nextlink ? ' | ' : ''
));
switch($row['status_name']) {
case 'Unconfirmed' :
Index: query.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/query.php,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- query.php 2001/11/13 05:20:49 1.39
+++ query.php 2001/11/14 04:11:02 1.40
@@ -100,7 +100,7 @@
}
function build_query($assignedto, $reportedby, $open) {
- global $q, $sess, $auth, $querystring, $_gv;
+ global $q, $auth, $_gv;
foreach ($_gv as $k => $v) { $$k = $v; }
@@ -159,13 +159,14 @@
}
if ($query) $querystring = delimit_list(' and ',$query);
+ return $querystring;
if (!$sess->is_registered('querystring')) $sess->register('querystring');
}
function list_items($assignedto = 0, $reportedby = 0, $open = 0) {
- global $querystring, $me, $q, $t, $selrange, $order, $sort, $query,
+ global $queryinfo, $me, $q, $t, $selrange, $order, $sort, $query,
$page, $op, $select, $TITLE, $STRING, $savedqueryname, $u, $auth,
- $default_db_fields, $all_db_fields;
+ $default_db_fields, $all_db_fields, $sess;
$t->set_file('content','buglist.html');
$t->set_block('content','row','rows');
@@ -179,17 +180,31 @@
values (".$q->nextid(TBL_SAVED_QUERY).", $u, '$savedqueryname', '$savedquerystring')");
}
if (!$order) {
- $order = 'bug_id';
- $sort = 'asc';
+ if (isset($queryinfo['order'])) {
+ $order = $queryinfo['order'];
+ $sort = $queryinfo['sort'];
+ } else {
+ $order = 'bug_id';
+ $sort = 'asc';
+ }
+ }
+ $queryinfo['order'] = $order;
+ $queryinfo['sort'] = $sort;
+
+ if (!$queryinfo['query'] or $op) {
+ $queryinfo['query'] = build_query($assignedto, $reportedby, $open);
}
- if (!$querystring or $op) {
- build_query($assignedto, $reportedby, $open);
+
+ if (!$sess->is_registered('queryinfo')) {
+ $sess->register('queryinfo');
}
+
$nr = $q->grab_field('select count(*) from '.TBL_BUG.' b
left join '.TBL_AUTH_USER.' owner on b.assigned_to = owner.user_id
left join '.TBL_AUTH_USER.' reporter on b.created_by = reporter.user_id '.
- ($querystring != '' ? "where $querystring": ''));
+ ($queryinfo['query'] != '' ? "where {$queryinfo['query']}": ''));
+ $queryinfo['numrows'] = $nr;
list($selrange, $llimit, $npages, $pages) = multipages($nr,$page,
"order=$order&sort=$sort");
@@ -213,7 +228,7 @@
where b.severity_id = severity.severity_id and b.status_id = status.status_id
and b.os_id = os.os_id and b.version_id = version.version_id
and b.component_id = component.component_id and b.project_id = project.project_id '.
- ($querystring != '' ? "and $querystring " : '').
+ ($queryinfo['query'] != '' ? "and {$queryinfo['query']} " : '').
"order by $order $sort", $selrange, $llimit);
$headers = array(
@@ -260,6 +275,7 @@
$t->parse('rows', 'row', true);
$t->set_var('cols', '');
+ $pos = 0;
// Data rows
while ($row = $q->grab()) {
$bgcolor = USE_SEVERITY_COLOR ? $row['severity_color'] :
@@ -279,7 +295,7 @@
break;
case 'bug_id' :
case 'title' :
- $coldata = "<a href='bug.php?op=show&bugid={$row['bug_id']}'>{$row[$field]}</a>";
+ $coldata = "<a href='bug.php?op=show&bugid={$row['bug_id']}&pos=$pos'>{$row[$field]}</a>";
$td_extra = '';
break;
case 'reporter' :
@@ -306,6 +322,7 @@
$t->set_var('tr-extra', "class='$trclass' bgcolor='$bgcolor' onClick=\"document.location.href='bug.php?op=show&bugid={$row['bug_id']}'\" onMouseOver=\"this.style.fontWeight='bold'\" onMouseOut=\"this.style.fontWeight='normal'\"");
$t->parse('rows','row',true);
$t->set_var('cols', '');
+ ++$pos;
}
$t->set_var('numcols', count($db_fields));
}
@@ -314,7 +331,7 @@
if ($op) switch($op) {
case 'query' : show_query(); break;
- case 'doquery' : $querystring = ''; list_items(); break;
+ case 'doquery' : $queryinfo['query'] = ''; list_items(); break;
case 'delquery' : delete_saved_query($queryid); break;
case 'mybugs' : list_items($assignedto, $reportedby, $open); break;
default : show_query(); break;
|