[LON-CAPA-cvs] cvs: loncom /interface courseprefs.pm lonconfigsettings.pm
raeburn
raeburn at source.lon-capa.org
Sat Mar 12 16:24:17 EST 2022
raeburn Sat Mar 12 21:24:17 2022 EDT
Modified files:
/loncom/interface lonconfigsettings.pm courseprefs.pm
Log:
- Bug 6907.
- Assign unique name and id to "Visible input?" checkbox for each Link
Protection item, and uncheck each one on page load on course's home server.
- Uncheck "Visible input?" checkbox and set type to password for textbox
for secret on form submission.
-------------- next part --------------
Index: loncom/interface/lonconfigsettings.pm
diff -u loncom/interface/lonconfigsettings.pm:1.61 loncom/interface/lonconfigsettings.pm:1.62
--- loncom/interface/lonconfigsettings.pm:1.61 Thu Mar 10 19:35:18 2022
+++ loncom/interface/lonconfigsettings.pm Sat Mar 12 21:24:17 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: lonconfigsettings.pm,v 1.61 2022/03/10 19:35:18 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.62 2022/03/12 21:24:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -148,27 +148,42 @@
var linkprotradio = '';
var secretinput = '';
+var posscheck = '';
+
ENDJS
if (@changeable) {
foreach my $num (@changeable) {
($numrules,$intargjs) =
&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'];
-secretinput = document.display.elements['linkprot_secret_$num'].value;
if (linkprotradio.length) {
for (var i=0; i<linkprotradio.length; i++) {
if (linkprotradio[i].checked) {
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
}
+ $linkprot_check .= <<ENDJS;
+if (posscheck) {
+ document.display.elements['linkprot_secret_$num'].type = 'password';
+}
+
+ENDJS
}
}
if (@settable) {
@@ -179,8 +194,13 @@
$linkprot_check .= <<ENDJS;
secretinput = document.display.elements['linkprot_secret_$num'].value;
$intargjs
+
ENDJS
}
+ $linkprot_check .= <<ENDJS;
+document.display.elements['linkprot_secret_$num'].type = 'password';
+
+ENDJS
}
}
($numrules,$intargjs) =
@@ -191,8 +211,13 @@
if (document.display.elements['linkprot_add'].checked) {
$intargjs
}
+
ENDJS
}
+ $linkprot_check .= <<ENDJS;
+document.display.elements['linkprot_secret_add'].type = 'password';
+
+ENDJS
}
}
}
@@ -382,6 +407,12 @@
my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
$ltiauth = $domdefs{'crsltiauth'};
}
+ 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;
@@ -397,6 +428,9 @@
$onload .= "toggleLinkProtReqUser(document.display,'requser','optional','1','block','$num');".
"toggleLinkProtReqUser(document.display,'mapuser','userfield','other','inline-block','$num');";
}
+ if ($ishome) {
+ $onload .= "uncheckLinkProtMakeVis('visible','$num');";
+ }
}
}
}
Index: loncom/interface/courseprefs.pm
diff -u loncom/interface/courseprefs.pm:1.105 loncom/interface/courseprefs.pm:1.106
--- loncom/interface/courseprefs.pm:1.105 Mon Feb 21 15:44:57 2022
+++ loncom/interface/courseprefs.pm Sat Mar 12 21:24:17 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.105 2022/02/21 15:44:57 raeburn Exp $
+# $Id: courseprefs.pm,v 1.106 2022/03/12 21:24:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2815,6 +2815,16 @@
}
return;
}
+
+function uncheckLinkProtMakeVis(item,num) {
+ if (document.getElementById('linkprot_'+item+'_'+num)) {
+ var currtype = document.getElementById('linkprot_'+item+'_'+num).type;
+ if (currtype.toLowerCase() == 'checkbox') {
+ document.getElementById('linkprot_'+item+'_'+num).checked = false;
+ }
+ }
+ return;
+}
ENDSCRIPT
}
@@ -5764,13 +5774,13 @@
'</label> </span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
'<span class="LC_nobreak">'.&mt('New Secret').':'.
'<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'.
- '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'.
+ '<label><input type="checkbox" name="linkprot_visible_'.$i.'" id="linkprot_visible_'.$i.'" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'.
'<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span></div>';
} else {
$datatable .=
'<span class="LC_nobreak">'.$desc{'secret'}.':'.
'<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'.
- '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'.
+ '<label><input type="checkbox" name="linkprot_visible_'.$i.'" id="linkprot_visible_'.$i.'" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'.
'<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>';
}
}
@@ -5822,7 +5832,7 @@
$datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':<input type="text" size="25" name="linkprot_key_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
(' 'x2).
'<span class="LC_nobreak">'.$desc{'secret'}.':<input type="password" size="20" name="linkprot_secret_add" value="" autocomplete="off"'.$disabled.' />'.
- '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_add.type='."'text'".' } else { this.form.linkprot_secret_add.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label></span> '."\n";
+ '<label><input type="checkbox" name="linkprot_visible_add" id="linkprot_visible_add" onclick="if (this.checked) { this.form.linkprot_secret_add.type='."'text'".' } else { this.form.linkprot_secret_add.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label></span> '."\n";
}
if ($ltiauth) {
$datatable .= '</fieldset>'.
More information about the LON-CAPA-cvs
mailing list