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