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

banghart lon-capa-cvs@mail.lon-capa.org
Wed, 16 Aug 2006 18:02:02 -0000


banghart		Wed Aug 16 14:02:02 2006 EDT

  Modified files:              
    /loncom/interface	lonmeta.pm 
  Log:
  	Close some input tags, etc.
  	Address bug 3923, return user to portfolio after editing
  	portfolio metadata.
  
  
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.168 loncom/interface/lonmeta.pm:1.169
--- loncom/interface/lonmeta.pm:1.168	Thu Aug 10 18:19:06 2006
+++ loncom/interface/lonmeta.pm	Wed Aug 16 14:02:01 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.168 2006/08/10 22:19:06 banghart Exp $
+# $Id: lonmeta.pm,v 1.169 2006/08/16 18:02:01 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -366,6 +366,8 @@
     $output = &select_course();
     $r->print($output.'<br /><input type="submit" name="store" value="'.
                   &mt('Associate Resource With Selected Course').'" />');
+    $r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />');
+    $r->print('<input type="hidden" name="associate" value="true" />');
     $r->print('</form>');
     
     my ($port_path,$group) = &get_port_path_and_group($uri);
@@ -718,6 +720,8 @@
 sub handler {
     my $r=shift;
     #
+    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+         ['currentpath']);
     my $uri=$r->uri;
     #
     # Set document type
@@ -1143,7 +1147,7 @@
 	my $goback=&mt('Back to Source File');
         $r->print(<<ENDBOMBS);
 <h1>$disuri</h1>
-<form method="post" name="defaultmeta">
+<form method="post" action="" name="defaultmeta">
 ENDBOMBS
         if ($showdel) {
 	    $r->print(<<ENDDEL);
@@ -1173,9 +1177,9 @@
         }
         $r->print(<<ENDEDIT);
 <h1>$displayfile</h1>
-<form method="post" name="defaultmeta">
+<form method="post" action="" name="defaultmeta">
 ENDEDIT
-        $r->print('<script language="JavaScript">'.
+        $r->print('<script type="JavaScript">'.
                   &Apache::loncommon::browser_and_searcher_javascript().
                   '</script>');
         my %lt=&fieldnames($file_type);
@@ -1282,10 +1286,18 @@
 	    if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/portfolio/|) {
 		my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|);
                 $r->print(&store_portfolio_metadata($formname,$file_content,$path,
-                                                    $new_fn));    
+                                                    $new_fn));
+                unless ($env{'form.associate'}) {
+                    $r->print(&Apache::portfolio::done("return",'/adm/portfolio'));
+                    return;
+                }  
             } elsif ($fn =~  m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/groups/\w+/portfolio/|) {
                 my ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|);
                 $r->print(&store_portfolio_metadata($formname,$file_content,$path,$new_fn));
+                unless ($env{'form.associate'}) {
+                    $r->print(&Apache::portfolio::done("return",'/adm/portfolio'));
+                    return;
+                }  
 	    } else {
 		if (!  ($mfh=Apache::File->new('>'.$fn))) {
 		    $r->print('<p><font color="red">'.
@@ -1297,22 +1309,27 @@
 			      ' '.&Apache::lonlocal::locallocaltime(time).
 			      '</font></p>');
 		}
+                unless ($env{'form.associate'}) {
+                    $r->print(&Apache::portfolio::done("return",'/adm/portfolio'));
+                    return;
+                }  
 	    }
 	}
 	
 	$r->print($output.'<br /><input type="submit" name="store" value="'.
-                  &mt('Store Catalog Information').'">');
+                  &mt('Store Catalog Information').'" />');
 
 	if ($file_type eq 'portfolio') {
 	    my ($port_path,$group) = &get_port_path_and_group($uri);
             if ($group) {
                 $r->print('<input type="hidden" name="group" value="'.$group.'" />');
             }
+            $r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />');
 	    $r->print('</form>
-               <br /><br /><form method="POST" action="'.$port_path.'">'.
+               <br /><br /><form method="post" action="'.$port_path.'">'.
 		      '<input type="hidden" name="group" value="'.$group.'" />'.
 		      '<input type="hidden" name="currentpath" value="'.$path.'" />'.
-		      '<input type="submit" name="cancel" value="'.&mt('Discard Edits and Return to Portfolio').'">');
+		      '<input type="submit" name="cancel" value="'.&mt('Discard Edits and Return to Portfolio').'" />');
 	}
     }