--- rat/lonpage.pm 2017/09/11 12:30:55 1.124
+++ rat/lonpage.pm 2018/02/28 14:41:47 1.126
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Page Handler
#
-# $Id: lonpage.pm,v 1.124 2017/09/11 12:30:55 raeburn Exp $
+# $Id: lonpage.pm,v 1.126 2018/02/28 14:41:47 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,6 +42,7 @@ use Apache::lonlocal;
use Apache::lonmenu;
use Apache::lonhomework;
use Apache::lonparmset;
+use Apache::lonenc();
use HTML::TokeParser;
use GDBM_File;
use Apache::lonsequence;
@@ -323,8 +324,8 @@ ENDEXT
}
} elsif ($cellemb{$_} eq 'ssi') {
# --------------------------------------------------------- This is an SSI cell
- my $prefix=$_.'_';
- my $idprefix= join('_',($mapid,$resid,''));
+ my $prefix='p_'.$_.'_';
+ my $idprefix= 'p_'.join('_',($mapid,$resid,''));
my %posthash=('request.prefix' => $prefix,
'LONCAPA_INTERNAL_no_discussion' => 'true',
'symb' => $symb);
@@ -947,24 +948,61 @@ sub get_buttons {
'';
}
}
- if (($env{'request.course.id'}) && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
+ if ($env{'request.course.id'}) {
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my $file=&Apache::lonnet::declutter($hash->{'src_'.$rid});
- my ($cfile,$home,$switchserver,$forceedit,$forceview) =
- &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,$hash->{'src_'.$rid},$symb);
- if ($cfile ne '') {
- my $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
- $forceedit,1,$symb,undef,
- &escape($env{'form.title'}),
- $hostname);
- if ($jscall) {
+ my $editbutton = '';
+ if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
+ my ($cfile,$home,$switchserver,$forceedit,$forceview) =
+ &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,$hash->{'src_'.$rid},$symb);
+ if ($cfile ne '') {
+ my $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
+ $forceedit,1,$symb,undef,
+ &escape($env{'form.title'}),
+ $hostname);
+ if ($jscall) {
+ $editbutton = 1;
+ my $icon = 'pcstr.png';
+ my $label = &mt('Edit');
+ my $title = &mt('Edit this resource');
+ my $pic = '';
+ $metainfo .= ' '.$pic.'';
+ }
+ }
+ }
+ if ((!$editbutton) && ($file=~/$LONCAPA::assess_re/)) {
+ my $url = &Apache::lonnet::clutter($file);
+ my $viewsrcbutton;
+ if ((&Apache::lonnet::allowed('cre','/')) &&
+ (&Apache::lonnet::metadata($url,'sourceavail') eq 'open')) {
+ $viewsrcbutton = 1;
+ } elsif (&Apache::lonnet::allowed('vxc',$env{'request.course.id'})) {
+ if ($url =~ m{^\Q/res/$cdom/\E($LONCAPA::match_username)/}) {
+ my $auname = $1;
+ if (($env{'request.course.adhocsrcaccess'} ne '') &&
+ (grep(/^\Q$auname\E$/,split(/,/,$env{'request.course.adhocsrcaccess'})))) {
+ $viewsrcbutton = 1;
+ }
+ }
+ }
+ if ($viewsrcbutton) {
my $icon = 'pcstr.png';
- my $label = &mt('Edit');
- my $title = &mt('Edit this resource');
+ my $label = &mt('View Source');
+ my $title = &mt('View source code');
+ my $jsrid = $rid;
+ $jsrid =~ s/\./_/g;
+ my $showurl = &escape(&Apache::lonenc::check_encrypt($url));
my $pic = '';
- $metainfo .= ' '.$pic.'';
+ $metainfo .= ' '.$pic.''."\n".
+ '\n";
}
}
}