--- loncom/interface/lonsearchcat.pm 2015/06/18 15:10:52 1.347 +++ loncom/interface/lonsearchcat.pm 2022/05/29 03:19:00 1.355 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.347 2015/06/18 15:10:52 damieng Exp $ +# $Id: lonsearchcat.pm,v 1.355 2022/05/29 03:19:00 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -178,6 +178,15 @@ sub handler { if (@allowed_searches ==2) { $crumb_text = 'Portfolio and Catalog Search'; } + my $target = '_top'; + if ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) || + (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) { + if ($env{'form.phase'} =~ /^(sort|run_search)$/) { + $target = '_parent'; + } else { + $target = ''; + } + } &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/searchcat?'. &Apache::loncommon::inhibit_menu_check(). @@ -185,7 +194,7 @@ sub handler { '&launch='.$env{'form.launch'}. '&mode='.$env{'form.mode'}, text=>"$crumb_text", - target=>'_top', + target=>$target, bug=>'Searching',}); # if ($env{'form.phase'} !~ m/(basic|adv|course)_search/) { @@ -479,14 +488,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 = '{'url'}); # Check for priv - if (($Metadata->{'copyright'} eq 'priv') && - (($env{'user.name'} ne $resname) && - ($env{'user.domain'} ne $resdom))) { - return 0; + if ($Metadata->{'copyright'} eq 'priv') { + unless (($env{'user.name'} eq $resname) && + ($env{'user.domain'} eq $resdom)) { + return 0; + } } # Check for domain if (($Metadata->{'copyright'} eq 'domain') && @@ -2051,7 +2096,14 @@ sub print_sort_form { &Apache::lonnet::logthis(&Apache::lonmysql::get_error()); return; } - my $start_page = &Apache::loncommon::start_page('Results',undef); + my $target = '_top'; + my $args; + if ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) || + (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) { + $target = '_parent'; + $args = {'links_target' => $target}; + } + my $start_page = &Apache::loncommon::start_page('Results',undef,$args); my $breadcrumbs= &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching', $env{'form.catalogmode'} ne 'import'); @@ -2059,7 +2111,7 @@ sub print_sort_form { my $result = < +
END @@ -2370,8 +2422,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}))); } @@ -2411,6 +2461,7 @@ END ## Prepare for the big loop. my $hitcountsum; my $oldhitcountsum; + my $displaycount; my %matches; my $server; my $status; @@ -2535,8 +2586,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; } @@ -3527,17 +3580,17 @@ sub display_url { } elsif ($url=~m{^(http://|/uploaded/)}) { $link=''.$url.''; } else { + # replace the links to open in a new window + # (because the search opens in a new window, it gets + # confusing when the links open a tab in the + # parent window; ideally we should not force windows) + my $onclick = " onclick=\"window.open(this.href, '_blank', 'toolbar=1,location=1,menubar=0');return false;\""; $link=&Apache::lonhtmlcommon::crumbs( $url, 'preview', '', '', - $skiplast).' '; - # replace the links to open in a new window - # (because the search opens in a new window, it gets - # confusing when the links open a tab in the - # parent window; ideally we should not force windows) - $link =~ s/(href="[^"]*")/\1 onclick="window.open(this.href, '_blank', 'toolbar=1,location=1,menubar=0');return false;"/g; + $skiplast,$onclick).' '; } return $link; }