Diff for /loncom/interface/lonsearchcat.pm between versions 1.131 and 1.132

version 1.131, 2002/06/26 18:19:41 version 1.132, 2002/06/27 14:46:00
Line 389  ENDHEADER Line 389  ENDHEADER
  $ENV{'form.owner'});   $ENV{'form.owner'});
     $scrout.="</table>\n";      $scrout.="</table>\n";
     $ENV{'form.category'}='any' unless length($ENV{'form.category'});      $ENV{'form.category'}='any' unless length($ENV{'form.category'});
     $scrout.=&selectbox('Limit by file category','category',      $scrout.=&selectbox('File Category','category',
  $ENV{'form.category'},   $ENV{'form.category'},
  'any','Any category',   'any','Any category',
  undef,   undef,
  (&Apache::loncommon::filecategories()));   (&Apache::loncommon::filecategories()));
     $ENV{'form.language'}='any' unless length($ENV{'form.language'});      $ENV{'form.language'}='any' unless length($ENV{'form.language'});
       #
       # Allow restriction to multiple domains.
       #   I make the crazy assumption that there will never be a domain 'any'.
       #
       my @domains =&Apache::loncommon::get_domains();
       # adjust the size of the select box
       my $size = 4;
       my $size = (scalar @domains < ($size - 1) ? scalar @domains + 1 : $size);
       # standalone machines do not get to choose a domain to search.
       if ((scalar @domains) == 1) {
           $scrout .='<input type="hidden" name="domains" value="any" />'."\n";
       } else {
           $scrout.='<font color="#800000" face="helvetica"><b>'.
               'DOMAINS</b></font><br />'.
                   '<select name="domains" size="'.$size.'" multiple>'."\n".
                       '<option name="any" selected>all domains</option>'."\n";
           foreach my $dom (sort @domains) {
               $scrout.="<option name=\"$dom\">$dom</option>\n";
           }
           $scrout.="</select>\n";
       }
       #
       # 
       #
     $scrout.=&selectbox('Limit by language','language',      $scrout.=&selectbox('Limit by language','language',
  $ENV{'form.language'},'any','Any Language',   $ENV{'form.language'},'any','Any Language',
  \&{Apache::loncommon::languagedescription},   \&{Apache::loncommon::languagedescription},
Line 786  sub advancedsearch { Line 810  sub advancedsearch {
  my @fields=split(/\s+/,$customshow);   my @fields=split(/\s+/,$customshow);
  $customshow=join(" ",@fields);   $customshow=join(" ",@fields);
     }      }
       ##
       ## Deal with restrictions to given domains
       ## 
       my $libraries_to_query = undef;
       # $ENV{'form.domains'} can be either a scalar or an array reference.
       # We need an array.
       my @allowed_domains = (ref($ENV{'form.domains'}) ? @{$ENV{'form.domains'}} 
                              :  ($ENV{'form.domains'}) );
       my %domain_hash = ();
       foreach (@allowed_domains) {
           $domain_hash{$_}++;
       }
       foreach (keys(%Apache::lonnet::libserv)) {
           if ($_ eq 'any') {
               $libraries_to_query = undef;
               last;
           }
           if (exists($domain_hash{$Apache::lonnet::hostdom{$_}})) {
               push @$libraries_to_query,$_;
           }
       }
       if (defined($libraries_to_query)) {
           &Apache::lonnet::logthis("libraries: @$libraries_to_query");
       } else {
           &Apache::lonnet::logthis("libraries: undef");
       }
       #
     # Send query statements over the network to be processed by either the SQL      # Send query statements over the network to be processed by either the SQL
     # database or a recursive scheme of 'grep'-like actions (for custom      # database or a recursive scheme of 'grep'-like actions (for custom
     # metadata).      # metadata).
Line 794  sub advancedsearch { Line 845  sub advancedsearch {
  $query="select * from metadata where $query";   $query="select * from metadata where $query";
  my $reply; # reply hash reference   my $reply; # reply hash reference
  unless ($customquery or $customshow) {   unless ($customquery or $customshow) {
     $reply=&Apache::lonnet::metadata_query($query);              $reply=&Apache::lonnet::metadata_query($query,undef,undef,
                                                      $libraries_to_query);
  }   }
  else {   else {
     $reply=&Apache::lonnet::metadata_query($query,      $reply=&Apache::lonnet::metadata_query($query,
    $customquery,$customshow);     $customquery,$customshow,
                                                      $libraries_to_query);
  }   }
  &output_results('Advanced',$r,$customquery,$reply,$hidden);   &output_results('Advanced',$r,$customquery,$reply,$hidden);
         return OK;          return OK;
     } elsif ($customquery) {      } elsif ($customquery) {
  my $reply; # reply hash reference   my $reply; # reply hash reference
  $reply=&Apache::lonnet::metadata_query('',   $reply=&Apache::lonnet::metadata_query('',
        $customquery,$customshow);         $customquery,$customshow,
                                                  $libraries_to_query);
  &output_results('Advanced',$r,$customquery,$reply,$hidden);   &output_results('Advanced',$r,$customquery,$reply,$hidden);
         return OK;          return OK;
     }      }

Removed from v.1.131  
changed lines
  Added in v.1.132


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>