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

raeburn raeburn at source.lon-capa.org
Mon Sep 3 22:22:31 EDT 2018


raeburn		Tue Sep  4 02:22:31 2018 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonmenu.pm 
  Log:
  - For 2.11
    Backport 1.480, 1.481
  
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.369.2.72 loncom/interface/lonmenu.pm:1.369.2.73
--- loncom/interface/lonmenu.pm:1.369.2.72	Mon Sep  3 14:30:16 2018
+++ loncom/interface/lonmenu.pm	Tue Sep  4 02:22:30 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.369.2.72 2018/09/03 14:30:16 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.73 2018/09/04 02:22:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1486,8 +1486,9 @@
     }
 
     my $editbutton = '';
+    my $viewsrcbutton = '';
 #
-# Determine whether or not to display 'Edit' icon/button
+# Determine whether or not to display 'Edit' or 'View Source' icon/button
 #
     if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
         my $file=&Apache::lonnet::declutter($env{'request.filename'});
@@ -1561,6 +1562,29 @@
                     $editbutton = &get_editbutton($cfile,$home,$switchserver,
                                                   $forceedit,$forceview,$forcereg);
                 }
+                if ((($cfile eq '') || (!$editbutton)) &&
+                    ($resurl =~ /$LONCAPA::assess_re/)) {
+                    my $showurl = &Apache::lonnet::clutter($resurl);
+                    if ((&Apache::lonnet::allowed('cre','/')) &&
+                        (&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open')) {
+                        $viewsrcbutton = 1;
+                    } elsif (&Apache::lonnet::allowed('vxc',$env{'request.course.id'})) {
+                        if ($showurl =~ m{^\Q/res/$cdom/\E($match_username)/}) {
+                            my $auname = $1;
+                            if (($env{'request.course.adhocsrcaccess'} ne '') &&
+                                (grep(/^\Q$auname\E$/,split(/,/,$env{'request.course.adhocsrcaccess'})))) {
+                                $viewsrcbutton = 1;
+                            } elsif ((&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open') &&
+                                     (&Apache::lonnet::allowed('bre','/'))) {
+                                $viewsrcbutton = 1;
+                            }
+                        }
+                    }
+                    if ($viewsrcbutton) {
+                        &switch('','',6,1,'pcstr.png','View Source','resource[_2]','open_source()',
+                                'View source code');
+                    }
+                }
             }
         }
     }




More information about the LON-CAPA-cvs mailing list