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

raeburn raeburn@source.lon-capa.org
Mon, 16 Aug 2010 00:30:47 -0000


raeburn		Mon Aug 16 00:30:47 2010 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Bug 6228.
    - next to update folderpath with client side javascript if tabs are used
      to switch from Main Documents to/from Supplemental Documents to prevent
      import into wrong area. 
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.432 loncom/interface/londocs.pm:1.433
--- loncom/interface/londocs.pm:1.432	Sat Aug 14 04:28:21 2010
+++ loncom/interface/londocs.pm	Mon Aug 16 00:30:47 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.432 2010/08/14 04:28:21 raeburn Exp $
+# $Id: londocs.pm,v 1.433 2010/08/16 00:30:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2721,6 +2721,17 @@
 	    '<input type="hidden" name="pagesymb" value="" />';
         $uploadtag = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
 	    '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />';
+    } else {
+        my $folderpath=$env{'form.folderpath'};
+        if (!$folderpath) {
+            if ($env{'form.folder'} eq '' ||
+                $env{'form.folder'} eq 'supplemental') {
+                $folderpath='default&'.
+                    &escape(&mt('Main '.$crstype.' Documents'));
+            }
+        }
+        $containertag = '<input type="hidden" name="folderpath" value="" />';
+        $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
     }
     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
        $showdoc='/'.$1;
@@ -3013,18 +3024,6 @@
                                          'sl' => 'Show Log'
 					  );
 
-       my $folderpath=$env{'form.folderpath'};
-       if (!$folderpath) {
-	   if ($env{'form.folder'} eq '' ||
-	       $env{'form.folder'} eq 'supplemental') {
-	       $folderpath='default&'.
-		   &escape(&mt('Main '.$crstype.' Documents'));
-	   }
-       }
-       unless ($env{'form.pagepath'}) {
-           $containertag = '<input type="hidden" name="folderpath" value="" />';
-           $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
-       }
 	$r->print(<<HIDDENFORM);
 	<form name="renameform" method="post" action="/adm/coursedocs">
    <input type="hidden" name="title" />
@@ -3589,6 +3588,12 @@
                                           p_ctr2b => '?[_98]'
                                         );
 
+    my $crstype = &Apache::loncommon::course_type();
+    my $docs_folderpath = $env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'};
+    my $docs_pagepath = $env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'};
+    my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents';
+    my $toplevelsupp = 'supplemental&Supplemental%20'.$crstype.'%20Documents';
+
     return <<ENDNEWSCRIPT;
 function makenewfolder(targetform,folderseq) {
     var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
@@ -3817,6 +3822,26 @@
 	current.className = 'active';
 	currentData = document.getElementById(pageId);
 	currentData.style.display = 'block';
+        if (nav == 'mainnav') {
+            var storedpath = "$docs_folderpath";
+            if (storedpath == '') {
+                storedpath = "$docs_pagepath";
+            }
+            var reg = new RegExp("^supplemental");
+            if (pageId == 'mainCourseDocuments') {
+                if (reg.test(storedpath)) {
+                    document.simpleedit.folderpath.value = '$toplevelmain';
+                    document.uploaddocument.folderpath.value = '$toplevelmain';
+                    document.newext.folderpath.value = '$toplevelmain';
+                }
+            } else {
+                if (!reg.test(storedpath)) {
+                    document.simpleedit.folderpath.value = '$toplevelsupp';
+                    document.supuploaddocument.folderpath.value = '$toplevelsupp';
+                    document.supnewext.folderpath.value = '$toplevelsupp';
+                }
+            }
+        }
 	return false;
 }