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