summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/log.pm13
-rw-r--r--httemplate/search/log.html8
2 files changed, 17 insertions, 4 deletions
diff --git a/FS/FS/log.pm b/FS/FS/log.pm
index 753a31f95..547beb7d0 100644
--- a/FS/FS/log.pm
+++ b/FS/FS/log.pm
@@ -312,9 +312,16 @@ sub search {
if ( $params->{'context'} ) {
my $quoted = dbh->quote($params->{'context'});
- push @where,
- "EXISTS(SELECT 1 FROM log_context WHERE log.lognum = log_context.lognum ".
- "AND log_context.context = $quoted)";
+ if ( $params->{'context_height'} =~ /^\d+$/ ) {
+ my $subq = 'SELECT context FROM log_context WHERE log.lognum = log_context.lognum'.
+ ' ORDER BY logcontextnum DESC LIMIT '.$params->{'context_height'};
+ push @where,
+ "EXISTS(SELECT 1 FROM ($subq) AS log_context_x WHERE log_context_x.context = $quoted)";
+ } else {
+ push @where,
+ "EXISTS(SELECT 1 FROM log_context WHERE log.lognum = log_context.lognum ".
+ "AND log_context.context = $quoted)";
+ }
}
# agent virtualization
diff --git a/httemplate/search/log.html b/httemplate/search/log.html
index 7714f4614..d4fed54c9 100644
--- a/httemplate/search/log.html
+++ b/httemplate/search/log.html
@@ -100,6 +100,12 @@ a:visited {text-decoration: none}
labels => { map {$_, $_} @contexts },
curr_value => ($cgi->param('context') || ''),
&>
+ <BR><& /elements/checkbox.html,
+ 'field' => 'context_height',
+ 'postfix' => 'Only match most specific context',
+ 'value' => 1,
+ 'curr_value' => scalar($cgi->param('context_height')),
+ &>
</TD>
</TR>
<TR>
@@ -210,7 +216,7 @@ $cgi->param('max_level', 7) unless defined($cgi->param('max_level'));
my %search = ();
$search{'date'} = [ FS::UI::Web::parse_beginning_ending($cgi) ];
$search{'level'} = [ $cgi->param('min_level'), $cgi->param('max_level') ];
-foreach my $param (qw(agentnum context tablename tablenum custnum message)) {
+foreach my $param (qw(agentnum context context_height tablename tablenum custnum message)) {
if ( $cgi->param($param) ) {
$search{$param} = $cgi->param($param);
}