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

raeburn raeburn@source.lon-capa.org
Sun, 18 Oct 2009 15:32:36 -0000


raeburn		Sun Oct 18 15:32:36 2009 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Users without editing rights using /adm/coursedocs to view Supplemental Documents: 
     - Do not display single "Tab".
     - Use &breadcrumbs() to generate breadcrumbs in standard location.
  - Eliminate unused first argument ($where) from breadcrumbs subroutine.    
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.394 loncom/interface/londocs.pm:1.395
--- loncom/interface/londocs.pm:1.394	Sat Oct 17 00:09:26 2009
+++ loncom/interface/londocs.pm	Sun Oct 18 15:32:36 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.394 2009/10/17 00:09:26 droeschl Exp $
+# $Id: londocs.pm,v 1.395 2009/10/18 15:32:36 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -998,7 +998,7 @@
 }
 
 sub breadcrumbs {
-    my ($where,$allowed,$type)=@_;
+    my ($allowed,$type)=@_;
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     my (@folders);
     if ($env{'form.pagepath'}) {
@@ -1013,6 +1013,15 @@
     my $isencrypted=0;
     my $ishidden=0;
     my $is_random_order=0;
+    if (!$allowed) {
+        my $description = $env{'course.'.$env{'request.course.id'}.'.description'};
+        &Apache::lonhtmlcommon::add_breadcrumb(
+                                               {'href' => '/adm/menu',
+                                                'title'=> 'Go to main menu',
+                                                'text' => $description,
+                                               });
+        $plain .= $description.' >';
+    }
     while (@folders) {
 	my $folder=shift(@folders);
     	my $foldername=shift(@folders);
@@ -1503,9 +1512,14 @@
         $LONCAPA::map::resources[$idx]='';
     }
 
-    my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
-	&breadcrumbs($folder,$allowed,$type);
-    $r->print($breadcrumbtrail);
+    my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
+    if ($allowed) {
+        ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
+	    &breadcrumbs($allowed,$type);
+        $r->print($breadcrumbtrail);
+    } else {
+        $randompick = -1;
+    }
 
 # ------------------------------------------------------------ Process commands
 
@@ -2756,12 +2770,14 @@
                      'Docs_Adding_Course_Doc')
         );
     } else {
-        my $lc_type = lc($type);
-        &Apache::lonhtmlcommon::add_breadcrumb({
-            href=>"/adm/coursedocs",text=>"Supplemental $lc_type documents"});
-
+        my $folder=$env{'form.folder'};
+        if ($folder eq '' || $folder eq 'supplemental') {
+            $env{'form.folderpath'} = 'supplemental&'.
+                                      &escape(&mt('Supplemental '.$type.' Documents'));
+        }
+        my ($breadcrumbtrail) = &breadcrumbs($allowed,$type);
         $r->print(&Apache::loncommon::start_page("Supplemental documents").
-                  &Apache::lonhtmlcommon::breadcrumbs());
+                  $breadcrumbtrail);
     }
 
   my %allfiles = ();
@@ -2994,33 +3010,35 @@
 HIDDENFORM
     }
 # --------------------------------------------------------- Main tab structure
-    
+ 
     my $activeClass = 1;
     my $active = '';
 
-    $r->print('<ul class="LC_TabContentBigger" id="mainnav">');
-    if (($standard) && ($allowed) && (!$forcesupplement) && (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'}eq"" || ($env{'form.pagepath'}))) {
-        if($activeClass == 1){
-           $active = 'class="active"';
-	   $activeClass = 0;
-	}
-    }
-    if ($allowed){
+    if ($allowed) {
+        $r->print('<ul class="LC_TabContentBigger" id="mainnav">');
+        if (($standard) && ($allowed) && (!$forcesupplement) && (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'}eq"" || ($env{'form.pagepath'}))) {
+            if($activeClass == 1){
+                $active = 'class="active"';
+	        $activeClass = 0;
+	    }
+        }
         $r->print('<li '.$active.' onclick="javascript:showPage(this,\'mainCourseDocuments\',\'mainnav\',\'maincoursedoc\');"><a href="#"><b>'.&mt('Main Course Documents').'</b></a></li>');
-    }
-    $active = '';
-    if (!$forcestandard || ($env{'form.folderpath'}=~/^supplemental/)) {
-        if($activeClass == 1){
-           $active = 'class="active"';
+        $active = '';
+        if (!$forcestandard || ($env{'form.folderpath'}=~/^supplemental/)) {
+            if($activeClass == 1){
+                $active = 'class="active"';
+            }
         }
+        $r->print('<li '.$active.' onclick="javascript:showPage(this,\'supplCourseDocuments\',\'mainnav\',\'maincoursedoc\');"><a href="#"><b>'.&mt('Supplemental Course Documents').'</b></a></li>');
+        $r->print('</ul>');
+    } else {
+        $r->print('<br />');
     }
-    $r->print('<li '.$active.' onclick="javascript:showPage(this,\'supplCourseDocuments\',\'mainnav\',\'maincoursedoc\');"><a href="#"><b>'.&mt('Supplemental Course Documents').'</b></a></li>');
-    $r->print('</ul>'
-             .'<div class="LC_Box" style="clear:both;margin:0;">'
+    $r->print('<div class="LC_Box" style="clear:both;margin:0;">'
              .'<div id="maincoursedoc" style="margin:0 0;padding:0 0;">');
 # --------------------------------------------------------- Standard documents
        my $savefolderpath;
-       my $active = 'style="display: none;"';
+       $active = 'style="display: none;"';
        if($activeClass == 0){
           $active = 'style="display: block;"';
        }
@@ -3272,7 +3290,7 @@
        if ($env{'form.pagepath'}) {
        }
 # ----------------------------------------------------- Supplemental documents
-       my $active = 'style="display: none;"';
+       $active = 'style="display: none;"';
        if($activeClass == 1){
           $active = 'style="display: block;"';
        }