--- rat/lonpage.pm 2017/10/14 22:16:59 1.120.4.3
+++ rat/lonpage.pm 2017/09/11 12:30:55 1.124
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Page Handler
#
-# $Id: lonpage.pm,v 1.120.4.3 2017/10/14 22:16:59 raeburn Exp $
+# $Id: lonpage.pm,v 1.124 2017/09/11 12:30:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,7 +42,6 @@ use Apache::lonlocal;
use Apache::lonmenu;
use Apache::lonhomework;
use Apache::lonparmset;
-use Apache::lonenc();
use HTML::TokeParser;
use GDBM_File;
use Apache::lonsequence;
@@ -186,6 +185,7 @@ sub handler {
my $fn=$env{'request.course.fn'};
if (-e "$fn.db") {
my %buttonshide;
+ my $hostname = $r->hostname();
if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) {
# ------------------------------------------------------------------- Hash tied
my $firstres=$hash{'map_start_'.$requrl};
@@ -357,9 +357,6 @@ ENDEXT
$posthash{'all_submit'}='yes';
}
}
- if ($env{'environment.remote'} eq 'on') {
- $posthash{'inhibitmenu'} = 'yes';
- }
my $output=Apache::lonnet::ssi($src,%posthash);
$output=~s|//(\s*)?\s||gs;
if (($target eq 'tex') || ($target eq 'tex_answer')) {
@@ -752,7 +749,7 @@ ENDEXT
my $avespan=$lcm/($#colcont+1);
for ($j=0;$j<=$#colcont;$j++) {
my $rid=$colcont[$j];
- my $metainfo =&get_buttons(\%hash,$rid,\%buttonshide).'
';
+ my $metainfo =&get_buttons(\%hash,$rid,\%buttonshide,$hostname).'
';
unless (($target eq 'tex') || ($target eq 'tex_answer')) {
$r->print('
{'src_'.$rid});
@@ -950,60 +947,24 @@ sub get_buttons {
'';
}
}
- if ($env{'request.course.id'}) {
+ if (($env{'request.course.id'}) && (&Apache::lonnet::allowed('mdc',$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 $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'}));
- 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 ($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 $icon = 'pcstr.png';
- 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 $label = &mt('Edit');
+ my $title = &mt('Edit this resource');
my $pic = '';
- $metainfo .= ' '.$pic.''."\n".
- '\n";
+ $metainfo .= ' '.$pic.'';
}
}
}
|