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