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

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 27 Sep 2006 19:32:14 -0000


raeburn		Wed Sep 27 15:32:14 2006 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
  Log:
  Some wording changes in breadcrumbs. Advanced search now functional for portfolios.  Needs additional work on searching based on added metadata fields.
  
  
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.276 loncom/interface/lonsearchcat.pm:1.277
--- loncom/interface/lonsearchcat.pm:1.276	Tue Sep 26 11:24:18 2006
+++ loncom/interface/lonsearchcat.pm	Wed Sep 27 15:32:11 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.276 2006/09/26 15:24:18 raeburn Exp $
+# $Id: lonsearchcat.pm,v 1.277 2006/09/27 19:32:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -171,25 +171,32 @@
                 '_'.$env{'form.persistent_db_id'}.'_persistent_search.db';
     ##
     &Apache::lonhtmlcommon::clear_breadcrumbs();
+
+    my @allowed_searches = ('portfolio');
+    if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {
+        push(@allowed_searches,'res');
+    } 
     if (exists($env{'request.course.id'}) && $env{'request.course.id'} ne '') {
-        &Apache::lonhtmlcommon::add_breadcrumb
-             ({href=>'/adm/searchcat?'.
-                   'catalogmode='.$env{'form.catalogmode'}.
-                   '&launch='.$env{'form.launch'}.
-                   '&mode='.$env{'form.mode'},
-              text=>"Course and Catalog Search",
-              target=>'_top',
-              bug=>'Searching',});
-    } else {
-        &Apache::lonhtmlcommon::add_breadcrumb
-             ({href=>'/adm/searchcat?'.
-                   'catalogmode='.$env{'form.catalogmode'}.
-                   '&launch='.$env{'form.launch'}.
-                   '&mode='.$env{'form.mode'},
-              text=>"Catalog Search",
+        push(@allowed_searches,'course');
+    }
+    my $crumb_text = 'Portfolio Search';
+    if (@allowed_searches == 3) {
+        $crumb_text = 'Course, Portfolio and Catalog Search';
+    } elsif (@allowed_searches ==2) {
+        if (grep(/^res$/,@allowed_searches)) {
+            $crumb_text = 'Portfolio and Catalog Search'; 
+        } elsif (grep(/^course$/,@allowed_searches)) {
+            $crumb_text = 'Portfolio and Course Search';
+        }
+    }
+    &Apache::lonhtmlcommon::add_breadcrumb
+       ({href=>'/adm/searchcat?'.
+               'catalogmode='.$env{'form.catalogmode'}.
+               '&launch='.$env{'form.launch'}.
+               '&mode='.$env{'form.mode'},
+              text=>"$crumb_text",
               target=>'_top',
               bug=>'Searching',});
-    }
     #
     if ($env{'form.phase'} !~ m/(basic|adv|course)_search/) {
         if (! &get_persistent_form_data($persistent_db_file)) {
@@ -297,12 +304,16 @@
     }
     #
     if ($env{'form.searchmode'} eq 'advanced') {
+        my $srchtype = 'Catalog';
+        if ($env{'form.area'} eq 'portfolio') {
+            $srchtype = 'Portfolio';
+        }
         &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>'/adm/searchcat?phase=disp_adv&'.
                   'catalogmode='.$env{'form.catalogmode'}.
                   '&launch='.$env{'form.launch'}.
                   '&mode='.$env{'form.mode'},
-                  text=>"Advanced Search",
+                  text=>"Advanced $srchtype Search",
                   bug=>'Searching',});
     } elsif ($env{'form.searchmode'} eq 'course search') {
         &Apache::lonhtmlcommon::add_breadcrumb
@@ -821,7 +832,11 @@
 <input type="reset" name="reset" value='$lt{"reset"}' />
 $closebutton
 END
-    my $scrout= &Apache::loncommon::start_page('Advanced Catalog Search');
+    my $srchtype = 'Catalog';
+    if ($env{'form.area'} eq 'portfolio') {
+        $srchtype = 'Portfolio';
+    }
+    my $scrout= &Apache::loncommon::start_page("Advanced $srchtype Search");
     $scrout .= <<"ENDHEADER";
 $bread_crumb
 <form method="post" action="/adm/searchcat" name="advsearch">
@@ -832,7 +847,7 @@
         '<input type="hidden" name="phase" value="adv_search" />';
     my %fields=&Apache::lonmeta::fieldnames();
     #
-    $scrout .= '<h3>'.&mt('Standard Metadata').'</h3>';
+    $scrout .= '<h3>'.&mt('Standard [_1] Metadata',$srchtype).'</h3>';
     $scrout .= "<table>\n";
     $scrout .= '<tr><td>&nbsp;</td><td colspan="2"><font size="-1">'.
         ('&nbsp;'x2).&searchhelp()."</font></td></tr>\n";
@@ -1583,7 +1598,11 @@
     }
     #
     if (@queries) {
-	$query="SELECT * FROM metadata WHERE (".join(") AND (",@queries).')';
+        if ($env{'form.area'} eq 'portfolio') {
+            $query ="SELECT pm.*,pa.keynum,pa.scope FROM portfolio_metadata pm, portfolio_access pa  WHERE (pm.url = pa.url AND (pa.start < NOW() AND (pa.end IS NULL OR pa.end > NOW())) AND (".join(') AND (',@queries).'))';
+        } else {
+	    $query="SELECT * FROM metadata WHERE (".join(") AND (",@queries).')';
+        }
     } elsif ($customquery) {
         $query = '';
     }