--- rat/lonpage.pm 2018/02/28 23:03:10 1.120.4.4 +++ rat/lonpage.pm 2017/02/20 18:29:33 1.121 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.120.4.4 2018/02/28 23:03:10 raeburn Exp $ +# $Id: lonpage.pm,v 1.121 2017/02/20 18:29:33 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; @@ -323,8 +322,8 @@ ENDEXT } } elsif ($cellemb{$_} eq 'ssi') { # --------------------------------------------------------- This is an SSI cell - my $prefix='p_'.$_.'_'; - my $idprefix='p_'.join('_',($mapid,$resid,'')); + my $prefix=$_.'_'; + my $idprefix= join('_',($mapid,$resid,'')); my %posthash=('request.prefix' => $prefix, 'LONCAPA_INTERNAL_no_discussion' => 'true', 'symb' => $symb); @@ -357,9 +356,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')) { @@ -446,8 +442,6 @@ ENDEXT s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi; $output=~ s/\<((?:input|select|button|textarea)[^\>]+)id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 id="$idprefix$2" $3\>/gsi; - $output=~ - s/(\Qthis.form.elements['\E)(HW(?:VAL|CHK)_[^']+\'\]\.(?:value=\'|checked))/$1$prefix$2/gsi; if ($hastimer) { $output=~ s/\<(input[^\>]+name=\Q"$prefix\Eaccessbutton"[^\>]+)(?:\Qdocument.markaccess.submit();\E)([^\>]*)\>/\<$1pageTimer(this.form,'$prefix')$2\>/gsi; @@ -950,60 +944,25 @@ 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 = ''.$label.''; - $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 $hostname = $r->hostname(); + 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 = ''.$label.''; - $metainfo .= ' '.$pic.''."\n". - '\n"; + $metainfo .= ' '.$pic.''; } } }