--- loncom/interface/londocs.pm 2023/09/06 13:35:14 1.484.2.93.2.15 +++ loncom/interface/londocs.pm 2025/03/15 03:08:02 1.484.2.93.2.19 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.484.2.93.2.15 2023/09/06 13:35:14 raeburn Exp $ +# $Id: londocs.pm,v 1.484.2.93.2.19 2025/03/15 03:08:02 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -716,7 +716,7 @@ sub group_import { my $marker = $2; my $info = $3; my ($toolid,$toolprefix,$tooltype,%toolhash,%toolsettings); - my @extras = ('linktext','explanation','crslabel','crstitle','crsappend'); + my @extras = ('linktext','explanation','crslabel','crstitle','crsappend','returnurl','backtourl'); my @toolinfo = split(/:/,$info); if ($residx) { %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum); @@ -733,7 +733,8 @@ sub group_import { $toolid =~ s/\D//g; ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'}, $toolhash{'linktext'},$toolhash{'explanation'},$toolhash{'crslabel'}, - $toolhash{'crstitle'},$toolhash{'crsappend'},$toolhash{'gradable'}) = @toolinfo; + $toolhash{'crstitle'},$toolhash{'crsappend'},$toolhash{'gradable'}, + $toolhash{'returnurl'},$toolhash{'backtourl'}) = @toolinfo; foreach my $item (@extras) { $toolhash{$item} = &unescape($toolhash{$item}); } @@ -820,6 +821,14 @@ sub group_import { } } } + if ($tools{'crsconf'}{'returnurl'}) { + unless ($toolhash{'returnurl'} eq 'custom') { + delete($toolhash{'backtourl'}); + } + } else { + delete($toolhash{'returnurl'}); + delete($toolhash{'backtourl'}); + } } if ($toolhash{'passback'}) { my $gradesecret = UUID::Tiny::create_uuid_as_string(UUID_V4); @@ -848,6 +857,14 @@ sub group_import { } } } + if ($residx) { + if (($toolsettings{'backtourl'} ne '') && (!exists($toolhash{'backtourl'}))) { + push(@deleted,'backtourl'); + } + if (($toolsettings{'returnurl'} ne '') && (!exists($toolhash{'returnurl'}))) { + push(@deleted,'returnurl'); + } + } my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum); if ($putres eq 'ok') { if (@deleted) { @@ -4605,7 +4622,7 @@ END $nomodal = 1; } } - my ($checkencrypt,$shownurl); + my $checkencrypt; if (!$env{'request.role.adv'}) { if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) || ($isencrypted) || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) { @@ -4625,7 +4642,7 @@ END my $currenc = $env{'request.enc'}; $env{'request.enc'} = 1; $shownsymb = &Apache::lonenc::encrypted($symb); - $shownurl = &Apache::lonenc::encrypted($url); + my $shownurl = &Apache::lonenc::encrypted($url); if (&Apache::lonnet::symbverify($symb,$url)) { $url = $shownurl; } else { @@ -4640,7 +4657,8 @@ END $url = &Apache::lonnet::clutter($url); } } - $shownurl = $url; + } else { + $url = ''; } unless ($env{'request.role.adv'}) { if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) { @@ -4651,8 +4669,8 @@ END $hiddenres = 1; } } - if ($url ne '') { - $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb); + if (($url ne '') && ($shownsymb ne '')) { + $url .= (($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb); } } } elsif ($supplementalflag) { @@ -4681,7 +4699,7 @@ END } $nomodal = 1; } - } elsif (($uploaded) && (!$allowed) && ($url ne '/adm/supplemental?')) { + } elsif (($uploaded) && ($url ne '/adm/supplemental?') && ($url ne '/adm/coursedocs?')) { my $embstyle=&Apache::loncommon::fileembstyle($extension); unless ($embstyle eq 'ssi') { if (($embstyle eq 'img') @@ -4787,7 +4805,7 @@ $form_common."\n". ''. $form_end; } - } elsif ($supplementalflag && !$allowed) { + } elsif ($supplementalflag) { my $isexttool; if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) { $url='/adm/wrapper'.$url; @@ -4871,12 +4889,20 @@ $form_end; $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&'); } } - if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) { + if (($nomodal) && ($hostname ne '')) { $link = 'http://'.$hostname.$url; } else { $link = $url; } - $link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.$anchor); + my $inhibitmenu; + if ((($supplementalflag) && ($allowed) && ($url =~ m{^/adm/wrapper/})) || + (($allowed) && (($url =~ m{^/adm/(viewclasslist|$match_domain/$match_username/aboutme)(\?|$)}) || + ($url =~ m{^/public/$match_domain/$match_courseid/syllabus(\?|$)})))) { + $inhibitmenu = 'only_body=1'; + } else { + $inhibitmenu = 'inhibitmenu=yes'; + } + $link = &js_escape($link.(($url=~/\?/)?'&':'?').$inhibitmenu.$anchor); if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage && !$uploaded) { if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) { $nolink = 1; @@ -5325,7 +5351,7 @@ sub short_urls { } my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum); $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef, - undef,undef,undef,undef,undef,\%currtiny,$readonly)); + undef,undef,undef,undef,undef,\%currtiny,undef,$readonly)); } $r->print(&endContentScreen()); } @@ -5936,8 +5962,11 @@ sub handler { } if ($env{'form.forcesupplement'}) { $supplementalflag=1; } if ($env{'form.forcestandard'}) { $supplementalflag=0; } - unless ($allowed) { $supplementalflag=1; } - unless ($standard) { $supplementalflag=1; } + unless (($supplementalflag) || + ($r->uri =~ m{^/adm/coursedocs/showdoc/uploaded/\Q$coursedom\E/\Q$coursenum\E/docs/})) { + unless ($allowed) { $supplementalflag=1; } + unless ($standard) { $supplementalflag=1; } + } my $toolsflag=0; if ($env{'form.tools'}) { $toolsflag=1; } @@ -6013,9 +6042,9 @@ sub handler { &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom); } } - -# If we are not allowed to make changes, all we can see are supplemental docs - if (!$allowed) { + +# If we are not allowed to make changes and this is supplemental content set folderpath + if ((!$allowed) && ($supplementalflag)) { unless ($env{'form.folderpath'} =~ /^supplemental/) { $env{'form.folderpath'} = &supplemental_base(); } @@ -6245,7 +6274,8 @@ sub handler { if ($supplementalflag) { my $title = &HTML::Entities::encode($env{'form.title'},'\'"<>&'); my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); - $args = {'bread_crumbs' => $brcrum}; + $args = {'bread_crumbs' => $brcrum, + 'bread_crumbs_nomenu' => 1}; } else { $args = {'force_register' => $showdoc}; } @@ -6274,8 +6304,13 @@ sub handler { } } my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype); + my $args = {'bread_crumbs' => $brcrum}; + unless (($env{'form.folderpath'} eq '') || + ($env{'form.folder'} eq 'supplemental')) { + $args->{'bread_crumbs_nomenu'} = 1; + } $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef, - {'bread_crumbs' => $brcrum,})); + $args)); } else { my ($breadtext,$breadtitle,$helpitem); $breadtext = "$crstype Editor";