--- loncom/interface/lonconfigsettings.pm 2022/02/15 04:28:01 1.59 +++ loncom/interface/lonconfigsettings.pm 2022/03/12 23:03:09 1.63 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: lonconfigsettings.pm,v 1.59 2022/02/15 04:28:01 raeburn Exp $ +# $Id: lonconfigsettings.pm,v 1.63 2022/03/12 23:03:09 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -117,7 +117,7 @@ ENDSCRIPT } } if (($context eq 'course') && ($phase eq 'display') && - (grep(/^linkprotection$/,@actions))) { + (grep(/^linkprot$/,@actions))) { my $allowed; my $home = &Apache::lonnet::homeserver($confname,$dom); unless ($home eq 'no_host') { @@ -126,14 +126,14 @@ ENDSCRIPT } if ($allowed) { my (@changeable,@settable); - if (ref($values->{'linkprotection'}) eq 'HASH') { - if (keys(%{$values->{'linkprotection'}})) { - my @current = sort { $a <=> $b } keys(%{$values->{'linkprotection'}}); + if (ref($values->{'linkprot'}) eq 'HASH') { + if (keys(%{$values->{'linkprot'}})) { + my @current = sort { $a <=> $b } keys(%{$values->{'linkprot'}}); if (@current) { for (my $i=0; $i<@current; $i++) { my $num = $current[$i]; - if (ref($values->{'linkprotection'}->{$num}) eq 'HASH') { - if ($values->{'linkprotection'}->{$num}->{'usable'}) { + if (ref($values->{'linkprot'}->{$num}) eq 'HASH') { + if ($values->{'linkprot'}->{$num}->{'usable'}) { push(@changeable,$i); } else { push(@settable,$i); @@ -148,39 +148,61 @@ $linkprot_check .= <{'linkprotection'}) eq 'HASH') { + if (ref($values->{'linkprot'}) eq 'HASH') { my $ltiauth; if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; @@ -382,14 +410,20 @@ $jscript my %domdefs = &Apache::lonnet::get_domain_defaults($dom); $ltiauth = $domdefs{'crsltiauth'}; } - my $posslti = scalar(keys(%{$values->{'linkprotection'}})); + my $ishome; + my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; + unless (($chome eq 'no_host') || ($chome eq '')) { + my @ids=&Apache::lonnet::current_machine_ids(); + foreach my $id (@ids) { if ($id eq $chome) { $ishome=1; } } + } + my $posslti = scalar(keys(%{$values->{'linkprot'}})); for (my $i=0; $i<=$posslti; $i++) { my $num = $i; if ($i == $posslti) { $num = 'add'; } - if (ref($values->{'linkprotection'}->{$i}) eq 'HASH') { - if ($values->{'linkprotection'}->{$i}->{'usable'}) { + if (ref($values->{'linkprot'}->{$i}) eq 'HASH') { + if ($values->{'linkprot'}->{$i}->{'usable'}) { $onload .= "toggleLinkProt(document.display,'$num','secret');"; } } @@ -397,6 +431,9 @@ $jscript $onload .= "toggleLinkProtReqUser(document.display,'requser','optional','1','block','$num');". "toggleLinkProtReqUser(document.display,'mapuser','userfield','other','inline-block','$num');"; } + if ($ishome) { + $onload .= "uncheckLinkProtMakeVis('visible','$num');"; + } } } }