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