[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonnavmaps.pm

raeburn raeburn at source.lon-capa.org
Tue Nov 29 10:13:20 EST 2016


raeburn		Tue Nov 29 15:13:20 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonnavmaps.pm 
  Log:
  - For 2.11
    - Backport 1.515 (part), 1.516 (part), 1.517, 1.521, 1.525, 1.526 (part)
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.509.2.4 loncom/interface/lonnavmaps.pm:1.509.2.5
--- loncom/interface/lonnavmaps.pm:1.509.2.4	Thu Oct 27 15:17:42 2016
+++ loncom/interface/lonnavmaps.pm	Tue Nov 29 15:13:19 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.509.2.4 2016/10/27 15:17:42 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.509.2.5 2016/11/29 15:13:19 raeburn Exp $
 
 #
 # Copyright Michigan State University Board of Trustees
@@ -996,7 +996,8 @@
             $linkopen = "";
             $linkclose = "";
         }
-        if ((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
+        if (((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) ||
+             (&Apache::lonnet::allowed('cev',$env{'request.course.id'}))) &&
             ($resource->symb=~/\_\_\_[^\_]+\_\_\_uploaded/)) {
             if (!$params->{'map_no_edit_link'}) {
                 my $icon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';
@@ -1541,7 +1542,8 @@
 	$result.='</form>';
     }
     if (($args->{'caller'} eq 'navmapsdisplay') &&
-        (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
+        ((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) ||
+         (&Apache::lonnet::allowed('cev',$env{'request.course.id'})))) {
         my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
         my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
         if ($env{'course.'.$env{'request.course.id'}.'.url'} eq 
@@ -2732,6 +2734,23 @@
     if (defined($pack_def)) { return [$pack_def,'resource']; }
     return [''];
 }
+
+sub recurseup_maps {
+    my ($self,$mapname) = @_;
+    my @recurseup;
+    if ($mapname) {
+        my $res = $self->getResourceByUrl($mapname);
+        if (ref($res)) {
+            my @pcs = split(/,/,$res->map_hierarchy());
+            shift(@pcs);
+            if (@pcs) {
+                @recurseup = map { &Apache::lonnet::declutter($self->getByMapPc($_)->src()); } reverse(@pcs);
+            }
+        }
+    }
+    return @recurseup;
+}
+
 #
 #  Determines the open/close dates for printing a map that
 #  encloses a resource.
@@ -2812,6 +2831,20 @@
 	if (defined($$useropt{$courselevel})) {
 	    return $$useropt{$courselevel};
 	}
+        if ($what =~ /\.(encrypturl|hiddenresource)$/) {
+            unless ($recursed) {
+                @recurseup = $self->recurseup_maps($mapname);
+                $recursed = 1;
+            }
+            foreach my $item (@recurseup) {
+                my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what;
+                if (defined($$useropt{$norecursechk})) {
+                    if ($what =~ /\.(encrypturl|hiddenresource)$/) {
+                        return $$useropt{$norecursechk};
+                    }
+                }
+            }
+        }
     }
 
     # Check course -- group
@@ -2822,6 +2855,20 @@
 	if (defined($$courseopt{$grplevel})) {
 	    return $$courseopt{$grplevel};
 	}
+        if ($what =~ /\.(encrypturl|hiddenresource)$/) {
+            unless ($recursed) {
+                @recurseup = $self->recurseup_maps($mapname);
+                $recursed = 1;
+            }
+            foreach my $item (@recurseup) {
+                my $norecursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(all).'.$what;
+                if (defined($$courseopt{$norecursechk})) {
+                    if ($what =~ /\.(encrypturl|hiddenresource)$/) {
+                        return $$courseopt{$norecursechk};
+                    }
+                }
+            }
+        }
     }
 
     # Check course -- section
@@ -2834,6 +2881,20 @@
 	if (defined($$courseopt{$seclevel})) {
 	    return $$courseopt{$seclevel};
 	}
+        if ($what =~ /\.(encrypturl|hiddenresource)$/) {
+            unless ($recursed) {
+                @recurseup = $self->recurseup_maps($mapname);
+                $recursed = 1;
+            }
+            foreach my $item (@recurseup) {
+                my $norecursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(all).'.$what;
+                if (defined($$courseopt{$norecursechk})) {
+                    if ($what =~ /\.(encrypturl|hiddenresource)$/) {
+                        return $$courseopt{$norecursechk};
+                    }
+                }
+            }
+        }
     }
     # Check the map parameters themselves:
 
@@ -2852,6 +2913,20 @@
 	if (defined($$courseopt{$courselevel})) {
 	    return $$courseopt{$courselevel};
 	}
+        if ($what =~ /\.(encrypturl|hiddenresource)$/) {
+            unless ($recursed) {
+                @recurseup = $self->recurseup_maps($mapname);
+                $recursed = 1;
+            }
+            foreach my $item (@recurseup) {
+                my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what;
+                if (defined($$courseopt{$norecursechk})) {
+                    if ($what =~ /\.(encrypturl|hiddenresource)$/) {
+                        return $$courseopt{$norecursechk};
+                    }
+                }
+            }
+        }
     }
     return undef;		# Unefined if we got here.
 }




More information about the LON-CAPA-cvs mailing list