';
+}
+
######################################################################
=pod
@@ -444,19 +517,31 @@ Prints the form for the basic search. S
######################################################################
sub print_basic_search_form {
my ($r,$closebutton,$hidden_fields) = @_;
+ my %lt = &Apache::lonlocal::texthash (
+ res => 'Content Library Search',
+ portfolio => 'Portfolio Search',
+ );
my $result = ($env{'form.catalogmode'} ne 'import');
+ my $area;
my $bread_crumb =
&Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic',
$env{'form.catalogmode'} ne 'import');
- my $scrout = &Apache::loncommon::start_page('Content Library').$bread_crumb;
-# Search form for resource space
+ my $scrout = &Apache::loncommon::start_page('Content Library').$bread_crumb.
+ '
'."\n".
+ &start_search_tabs();
if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'}) eq 'F') {
- $scrout .= &setup_basic_search($r,'res',$hidden_fields,$closebutton);
- $scrout .= ' ';
- }
+ if ($env{'form.area'} eq 'portfolio') {
# Search form for accessible portfolio files
- $scrout.= &setup_basic_search($r,'portfolio',$hidden_fields,$closebutton);
- $scrout .= &Apache::loncommon::end_page();
+ $scrout .= &setup_basic_search($r,'portfolio',$hidden_fields,$closebutton);
+ } else {
+# Search form for resource space
+ $scrout .= &setup_basic_search($r,'res',$hidden_fields,$closebutton);
+ }
+ } else {
+# Search form for accessible portfolio files
+ $scrout .= &setup_basic_search($r,'portfolio',$hidden_fields,$closebutton);
+ }
+ $scrout .= &end_search_tabs().&Apache::loncommon::end_page();
$r->print($scrout);
return;
}
@@ -465,7 +550,7 @@ sub setup_basic_search {
my ($r,$area,$hidden_fields,$closebutton) = @_;
# Define interface components
my %lt = &Apache::lonlocal::texthash (
- res => 'LON-CAPA Catalog Search',
+ res => 'Content Library Search',
portfolio => 'Portfolio Search',
);
my ($userelatedwords,$onlysearchdomain,$inclext,$adv_search_link,$scrout);
@@ -479,14 +564,31 @@ sub setup_basic_search {
.&mt('use related words')
.'';
+ my $anydom = 1;
+ if ($area eq 'res') {
+ unless (&Apache::lonnet::allowed('bre','/res/') eq 'F') {
+ $anydom = 0;
+ }
+ }
+ my $singledom;
+ my ($disabled,$checked);
+ if ($anydom) {
+ $singledom = $r->dir_config('lonDefDomain');
+ if ($env{'form.domains'} eq $singledom) {
+ $checked = 1;
+ }
+ } else {
+ $singledom = $env{'user.domain'};
+ $disabled = ' disabled="disabled"';
+ $checked = 1;
+ }
$onlysearchdomain = '';
$adv_search_link = '';
}
#
- $scrout .= '
'.$/;
-# if ($env{'request.course.id'}) {
- $scrout .= '
'.$lt{$area}.'
';
-# } else {
- # No need to tell them they are searching
-# $scrout.= (' 'x2);
-# }
- $scrout.='
'.&Apache::loncommon::end_page());
return;
}
@@ -2230,13 +2383,11 @@ SCRIPT
sub reload_result_frame {
my ($r) = @_;
my $newloc = '/adm/searchcat?phase=results&persistent_db_id='.
- $env{'form.persistent_db_id'};
+ $env{'form.persistent_db_id'}.'&area='.$env{'form.area'}.
+ '&catalogmode='.$env{'form.catalogmode'};
$r->print(<
SCRIPT
@@ -2303,7 +2454,9 @@ sub revise_button {
my $newloc = '/adm/searchcat'.
'?persistent_db_id='.$env{'form.persistent_db_id'}.
'&cleargroupsort=1'.
- '&phase='.$revise_phase;
+ '&phase='.$revise_phase.
+ '&area='.$env{'form.area'}.
+ '&catalogmode='.$env{'form.catalogmode'};
my $result = qq{ };
return $result;
@@ -2325,7 +2478,7 @@ results into MySQL.
######################################################################
sub run_search {
my ($r,$query,$customquery,$customshow,$serverlist,
- $pretty_string,$area,$domainsref) = @_;
+ $pretty_string,$area,$domainsref,$target) = @_;
my $tabletype = 'metadata';
if ($area eq 'portfolio') {
$tabletype = 'portfolio_search';
@@ -2334,13 +2487,19 @@ sub run_search {
#
# Print run_search header
#
- my $start_page = &Apache::loncommon::start_page('Search Status',undef);
+ my $args;
+ if ($target eq '_parent') {
+ $args = {'links_target' => $target};
+ }
+ my $start_page = &Apache::loncommon::start_page('Search Status',undef,$args);
my $breadcrumbs =
&Apache::lonhtmlcommon::breadcrumbs('Searching','Searching',
- $env{'form.catalogmode'} ne 'import');
+ $env{'form.catalogmode'} ne 'import',
+ '','','','','','',$target);
$r->print(<
END
# Remove leading and trailing
$pretty_string =~ s:^\s* ::i;
@@ -2385,8 +2544,6 @@ END
%all_library_servers = (%library_servers,%older_library_servers);
@Servers_to_contact = sort(keys(%all_library_servers));
foreach my $server (@Servers_to_contact) {
- my %possdoms;
- map { $possdoms{$_}=1; } &Apache::lonnet::machine_domains($all_library_servers{$server});
$domains_by_server{$server} =
join(',',sort(&Apache::lonnet::machine_domains($all_library_servers{$server})));
}
@@ -2426,6 +2583,7 @@ END
## Prepare for the big loop.
my $hitcountsum;
my $oldhitcountsum;
+ my $displaycount;
my %matches;
my $server;
my $status;
@@ -2472,7 +2630,7 @@ END
&update_status($r,
&mt('waiting on [_1]',join(' ',keys(%Server_status))));
}
- Time::HiRes::sleep(0.1);
+ sleep(0.1);
}
#
# Loop through the servers we have contacted but do not
@@ -2525,8 +2683,8 @@ END
if ($area eq 'portfolio') {
next if (defined($matches{$Fields{'url'}}));
- # Skip if inaccessible
- next if (!&Apache::lonnet::portfolio_access($Fields{'url'}));
+ # Skip unless access control set to public or passphrase-protected
+ next unless (($Fields{'scope'} eq 'public') || ($Fields{'scope'} eq 'guest'));
$matches{$Fields{'url'}} = 1;
}
#
@@ -2550,8 +2708,10 @@ END
last if ($connection->aborted());
if ($oldhitcountsum < $hitcountsum) {
&update_count_status($r,$hitcountsum);
- if ($hitcountsum <= $env{'form.show'}) {
+ if (($hitcountsum <= $env{'form.show'}) ||
+ (!$displaycount && $hitcountsum)) {
reload_result_frame($r);
+ $displaycount = $hitcountsum;
}
$oldhitcountsum = $hitcountsum;
}
@@ -2567,11 +2727,11 @@ END
# We have run out of time or run out of servers to talk to and
# results to get, so let the client know the top frame needs to be
# loaded from /adm/searchcat
- $r->print(&Apache::loncommon::end_page());
+ $r->print('
'.&Apache::loncommon::end_page());
# if ($env{'form.catalogmode'} ne 'import') {
$r->print(<
SCRIPT
# }
@@ -2631,7 +2791,8 @@ sub display_results {
if (!defined($viewfunction)) {
$r->print('
'
.&mt('Internal Error - Bad view selected.')
- .'
'."\n");
+ .''."\n"
+ .''.&Apache::loncommon::end_page());
$r->rflush();
return;
}
@@ -2642,7 +2803,8 @@ sub display_results {
##
## Get the catalog controls setup
##
- my $action = "/adm/searchcat?phase=results";
+ my $action = '/adm/searchcat?phase=results&area='.$env{'form.area'}.
+ '&catalogmode='.$env{'form.catalogmode'};
##
## Deal with import by opening the import db file.
if ($env{'form.catalogmode'} eq 'import') {
@@ -2653,7 +2815,7 @@ sub display_results {
$r->print('