[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /interface loncommon.pm londocs.pm lonnavdisplay.pm /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Tue Aug 6 20:03:34 EDT 2013


raeburn		Wed Aug  7 00:03:34 2013 EDT

  Modified files:              
    /loncom/interface	londocs.pm loncommon.pm lonnavdisplay.pm 
    /loncom/auth	lonroles.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Supplemental Content Tab not shown on Course Contents screen unless 
    user has mdc priv in course, or Supplemental content contains one or
    more resources (folders not counted).
  
  
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.556 loncom/interface/londocs.pm:1.557
--- loncom/interface/londocs.pm:1.556	Tue Aug  6 14:18:52 2013
+++ loncom/interface/londocs.pm	Wed Aug  7 00:03:24 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.556 2013/08/06 14:18:52 raeburn Exp $
+# $Id: londocs.pm,v 1.557 2013/08/07 00:03:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,6 +56,7 @@
 my %alreadyseen=();
 
 my $hadchanges;
+my $suppchanges;
 
 
 my %help=();
@@ -79,7 +80,11 @@
 			      $map,1,$report);
     if ($errtext) { return ($errtext,2); }
 
-    $hadchanges=1;
+    if ($map =~ /^default/) {
+        $hadchanges=1;
+    } else {
+        $suppchanges=1;
+    }
     return ($errtext,0);
 }
 
@@ -402,6 +407,11 @@
     }
     my ($errtext,$fatal) =
         &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
+    unless ($fatal) {
+        if ($folder =~ /^supplemental/) {
+            &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
+        }
+    }
     return ($errtext,$fatal,$fixuperrors);
 }
 
@@ -4976,7 +4986,19 @@
                                $supplementalflag,\%suporderhash,$iconpath,$pathitem);
            if ($error) {
               $r->print('<p><span class="LC_error">'.$error.'</span></p>');
-           }
+           } else {
+               if ($suppchanges) {
+                   my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
+                   my @ids=&Apache::lonnet::current_machine_ids();
+                   foreach my $server (keys(%servers)) {
+                       next if (grep(/^\Q$server\E$/, at ids));
+                       my $hashid=$coursenum.':'.$coursedom;
+                       &Apache::lonnet::remote_devalidate_cache($server,'suppcount',$hashid);
+                   }
+                   &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
+                   undef($suppchanges);
+               }  
+           } 
         }
     } elsif ($supplementalflag) {
         my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1142 loncom/interface/loncommon.pm:1.1143
--- loncom/interface/loncommon.pm:1.1142	Mon Jul 22 20:50:01 2013
+++ loncom/interface/loncommon.pm	Wed Aug  7 00:03:25 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1142 2013/07/22 20:50:01 raeburn Exp $
+# $Id: loncommon.pm,v 1.1143 2013/08/07 00:03:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -14576,6 +14576,30 @@
     return $title;
 }
 
