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

raeburn raeburn@source.lon-capa.org
Fri, 16 Oct 2009 19:00:44 -0000


raeburn		Fri Oct 16 19:00:44 2009 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Display supplemental docs to users without editing privileges.
  - Eliminate unused columns when displaying supplemental docs to editors
  - Replace switch based on cc role with switch based on mdc priv($allowed).
  - Ensure that folderpath is preserved for supplemental docs when non-editor
    so breadcrumbs allow navigation 
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.392 loncom/interface/londocs.pm:1.393
--- loncom/interface/londocs.pm:1.392	Fri Oct 16 18:50:18 2009
+++ loncom/interface/londocs.pm	Fri Oct 16 19:00:44 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.392 2009/10/16 18:50:18 raeburn Exp $
+# $Id: londocs.pm,v 1.393 2009/10/16 19:00:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1032,11 +1032,7 @@
             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');
-                }
+                $name = &mt('Supplemental '.$type.' Documents');
             }
 	    &Apache::lonhtmlcommon::add_breadcrumb(
 		      {'href'=>$url.$cpinfo,
@@ -1493,7 +1489,6 @@
 
 sub editor {
     my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
-
     my $container= ($env{'form.pagepath'}) ? 'page'
 		                           : 'sequence';
 
@@ -1632,18 +1627,21 @@
         $shown++;
     }
     if ($shown) {
-    $r->print(&Apache::loncommon::start_data_table()
-             .&Apache::loncommon::start_data_table_header_row()
-             .'<th colspan="2">'.&mt('Move').'</th>'
-             .'<th>'.&mt('Actions').'</th>'
-             .'<th colspan="2">'.&mt('Document').'</th>'
-             .'<th colspan="4">'.&mt('Settings').'</th>'
-             .&Apache::loncommon::end_data_table_header_row()
-             .$output
-             .&Apache::loncommon::end_data_table()
-    )
-    } 
-    unless($shown) {
+        $r->print(&Apache::loncommon::start_data_table());
+        if ($allowed) {
+            $r->print(&Apache::loncommon::start_data_table_header_row()
+                     .'<th colspan="2">'.&mt('Move').'</th>'
+                     .'<th>'.&mt('Actions').'</th>'
+                     .'<th colspan="2">'.&mt('Document').'</th>');
+            if ($folder !~ /^supplemental/) {
+                $->print('<th colspan="4">'.&mt('Settings').'</th>');
+            }
+            $r->print(&Apache::loncommon::end_data_table_header_row());
+        }
+        $r->print($output
+                 .&Apache::loncommon::end_data_table()
+        );
+    } else {
         $r->print('<p class="LC_info">'
                  .&mt('Currently no documents.')
                  .'</p>'
@@ -1793,7 +1791,6 @@
 
 sub entryline {
     my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
-
     my ($foldertitle,$pagetitle,$renametitle);
     if (&is_supplemental_title($title)) {
 	($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
@@ -3008,8 +3005,8 @@
 	   $activeClass = 0;
 	}
     }
-    if($env{'request.role'}=~/^cc/){
-    $r->print('<li '.$active.' onclick="javascript:showPage(this,\'mainCourseDocuments\',\'mainnav\',\'maincoursedoc\');"><a href="#"><b>'.&mt('Main Course Documents').'</b></a></li>');
+    if ($allowed){
+        $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/)) {
@@ -3027,7 +3024,7 @@
        if($activeClass == 0){
           $active = 'style="display: block;"';
        }
-       if($env{'request.role'}=~/^cc/){
+       if ($allowed) {
        $r->print('<div class="LC_ContentBox" id="mainCourseDocuments" '.$active.'>');
        my $folder=$env{'form.folder'};
        if ($folder eq '' || $folder=~/^supplemental/) {
@@ -3288,7 +3285,7 @@
 	   (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
           $env{'form.folderpath'} = 'supplemental&'.
                                     &escape(&mt('Supplemental '.$type.' Documents'));
-       }else{
+       } elsif ($allowed) {
 	  $env{'form.folderpath'} = $savefolderpath;
        }
        $env{'form.pagepath'} = '';
@@ -3374,14 +3371,19 @@
                 'ff' => ['Special Documents',create_form_ul(create_list_elements(@specialdocs))]
                 );
 
-my $tid='2';
-my $varscd = 'Supplemental Course Documents';
-my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
-       if ($error) {
-           $r->print('<p><span class="LC_error">'.$error.'</span></p>');
+        my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
+        if ($error) {
+            $r->print('<p><span class="LC_error">'.$error.'</span></p>');
         }
-$r->print(&generate_edit_table($tid,$varscd,\%suporderhash));
-}
+        my $tid='2';
+        my $varscd = 'Supplemental Course Documents';
+        $r->print(&generate_edit_table($tid,$varscd,\%suporderhash));
+    } else {
+        my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
+        if ($error) {
+            $r->print('<p><span class="LC_error">'.$error.'</span></p>');
+        }
+    }
 
 
 $r->print('</div>');