--- loncom/interface/lonsearchcat.pm 2005/02/17 08:29:43 1.238
+++ loncom/interface/lonsearchcat.pm 2005/03/21 21:01:15 1.240
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.238 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonsearchcat.pm,v 1.240 2005/03/21 21:01:15 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1535,8 +1535,9 @@ sub parse_advanced_search {
##
## Deal with restrictions to given domains
##
- my ($libraries_to_query,$pretty_domains_string) =
+ my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) =
&parse_domain_restrictions();
+ push(@queries,$domain_sql_restriction);
$pretty_search_string .= $pretty_domains_string."
\n";
#
if (@queries) {
@@ -1544,7 +1545,7 @@ sub parse_advanced_search {
} elsif ($customquery) {
$query = '';
}
- # &Apache::lonnet::logthis('query = '.$/.$query);
+ &Apache::lonnet::logthis('advanced query = '.$/.$query);
return ($query,$customquery,$customshow,$libraries_to_query,
$pretty_search_string);
}
@@ -1554,7 +1555,7 @@ sub parse_domain_restrictions {
# $ENV{'form.domains'} can be either a scalar or an array reference.
# We need an array.
if (! exists($ENV{'form.domains'}) || $ENV{'form.domains'} eq '') {
- return (undef,'');
+ return (undef,'',undef);
}
my @allowed_domains;
if (ref($ENV{'form.domains'})) {
@@ -1565,17 +1566,21 @@ sub parse_domain_restrictions {
#
my %domain_hash = ();
my $pretty_domains_string;
+ my $domain_sql_restriction;
foreach (@allowed_domains) {
$domain_hash{$_}++;
}
if ($domain_hash{'any'}) {
$pretty_domains_string = "In all LON-CAPA domains.";
+ $domain_sql_restriction = undef;
} else {
if (@allowed_domains > 1) {
$pretty_domains_string = "In LON-CAPA domains:";
} else {
$pretty_domains_string = "In LON-CAPA domain ";
}
+ $domain_sql_restriction =
+ '(domain="'.join('" OR domain="',@allowed_domains).'")';
foreach (sort @allowed_domains) {
$pretty_domains_string .= "".$_." ";
}
@@ -1585,7 +1590,9 @@ sub parse_domain_restrictions {
}
}
}
- return ($libraries_to_query,$pretty_domains_string);
+ return ($libraries_to_query,
+ $pretty_domains_string,
+ $domain_sql_restriction);
}
######################################################################
@@ -1614,7 +1621,7 @@ sub parse_basic_search {
$ENV{"form.$_"}=&Apache::lonnet::unescape($ENV{"form.$_"});
$ENV{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
}
- my ($libraries_to_query,$pretty_domains_string) =
+ my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) =
&parse_domain_restrictions();
#
# Check to see if enough of a query is filled in
@@ -1638,6 +1645,9 @@ sub parse_basic_search {
return;
}
push(@Queries,$SQLQuery);
+ if (defined($domain_sql_restriction) && $domain_sql_restriction ne '') {
+ push(@Queries,$domain_sql_restriction);
+ }
#foreach my $q (@Queries) {
# &Apache::lonnet::logthis(' '.$q);
#}
@@ -1648,7 +1658,7 @@ sub parse_basic_search {
}
$pretty_search_string .= "
\n";
$pretty_search_string =~ s:^
and ::;
- # &Apache::lonnet::logthis($final_query);
+ &Apache::lonnet::logthis('simple search final query = '.$/.$final_query);
return ($final_query,$pretty_search_string,
$libraries_to_query);
}
@@ -2436,7 +2446,7 @@ END
Status | Total Matches | Time Remaining | ||
---|---|---|---|---|
+ | $revise | @@ -3384,7 +3394,7 @@ $prefix