--- loncom/interface/lonsearchcourse.pm 2011/01/17 20:18:02 1.1 +++ loncom/interface/lonsearchcourse.pm 2020/09/22 12:19:15 1.6 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Course # -# $Id: lonsearchcourse.pm,v 1.1 2011/01/17 20:18:02 www Exp $ +# $Id: lonsearchcourse.pm,v 1.6 2020/09/22 12:19:15 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; @@ -54,47 +54,32 @@ my $totalfound; sub menu { my $scrout=''; if ($env{'request.course.id'}) { - my %lt=&Apache::lonlocal::texthash('srch' => 'Search', - 'header' => 'Course Search', - 'note' => 'Enter terms or phrases, then press "Search" below', + my %lt=&Apache::lonlocal::texthash( + 'srch' => 'Search', + 'note' => 'Search terms', + 'options' => 'Options', 'use' => 'use related words', 'full' =>'fulltext search (time consuming)', 'disc' => 'search discussion postings (resources and discussion boards)', ); $scrout.=(< -
-
-

$lt{'header'}

-

-$lt{'note'}. -

- - - - - -
ENDCOURSESEARCH - $scrout.=' '. - &Apache::lonhtmlcommon::textbox('courseexp', - $env{'form.courseexp'},40); - my $crscheckbox = - &Apache::lonhtmlcommon::checkbox('crsfulltext', - $env{'form.crsfulltext'}); - my $relcheckbox = - &Apache::lonhtmlcommon::checkbox('crsrelated', - $env{'form.crsrelated'}); - my $discheckbox = - &Apache::lonhtmlcommon::checkbox('crsdiscuss', - $env{'form.crsrelated'}); + $scrout.=&Apache::lonhtmlcommon::start_pick_box(). + &Apache::lonhtmlcommon::row_title($lt{'note'}). + &Apache::lonhtmlcommon::textbox('courseexp', + $env{'form.courseexp'},40). + &Apache::lonhtmlcommon::row_closure(). + &Apache::lonhtmlcommon::row_title($lt{'options'}). + '
\n". + '
\n". + '
\n". + &Apache::lonhtmlcommon::end_pick_box(); $scrout.=(<

-
ENDENDCOURSE } @@ -243,9 +228,6 @@ sub course_search { $r->print('
'.&mt('An error occurred retrieving information about resources in the course.').'
'.&mt('It is recommended that you [_1]re-initialize the course[_2] and then try your search again.','','').'
'); } } - -# =================================================== Done going through course - $r->print(&Apache::loncommon::end_page()); } # =============================== This pulls up a resource and its dependencies @@ -327,16 +309,48 @@ sub handler { my $crstype = &Apache::loncommon::course_type(); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['phase']); - &Apache::lonhtmlcommon::clear_breadcrumbs(); $r->print(&Apache::loncommon::start_page("$crstype Search")); - $r->print(&Apache::lonhtmlcommon::breadcrumbs("$crstype Search")); - &Apache::londocs::startContentScreen($r,'coursesearch'); + &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"}); if ($env{'form.phase'} eq 'results') { - &course_search($r); + &Apache::lonhtmlcommon::add_breadcrumb( + { href => '/adm/searchcourse?phase=results', + text => 'Search Results'}); + } + $r->print(&Apache::lonhtmlcommon::breadcrumbs("$crstype Search")); + &Apache::lonnavdisplay::startContentScreen($r,'coursesearch'); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my ($blocked,$blocktext) = + &Apache::loncommon::blocking_status('search',$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; }