--- loncom/interface/londocs.pm 2023/01/20 16:30:43 1.484.2.93.2.8 +++ loncom/interface/londocs.pm 2023/03/12 02:22:09 1.484.2.93.2.11 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.484.2.93.2.8 2023/01/20 16:30:43 raeburn Exp $ +# $Id: londocs.pm,v 1.484.2.93.2.11 2023/03/12 02:22:09 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -86,7 +86,7 @@ sub storemap { if ($map =~ /^default/) { $hadchanges=1; - } else { + } elsif ($contentchg) { $suppchanges=1; } return ($errtext,0); @@ -178,43 +178,62 @@ sub default_folderpath { } } -sub validate_folderpath { - my ($supplementalflag) = @_; - if ($env{'form.folderpath'} ne '') { - my @items = split(/\&/,$env{'form.folderpath'}); - my $badpath; - for (my $i=0; $i<@items; $i++) { - my $odd = $i%2; - if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) { - $badpath = 1; - } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) { - $badpath = 1; - } - last if ($badpath); - } - if ($badpath) { - delete($env{'form.folderpath'}); - } - } - return; -} - -sub validate_suppath { +sub validate_supppath { + my ($coursenum,$coursedom) = @_; + my $backto; if ($env{'form.supppath'} ne '') { my @items = split(/\&/,$env{'form.supppath'}); - my $badpath; + my ($badpath,$got_supp,$supppath,%supphidden,%suppids); for (my $i=0; $i<@items; $i++) { my $odd = $i%2; if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) { $badpath = 1; + last; + } elsif ($odd) { + my $suffix; + my $idx = $i-1; + if ($items[$i] =~ /^([^:]*)::(|1):::$/) { + $backto .= '&'.$1; + } elsif ($items[$idx] eq 'supplemental') { + $backto .= '&'.$items[$i]; + } else { + $backto .= '&'.$items[$i]; + my $is_hidden; + unless ($got_supp) { + my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom); + if (ref($supplemental) eq 'HASH') { + if (ref($supplemental->{'hidden'}) eq 'HASH') { + %supphidden = %{$supplemental->{'hidden'}}; + } + if (ref($supplemental->{'ids'}) eq 'HASH') { + %suppids = %{$supplemental->{'ids'}}; + } + } + $got_supp = 1; + } + if (ref($suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}) eq 'ARRAY') { + my $mapid = $suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}->[0]; + if ($supphidden{$mapid}) { + $is_hidden = 1; + } + } + $suffix = '::'.$is_hidden.':::'; + } + $supppath .= '&'.$items[$i].$suffix; + } else { + $supppath .= '&'.$items[$i]; + $backto .= '&'.$items[$i]; } - last if ($badpath); } if ($badpath) { delete($env{'form.supppath'}); + } else { + $supppath =~ s/^\&//; + $backto =~ s/^\&//; + $env{'form.supppath'} = $supppath; } } - return; + return $backto; } sub dumpcourse { @@ -907,7 +926,6 @@ END &storemap($coursenum, $coursedom, $folder.'.'.$container,1); unless ($fatal) { if ($folder =~ /^supplemental/) { - &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1); my ($errtext,$fatal) = &mapread($coursenum,$coursedom, $folder.'.'.$container); } @@ -1143,6 +1161,8 @@ sub docs_change_log { my ($title,$url) = split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'},3); if ($title eq '') { ($title) = ($url =~ m{/([^/]+)$}); + } elsif ($is_supp) { + $title = &Apache::loncommon::parse_supplemental_title($title); } $r->print(&LONCAPA::map::qtescape($title).':
' .&Apache::loncommon::help_open_menu('Navigation Screen', - 'Navigation_Screen',undef,'RAT') + $helpitem,undef,'RAT') .' | '.&mt('Tools:').' | ' .'
| '.
''. ' | '. - ' | '. + ' | '. &multiple_check_form('settings',\%lists,$canedit). ' | '. &Apache::loncommon::end_data_table_row(); @@ -3854,12 +3897,14 @@ sub is_supplemental_title { sub entryline { my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups, - $ltitoolsref,$canedit,$isencrypted,$navmapref,$hostname)=@_; - my ($foldertitle,$renametitle,$oldtitle); + $ltitoolsref,$canedit,$isencrypted,$ishidden,$navmapref,$hostname)=@_; + my ($foldertitle,$renametitle,$oldtitle,$encodedtitle); if (&is_supplemental_title($title)) { ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title); + $encodedtitle=$title; } else { $title=&HTML::Entities::encode($title,'"<>&\''); + $encodedtitle=$title; $renametitle=$title; $foldertitle=$title; } @@ -4081,6 +4126,7 @@ END my $ispage; my $containerarg; my $folderurl; + my $plainurl; if ($uploaded) { if (($extension eq 'sequence') || ($extension eq 'page')) { $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/; @@ -4099,7 +4145,7 @@ END $url='/adm/supplemental?'; } } else { - &Apache::lonnet::allowuploaded('/adm/coursedoc',$url); + $plainurl = $url; } } @@ -4225,6 +4271,22 @@ END } $nomodal = 1; } + } elsif (($uploaded) && (!$allowed) && ($url ne '/adm/supplemental?')) { + my $embstyle=&Apache::loncommon::fileembstyle($extension); + unless ($embstyle eq 'ssi') { + if (($embstyle eq 'img') + || ($embstyle eq 'emb') + || ($embstyle eq 'wrp')) { + $url='/adm/wrapper'.$url; + } elsif ($url !~ /\.(sequence|page)$/) { + $url='/adm/coursedocs/showdoc'.$url; + } + } + } + unless ($allowed && $env{'request.role.adv'}) { + if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) { + $hiddenres = 1; + } } } my ($rand_pick_text,$rand_order_text,$hiddenfolder); @@ -4236,6 +4298,9 @@ END if (!$allowed && $supplementalflag) { $folderpath.=$containerarg.'&'.$foldername; $url.='folderpath='.&escape($folderpath); + if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) { + $hiddenfolder = 1; + } } else { my $rpicknum = (&LONCAPA::map::getparameter($orderidx, 'parameter_randompick'))[0]; @@ -4321,7 +4386,7 @@ $form_end; $url .= ($url =~ /\?/) ? '&':'?'; $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"'); if ($title) { - $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"'); + $url .= '&title='.$encodedtitle; } if ((($isexternal) || ($isexttool)) && $orderidx) { $url .= '&idx='.$orderidx; @@ -4376,9 +4441,18 @@ $form_end; $reinit = &mt('(re-initialize course to access)'); } $line.=''.$editlink.$renamelink;
- my $link;
+ my ($link,$nolink);
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
- $line.=' | ';
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
- $line.=''.$title.'';
+ if ($nolink) {
+ $line.=$title;
+ } else {
+ $line.=''.$title.'';
+ }
+ if (!$allowed && $supplementalflag && $canedit && $isfolder) {
+ my $editicon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';
+ my $editurl = $url;
+ $editurl =~ s{^\Q/adm/supplemental?\E}{/adm/coursedocs?command=direct&forcesupplement=1&};
+ $line .= ' '.''.
+ ' | ";
$rand_pick_text = ' ' if ($rand_pick_text eq '');
$rand_order_text = ' ' if ($rand_order_text eq '');
- if (($allowed) && ($folder!~/^supplemental/)) {
- my %lt=&Apache::lonlocal::texthash(
- 'hd' => 'Hidden',
- 'ec' => 'URL hidden');
- my ($enctext,$hidtext);
- if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
- $enctext = ' checked="checked"';
- if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
- push(@{$filtersref->{'encrypturl'}},$orderidx);
- }
+ if ($uploaded && $url && !$isfolder && !$ispage) {
+ if (($plainurl ne '') && ($env{'request.role.adv'} || $allowed || !$hiddenres)) {
+ &Apache::lonnet::allowuploaded('/adm/coursedoc',$plainurl);
}
+ }
+ if ($allowed) {
+ my %lt=&Apache::lonlocal::texthash(
+ 'hd' => 'Hidden',
+ 'ec' => 'URL hidden');
+ my ($enctext,$hidtext,$formhidden,$formurlhidden);
if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
$hidtext = ' checked="checked"';
- if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
+ if (($ishash) && (ref($filtersref->{'hiddenresource'}) eq 'ARRAY')) {
push(@{$filtersref->{'hiddenresource'}},$orderidx);
}
}
- my $formhidden = 'edit_hiddenresource_'.$orderidx;
- my $formurlhidden = 'edit_encrypturl_'.$orderidx;
- $line.=(<