--- loncom/interface/lonsearchcourse.pm 2011/01/17 22:56:27 1.3 +++ loncom/interface/lonsearchcourse.pm 2024/02/11 20:32:42 1.8 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Course # -# $Id: lonsearchcourse.pm,v 1.3 2011/01/17 22:56:27 www Exp $ +# $Id: lonsearchcourse.pm,v 1.8 2024/02/11 20:32:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,7 +41,7 @@ use Apache::lonlocal; use LONCAPA::lonmetadata(); use HTML::Entities(); use Apache::lonnavmaps; -use Apache::londocs(); +use Apache::lonnavdisplay(); use Apache::lonindexer(); use LONCAPA; @@ -261,10 +261,18 @@ sub checkonthis { } my $href=$url; if ($hash{'encrypted_'.$id} && !$env{'request.role.adv'}) { - $href=&Apache::lonenc::encrypted($href) - .'?symb='.&Apache::lonenc::encrypted($symb); + $href=&Apache::lonenc::encrypted($href); + if ($href =~ /\.sequence$/) { + $href .= '?navmap=1'; + } else { + $href .= '?symb='.&Apache::lonenc::encrypted($symb); + } } else { - $href.='?symb='.&escape($symb); + if ($href =~ /\.sequence$/) { + $href .= '?navmap=1'; + } else { + $href .= '?symb='.&escape($symb); + } } $r->print(''.($title?$title:$url). '
'); @@ -311,6 +319,14 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['phase']); $r->print(&Apache::loncommon::start_page("$crstype Search")); &Apache::lonhtmlcommon::clear_breadcrumbs(); + if ($env{'request.course.id'} eq '') { + $r->print(&Apache::lonhtmlcommon::breadcrumbs("$crstype Search")); + $r->print(&Apache::loncommon::end_page()); + my $requrl = $r->uri; + $env{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized"; + $env{'user.reinit'} = 1; + return HTTP_NOT_ACCEPTABLE; + } &Apache::lonhtmlcommon::add_breadcrumb( { href => '/adm/searchcourse', text => "$crstype Search"}); @@ -320,13 +336,30 @@ sub handler { text => 'Search Results'}); } $r->print(&Apache::lonhtmlcommon::breadcrumbs("$crstype Search")); - &Apache::londocs::startContentScreen($r,'coursesearch'); - if ($env{'form.phase'} eq 'results') { - &course_search($r); + &Apache::lonnavdisplay::startContentScreen($r,'coursesearch'); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $clientip = &Apache::lonnet::get_requestor_ip($r); + my ($blocked,$blocktext) = + &Apache::loncommon::blocking_status('search',$clientip,$cnum,$cdom); + if ($blocked) { + my $checkrole = "cm./$cdom/$cnum"; + if ($env{'request.course.sec'} ne '') { + $checkrole .= "/$env{'request.course.sec'}"; + } + if ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) && + ($env{'request.role'} !~ m{^st\./$cdom/$cnum})) { + undef($blocked); + } + } + if ($blocked) { + $r->print($blocktext); + } elsif ($env{'form.phase'} eq 'results') { + &course_search($r); } else { - $r->print(&menu()); + $r->print(&menu()); } - &Apache::londocs::endContentScreen($r); + &Apache::lonnavdisplay::endContentScreen($r); $r->print(&Apache::loncommon::end_page()); return OK; }