From 0ce3ddd40bf1f9142e3fdb4f3b3da15ac268c720 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 26 Sep 2006 18:55:59 +0000 Subject: [PATCH] fix username@domain search --- httemplate/search/svc_Smart.html | 51 ++++++++++++++++++++-------------------- httemplate/search/svc_acct.cgi | 12 ++++++++++ 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/httemplate/search/svc_Smart.html b/httemplate/search/svc_Smart.html index 4d8f3e20e..706471ba0 100644 --- a/httemplate/search/svc_Smart.html +++ b/httemplate/search/svc_Smart.html @@ -1,29 +1,28 @@ +% if ( $cgi->param('search_svc') =~ /\.[a-z]{2,8}$/i +% && $cgi->param('search_svc') !~ /\@/ +% ) +% { + +% # looks (enough) like a domain + <% $cgi->redirect('svc_domain.cgi?domain='. uri_escape( $cgi->param('search_svc') ) ) %> + +% } elsif ( $cgi->param('search_svc') =~ /\w/ ) { % -% -%if ( $cgi->param('search_svc') =~ /\.[a-z]{2,8}$/i ) { -% -% # looks (enough) like a domain -% -% -<% $cgi->redirect('svc_domain.cgi?domain='. uri_escape( $cgi->param('search_svc') ) ) %> -% -% -%} elsif ( $cgi->param('search_svc') =~ /\w/ ) { -% -% #looks (enough) like a username -% -% -<% $cgi->redirect('svc_acct.cgi?username_type=Exact;username='. uri_escape( $cgi->param('search_svc') ) ) %> -% -% -%} else { -% -% -<% include('/elements/header.html', 'Unrecognized service string') %> +% if ( $cgi->param('search_svc') =~ /^(.+)\@(.+)$/ ) { + +% #looks (enough) like a username@domain + <% $cgi->redirect('svc_acct.cgi?username_type=Exact;username='. uri_escape($1). ';domain='. uri_escape($2) ) %> + +% } else { + +% #looks (enough) like a username + <% $cgi->redirect('svc_acct.cgi?username_type=Exact;username='. uri_escape( $cgi->param('search_svc') ) ) %> + +% } + +% } else { + + <% include('/elements/header.html', 'Unrecognized service string') %> <% include('/elements/footer.html') %> -% -% -%} -% -% +% } diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index d293e2455..2a1414bea 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -11,6 +11,18 @@ % push @extra_sql, 'pkgnum IS NULL'; %} % +% if ( $cgi->param('domain') ) { +% my $svc_domain = +% qsearchs('svc_domain', { 'domain' => $cgi->param('domain') } ); +% unless ( $svc_domain ) { +% #it would be nice if this looked more like the other "not found" +% #errors, but this will do for now. +% eidiot "Domain ". $cgi->param('domain'). " not found at all"; +% } else { +% push @extra_sql, 'domsvc = '. $svc_domain->svcnum; +% } +% } +% %if ( $query eq 'svcnum' ) { % #$orderby = "ORDER BY svcnum"; %} elsif ( $query eq 'username' ) { -- 2.11.0