+sub recurse_supplemental {
+    my ($cnum,$cdom,$suppmap,$numfiles,$errors) = @_;
+    if ($suppmap) {
+        my ($errtext,$fatal) = &LONCAPA::map::mapread('/uploaded/'.$cdom.'/'.$cnum.'/'.$suppmap);
+        if ($fatal) {
+            $errors ++;
+        } else {
+            if ($#LONCAPA::map::resources > 0) {
+                foreach my $res (@LONCAPA::map::resources) {
+                    my ($title,$src,$ext,$type,$status)=split(/\:/,$res);
+                    if (($src ne '') && ($status eq 'res')) {
+                        if ($src =~ m{^\Q/uploaded/$cdom/$cnum/\E(supplemental_/d+\.sequence)$}) {
+                            $numfiles = &recurse_supplemental($cnum,$cdom,$1,$numfiles);
+                        } else {
+                            $numfiles ++;
+                        }
+                    }
+                }
+            }
+        }
+    }
+    return ($numfiles,$errors);
+}
+
 sub symb_to_docspath {
     my ($symb) = @_;
     return unless ($symb);
Index: loncom/interface/lonnavdisplay.pm
diff -u loncom/interface/lonnavdisplay.pm:1.22 loncom/interface/lonnavdisplay.pm:1.23
--- loncom/interface/lonnavdisplay.pm:1.22	Mon Jan  2 23:10:58 2012
+++ loncom/interface/lonnavdisplay.pm	Wed Aug  7 00:03:25 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavdisplay.pm,v 1.22 2012/01/02 23:10:58 www Exp $
+# $Id: lonnavdisplay.pm,v 1.23 2013/08/07 00:03:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -293,7 +293,16 @@
 
     $r->print("\n".'<ul class="LC_TabContentBigger" id="mainnav">'."\n");
     $r->print('<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b>       '.&mt('Main Content').'       </b></a></li>'."\n");
-    $r->print('<li '.(($mode eq 'supplemental')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>');
+    my $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+    my ($suppcount,$errors);
+    unless ($allowed) {
+        my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+        my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; 
+        ($suppcount,$errors) = &Apache::lonnet::get_numsuppfiles($cnum,$cdom);
+    }
+    if ($allowed || $suppcount) { 
+        $r->print('<li '.(($mode eq 'supplemental')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>');
+    }
     $r->print('<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b>     '.&mt('Content Search').'     </b></a></li>'."\n");
     $r->print('<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b>      '.&mt('Content Index').'      </b></a></li>'."\n");
     $r->print("\n".'</ul>'."\n");
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.288 loncom/auth/lonroles.pm:1.289
--- loncom/auth/lonroles.pm:1.288	Tue Jun  4 22:20:31 2013
+++ loncom/auth/lonroles.pm	Wed Aug  7 00:03:29 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.288 2013/06/04 22:20:31 raeburn Exp $
+# $Id: lonroles.pm,v 1.289 2013/08/07 00:03:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -532,6 +532,7 @@
                             my ($feeds,$syllabus_time);
                             &Apache::lonrss::advertisefeeds($cnum,$cdom,undef,\$feeds);
                             &Apache::lonnet::appenv({'request.course.feeds' => $feeds});
+                            &Apache::lonnet::get_numsuppfiles($cnum,$cdom,1);
                             unless ($env{'course.'.$cdom.'_'.$cnum.'.updatedsyllabus'}) {
                                 unless (($env{'course.'.$cdom.'_'.$cnum.'.externalsyllabus'}) ||
                                         ($env{'course.'.$cdom.'_'.$cnum.'.uploadedsyllabus'})) {
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1235 loncom/lonnet/perl/lonnet.pm:1.1236
--- loncom/lonnet/perl/lonnet.pm:1.1235	Tue Aug  6 23:17:39 2013
+++ loncom/lonnet/perl/lonnet.pm	Wed Aug  7 00:03:33 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1235 2013/08/06 23:17:39 raeburn Exp $
+# $Id: lonnet.pm,v 1.1236 2013/08/07 00:03:33 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -9637,6 +9637,26 @@
     return undef;
 }
 
+sub get_numsuppfiles {
+    my ($cnum,$cdom,$ignorecache)=@_;
+    my $hashid=$cnum.':'.$cdom;
+    my ($suppcount,$cached);
+    unless ($ignorecache) {
+        ($suppcount,$cached) = &is_cached_new('suppcount',$hashid);
+    }
+    unless (defined($cached)) {
+        my $chome=&homeserver($cnum,$cdom);
+        unless ($chome eq 'no_host') {
+            ($suppcount,my $errors) = (0,0);
+            my $suppmap = 'supplemental.sequence';
+            ($suppcount,$errors) = 
+                &Apache::loncommon::recurse_supplemental($cnum,$cdom,$suppmap,$suppcount,$errors);
+        }
+        &do_cache_new('suppcount',$hashid,$suppcount,600);
+    }
+    return $suppcount;
+}
+
 #
 # EXT resource caching routines
 #
@@ -12862,6 +12882,10 @@
 values that are the resource value.  I believe that the timestamps and
 versions are also returned.
 
+get_numsuppfiles($cnum,$cdom) : retrieve number of files in a course's
+supplemental content area. This routine caches the number of files for 
+10 minutes.
+
 =back
 
 =head2 Course Modification


More information about the LON-CAPA-cvs mailing list