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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Thu, 04 Sep 2008 17:07:31 -0000


raeburn		Thu Sep  4 13:07:31 2008 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Bug 5781.
    - $env{'form.folderpath'} now set for users viewing Top level of Supplemental Documents.
    - For users without edit privs who previously accessed Supplemental Docs folders below the top level, and as a result have incomplete $env{'form.folderpath'} stored for the course in environment.db, prepend the folder and title for the top level.
    - Set text in breadcrumbs for top level folder in Supplemental Docs to "Course Documents" for users without edit privs, for consistency with the rest of the interface.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.308 loncom/interface/londocs.pm:1.309
--- loncom/interface/londocs.pm:1.308	Mon Jun  9 18:34:55 2008
+++ loncom/interface/londocs.pm	Thu Sep  4 13:07:28 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.308 2008/06/09 22:34:55 raeburn Exp $
+# $Id: londocs.pm,v 1.309 2008/09/04 17:07:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -949,7 +949,7 @@
 }
 
 sub breadcrumbs {
-    my ($where)=@_;
+    my ($where,$allowed,$type)=@_;
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     my (@folders);
     if ($env{'form.pagepath'}) {
@@ -966,7 +966,7 @@
     my $is_random_order=0;
     while (@folders) {
 	my $folder=shift(@folders);
-	my $foldername=shift(@folders);
+    	my $foldername=shift(@folders);
 	if ($folderpath) {$folderpath.='&';}
 	$folderpath.=$folder.'&'.$foldername;
 	my $url='/adm/coursedocs?folderpath='.
@@ -982,6 +982,13 @@
             if ($2) { $ishidden=1; }
             if ($3) { $isencrypted=1; }
 	    if ($4 ne '') { $is_random_order = 1; }
+            if ($folder eq 'supplemental') {
+                if ($allowed) {
+                    $name = &mt('Supplemental '.$type.' Documents');
+                } else {
+                    $name = &mt($type.' Documents');
+                }
+            }
 	    &Apache::lonhtmlcommon::add_breadcrumb(
 		      {'href'=>$url.$cpinfo,
 		       'title'=>$name,
@@ -1370,7 +1377,7 @@
 }
 
 sub editor {
-    my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$which)=@_;
+    my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
 
     my $container= ($env{'form.pagepath'}) ? 'page'
 		                           : 'sequence';
@@ -1387,7 +1394,7 @@
     }
     
     my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
-	&breadcrumbs($folder);
+	&breadcrumbs($folder,$allowed,$type);
     $r->print($breadcrumbtrail);
     
 # ------------------------------------------------------------ Process commands
@@ -1489,7 +1496,6 @@
 	$r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
     }
     $r->print("\n</table>\n");
-    
     &print_paste_buffer($r,$container);
     return;
 }
@@ -2476,6 +2482,11 @@
     if ($env{'form.pagepath'}) {
        $env{'form.folderpath'}='';
     }
+    if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
+        $env{'form.folderpath'} = 'supplemental&'.
+                                  &escape(&mt('Supplemental '.$type.' Documents')).'&'.
+                                  $env{'form.folderpath'};
+    }
     &Apache::loncommon::store_course_settings('docs_folderpath',
                                                 {'pagepath' => 'scalar',
                                                  'folderpath' => 'scalar'});
@@ -2740,7 +2751,7 @@
        }
        $hadchanges=0;
        my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
-			   $upload_output);
+			   $upload_output,$type);
        if ($error) {
 	   $r->print('<p><span class="LC_error">'.$error.'</span></p>');
        }
@@ -2986,11 +2997,11 @@
 	   $folder='supplemental';
        }
        if ($folder =~ /^supplemental$/ &&
-	   $env{'form.folderpath'} =~ /^default\&/) {
-	   $env{'form.folderpath'}='supplemental&'.
-	       &escape(&mt('Supplemental '.$type.' Documents'));
+	   (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
+          $env{'form.folderpath'} = 'supplemental&'.
+                                    &escape(&mt('Supplemental '.$type.' Documents'));
        }
-       my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed);
+       my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
        if ($error) {
 	   $r->print('<p><span class="LC_error">'.$error.'</span></p>');
        }