--- loncom/interface/lonsearchcat.pm 2004/05/03 19:24:14 1.220 +++ loncom/interface/lonsearchcat.pm 2004/05/04 15:20:17 1.221 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.220 2004/05/03 19:24:14 matthew Exp $ +# $Id: lonsearchcat.pm,v 1.221 2004/05/04 15:20:17 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -117,7 +117,7 @@ sub handler { my $loaderror=&Apache::lonnet::overloaderror($r); if ($loaderror) { return $loaderror; } - + # my $closebutton; # button that closes the search window # This button is different for the RAT compared to # normal invocation. @@ -185,11 +185,13 @@ sub handler { bug=>'Searching',}); } # - if (! &get_persistent_form_data($persistent_db_file)) { - if ($ENV{'form.phase'} =~ /(run_search|results)/) { - &Apache::lonnet::logthis("lonsearchcat:Unable to recover data ". - "from $persistent_db_file"); - $r->print(<print(< LON-CAPA Search Error $bodytag @@ -198,8 +200,11 @@ error and has been logged. Please alert END - return OK; + return OK; + } } + } else { + &clean_up_environment(); } ## ## Clear out old values from groupsearch database @@ -389,6 +394,34 @@ END return OK; } +# +# The mechanism used to store values away and retrieve them does not +# handle the case of missing environment variables being significant. +# +# This routine sets non existant checkbox form elements to ''. +# +sub clean_up_environment { + if ($ENV{'form.phase'} eq 'basic_search') { + if (! exists($ENV{'form.related'})) { + $ENV{'form.related'} = ''; + } + if (! exists($ENV{'form.domains'})) { + $ENV{'form.domains'} = ''; + } + } elsif ($ENV{'form.phase'} eq 'adv_search') { + foreach my $field ('title','keywords','notes', + 'abstract','standards','mime') { + if (! exists($ENV{'form.'.$field.'_related'})) { + $ENV{'form.'.$field.'_related'} = ''; + } + } + } elsif ($ENV{'form.phase'} eq 'course_search') { + if (! exists($ENV{'form.crsrelated'})) { + $ENV{'form.crsrelated'} = ''; + } + } +} + ###################################################################### ###################################################################### ## @@ -532,12 +565,15 @@ sub print_basic_search_form { my $userelatedwords= &mt('[_1] use related words', &Apache::lonhtmlcommon::checkbox - ('related',$ENV{'form.related'})); + ('related',$ENV{'form.related'},'related')); my $onlysearchdomain= &mt('[_1] only search domain [_2]', - &Apache::lonhtmlcommon::checkbox - ('domains',$ENV{'form.domains'}), - $r->dir_config('lonDefDomain')); + &Apache::lonhtmlcommon::checkbox('domains', + $ENV{'form.domains'}, + $r->dir_config('lonDefDomain') + ), + $r->dir_config('lonDefDomain') + ); my $adv_search_link = '