File:
[LON-CAPA] /
loncom /
interface /
lonconfigsettings.pm
Revision
1.58:
download - view:
text,
annotated -
select for diffs
Mon Feb 14 02:48:46 2022 UTC (2 years, 4 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
- Bug 6907
- Rename "LTI Provider" domain config item.
- Add three additional sections: "Encryption of shared secrets",
"Rules for shared secrets" and Link Protectors (domain).
- Keys used in domain for a particular library server may only be set in
a session on that server (and use Lond.pm and not lonc/lond).
- Min and max length and character requirements can be set for secrets used
for LTI-based link protection for deep-links.
1: # The LearningOnline Network with CAPA
2: # Handler to set domain-wide configuration settings
3: #
4: # $Id: lonconfigsettings.pm,v 1.58 2022/02/14 02:48:46 raeburn Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: #
28: ###############################################################
29: ##############################################################
30:
31: package Apache::lonconfigsettings;
32:
33: use strict;
34: use Apache::lonnet;
35: use Apache::loncommon();
36: use Apache::lonhtmlcommon();
37: use Apache::lonlocal;
38: use Apache::lonparmset();
39: use Apache::courseclassifier();
40: use LONCAPA qw(:DEFAULT :match);
41:
42: sub print_header {
43: my ($r,$phase,$context,$jscript,$container,$instcode,$dom,$values) = @_;
44: my ($pagetitle,$brcrumtitle,$action,$call_category_check,$instcode_check,
45: $crstype,@actions,@code_order);
46: if ($phase eq 'display') {
47: @actions = &Apache::loncommon::get_env_multiple('form.actions');
48: }
49: if ($context eq 'domain') {
50: ($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','View/Modify Domain Settings');
51: $action = '/adm/domainprefs';
52: if ($phase eq 'display') {
53: if (grep(/^coursecategories$/,@actions)) {
54: $call_category_check = qq|
55: if (formname == document.display) {
56: if (!categoryCheck(formname)) {
57: return;
58: }
59: }
60: |;
61: }
62: }
63: } else {
64: $crstype = &Apache::loncommon::course_type();
65: if ($crstype eq 'Community') {
66: ($pagetitle,$brcrumtitle) = ('Community Configuration','Community Configuration');
67: } else {
68: ($pagetitle,$brcrumtitle) = ('Course Configuration','Course Configuration');
69: }
70: $action = '/adm/courseprefs';
71: if ($phase eq 'display') {
72: if (grep(/^courseinfo$/,@actions)) {
73: my %codedefaults;
74: &Apache::lonnet::auto_instcode_defaults($env{'request.role.domain'},\%codedefaults,
75: \@code_order);
76: if (@code_order) {
77: my $noinstcodestr = &mt('You indicated cloning based on category, but did not select any categories.');
78: &js_escape(\$noinstcodestr);
79: $instcode_check = <<"ENDSCRIPT";
80: if (formname == document.display) {
81: if (formname.cloners_instcode.length) {
82: for (var j=0; j<formname.cloners_instcode.length; j++) {
83: if (formname.cloners_instcode[j].checked) {
84: if (formname.cloners_instcode[j].value == 1) {
85: var codes;
86: if (document.getElementsByClassName) {
87: codes = document.getElementsByClassName('LC_cloners_instcodes');
88: } else {
89: codes = getElementsByClassName(document.body,'LC_cloners_instcodes');
90: }
91: if (codes.length) {
92: var gotcode = 0;
93: for (var i=0; i<codes.length; i++) {
94: if (codes[i].selectedIndex != 0) {
95: gotcode = 1;
96: break;
97: }
98: }
99: if (!gotcode) {
100: for (var k=0; k<formname.cloners_instcode.length; k++) {
101: if (formname.cloners_instcode[k].value == 0) {
102: formname.cloners_instcode[k].checked = true;
103: }
104: }
105: toggleCloners(document.display.cloners_instcode);
106: alert('$noinstcodestr');
107: return false;
108: }
109: }
110: }
111: }
112: }
113: }
114: }
115:
116: ENDSCRIPT
117: }
118: }
119: }
120: }
121: my $alert = &mt('You must select at least one functionality type to display.');
122: &js_escape(\$alert);
123: my $js = '
124: <script type="text/javascript">
125: // <![CDATA[
126:
127: function changePage(formname,newphase) {
128: formname.phase.value = newphase;
129: numchecked = 0;
130: if (formname == document.pickactions) {
131: if (formname.actions.length > 0) {
132: for (var i = 0; i<formname.actions.length; i++) {
133: if (formname.actions[i].checked) {
134: numchecked ++;
135: }
136: }
137: } else {
138: if (formname.actions.checked) {
139: numchecked ++;
140: }
141: }
142: if (numchecked > 0) {
143: formname.submit();
144: } else {
145: alert("'.$alert.'");
146: return;
147: }
148: }
149: '.$instcode_check.$call_category_check.'
150: formname.submit();
151: }'."\n";
152: if ($phase eq 'pickactions') {
153: $js .= &Apache::lonhtmlcommon::color_picker();
154: $js .=
155: &Apache::lonhtmlcommon::set_form_elements({actions => 'checkbox'})."\n";
156: } elsif ($phase eq 'display') {
157: $js .= &Apache::lonhtmlcommon::color_picker();
158: $js .= &color_pick_js()."\n";
159: }
160: $js .= &Apache::loncommon::viewport_size_js().'
161:
162: // ]]>
163: </script>
164: ';
165: if ($jscript) {
166: $js .= "
167:
168: $jscript
169:
170: ";
171: }
172: my $additem;
173: if ($phase eq 'pickactions') {
174: my %loaditems = (
175: 'onload' => "setFormElements(document.pickactions);",
176: );
177: $additem = {'add_entries' => \%loaditems,};
178: } elsif ($phase eq 'display') {
179: if ($context eq 'domain') {
180: my $onload;
181: if (grep(/^coursedefaults$/,@actions)) {
182: $onload = "toggleDisplay(document.display,'cloneinstcode');".
183: "toggleDisplay(document.display,'credits');".
184: "toggleDisplay(document.display,'studentsubmission');";
185: }
186: if (grep(/^selfcreation$/,@actions)) {
187: my $prefix = 'cancreate_emailverified';
188: my $customclass = 'LC_selfcreate_email';
189: my $classprefix = 'LC_canmodify_emailusername_';
190: my $optionsprefix = 'LC_options_emailusername_';
191: $onload .= "toggleRows(document.display,'cancreate_email','selfassign','$customclass','$classprefix','$optionsprefix');";
192: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
193: my $hascustom;
194: my ($emailrules,$emailruleorder) = &Apache::lonnet::inst_userrules($dom,'email');
195: if (ref($emailrules) eq 'HASH') {
196: if (keys(%{$emailrules}) > 0) {
197: $hascustom = 'cancreate_emailrule';
198: }
199: }
200: my @posstypes;
201: if (ref($types) eq 'ARRAY') {
202: @posstypes = @{$types};
203: push(@posstypes,'default');
204: foreach my $type (@posstypes) {
205: $onload .= "toggleEmailOptions(document.display,'cancreate_emailoptions','$hascustom',".
206: "'cancreate_emaildomain','$type');";
207: }
208: } else {
209: $onload .= "toggleEmailOptions(document.display,'cancreate_emailoptions','$hascustom',".
210: "'cancreate_emaildomain','default');";
211: }
212: }
213: if (grep(/^contacts$/,@actions)) {
214: my $customclass = 'LC_helpdesk_override';
215: my $optionsprefix = 'LC_options_helpdesk_';
216: $onload .= "toggleHelpdeskRow(document.display,'overrides','$customclass','$optionsprefix');";
217: }
218: if (grep(/^lti$/,@actions)) {
219: $onload .= "toggleLTI(document.display,'user','add');".
220: "toggleLTI(document.display,'crs','add');".
221: "toggleLTI(document.display,'sec','add');".
222: "toggleLTI(document.display,'lcauth','add');".
223: "toggleLTI(document.display,'lcmenu','add');".
224: "toggleLTI(document.display,'passback','add');".
225: "toggleLTI(document.display,'callback','add');";
226: if (ref($values) eq 'HASH') {
227: if (ref($values->{'lti'}) eq 'HASH') {
228: my $numlti = scalar(keys(%{$values->{'lti'}}));
229: for (my $i=0; $i<$numlti; $i++) {
230: $onload .= "toggleLTI(document.display,'user','$i');".
231: "toggleLTI(document.display,'crs','$i');".
232: "toggleLTI(document.display,'sec','$i');".
233: "toggleLTI(document.display,'lcauth','$i');".
234: "toggleLTI(document.display,'lcmenu','$i');".
235: "toggleLTI(document.display,'passback','$i');".
236: "toggleLTI(document.display,'callback','$i');";
237: }
238: }
239: }
240: my %servers = &Apache::lonnet::get_servers($dom,'library');
241: foreach my $server (keys(%servers)) {
242: $onload .= "togglePrivKey(document.display,'$server');";
243: }
244: $onload .= "toggleLTIEncKey(document.display);";
245: }
246: if (grep(/^ltitools$/,@actions)) {
247: $onload .= "toggleLTITools(document.display,'passback','add');".
248: "toggleLTITools(document.display,'roster','add');".
249: "toggleLTITools(document.display,'user','add');";
250: if (ref($values) eq 'HASH') {
251: if (ref($values->{'ltitools'}) eq 'HASH') {
252: my $numltitools = scalar(keys(%{$values->{'ltitools'}}));
253: for (my $i=0; $i<$numltitools; $i++) {
254: $onload .= "toggleLTITools(document.display,'passback','$i');".
255: "toggleLTITools(document.display,'roster','$i');".
256: "toggleLTITools(document.display,'user','$i');";
257: }
258: }
259: }
260: }
261: if (grep(/^wafproxy$/,@actions)) {
262: $onload .= "toggleWAF();checkWAF();updateWAF();";
263: }
264: if (grep(/^proctoring$/,@actions)) {
265: $onload .= "toggleProctoring(document.display,'proctorio');".
266: "toggleProctoring(document.display,'examity');";
267: }
268: if (grep(/^scantron$/,@actions)) {
269: $onload .= "toggleScantron(document.display);";
270: }
271: if (grep(/^autoupdate$/,@actions)) {
272: $onload .= "toggleLastActiveDays(document.display);";
273: }
274: if (grep(/^autoenroll$/,@actions)) {
275: $onload .= "toggleFailsafe(document.display);";
276: }
277: if (grep(/^login$/,@actions)) {
278: my %domservers = &Apache::lonnet::get_servers($dom);
279: foreach my $server (sort(keys(%domservers))) {
280: $onload .= "toggleSamlOptions(document.display,'$server');";
281: }
282: }
283: if ($onload) {
284: my %loaditems = (
285: 'onload' => $onload,
286: );
287: $additem = {'add_entries' => \%loaditems,};
288: }
289: } elsif ($context eq 'course') {
290: my $onload;
291: if (grep(/^courseinfo$/,@actions)) {
292: if (@code_order) {
293: $onload = "courseSet('','load');toggleCloners(document.display.cloners_instcode);";
294: }
295: }
296: if (grep(/^linkprotection$/,@actions)) {
297: if (ref($values) eq 'HASH') {
298: if (ref($values->{'linkprotection'}) eq 'HASH') {
299: my $ltiauth;
300: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
301: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
302: } else {
303: my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
304: $ltiauth = $domdefs{'crsltiauth'};
305: }
306: my $posslti = scalar(keys(%{$values->{'linkprotection'}}));
307: for (my $i=0; $i<=$posslti; $i++) {
308: my $num = $i;
309: if ($i == $posslti) {
310: $num = 'add';
311: }
312: if (ref($values->{'linkprotection'}->{$i}) eq 'HASH') {
313: if ($values->{'linkprotection'}->{$i}->{'usable'}) {
314: $onload .= "toggleLTI(document.display,'$num','secret');";
315: }
316: }
317: if ($ltiauth) {
318: $onload .= "toggleLTIReqUser(document.display,'requser','optional','1','block','$num');".
319: "toggleLTIReqUser(document.display,'mapuser','userfield','other','inline-block','$num');";
320: }
321: }
322: }
323: }
324: }
325: if ($onload) {
326: my %loaditems = (
327: 'onload' => $onload,
328: );
329: $additem = {'add_entries' => \%loaditems,};
330: }
331: }
332: }
333: $r->print(&Apache::loncommon::start_page($pagetitle,$js,$additem));
334: $r->print(&Apache::lonhtmlcommon::breadcrumbs($brcrumtitle));
335: $r->print('
336: <form name="parmform" action="">
337: <input type="hidden" name="pres_marker" />
338: <input type="hidden" name="pres_type" />
339: <input type="hidden" name="pres_value" />
340: </form>
341: ');
342: if ($container) {
343: &Apache::lonparmset::startSettingsScreen($r,$container,$crstype);
344: }
345: $r->print('<form method="post" name="'.$phase.'" action="'.$action.'"'.
346: ' enctype="multipart/form-data">');
347: return;
348: }
349:
350: sub print_footer {
351: my ($r,$phase,$newphase,$button_text,$actions,$container,$parm_permission) = @_;
352: $button_text = &mt($button_text);
353: $r->print('<input type="hidden" name="phase" value="" />');
354: if (defined($env{'form.origin'})) {
355: $r->print('<input type="hidden" name="origin" value="'.$env{'form.origin'}.'" />'."\n");
356: }
357: if (($phase eq 'display') || ($phase eq 'process')) {
358: if (ref($actions) eq 'ARRAY') {
359: foreach my $item (@{$actions}) {
360: $r->print('<input type="hidden" name="actions" value="'.$item.'" />'."\n");
361: }
362: }
363: }
364: my $dest='"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
365: if ($phase eq 'process') {
366: $r->print(
367: &Apache::lonhtmlcommon::actionbox(
368: ['<a href='.$dest.'>'.$button_text.'</a>']));
369: } else {
370: my $onclick;
371: if ($phase eq 'display') {
372: $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
373: } else {
374: $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
375: }
376: my $showbutton = 1;
377: if (ref($parm_permission) eq 'HASH') {
378: unless (($parm_permission->{'process'}) || ($newphase eq 'display')) {
379: $showbutton = 0;
380: }
381: }
382: if ($showbutton) {
383: $r->print('<p><input type="button" name="store" value="'.
384: $button_text.'" onclick='.$onclick.' /></p>');
385: }
386: }
387: if ($phase eq 'process') {
388: $r->print('</form>');
389: if ($container) {
390: &Apache::lonparmset::endSettingsScreen($r);
391: }
392: $r->print(&Apache::loncommon::end_page());
393: }
394: return;
395: }
396:
397: sub make_changes {
398: my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$roles,
399: $allitems,$container,$parm_permission) = @_;
400: my %brcrumtext = &get_crumb_text();
401: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
402: my ($numchanged,%changes,%disallowed);
403: &Apache::lonhtmlcommon::add_breadcrumb
404: ({href=>"javascript:changePage(document.$phase,'display')",
405: text=>$brcrumtext{$context}},
406: {href=>"javascript:changePage(document.$phase,'$phase')",
407: text=>"Updated"});
408: &print_header($r,$phase,$context,undef,$container);
409: my ($crstype,%lastact,$errors);
410: if ($context eq 'course') {
411: $crstype = &Apache::loncommon::course_type();
412: }
413: if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') &&
414: (ref($prefs) eq 'HASH')) {
415: foreach my $item (@{$prefs_order}) {
416: if (grep(/^\Q$item\E$/,@actions)) {
417: if ($context eq 'domain') {
418: $r->print('<h3>'.&mt($prefs->{$item}{'text'}).'</h3>'.
419: &Apache::domainprefs::process_changes($r,$dom,
420: $confname,$item,$roles,$values,\%lastact));
421: } else {
422: $changes{$item} = {};
423: $errors =
424: &Apache::courseprefs::process_changes($dom,$confname,$item,$values,
425: $prefs->{$item},$changes{$item},
426: $allitems,\%disallowed,$crstype);
427: if (keys(%{$changes{$item}}) > 0) {
428: $numchanged ++;
429: }
430: }
431: }
432: }
433: }
434: if ($context eq 'course') {
435: if ($numchanged) {
436: my $message = &Apache::courseprefs::store_changes($dom,$confname,$prefs_order,\@actions,
437: $prefs,$values,\%changes,$crstype);
438: $r->print(&Apache::loncommon::confirmwrapper($message));
439: } else {
440: if ($crstype eq 'Community') {
441: $r->print(&Apache::loncommon::confirmwrapper(&mt("No changes made to community configuration.")));
442: } else {
443: $r->print(&Apache::loncommon::confirmwrapper(&mt("No changes made to course configuration.")));
444: }
445: }
446: if (keys(%disallowed) > 0) {
447: $r->print('<p>');
448: foreach my $item ('cloners','rolenames','feedback','discussion','localization') {
449: if (ref($disallowed{$item}) eq 'HASH') {
450: if (keys(%{$disallowed{$item}}) > 0) {
451: $r->print(&Apache::courseprefs::display_disallowed($item,$disallowed{$item},
452: $prefs,$crstype));
453: }
454: }
455: }
456: $r->print('</p>');
457: }
458: if ($errors) {
459: $r->print('<p>'.$errors.'</p>');
460: }
461: }
462: $r->print('<p>');
463: my $footer_text = 'Back to configuration display';
464: if ($context eq 'course') {
465: $footer_text = 'Back to display/edit settings';
466: }
467: &print_footer($r,$phase,'display',$footer_text,\@actions,$container,$parm_permission);
468: $r->print('</p>');
469: return \%lastact;
470: }
471:
472: sub display_settings {
473: my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript,
474: $allitems,$crstype,$container,$parm_permission) = @_;
475: my %brcrumtext = &get_crumb_text();
476: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
477: &Apache::lonhtmlcommon::add_breadcrumb
478: ({href=>"javascript:changePage(document.$phase,'display')",
479: text=>"Display/Edit Settings"});
480: my $instcode;
481: if (ref($values) eq 'HASH') {
482: $instcode = $values->{'internal.coursecode'};
483: }
484: &print_header($r,$phase,$context,$jscript,$container,$instcode,$dom,$values);
485: my $divwidth = 900;
486: if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && (ref($values) eq 'HASH')) {
487: if (@actions > 0) {
488: my $rowsum = 0;
489: my (%output,%rowtotal,@items,$got_check_uncheck);
490: foreach my $item (@{$prefs_order}) {
491: if (grep(/^\Q$item\E$/,@actions)) {
492: push(@items,$item);
493: if ($context eq 'domain') {
494: my $settings;
495: if (ref($values) eq 'HASH') {
496: $settings = $values->{$item};
497: }
498: if (($item eq 'usersessions') || ($item eq 'ssl')) {
499: unless ($got_check_uncheck) {
500: $r->print('<script type="text/javascript">'."\n".
501: '// <![CDATA['."\n".
502: &Apache::loncommon::check_uncheck_jscript()."\n".
503: '// ]]>'."\n".
504: '</script>'."\n");
505: $got_check_uncheck = 1;
506: }
507: } elsif ($item eq 'selfcreation') {
508: if (ref($values) eq 'HASH') {
509: $settings = $values->{'usercreation'};
510: }
511: } elsif ($item eq 'defaults') {
512: if (ref($values->{'inststatus'}) eq 'HASH') {
513: if (ref($values->{'defaults'}) eq 'HASH') {
514: $settings = {%{$values->{'inststatus'}},%{$values->{'defaults'}}};
515: } else {
516: $settings = $values->{'inststatus'};
517: }
518: } else {
519: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
520: my $inststatus = {
521: inststatustypes => $usertypes,
522: inststatusorder => $types,
523: inststatusguest => [],
524: };
525: if (ref($values->{defaults}) eq 'HASH') {
526: $settings = {%{$inststatus},%{$values->{'defaults'}}};
527: } else {
528: $settings = $inststatus;
529: }
530: }
531: } elsif ($item eq 'lti') {
532: if (ref($values->{'ltisec'}) eq 'HASH') {
533: if (ref($values->{'lti'}) eq 'HASH') {
534: $settings = {%{$values->{'lti'}},%{$values->{'ltisec'}}};
535: } else {
536: $settings = $values->{'ltisec'};
537: }
538: } elsif (ref($values->{'lti'}) eq 'HASH') {
539: $settings = $values->{'lti'};
540: }
541: }
542: ($output{$item},$rowtotal{$item}) =
543: &Apache::domainprefs::print_config_box($r,$dom,$confname,
544: $phase,$item,$prefs->{$item},$settings);
545: } else {
546: ($output{$item},$rowtotal{$item}) =
547: &Apache::courseprefs::print_config_box($r,$dom,$confname,$phase,
548: $item,$prefs->{$item},$values,$allitems,$crstype,$parm_permission);
549: }
550: $rowsum += $rowtotal{$item};
551: }
552: }
553: $r->print('<div id="prefs" style="max-width:'.$divwidth.'px;margin: 10px auto 10px auto;">');
554: for (my $i=0; $i<@items; $i++) {
555: $r->print($output{$items[$i]});
556: }
557: $r->print('</div>');
558: $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions,$container,$parm_permission));
559: } else {
560: $r->print('<input type="hidden" name="phase" value="" />'.
561: '<span class="LC_error">'.&mt('No settings chosen').
562: '</span>');
563: }
564: $r->print('</form>');
565: }
566: if ($container) {
567: &Apache::lonparmset::endSettingsScreen($r);
568: }
569: $r->print(&Apache::loncommon::end_page());
570: return;
571: }
572:
573: sub display_choices {
574: my ($r,$phase,$context,$prefs_order,$prefs,$container,$parm_permission) = @_;
575: if ($phase eq '') {
576: $phase = 'pickactions';
577: }
578: my %helphash;
579: &print_header($r,$phase,$context,undef,$container);
580: $r->print('<script type="text/javascript">'."\n".
581: '// <![CDATA['."\n".
582: &Apache::loncommon::check_uncheck_jscript()."\n".
583: '// ]]>'."\n".
584: '</script>'."\n");
585: my $heading = &mt('Settings to display/modify');
586: if (ref($parm_permission) eq 'HASH') {
587: unless ($parm_permission->{'process'}) {
588: $heading = &mt('Settings to display');
589: }
590: }
591: $r->print('<h3>'.$heading.'</h3>'.
592: '<div><input type="button" value="'.&mt('check all').'" '.
593: 'onclick="javascript:checkAll(document.pickactions.actions)"'.
594: ' />'.(' 'x2).
595: '<input type="button" value="'.&mt('uncheck all').'" '.
596: 'onclick="javascript:uncheckAll(document.pickactions.actions)" />'.
597: "\n".
598: '</div><div class="LC_left_float">');
599: my ($numitems,$maxincol,$firstthird,$secondthird,$seconddiv,$thirddiv,$count);
600: if (ref($prefs_order) eq 'ARRAY') {
601: $numitems = @{$prefs_order};
602: }
603: my $numcols = 3;
604: $maxincol = int($numitems/$numcols);
605: if ($numitems%$numcols) {
606: $maxincol ++;
607: }
608: $firstthird = $maxincol;
609: $secondthird = $firstthird + $maxincol;
610: $count = 0;
611: if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH')) {
612: foreach my $item (@{$prefs_order}) {
613: $r->print('<h4>'.
614: &Apache::loncommon::help_open_topic($prefs->{$item}->{'help'}).
615: '<label><input type="checkbox" name="actions" value="'.$item.
616: '" /> '.&mt($prefs->{$item}->{'text'}).'</label></h4>');
617: $count ++;
618: if ((!$seconddiv) && ($count >= $firstthird)) {
619: $r->print('</div>'."\n".'<div class="LC_left_float">'."\n");
620: $seconddiv = 1;
621: }
622: if ((!$thirddiv) && ($count >= $secondthird)) {
623: $r->print('</div>'."\n".'<div class="LC_left_float">'."\n");
624: $thirddiv = 1;
625: }
626: }
627: }
628: $r->print('</div><div style="padding:0;clear:both;margin:0;border:0"></div>');
629: $r->print(&print_footer($r,$phase,'display','Display',undef,$container,$parm_permission));
630: $r->print('</form>');
631: if ($container) {
632: &Apache::lonparmset::endSettingsScreen($r);
633: }
634: $r->print(&Apache::loncommon::end_page());
635: return;
636: }
637:
638: sub color_pick_js {
639: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
640: my $output = <<"ENDCOL";
641:
642: $pjump_def
643:
644: function psub() {
645: modalWindow.close();
646: if (document.parmform.pres_marker.value!='') {
647: if (document.parmform.pres_type.value!='') {
648: eval('document.display.'+
649: document.parmform.pres_marker.value+
650: '.value=document.parmform.pres_value.value;');
651: }
652: } else {
653: document.parmform.pres_value.value='';
654: document.parmform.pres_marker.value='';
655: }
656: }
657:
658: function get_id (span_id) {
659: if (document.getElementById) {
660: return document.getElementById(span_id);
661: }
662: if (document.all) {
663: return document.all[span_id];
664: }
665: return false;
666: }
667:
668: function colchg_span (span_id_str,new_color_item) {
669: var span_ref = get_id(span_id_str);
670: if (span_ref.style) { span_ref = span_ref.style; }
671: span_ref.background = new_color_item.value;
672: span_ref.backgroundColor = new_color_item.value;
673: span_ref.bgColor = new_color_item.value;
674: }
675:
676: ENDCOL
677: return $output;
678: }
679:
680: sub get_crumb_text {
681: my %brcrumbtext = (
682: domain => 'Domain Settings',
683: course => 'Display/Edit Settings',
684: );
685: return %brcrumbtext;
686: }
687:
688: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>