Annotation of loncom/interface/lonconfigsettings.pm, revision 1.52
1.1 raeburn 1: # The LearningOnline Network with CAPA
2: # Handler to set domain-wide configuration settings
3: #
1.52 ! raeburn 4: # $Id: lonconfigsettings.pm,v 1.51 2021/08/04 20:10:34 raeburn Exp $
1.1 raeburn 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;
1.20 www 38: use Apache::lonparmset();
1.30 raeburn 39: use Apache::courseclassifier();
40: use LONCAPA qw(:DEFAULT :match);
1.1 raeburn 41:
42: sub print_header {
1.39 raeburn 43: my ($r,$phase,$context,$jscript,$container,$instcode,$dom,$values) = @_;
1.30 raeburn 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: }
1.1 raeburn 49: if ($context eq 'domain') {
1.12 raeburn 50: ($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','View/Modify Domain Settings');
1.1 raeburn 51: $action = '/adm/domainprefs';
1.8 raeburn 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: }
1.1 raeburn 63: } else {
1.24 raeburn 64: $crstype = &Apache::loncommon::course_type();
65: if ($crstype eq 'Community') {
1.7 raeburn 66: ($pagetitle,$brcrumtitle) = ('Community Configuration','Community Configuration');
67: } else {
68: ($pagetitle,$brcrumtitle) = ('Course Configuration','Course Configuration');
69: }
1.1 raeburn 70: $action = '/adm/courseprefs';
1.30 raeburn 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.');
1.31 damieng 78: &js_escape(\$noinstcodestr);
1.30 raeburn 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: }
1.1 raeburn 120: }
121: my $alert = &mt('You must select at least one functionality type to display.');
1.31 damieng 122: &js_escape(\$alert);
1.1 raeburn 123: my $js = '
124: <script type="text/javascript">
1.6 raeburn 125: // <![CDATA[
126:
1.1 raeburn 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: }
1.30 raeburn 149: '.$instcode_check.$call_category_check.'
1.1 raeburn 150: formname.submit();
151: }'."\n";
152: if ($phase eq 'pickactions') {
1.22 foxr 153: $js .= &Apache::lonhtmlcommon::color_picker();
1.1 raeburn 154: $js .=
1.12 raeburn 155: &Apache::lonhtmlcommon::set_form_elements({actions => 'checkbox'})."\n";
1.1 raeburn 156: } elsif ($phase eq 'display') {
1.22 foxr 157: $js .= &Apache::lonhtmlcommon::color_picker();
1.1 raeburn 158: $js .= &color_pick_js()."\n";
159: }
160: $js .= &Apache::loncommon::viewport_size_js().'
1.6 raeburn 161:
162: // ]]>
1.1 raeburn 163: </script>
164: ';
1.2 raeburn 165: if ($jscript) {
166: $js .= "
167:
168: $jscript
169:
170: ";
171: }
1.1 raeburn 172: my $additem;
173: if ($phase eq 'pickactions') {
174: my %loaditems = (
1.12 raeburn 175: 'onload' => "setFormElements(document.pickactions);",
1.1 raeburn 176: );
177: $additem = {'add_entries' => \%loaditems,};
1.30 raeburn 178: } elsif ($phase eq 'display') {
179: if ($context eq 'domain') {
1.34 raeburn 180: my $onload;
1.30 raeburn 181: if (grep(/^coursedefaults$/,@actions)) {
1.34 raeburn 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';
1.36 raeburn 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');";
1.34 raeburn 207: }
1.36 raeburn 208: } else {
209: $onload .= "toggleEmailOptions(document.display,'cancreate_emailoptions','$hascustom',".
210: "'cancreate_emaildomain','default');";
1.34 raeburn 211: }
1.37 raeburn 212: }
213: if (grep(/^contacts$/,@actions)) {
214: my $customclass = 'LC_helpdesk_override';
215: my $optionsprefix = 'LC_options_helpdesk_';
1.38 raeburn 216: $onload .= "toggleHelpdeskRow(document.display,'overrides','$customclass','$optionsprefix');";
1.34 raeburn 217: }
1.40 raeburn 218: if (grep(/^lti$/,@actions)) {
219: $onload .= "toggleLTI(document.display,'user','add');".
220: "toggleLTI(document.display,'crs','add');".
1.42 raeburn 221: "toggleLTI(document.display,'sec','add');".
1.43 raeburn 222: "toggleLTI(document.display,'lcauth','add');".
1.44 raeburn 223: "toggleLTI(document.display,'lcmenu','add');".
1.46 raeburn 224: "toggleLTI(document.display,'passback','add');".
225: "toggleLTI(document.display,'callback','add');";
1.40 raeburn 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');".
1.42 raeburn 232: "toggleLTI(document.display,'sec','$i');".
1.43 raeburn 233: "toggleLTI(document.display,'lcauth','$i');".
1.44 raeburn 234: "toggleLTI(document.display,'lcmenu','$i');".
1.46 raeburn 235: "toggleLTI(document.display,'passback','$i');".
236: "toggleLTI(document.display,'callback','$i');";
1.40 raeburn 237: }
238: }
1.41 raeburn 239: }
1.40 raeburn 240: }
1.39 raeburn 241: if (grep(/^ltitools$/,@actions)) {
242: $onload .= "toggleLTITools(document.display,'passback','add');".
1.41 raeburn 243: "toggleLTITools(document.display,'roster','add');".
244: "toggleLTITools(document.display,'user','add');";
1.39 raeburn 245: if (ref($values) eq 'HASH') {
246: if (ref($values->{'ltitools'}) eq 'HASH') {
247: my $numltitools = scalar(keys(%{$values->{'ltitools'}}));
248: for (my $i=0; $i<$numltitools; $i++) {
249: $onload .= "toggleLTITools(document.display,'passback','$i');".
1.41 raeburn 250: "toggleLTITools(document.display,'roster','$i');".
251: "toggleLTITools(document.display,'user','$i');";
1.39 raeburn 252: }
253: }
254: }
255: }
1.48 raeburn 256: if (grep(/^wafproxy$/,@actions)) {
257: $onload .= "toggleWAF();checkWAF();updateWAF();";
258: }
1.47 raeburn 259: if (grep(/^proctoring$/,@actions)) {
260: $onload .= "toggleProctoring(document.display,'proctorio');".
261: "toggleProctoring(document.display,'examity');";
262: }
1.45 raeburn 263: if (grep(/^scantron$/,@actions)) {
264: $onload .= "toggleScantron('document.display');";
265: }
1.52 ! raeburn 266: if (grep(/^autoupdate$/,@actions)) {
! 267: $onload .= "toggleLastActiveDays('document.display');";
! 268: }
1.34 raeburn 269: if ($onload) {
1.30 raeburn 270: my %loaditems = (
1.35 raeburn 271: 'onload' => $onload,
1.30 raeburn 272: );
273: $additem = {'add_entries' => \%loaditems,};
274: }
275: } elsif ($context eq 'course') {
276: if (grep(/^courseinfo$/,@actions)) {
277: if (@code_order) {
278: $additem = {
279: add_entries => {'onload' => "courseSet('','load');toggleCloners(document.display.cloners_instcode);"},
280: };
281: }
282: }
283: }
1.1 raeburn 284: }
285: $r->print(&Apache::loncommon::start_page($pagetitle,$js,$additem));
286: $r->print(&Apache::lonhtmlcommon::breadcrumbs($brcrumtitle));
287: $r->print('
288: <form name="parmform" action="">
289: <input type="hidden" name="pres_marker" />
290: <input type="hidden" name="pres_type" />
291: <input type="hidden" name="pres_value" />
292: </form>
293: ');
1.20 www 294: if ($container) {
1.24 raeburn 295: &Apache::lonparmset::startSettingsScreen($r,$container,$crstype);
1.20 www 296: }
1.1 raeburn 297: $r->print('<form method="post" name="'.$phase.'" action="'.$action.'"'.
298: ' enctype="multipart/form-data">');
299: return;
300: }
301:
302: sub print_footer {
1.33 raeburn 303: my ($r,$phase,$newphase,$button_text,$actions,$container,$parm_permission) = @_;
1.1 raeburn 304: $button_text = &mt($button_text);
1.12 raeburn 305: $r->print('<input type="hidden" name="phase" value="" />');
1.5 raeburn 306: if (defined($env{'form.origin'})) {
307: $r->print('<input type="hidden" name="origin" value="'.$env{'form.origin'}.'" />'."\n");
308: }
1.1 raeburn 309: if (($phase eq 'display') || ($phase eq 'process')) {
310: if (ref($actions) eq 'ARRAY') {
311: foreach my $item (@{$actions}) {
1.16 raeburn 312: $r->print('<input type="hidden" name="actions" value="'.$item.'" />'."\n");
1.1 raeburn 313: }
314: }
315: }
316: my $dest='"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
317: if ($phase eq 'process') {
1.23 bisitz 318: $r->print(
319: &Apache::lonhtmlcommon::actionbox(
320: ['<a href='.$dest.'>'.$button_text.'</a>']));
1.1 raeburn 321: } else {
322: my $onclick;
323: if ($phase eq 'display') {
324: $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
325: } else {
326: $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
327: }
1.33 raeburn 328: my $showbutton = 1;
329: if (ref($parm_permission) eq 'HASH') {
330: unless (($parm_permission->{'process'}) || ($newphase eq 'display')) {
331: $showbutton = 0;
332: }
333: }
334: if ($showbutton) {
335: $r->print('<p><input type="button" name="store" value="'.
336: $button_text.'" onclick='.$onclick.' /></p>');
337: }
1.1 raeburn 338: }
339: if ($phase eq 'process') {
1.20 www 340: $r->print('</form>');
341: if ($container) {
342: &Apache::lonparmset::endSettingsScreen($r);
343: }
344: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 345: }
346: return;
347: }
348:
349: sub make_changes {
1.33 raeburn 350: my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$roles,
351: $allitems,$container,$parm_permission) = @_;
1.1 raeburn 352: my %brcrumtext = &get_crumb_text();
353: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
1.4 raeburn 354: my ($numchanged,%changes,%disallowed);
1.1 raeburn 355: &Apache::lonhtmlcommon::add_breadcrumb
356: ({href=>"javascript:changePage(document.$phase,'display')",
357: text=>$brcrumtext{$context}},
358: {href=>"javascript:changePage(document.$phase,'$phase')",
359: text=>"Updated"});
1.20 www 360: &print_header($r,$phase,$context,undef,$container);
1.50 raeburn 361: my ($crstype,%lastact,$errors);
1.7 raeburn 362: if ($context eq 'course') {
363: $crstype = &Apache::loncommon::course_type();
364: }
1.1 raeburn 365: if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') &&
366: (ref($prefs) eq 'HASH')) {
367: foreach my $item (@{$prefs_order}) {
368: if (grep(/^\Q$item\E$/,@actions)) {
369: if ($context eq 'domain') {
1.4 raeburn 370: $r->print('<h3>'.&mt($prefs->{$item}{'text'}).'</h3>'.
371: &Apache::domainprefs::process_changes($r,$dom,
1.27 raeburn 372: $confname,$item,$roles,$values,\%lastact));
1.1 raeburn 373: } else {
1.4 raeburn 374: $changes{$item} = {};
1.50 raeburn 375: $errors =
1.51 raeburn 376: &Apache::courseprefs::process_changes($dom,$confname,$item,$values,
1.50 raeburn 377: $prefs->{$item},$changes{$item},
378: $allitems,\%disallowed,$crstype);
1.4 raeburn 379: if (keys(%{$changes{$item}}) > 0) {
380: $numchanged ++;
381: }
1.1 raeburn 382: }
383: }
384: }
385: }
1.4 raeburn 386: if ($context eq 'course') {
387: if ($numchanged) {
1.11 wenzelju 388: my $message = &Apache::courseprefs::store_changes($dom,$confname,$prefs_order,\@actions,
389: $prefs,$values,\%changes,$crstype);
390: $r->print(&Apache::loncommon::confirmwrapper($message));
1.4 raeburn 391: } else {
1.7 raeburn 392: if ($crstype eq 'Community') {
1.11 wenzelju 393: $r->print(&Apache::loncommon::confirmwrapper(&mt("No changes made to community configuration.")));
1.7 raeburn 394: } else {
1.11 wenzelju 395: $r->print(&Apache::loncommon::confirmwrapper(&mt("No changes made to course configuration.")));
1.7 raeburn 396: }
1.4 raeburn 397: }
398: if (keys(%disallowed) > 0) {
399: $r->print('<p>');
400: foreach my $item ('cloners','rolenames','feedback','discussion','localization') {
401: if (ref($disallowed{$item}) eq 'HASH') {
402: if (keys(%{$disallowed{$item}}) > 0) {
403: $r->print(&Apache::courseprefs::display_disallowed($item,$disallowed{$item},
1.7 raeburn 404: $prefs,$crstype));
1.4 raeburn 405: }
406: }
407: }
408: $r->print('</p>');
409: }
1.50 raeburn 410: if ($errors) {
411: $r->print('<p>'.$errors.'</p>');
412: }
1.4 raeburn 413: }
1.1 raeburn 414: $r->print('<p>');
1.4 raeburn 415: my $footer_text = 'Back to configuration display';
416: if ($context eq 'course') {
417: $footer_text = 'Back to display/edit settings';
418: }
1.33 raeburn 419: &print_footer($r,$phase,'display',$footer_text,\@actions,$container,$parm_permission);
1.1 raeburn 420: $r->print('</p>');
1.27 raeburn 421: return \%lastact;
1.1 raeburn 422: }
423:
424: sub display_settings {
1.3 raeburn 425: my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript,
1.33 raeburn 426: $allitems,$crstype,$container,$parm_permission) = @_;
1.1 raeburn 427: my %brcrumtext = &get_crumb_text();
428: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
429: &Apache::lonhtmlcommon::add_breadcrumb
430: ({href=>"javascript:changePage(document.$phase,'display')",
1.4 raeburn 431: text=>"Display/Edit Settings"});
1.30 raeburn 432: my $instcode;
433: if (ref($values) eq 'HASH') {
434: $instcode = $values->{'internal.coursecode'};
435: }
1.39 raeburn 436: &print_header($r,$phase,$context,$jscript,$container,$instcode,$dom,$values);
1.12 raeburn 437: my $divwidth = 900;
1.1 raeburn 438: if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && (ref($values) eq 'HASH')) {
439: if (@actions > 0) {
440: my $rowsum = 0;
1.32 raeburn 441: my (%output,%rowtotal,@items,$got_check_uncheck);
1.1 raeburn 442: foreach my $item (@{$prefs_order}) {
443: if (grep(/^\Q$item\E$/,@actions)) {
444: push(@items,$item);
445: if ($context eq 'domain') {
1.29 raeburn 446: my $settings;
447: if (ref($values) eq 'HASH') {
448: $settings = $values->{$item};
449: }
1.32 raeburn 450: if (($item eq 'usersessions') || ($item eq 'ssl')) {
451: unless ($got_check_uncheck) {
452: $r->print('<script type="text/javascript">'."\n".
453: '// <![CDATA['."\n".
454: &Apache::loncommon::check_uncheck_jscript()."\n".
455: '// ]]>'."\n".
456: '</script>'."\n");
457: $got_check_uncheck = 1;
458: }
1.28 raeburn 459: } elsif ($item eq 'selfcreation') {
1.29 raeburn 460: if (ref($values) eq 'HASH') {
461: $settings = $values->{'usercreation'};
462: }
463: } elsif ($item eq 'defaults') {
464: if (ref($values->{'inststatus'}) eq 'HASH') {
465: if (ref($values->{'defaults'}) eq 'HASH') {
466: $settings = {%{$values->{'inststatus'}},%{$values->{'defaults'}}};
467: } else {
468: $settings = $values->{'inststatus'};
469: }
470: } else {
471: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
472: my $inststatus = {
473: inststatustypes => $usertypes,
474: inststatusorder => $types,
475: inststatusguest => [],
476: };
477: if (ref($values->{defaults}) eq 'HASH') {
478: $settings = {%{$inststatus},%{$values->{'defaults'}}};
479: } else {
480: $settings = $inststatus;
481: }
482: }
1.15 raeburn 483: }
1.1 raeburn 484: ($output{$item},$rowtotal{$item}) =
485: &Apache::domainprefs::print_config_box($r,$dom,$confname,
1.28 raeburn 486: $phase,$item,$prefs->{$item},$settings);
1.1 raeburn 487: } else {
488: ($output{$item},$rowtotal{$item}) =
489: &Apache::courseprefs::print_config_box($r,$dom,$phase,
1.33 raeburn 490: $item,$prefs->{$item},$values,$allitems,$crstype,$parm_permission);
1.1 raeburn 491: }
492: $rowsum += $rowtotal{$item};
493: }
494: }
1.12 raeburn 495: $r->print('<div id="prefs" style="max-width:'.$divwidth.'px;margin: 10px auto 10px auto;">');
1.1 raeburn 496: for (my $i=0; $i<@items; $i++) {
497: $r->print($output{$items[$i]});
498: }
1.12 raeburn 499: $r->print('</div>');
1.33 raeburn 500: $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions,$container,$parm_permission));
1.1 raeburn 501: } else {
502: $r->print('<input type="hidden" name="phase" value="" />'.
1.12 raeburn 503: '<span class="LC_error">'.&mt('No settings chosen').
504: '</span>');
1.1 raeburn 505: }
506: $r->print('</form>');
507: }
1.25 raeburn 508: if ($container) {
509: &Apache::lonparmset::endSettingsScreen($r);
510: }
1.1 raeburn 511: $r->print(&Apache::loncommon::end_page());
512: return;
513: }
514:
515: sub display_choices {
1.33 raeburn 516: my ($r,$phase,$context,$prefs_order,$prefs,$container,$parm_permission) = @_;
1.1 raeburn 517: if ($phase eq '') {
518: $phase = 'pickactions';
519: }
520: my %helphash;
1.20 www 521: &print_header($r,$phase,$context,undef,$container);
1.1 raeburn 522: $r->print('<script type="text/javascript">'."\n".
1.6 raeburn 523: '// <![CDATA['."\n".
1.1 raeburn 524: &Apache::loncommon::check_uncheck_jscript()."\n".
1.6 raeburn 525: '// ]]>'."\n".
1.12 raeburn 526: '</script>'."\n");
1.33 raeburn 527: my $heading = &mt('Settings to display/modify');
528: if (ref($parm_permission) eq 'HASH') {
529: unless ($parm_permission->{'process'}) {
530: $heading = &mt('Settings to display');
531: }
532: }
533: $r->print('<h3>'.$heading.'</h3>'.
1.13 raeburn 534: '<div><input type="button" value="'.&mt('check all').'" '.
1.1 raeburn 535: 'onclick="javascript:checkAll(document.pickactions.actions)"'.
536: ' />'.(' 'x2).
537: '<input type="button" value="'.&mt('uncheck all').'" '.
1.12 raeburn 538: 'onclick="javascript:uncheckAll(document.pickactions.actions)" />'.
539: "\n".
1.13 raeburn 540: '</div><div class="LC_left_float">');
1.12 raeburn 541: my ($numitems,$maxincol,$firstthird,$secondthird,$seconddiv,$thirddiv,$count);
1.1 raeburn 542: if (ref($prefs_order) eq 'ARRAY') {
543: $numitems = @{$prefs_order};
544: }
1.12 raeburn 545: my $numcols = 3;
546: $maxincol = int($numitems/$numcols);
547: if ($numitems%$numcols) {
548: $maxincol ++;
1.1 raeburn 549: }
1.14 raeburn 550: $firstthird = $maxincol;
551: $secondthird = $firstthird + $maxincol;
1.1 raeburn 552: $count = 0;
553: if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH')) {
554: foreach my $item (@{$prefs_order}) {
555: $r->print('<h4>'.
556: &Apache::loncommon::help_open_topic($prefs->{$item}->{'help'}).
557: '<label><input type="checkbox" name="actions" value="'.$item.
558: '" /> '.&mt($prefs->{$item}->{'text'}).'</label></h4>');
559: $count ++;
1.12 raeburn 560: if ((!$seconddiv) && ($count >= $firstthird)) {
1.1 raeburn 561: $r->print('</div>'."\n".'<div class="LC_left_float">'."\n");
562: $seconddiv = 1;
563: }
1.12 raeburn 564: if ((!$thirddiv) && ($count >= $secondthird)) {
565: $r->print('</div>'."\n".'<div class="LC_left_float">'."\n");
566: $thirddiv = 1;
1.13 raeburn 567: }
1.1 raeburn 568: }
569: }
1.49 raeburn 570: $r->print('</div><div style="padding:0;clear:both;margin:0;border:0"></div>');
1.33 raeburn 571: $r->print(&print_footer($r,$phase,'display','Display',undef,$container,$parm_permission));
1.1 raeburn 572: $r->print('</form>');
1.25 raeburn 573: if ($container) {
574: &Apache::lonparmset::endSettingsScreen($r);
575: }
1.1 raeburn 576: $r->print(&Apache::loncommon::end_page());
577: return;
578: }
579:
580: sub color_pick_js {
581: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
582: my $output = <<"ENDCOL";
583:
584: $pjump_def
585:
586: function psub() {
1.21 www 587: modalWindow.close();
1.1 raeburn 588: if (document.parmform.pres_marker.value!='') {
589: if (document.parmform.pres_type.value!='') {
590: eval('document.display.'+
591: document.parmform.pres_marker.value+
592: '.value=document.parmform.pres_value.value;');
593: }
594: } else {
595: document.parmform.pres_value.value='';
596: document.parmform.pres_marker.value='';
597: }
598: }
599:
600: function get_id (span_id) {
601: if (document.getElementById) {
602: return document.getElementById(span_id);
603: }
604: if (document.all) {
605: return document.all[span_id];
606: }
607: return false;
608: }
609:
610: function colchg_span (span_id_str,new_color_item) {
611: var span_ref = get_id(span_id_str);
612: if (span_ref.style) { span_ref = span_ref.style; }
613: span_ref.background = new_color_item.value;
614: span_ref.backgroundColor = new_color_item.value;
615: span_ref.bgColor = new_color_item.value;
616: }
617:
618: ENDCOL
619: return $output;
620: }
621:
622: sub get_crumb_text {
623: my %brcrumbtext = (
624: domain => 'Domain Settings',
1.4 raeburn 625: course => 'Display/Edit Settings',
1.1 raeburn 626: );
627: return %brcrumbtext;
628: }
629:
630: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>