version 1.59, 2022/02/15 04:28:01
|
version 1.62, 2022/03/12 21:24:17
|
Line 117 ENDSCRIPT
|
Line 117 ENDSCRIPT
|
} |
} |
} |
} |
if (($context eq 'course') && ($phase eq 'display') && |
if (($context eq 'course') && ($phase eq 'display') && |
(grep(/^linkprotection$/,@actions))) { |
(grep(/^linkprot$/,@actions))) { |
my $allowed; |
my $allowed; |
my $home = &Apache::lonnet::homeserver($confname,$dom); |
my $home = &Apache::lonnet::homeserver($confname,$dom); |
unless ($home eq 'no_host') { |
unless ($home eq 'no_host') { |
Line 126 ENDSCRIPT
|
Line 126 ENDSCRIPT
|
} |
} |
if ($allowed) { |
if ($allowed) { |
my (@changeable,@settable); |
my (@changeable,@settable); |
if (ref($values->{'linkprotection'}) eq 'HASH') { |
if (ref($values->{'linkprot'}) eq 'HASH') { |
if (keys(%{$values->{'linkprotection'}})) { |
if (keys(%{$values->{'linkprot'}})) { |
my @current = sort { $a <=> $b } keys(%{$values->{'linkprotection'}}); |
my @current = sort { $a <=> $b } keys(%{$values->{'linkprot'}}); |
if (@current) { |
if (@current) { |
for (my $i=0; $i<@current; $i++) { |
for (my $i=0; $i<@current; $i++) { |
my $num = $current[$i]; |
my $num = $current[$i]; |
if (ref($values->{'linkprotection'}->{$num}) eq 'HASH') { |
if (ref($values->{'linkprot'}->{$num}) eq 'HASH') { |
if ($values->{'linkprotection'}->{$num}->{'usable'}) { |
if ($values->{'linkprot'}->{$num}->{'usable'}) { |
push(@changeable,$i); |
push(@changeable,$i); |
} else { |
} else { |
push(@settable,$i); |
push(@settable,$i); |
Line 148 $linkprot_check .= <<ENDJS;
|
Line 148 $linkprot_check .= <<ENDJS;
|
|
|
var linkprotradio = ''; |
var linkprotradio = ''; |
var secretinput = ''; |
var secretinput = ''; |
|
var posscheck = ''; |
|
|
ENDJS |
ENDJS |
if (@changeable) { |
if (@changeable) { |
foreach my $num (@changeable) { |
foreach my $num (@changeable) { |
($numrules,$intargjs) = |
($numrules,$intargjs) = |
&Apache::loncommon::passwd_validation_js('secretinput',$dom,'linkprot',$num); |
&Apache::loncommon::passwd_validation_js('secretinput',$dom,'linkprot',$num); |
if ($numrules) { |
$linkprot_check .= <<ENDJS; |
$linkprot_check .= <<ENDJS; |
posscheck = ''; |
|
|
linkprotradio = document.display.elements['linkprot_changesecret_$num']; |
linkprotradio = document.display.elements['linkprot_changesecret_$num']; |
secretinput = document.display.elements['linkprot_secret_$num'].value; |
|
if (linkprotradio.length) { |
if (linkprotradio.length) { |
for (var i=0; i<linkprotradio.length; i++) { |
for (var i=0; i<linkprotradio.length; i++) { |
if (linkprotradio[i].checked) { |
if (linkprotradio[i].checked) { |
if (linkprotradio[i].value == 1) { |
if (linkprotradio[i].value == 1) { |
$intargjs |
posscheck = 1; |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
|
ENDJS |
|
if ($numrules) { |
|
$linkprot_check .= <<ENDJS; |
|
if (posscheck) { |
|
secretinput = document.display.elements['linkprot_secret_$num'].value; |
|
$intargjs |
|
} |
|
|
ENDJS |
ENDJS |
} |
} |
|
$linkprot_check .= <<ENDJS; |
|
if (posscheck) { |
|
document.display.elements['linkprot_secret_$num'].type = 'password'; |
|
} |
|
|
|
ENDJS |
} |
} |
} |
} |
if (@settable) { |
if (@settable) { |
foreach my $num (@changeable) { |
foreach my $num (@settable) { |
($numrules,$intargjs) = |
($numrules,$intargjs) = |
&Apache::loncommon::passwd_validation_js('secretinput',$dom,'linkprot',$num); |
&Apache::loncommon::passwd_validation_js('secretinput',$dom,'linkprot',$num); |
if ($numrules) { |
if ($numrules) { |
$linkprot_check .= <<ENDJS; |
$linkprot_check .= <<ENDJS; |
secretinput = document.display.elements['linkprot_secret_$num'].value; |
secretinput = document.display.elements['linkprot_secret_$num'].value; |
$intargjs |
$intargjs |
|
|
ENDJS |
ENDJS |
} |
} |
|
$linkprot_check .= <<ENDJS; |
|
document.display.elements['linkprot_secret_$num'].type = 'password'; |
|
|
|
ENDJS |
} |
} |
} |
} |
($numrules,$intargjs) = |
($numrules,$intargjs) = |
Line 191 secretinput = document.display.elements[
|
Line 211 secretinput = document.display.elements[
|
if (document.display.elements['linkprot_add'].checked) { |
if (document.display.elements['linkprot_add'].checked) { |
$intargjs |
$intargjs |
} |
} |
|
|
ENDJS |
ENDJS |
} |
} |
|
$linkprot_check .= <<ENDJS; |
|
document.display.elements['linkprot_secret_add'].type = 'password'; |
|
|
|
ENDJS |
} |
} |
} |
} |
} |
} |
Line 372 $jscript
|
Line 397 $jscript
|
$onload = "courseSet('','load');toggleCloners(document.display.cloners_instcode);"; |
$onload = "courseSet('','load');toggleCloners(document.display.cloners_instcode);"; |
} |
} |
} |
} |
if (grep(/^linkprotection$/,@actions)) { |
if (grep(/^linkprot$/,@actions)) { |
if (ref($values) eq 'HASH') { |
if (ref($values) eq 'HASH') { |
if (ref($values->{'linkprotection'}) eq 'HASH') { |
if (ref($values->{'linkprot'}) eq 'HASH') { |
my $ltiauth; |
my $ltiauth; |
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { |
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { |
$ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; |
$ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; |
Line 382 $jscript
|
Line 407 $jscript
|
my %domdefs = &Apache::lonnet::get_domain_defaults($dom); |
my %domdefs = &Apache::lonnet::get_domain_defaults($dom); |
$ltiauth = $domdefs{'crsltiauth'}; |
$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++) { |
for (my $i=0; $i<=$posslti; $i++) { |
my $num = $i; |
my $num = $i; |
if ($i == $posslti) { |
if ($i == $posslti) { |
$num = 'add'; |
$num = 'add'; |
} |
} |
if (ref($values->{'linkprotection'}->{$i}) eq 'HASH') { |
if (ref($values->{'linkprot'}->{$i}) eq 'HASH') { |
if ($values->{'linkprotection'}->{$i}->{'usable'}) { |
if ($values->{'linkprot'}->{$i}->{'usable'}) { |
$onload .= "toggleLinkProt(document.display,'$num','secret');"; |
$onload .= "toggleLinkProt(document.display,'$num','secret');"; |
} |
} |
} |
} |
Line 397 $jscript
|
Line 428 $jscript
|
$onload .= "toggleLinkProtReqUser(document.display,'requser','optional','1','block','$num');". |
$onload .= "toggleLinkProtReqUser(document.display,'requser','optional','1','block','$num');". |
"toggleLinkProtReqUser(document.display,'mapuser','userfield','other','inline-block','$num');"; |
"toggleLinkProtReqUser(document.display,'mapuser','userfield','other','inline-block','$num');"; |
} |
} |
|
if ($ishome) { |
|
$onload .= "uncheckLinkProtMakeVis('visible','$num');"; |
|
} |
} |
} |
} |
} |
} |
} |