[LON-CAPA-cvs] cvs: loncom /interface lonsearchcat.pm

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 16 Mar 2005 22:46:24 -0000


matthew		Wed Mar 16 17:46:24 2005 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
  Log:
  Added 'domain' to SQL queries.
  
  
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.238 loncom/interface/lonsearchcat.pm:1.239
--- loncom/interface/lonsearchcat.pm:1.238	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lonsearchcat.pm	Wed Mar 16 17:46:24 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.238 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonsearchcat.pm,v 1.239 2005/03/16 22:46:24 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1535,8 +1535,9 @@
     ##
     ## Deal with restrictions to given domains
     ## 
-    my ($libraries_to_query,$pretty_domains_string) = 
+    my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) = 
         &parse_domain_restrictions();
+    push(@queries,$domain_sql_restriction);
     $pretty_search_string .= $pretty_domains_string."<br />\n";
     #
     if (@queries) {
@@ -1544,7 +1545,7 @@
     } elsif ($customquery) {
         $query = '';
     }
-    # &Apache::lonnet::logthis('query = '.$/.$query);
+    &Apache::lonnet::logthis('advanced query = '.$/.$query);
     return ($query,$customquery,$customshow,$libraries_to_query,
             $pretty_search_string);
 }
@@ -1565,17 +1566,21 @@
     #
     my %domain_hash = ();
     my $pretty_domains_string;
+    my $domain_sql_restriction;
     foreach (@allowed_domains) {
         $domain_hash{$_}++;
     }
     if ($domain_hash{'any'}) {
         $pretty_domains_string = "In all LON-CAPA domains.";
+        $domain_sql_restriction = undef;
     } else {
         if (@allowed_domains > 1) {
             $pretty_domains_string = "In LON-CAPA domains:";
         } else {
             $pretty_domains_string = "In LON-CAPA domain ";
         }
+        $domain_sql_restriction = 
+            '(domain="'.join('" OR domain="',@allowed_domains).'")';
         foreach (sort @allowed_domains) {
             $pretty_domains_string .= "<b>".$_."</b> ";
         }
@@ -1585,7 +1590,9 @@
             }
         }
     }
-    return ($libraries_to_query,$pretty_domains_string);
+    return ($libraries_to_query,
+            $pretty_domains_string,
+            $domain_sql_restriction);
 }
 
 ######################################################################
@@ -1614,7 +1621,7 @@
 	$ENV{"form.$_"}=&Apache::lonnet::unescape($ENV{"form.$_"});
 	$ENV{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }
-    my ($libraries_to_query,$pretty_domains_string) = 
+    my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) = 
         &parse_domain_restrictions();
     #
     # Check to see if enough of a query is filled in
@@ -1638,6 +1645,7 @@
         return;
     }
     push(@Queries,$SQLQuery);
+    push(@Queries,$domain_sql_restriction);
     #foreach my $q (@Queries) {
     #    &Apache::lonnet::logthis('    '.$q);
     #}
@@ -1648,7 +1656,7 @@
     }
     $pretty_search_string .= "<br />\n";
     $pretty_search_string =~ s:^<br /> and ::;
-    # &Apache::lonnet::logthis($final_query);
+    &Apache::lonnet::logthis('simple search final query = '.$/.$final_query);
     return ($final_query,$pretty_search_string,
             $libraries_to_query);
 }
@@ -3384,7 +3392,7 @@
     <dd><a href="http://$ENV{'HTTP_HOST'}$values{'url'}" 
          target='search_preview'>$values{'url'}</a></dd>
 END
-    foreach my $field ('title','author','subject','keywords','notes',
+    foreach my $field ('title','author','domain','subject','keywords','notes',
                        'mimetag','language','creationdate','lastrevisiondate',
                        'owner','copyrighttag','hostname','abstract') {
         $result .= (' 'x4).'<dt>'.$Translated{$field}.'</dt>'."\n".
@@ -3425,7 +3433,7 @@
     my ($prefix,%values) = @_;
     my $xml = '<LonCapaResource>'."\n";
     # The usual suspects
-    foreach my $field ('url','title','author','subject','keywords','notes') {
+    foreach my $field ('url','title','author','subject','keywords','notes','domain') {
         $xml .= qq{<$field>$values{$field}</$field>}."\n";
     }
     #