[dev] Searching by type in Whups
Bo Daley
bo at tilda.com.au
Fri Jun 20 00:31:13 PDT 2003
this patch extends the search page to allow searching by bug type (3 files
follow below).
One thing I noticed with this is that I quickly started to run out of space in
the search_getvars column of the table whups_user_searches. The get vars are
truncated at 255 characters -- this was a problem before but is exacerbated by
this patch (which adds even more data to the query string). Can that column be
changed to 'text'?
bo.
Index: search.php
===================================================================
RCS file: /repository/whups/search.php,v
retrieving revision 1.43
diff -u -r1.43 search.php
--- search.php 23 May 2003 13:21:40 -0000 1.43
+++ search.php 20 Jun 2003 06:28:39 -0000
@@ -62,11 +62,28 @@
} else {
$catName = _("Any");
}
+ $types = $whups->getAllTypes();
+ $type = $vars->getVar('type');
+ if ($type) {
+ if (is_array($type)) {
+ $typeName = '';
+ foreach ($type as $t) {
+ if (!empty($typeName)) {
+ $typeName .= ', ';
+ }
+ $typeName .= $types[$t];
+ }
+ } else {
+ $typeName = $types[$type];
+ }
+ } else {
+ $typeName = _("Any");
+ }
$qUrl = Horde::removeParameter($_SERVER['QUERY_STRING'],
array(urlencode(session_name()),
'__formToken_' .
$form->getName(),
'_formvars'));
- $whups->saveSearch(sprintf(_("Module: %s, Ticket: %s, Category
%s"), $moduleName, $idName, $catName), $qUrl);
+ $whups->saveSearch(sprintf(_("Module: %s, Ticket: %s, Category: %s,
Type: %s"), $moduleName, $idName, $catName, $typeName), $qUrl);
}
// Munge the search criteria into acceptability.
@@ -78,6 +95,9 @@
}
if (empty($info['category'])) {
unset($info['category']);
+ }
+ if (empty($info['type'])) {
+ unset($info['type']);
}
$tickets = $whups->getTicketsByProperties($info);
Index: Search.php
===================================================================
RCS file: /repository/whups/lib/Search.php,v
retrieving revision 1.50
diff -u -r1.50 Search.php
--- Search.php 19 Jun 2003 04:02:53 -0000 1.50
+++ Search.php 20 Jun 2003 06:41:58 -0000
@@ -38,6 +38,7 @@
$this->addVariable(_("Ticket ID"), 'id', 'intlist', false);
$this->addVariable(_("Module Name"), 'module', $modtype, false, false,
null, $type_params);
$this->addVariable(_("Tickets which are"), 'category', 'multienum',
false, false, null, array($whups->getCategories(), 4));
+ $this->addVariable(_("Types"), 'type', 'multienum', false, false, null,
array($whups->getAllTypes(), 4));
}
}
Index: sql.php
===================================================================
RCS file: /repository/whups/lib/Driver/sql.php,v
retrieving revision 1.105
diff -u -r1.105 sql.php
--- sql.php 19 Jun 2003 18:48:16 -0000 1.105
+++ sql.php 20 Jun 2003 06:42:23 -0000
@@ -625,6 +625,24 @@
$cat = '';
}
+ // Type filters.
+ if (isset($info['type_id'])) {
+ if (is_array($info['type_id'])) {
+ $t = '';
+ foreach ($info['type_id'] as $type) {
+ if (!empty($t)) {
+ $t .= ' OR ';
+ }
+ $t .= 'whups_tickets.type_id = ' .
$this->_db->quote($type);
+ }
+ $t = ' AND (' . $t . ')';
+ } else {
+ $t = isset($info['type_id']) ? ' AND whups_tickets.type_id = '
. $this->_db->quote($info['type_id']) : '';
+ }
+ } else {
+ $t = '';
+ }
+
$nouc = isset($info['nouc']) ? " AND whups_states.state_category <>
'unconfirmed'" : '';
$nores = isset($info['nores']) ? " AND whups_states.state_category <>
'resolved'" : '';
$nonew = isset($info['nonew']) ? " AND whups_states.state_category <>
'new'" : '';
More information about the dev
mailing list