Annotation of loncom/interface/domainprefs.pm, revision 1.63
1.1 raeburn 1: # The LearningOnline Network with CAPA
2: # Handler to set domain-wide configuration settings
3: #
1.63 ! raeburn 4: # $Id: domainprefs.pm,v 1.62 2008/07/09 21:34:27 raeburn Exp $
1.2 albertel 5: #
1.1 raeburn 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::domainprefs;
32:
33: use strict;
34: use Apache::Constants qw(:common :http);
35: use Apache::lonnet;
36: use Apache::loncommon();
37: use Apache::lonhtmlcommon();
38: use Apache::lonlocal;
1.43 raeburn 39: use Apache::lonmsg();
1.48 raeburn 40: use LONCAPA;
1.6 raeburn 41: use LONCAPA::Enrollment;
1.9 raeburn 42: use File::Copy;
1.43 raeburn 43: use Locale::Language;
1.62 raeburn 44: use DateTime::TimeZone;
1.1 raeburn 45:
46: sub handler {
47: my $r=shift;
48: if ($r->header_only) {
49: &Apache::loncommon::content_type($r,'text/html');
50: $r->send_http_header;
51: return OK;
52: }
53:
54: my $dom = $env{'request.role.domain'};
1.5 albertel 55: my $domdesc = &Apache::lonnet::domain($dom,'description');
1.1 raeburn 56: if (&Apache::lonnet::allowed('mau',$dom)) {
57: &Apache::loncommon::content_type($r,'text/html');
58: $r->send_http_header;
59: } else {
60: $env{'user.error.msg'}=
61: "/adm/domainprefs:mau:0:0:Cannot modify domain settings";
62: return HTTP_NOT_ACCEPTABLE;
63: }
64: &Apache::lonhtmlcommon::clear_breadcrumbs();
65: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.58 raeburn 66: ['phase','actions']);
1.30 raeburn 67: my $phase = 'pickactions';
1.3 raeburn 68: if ( exists($env{'form.phase'}) ) {
69: $phase = $env{'form.phase'};
70: }
71: my %domconfig =
1.6 raeburn 72: &Apache::lonnet::get_dom('configuration',['login','rolecolors',
1.27 raeburn 73: 'quotas','autoenroll','autoupdate','directorysrch',
1.48 raeburn 74: 'usercreation','usermodification','contacts','defaults',
75: 'scantron','coursecategories'],$dom);
1.43 raeburn 76: my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
1.30 raeburn 77: 'autoupdate','directorysrch','contacts',
1.48 raeburn 78: 'usercreation','usermodification','scantron',
79: 'coursecategories');
1.30 raeburn 80: my %prefs = (
81: 'rolecolors' =>
82: { text => 'Default color schemes',
83: help => 'Default_Color_Schemes',
84: header => [{col1 => 'Student Settings',
85: col2 => '',},
86: {col1 => 'Coordinator Settings',
87: col2 => '',},
88: {col1 => 'Author Settings',
89: col2 => '',},
90: {col1 => 'Administrator Settings',
91: col2 => '',}],
92: },
93: 'login' =>
94: { text => 'Log-in page options',
95: help => 'Domain_Log-in_Page',
96: header => [{col1 => 'Item',
97: col2 => '',}],
98: },
1.43 raeburn 99: 'defaults' =>
1.54 raeburn 100: { text => 'Default authentication/language/timezone',
1.43 raeburn 101: help => '',
102: header => [{col1 => 'Setting',
103: col2 => 'Value'}],
104: },
1.30 raeburn 105: 'quotas' =>
106: { text => 'Default quotas for user portfolios',
107: help => 'Default_User_Quota',
108: header => [{col1 => 'User type',
109: col2 => 'Default quota'}],
110: },
111: 'autoenroll' =>
112: { text => 'Auto-enrollment settings',
113: help => 'Domain_Auto_Enrollment',
114: header => [{col1 => 'Configuration setting',
115: col2 => 'Value(s)'}],
116: },
117: 'autoupdate' =>
118: { text => 'Auto-update settings',
119: help => 'Domain_Auto_Update',
120: header => [{col1 => 'Setting',
121: col2 => 'Value',},
1.43 raeburn 122: {col1 => 'User population',
1.30 raeburn 123: col2 => 'Updataeable user data'}],
124: },
125: 'directorysrch' =>
126: { text => 'Institutional directory searches',
127: help => 'Domain_Directory_Search',
128: header => [{col1 => 'Setting',
129: col2 => 'Value',}],
130: },
131: 'contacts' =>
132: { text => 'Contact Information',
133: help => 'Domain_Contact_Information',
134: header => [{col1 => 'Setting',
135: col2 => 'Value',}],
136: },
137:
138: 'usercreation' =>
139: { text => 'User creation',
140: help => 'Domain_User_Creation',
1.43 raeburn 141: header => [{col1 => 'Format rule type',
142: col2 => 'Format rules in force'},
1.34 raeburn 143: {col1 => 'User account creation',
144: col2 => 'Usernames which may be created',},
1.30 raeburn 145: {col1 => 'Context',
1.43 raeburn 146: col2 => 'Assignable authentication types'}],
1.30 raeburn 147: },
1.33 raeburn 148: 'usermodification' =>
149: { text => 'User modification',
150: help => 'Domain_User_Modification',
151: header => [{col1 => 'Target user has role',
152: col2 => 'User information updateable in author context'},
153: {col1 => 'Target user has role',
1.63 ! raeburn 154: col2 => 'User information updateable in course context'},
! 155: {col1 => "Status of user",
! 156: col2 => 'Information settable when self-creating account (if directory data blank)'}],
1.33 raeburn 157: },
1.46 raeburn 158: 'scantron' =>
159: { text => 'Scantron format file',
160: help => 'Domain_Scantron_Formats',
161: header => [ {col1 => 'Item',
162: col2 => '',
163: }],
164: },
1.48 raeburn 165: 'coursecategories' =>
166: { text => 'Cataloging of courses',
167: help => 'Domain_Course_Catalog',
1.57 raeburn 168: header => [{col1 => 'Category settings',
169: col2 => '',},
170: {col1 => 'Categories',
171: col2 => '',
172: }],
1.48 raeburn 173: }
1.3 raeburn 174: );
1.6 raeburn 175: my @roles = ('student','coordinator','author','admin');
1.30 raeburn 176: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
1.3 raeburn 177: &Apache::lonhtmlcommon::add_breadcrumb
1.30 raeburn 178: ({href=>"javascript:changePage(document.$phase,'pickactions')",
179: text=>"Pick functionality"});
1.9 raeburn 180: my $confname = $dom.'-domainconfig';
1.3 raeburn 181: if ($phase eq 'process') {
1.1 raeburn 182: &Apache::lonhtmlcommon::add_breadcrumb
1.30 raeburn 183: ({href=>"javascript:changePage(document.$phase,'display')",
184: text=>"Domain Configuration"},
185: {href=>"javascript:changePage(document.$phase,'$phase')",
1.3 raeburn 186: text=>"Updated"});
187: &print_header($r,$phase);
1.30 raeburn 188: foreach my $item (@prefs_order) {
189: if (grep(/^\Q$item\E$/,@actions)) {
190: $r->print('<h3>'.&mt($prefs{$item}{'text'}).'</h3>'.
191: &process_changes($r,$dom,$confname,$item,
192: \@roles,%domconfig));
193: }
1.3 raeburn 194: }
195: $r->print('<p>');
1.30 raeburn 196: &print_footer($r,$phase,'display','Back to configuration display',
197: \@actions);
1.3 raeburn 198: $r->print('</p>');
1.30 raeburn 199: } elsif ($phase eq 'display') {
200: &Apache::lonhtmlcommon::add_breadcrumb
201: ({href=>"javascript:changePage(document.$phase,'display')",
202: text=>"Domain Configuration"});
203: &print_header($r,$phase);
204: if (@actions > 0) {
205: my $rowsum = 0;
206: my (%output,%rowtotal,@items);
207: my $halfway = @actions/2;
208: foreach my $item (@prefs_order) {
209: if (grep(/^\Q$item\E$/,@actions)) {
210: push(@items,$item);
211: ($output{$item},$rowtotal{$item}) =
212: &print_config_box($r,$dom,$confname,$phase,
213: $item,$prefs{$item},
214: $domconfig{$item});
215: $rowsum += $rowtotal{$item};
216: }
217: }
218: my $colend;
219: my $halfway = $rowsum/2;
220: my $aggregate = 0;
221: my $sumleft = 0;
222: my $sumright = 0;
223: my $crossover;
224: for (my $i=0; $i<@items; $i++) {
225: $aggregate += $rowtotal{$items[$i]};
226: if ($aggregate > $halfway) {
227: $crossover = $i;
228: last;
229: }
230: }
231: for (my $i=0; $i<$crossover; $i++) {
232: $sumleft += $rowtotal{$items[$i]};
233: }
234: for (my $i=$crossover+1; $i<@items; $i++) {
235: $sumright += $rowtotal{$items[$i]};
236: }
237: if ((@items > 1) && ($env{'form.numcols'} == 2)) {
238: my $sumdiff = $sumright - $sumleft;
239: if ($sumdiff > 0) {
240: $colend = $crossover + 1;
241: } else {
242: $colend = $crossover;
243: }
244: } else {
245: $colend = @items;
246: }
247: $r->print('<p><table class="LC_double_column"><tr><td class="LC_left_col">');
248: for (my $i=0; $i<$colend; $i++) {
249: $r->print($output{$items[$i]});
250: }
251: $r->print('</td><td></td><td class="LC_right_col">');
252: if ($colend < @items) {
253: for (my $i=$colend; $i<@items; $i++) {
254: $r->print($output{$items[$i]});
255: }
256: }
257: $r->print('</td></tr></table></p>');
258: $r->print(&print_footer($r,$phase,'process','Save',\@actions));
259: } else {
260: $r->print('<input type="hidden" name="phase" value="" />'.
261: '<input type="hidden" name="numcols" value="'.
262: $env{'form.numcols'}.'" />'."\n".
263: '<span clas="LC_error">'.&mt('No settings chosen').
264: '</span>');
265: }
266: $r->print('</form>');
267: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 268: } else {
1.3 raeburn 269: if ($phase eq '') {
1.30 raeburn 270: $phase = 'pickactions';
1.1 raeburn 271: }
1.30 raeburn 272: my %helphash;
1.3 raeburn 273: &print_header($r,$phase);
1.21 raeburn 274: if (keys(%domconfig) == 0) {
275: my $primarylibserv = &Apache::lonnet::domain($dom,'primary');
1.29 raeburn 276: my @ids=&Apache::lonnet::current_machine_ids();
277: if (!grep(/^\Q$primarylibserv\E$/,@ids)) {
1.21 raeburn 278: my %designhash = &Apache::loncommon::get_domainconf($dom);
1.41 raeburn 279: my @loginimages = ('img','logo','domlogo','login');
1.21 raeburn 280: my $custom_img_count = 0;
281: foreach my $img (@loginimages) {
282: if ($designhash{$dom.'.login.'.$img} ne '') {
283: $custom_img_count ++;
284: }
285: }
286: foreach my $role (@roles) {
287: if ($designhash{$dom.'.'.$role.'.img'} ne '') {
288: $custom_img_count ++;
289: }
290: }
291: if ($custom_img_count > 0) {
292: my $switch_server = &check_switchserver($dom,$confname);
1.29 raeburn 293: $r->print(
294: &mt('Domain configuration settings have yet to be saved for this domain via the web-based domain preferences interface.').'<br />'.
295: &mt("While this remains so, you must switch to the domain's primary library server in order to update settings.").'<br /><br />'.
296: &mt("Thereafter, (with a Domain Coordinator role selected in the domain) you will be able to update settings when logged in to any server in the LON-CAPA network.").'<br />'.
297: &mt("However, you will still need to switch to the domain's primary library server to upload new images or logos.").'<br /><br />');
298: if ($switch_server) {
1.30 raeburn 299: $r->print($switch_server.' '.&mt('to primary library server for domain: [_1]',$dom));
1.29 raeburn 300: }
1.21 raeburn 301: return OK;
302: }
303: }
304: }
1.30 raeburn 305: $r->print('<h3>'.&mt('Functionality to display/modify').'</h3>');
306: $r->print('<script type="text/javascript">'."\n".
307: &Apache::loncommon::check_uncheck_jscript()."\n".
1.56 bisitz 308: '</script>'."\n".'<p><input type="button" value="'.&mt('check all').'" '.
1.30 raeburn 309: 'onclick="javascript:checkAll(document.pickactions.actions)"'.
310: ' /> '.
1.56 bisitz 311: '<input type="button" value="'.&mt('uncheck all').'" '.
1.30 raeburn 312: 'onclick="javascript:uncheckAll(document.pickactions.actions)"'.
1.38 raeburn 313: ' /></p><div class="LC_left_float">');
314: my ($numitems,$midpoint,$seconddiv,$count);
315: $numitems = @prefs_order;
316: $midpoint = int($numitems/2);
317: if ($numitems%2) {
318: $midpoint ++;
319: }
320: $count = 0;
1.30 raeburn 321: foreach my $item (@prefs_order) {
1.56 bisitz 322: $r->print('<h4><label><input type="checkbox" name="actions" value="'.$item.'" /> '.&mt($prefs{$item}->{'text'}).'</label></h4>');
1.38 raeburn 323: $count ++;
324: if ((!$seconddiv) && ($count >= $midpoint)) {
325: $r->print('</div>'."\n".'<div class="LC_left_float">'."\n");
326: $seconddiv = 1;
327: }
1.30 raeburn 328: }
1.38 raeburn 329: $r->print('</div><div class="LC_clear_float_footer"></div><h3>'.
330: &mt('Display options').'</h3>'."\n".
1.30 raeburn 331: '<p><span class="LC_nobreak">'.&mt('Display using: ')."\n".
1.48 raeburn 332: '<label><input type="radio" name="numcols" value="1" />'.
333: &mt('one column').'</label> <label>'.
334: '<input type="radio" name="numcols" value="2" />'.
1.30 raeburn 335: &mt('two columns').'</label></span></p>');
336: $r->print(&print_footer($r,$phase,'display','Go'));
337: $r->print('</form>');
338: $r->print(&Apache::loncommon::end_page());
1.3 raeburn 339: }
340: return OK;
341: }
342:
343: sub process_changes {
1.9 raeburn 344: my ($r,$dom,$confname,$action,$roles,%domconfig) = @_;
1.3 raeburn 345: my $output;
346: if ($action eq 'login') {
1.9 raeburn 347: $output = &modify_login($r,$dom,$confname,%domconfig);
1.6 raeburn 348: } elsif ($action eq 'rolecolors') {
1.9 raeburn 349: $output = &modify_rolecolors($r,$dom,$confname,$roles,
350: %domconfig);
1.3 raeburn 351: } elsif ($action eq 'quotas') {
352: $output = &modify_quotas($dom,%domconfig);
353: } elsif ($action eq 'autoenroll') {
354: $output = &modify_autoenroll($dom,%domconfig);
355: } elsif ($action eq 'autoupdate') {
356: $output = &modify_autoupdate($dom,%domconfig);
1.23 raeburn 357: } elsif ($action eq 'directorysrch') {
358: $output = &modify_directorysrch($dom,%domconfig);
1.27 raeburn 359: } elsif ($action eq 'usercreation') {
1.28 raeburn 360: $output = &modify_usercreation($dom,%domconfig);
1.33 raeburn 361: } elsif ($action eq 'usermodification') {
362: $output = &modify_usermodification($dom,%domconfig);
1.28 raeburn 363: } elsif ($action eq 'contacts') {
364: $output = &modify_contacts($dom,%domconfig);
1.43 raeburn 365: } elsif ($action eq 'defaults') {
366: $output = &modify_defaults($dom,$r);
1.46 raeburn 367: } elsif ($action eq 'scantron') {
1.48 raeburn 368: $output = &modify_scantron($r,$dom,$confname,%domconfig);
369: } elsif ($action eq 'coursecategories') {
370: $output = &modify_coursecategories($dom,%domconfig);
1.3 raeburn 371: }
372: return $output;
373: }
374:
375: sub print_config_box {
1.9 raeburn 376: my ($r,$dom,$confname,$phase,$action,$item,$settings) = @_;
1.30 raeburn 377: my $rowtotal = 0;
1.49 raeburn 378: my $output;
379: if ($action eq 'coursecategories') {
380: $output = &coursecategories_javascript($settings);
381: }
382: $output .=
1.30 raeburn 383: '<table class="LC_nested_outer">
1.3 raeburn 384: <tr>
1.30 raeburn 385: <th align="left"><span class="LC_nobreak">'.&mt($item->{text}).
386: ' </span></th></tr>';
1.22 raeburn 387: #
388: # FIXME - put the help link back in when the help files exist
389: # <th>'.&mt($item->{text}).' '.
390: # &Apache::loncommon::help_open_topic($item->{'help'}).'</th>
391: # </tr>');
1.30 raeburn 392: $rowtotal ++;
1.28 raeburn 393: if (($action eq 'autoupdate') || ($action eq 'rolecolors') ||
1.57 raeburn 394: ($action eq 'usercreation') || ($action eq 'usermodification') ||
395: ($action eq 'coursecategories')) {
1.6 raeburn 396: my $colspan = ($action eq 'rolecolors')?' colspan="2"':'';
1.30 raeburn 397: $output .= '
1.3 raeburn 398: <tr>
399: <td>
400: <table class="LC_nested">
401: <tr class="LC_info_row">
1.59 bisitz 402: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[0]->{'col1'}).'</td>
403: <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
1.30 raeburn 404: </tr>';
405: $rowtotal ++;
1.6 raeburn 406: if ($action eq 'autoupdate') {
1.30 raeburn 407: $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal);
1.28 raeburn 408: } elsif ($action eq 'usercreation') {
1.33 raeburn 409: $output .= &print_usercreation('top',$dom,$settings,\$rowtotal);
410: } elsif ($action eq 'usermodification') {
411: $output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
1.57 raeburn 412: } elsif ($action eq 'coursecategories') {
413: $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
1.6 raeburn 414: } else {
1.30 raeburn 415: $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
1.6 raeburn 416: }
1.30 raeburn 417: $output .= '
1.6 raeburn 418: </table>
419: </td>
420: </tr>
421: <tr>
422: <td>
423: <table class="LC_nested">
424: <tr class="LC_info_row">
1.59 bisitz 425: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
1.57 raeburn 426: my $colspan = ($action eq 'coursecategories')?' colspan="2"':'';
427: $output .= '
1.59 bisitz 428: <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[1]->{'col2'}).'</td>
1.30 raeburn 429: </tr>';
430: $rowtotal ++;
1.6 raeburn 431: if ($action eq 'autoupdate') {
1.30 raeburn 432: $output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
1.28 raeburn 433: } elsif ($action eq 'usercreation') {
1.34 raeburn 434: $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'
435: </table>
436: </td>
437: </tr>
438: <tr>
439: <td>
440: <table class="LC_nested">
441: <tr class="LC_info_row">
1.59 bisitz 442: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
443: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> </tr>'.
1.34 raeburn 444: &print_usercreation('bottom',$dom,$settings,\$rowtotal);
445: $rowtotal ++;
1.33 raeburn 446: } elsif ($action eq 'usermodification') {
1.63 ! raeburn 447: $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal).'
! 448: </table>
! 449: </td>
! 450: </tr>
! 451: <tr>
! 452: <td>
! 453: <table class="LC_nested">
! 454: <tr class="LC_info_row">
! 455: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
! 456: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> </tr>'.
! 457:
! 458: &print_usermodification('bottom',$dom,$settings,\$rowtotal);
! 459: $rowtotal ++;
1.57 raeburn 460: } elsif ($action eq 'coursecategories') {
461: $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
1.6 raeburn 462: } else {
1.30 raeburn 463: $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
1.6 raeburn 464: </table>
465: </td>
466: </tr>
467: <tr>
468: <td>
469: <table class="LC_nested">
470: <tr class="LC_info_row">
1.59 bisitz 471: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
472: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
1.3 raeburn 473: </tr>'.
1.30 raeburn 474: &print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'
1.3 raeburn 475: </table>
476: </td>
477: </tr>
478: <tr>
479: <td>
480: <table class="LC_nested">
481: <tr class="LC_info_row">
1.59 bisitz 482: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col1'}).'</td>
483: <td class="LC_right_item">'.&mt($item->{'header'}->[3]->{'col2'}).'</td>
1.3 raeburn 484: </tr>'.
1.30 raeburn 485: &print_rolecolors($phase,'admin',$dom,$confname,$settings,\$rowtotal);
486: $rowtotal += 2;
1.6 raeburn 487: }
1.3 raeburn 488: } else {
1.30 raeburn 489: $output .= '
1.3 raeburn 490: <tr>
491: <td>
492: <table class="LC_nested">
1.30 raeburn 493: <tr class="LC_info_row">';
1.24 raeburn 494: if (($action eq 'login') || ($action eq 'directorysrch')) {
1.30 raeburn 495: $output .= '
1.59 bisitz 496: <td class="LC_left_item" colspan="2">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
1.6 raeburn 497: } else {
1.30 raeburn 498: $output .= '
1.59 bisitz 499: <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
1.6 raeburn 500: }
1.30 raeburn 501: $output .= '
1.59 bisitz 502: <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
1.30 raeburn 503: </tr>';
1.48 raeburn 504: $rowtotal ++;
1.3 raeburn 505: if ($action eq 'login') {
1.30 raeburn 506: $output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal);
1.3 raeburn 507: } elsif ($action eq 'quotas') {
1.30 raeburn 508: $output .= &print_quotas($dom,$settings,\$rowtotal);
1.3 raeburn 509: } elsif ($action eq 'autoenroll') {
1.30 raeburn 510: $output .= &print_autoenroll($dom,$settings,\$rowtotal);
1.23 raeburn 511: } elsif ($action eq 'directorysrch') {
1.30 raeburn 512: $output .= &print_directorysrch($dom,$settings,\$rowtotal);
1.28 raeburn 513: } elsif ($action eq 'contacts') {
1.30 raeburn 514: $output .= &print_contacts($dom,$settings,\$rowtotal);
1.43 raeburn 515: } elsif ($action eq 'defaults') {
516: $output .= &print_defaults($dom,\$rowtotal);
1.46 raeburn 517: } elsif ($action eq 'scantron') {
518: $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
1.27 raeburn 519: }
1.3 raeburn 520: }
1.30 raeburn 521: $output .= '
1.3 raeburn 522: </table>
523: </td>
524: </tr>
1.30 raeburn 525: </table><br />';
526: return ($output,$rowtotal);
1.1 raeburn 527: }
528:
529: sub print_header {
1.3 raeburn 530: my ($r,$phase) = @_;
1.30 raeburn 531: my $alert = &mt('You must select at least one functionality type to display.');
1.6 raeburn 532: my $js = '
1.1 raeburn 533: <script type="text/javascript">
534: function changePage(formname,newphase) {
535: formname.phase.value = newphase;
1.30 raeburn 536: numchecked = 0;
537: if (formname == document.pickactions) {
538: if (formname.actions.length > 0) {
1.48 raeburn 539: for (var i = 0; i<formname.actions.length; i++) {
1.30 raeburn 540: if (formname.actions[i].checked) {
541: numchecked ++;
542: }
543: }
544: } else {
545: if (formname.actions.checked) {
546: numchecked ++;
547: }
548: }
549: if (numchecked > 0) {
550: formname.submit();
551: } else {
552: alert("'.$alert.'");
553: return;
554: }
555: }
1.1 raeburn 556: formname.submit();
1.30 raeburn 557: }'."\n";
558: if ($phase eq 'pickactions') {
559: $js .=
560: &Apache::lonhtmlcommon::set_form_elements({actions => 'checkbox',numcols => 'radio',})."\n".
561: &javascript_set_colnums();
562: } elsif ($phase eq 'display') {
563: $js .= &color_pick_js()."\n";
564: }
1.31 raeburn 565: $js .= &Apache::loncommon::viewport_size_js().'
1.1 raeburn 566: </script>
1.6 raeburn 567: ';
1.30 raeburn 568: my $additem;
569: if ($phase eq 'pickactions') {
570: my %loaditems = (
1.31 raeburn 571: 'onload' => "javascript:getViewportDims(document.$phase.width,document.$phase.height);setDisplayColumns();setFormElements(document.pickactions);",
1.30 raeburn 572: );
573: $additem = {'add_entries' => \%loaditems,};
574: } else {
575: my %loaditems = (
1.31 raeburn 576: 'onload' => "javascript:getViewportDims(document.$phase.width,document.$phase.height);",
1.30 raeburn 577: );
578: $additem = {'add_entries' => \%loaditems,};
579: }
1.2 albertel 580: $r->print(&Apache::loncommon::start_page('View/Modify Domain Settings',
1.30 raeburn 581: $js,$additem));
1.3 raeburn 582: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Domain Settings'));
1.6 raeburn 583: $r->print('
1.8 raeburn 584: <form name="parmform" action="">
1.6 raeburn 585: <input type="hidden" name="pres_marker" />
586: <input type="hidden" name="pres_type" />
587: <input type="hidden" name="pres_value" />
588: </form>
589: ');
590: $r->print('<form method="post" name="'.$phase.'" action="/adm/domainprefs"'.
591: ' enctype="multipart/form-data">');
1.1 raeburn 592: return;
593: }
594:
595: sub print_footer {
1.30 raeburn 596: my ($r,$phase,$newphase,$button_text,$actions) = @_;
1.3 raeburn 597: $button_text = &mt($button_text);
1.30 raeburn 598: $r->print('<input type="hidden" name="phase" value="" />'.
599: '<input type="hidden" name="width" value="'.
600: $env{'form.width'}.'" />'.
601: '<input type="hidden" name="height" value="'.
602: $env{'form.height'}.'" />');
603: if (($phase eq 'display') || ($phase eq 'process')) {
604: if (ref($actions) eq 'ARRAY') {
605: foreach my $item (@{$actions}) {
606: $r->print('<input type="hidden" name="actions" value="'.$item.'" />')."\n";
607: }
608: }
609: $r->print('<input type="hidden" name="numcols" value="'.$env{'form.numcols'}.'" />');
610: }
1.3 raeburn 611: my $dest='"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
612: if ($phase eq 'process') {
1.30 raeburn 613: $r->print('<p><a href='.$dest.'>'.$button_text.'</a></p>');
1.3 raeburn 614: } else {
1.30 raeburn 615: my $onclick;
616: if ($phase eq 'display') {
617: $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
618: } else {
619: $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
620: }
621: $r->print('<p><input type="button" name="store" value="'.
622: $button_text.'" onclick='.$onclick.' /></p>');
623: }
624: if ($phase eq 'process') {
625: $r->print('</form>'.&Apache::loncommon::end_page());
1.3 raeburn 626: }
1.1 raeburn 627: return;
628: }
629:
1.3 raeburn 630: sub print_login {
1.30 raeburn 631: my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
1.6 raeburn 632: my %choices = &login_choices();
1.42 raeburn 633: my %defaultchecked = (
1.43 raeburn 634: 'coursecatalog' => 'on',
635: 'adminmail' => 'off',
636: 'newuser' => 'off',
637: );
638: my @toggles = ('coursecatalog','adminmail','newuser');
1.42 raeburn 639: my (%checkedon,%checkedoff);
640: foreach my $item (@toggles) {
641: if ($defaultchecked{$item} eq 'on') {
642: $checkedon{$item} = ' checked="checked" ';
643: $checkedoff{$item} = ' ';
644: } elsif ($defaultchecked{$item} eq 'off') {
645: $checkedoff{$item} = ' checked="checked" ';
646: $checkedon{$item} = ' ';
647: }
648: }
649: my $loginheader = 'image';
1.41 raeburn 650: my @images = ('img','logo','domlogo','login');
651: my @logintext = ('textcol','bgcol');
1.6 raeburn 652: my @bgs = ('pgbg','mainbg','sidebg');
653: my @links = ('link','alink','vlink');
1.7 albertel 654: my %designhash = &Apache::loncommon::get_domainconf($dom);
1.6 raeburn 655: my %defaultdesign = %Apache::loncommon::defaultdesign;
656: my (%is_custom,%designs);
657: my %defaults = (
658: font => $defaultdesign{'login.font'},
659: );
660: foreach my $item (@images) {
661: $defaults{$item} = $defaultdesign{'login.'.$item};
662: }
663: foreach my $item (@bgs) {
664: $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
665: }
1.41 raeburn 666: foreach my $item (@logintext) {
667: $defaults{'logintext'}{$item} = $defaultdesign{'login.'.$item};
668: }
1.6 raeburn 669: foreach my $item (@links) {
670: $defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
671: }
1.3 raeburn 672: if (ref($settings) eq 'HASH') {
1.42 raeburn 673: foreach my $item (@toggles) {
674: if ($settings->{$item} eq '1') {
675: $checkedon{$item} = ' checked="checked" ';
676: $checkedoff{$item} = ' ';
677: } elsif ($settings->{$item} eq '0') {
678: $checkedoff{$item} = ' checked="checked" ';
679: $checkedon{$item} = ' ';
680: }
1.1 raeburn 681: }
1.6 raeburn 682: foreach my $item (@images) {
683: if ($settings->{$item} ne '') {
684: $designs{$item} = $settings->{$item};
685: $is_custom{$item} = 1;
686: }
687: }
1.41 raeburn 688: foreach my $item (@logintext) {
689: if ($settings->{$item} ne '') {
690: $designs{'logintext'}{$item} = $settings->{$item};
691: $is_custom{$item} = 1;
692: }
693: }
694: if ($settings->{'loginheader'} ne '') {
695: $loginheader = $settings->{'loginheader'};
696: }
1.6 raeburn 697: if ($settings->{'font'} ne '') {
698: $designs{'font'} = $settings->{'font'};
699: $is_custom{'font'} = 1;
700: }
701: foreach my $item (@bgs) {
702: if ($settings->{$item} ne '') {
703: $designs{'bgs'}{$item} = $settings->{$item};
704: $is_custom{$item} = 1;
705: }
706: }
707: foreach my $item (@links) {
708: if ($settings->{$item} ne '') {
709: $designs{'links'}{$item} = $settings->{$item};
710: $is_custom{$item} = 1;
711: }
712: }
713: } else {
714: if ($designhash{$dom.'.login.font'} ne '') {
715: $designs{'font'} = $designhash{$dom.'.login.font'};
716: $is_custom{'font'} = 1;
717: }
1.8 raeburn 718: foreach my $item (@images) {
719: if ($designhash{$dom.'.login.'.$item} ne '') {
720: $designs{$item} = $designhash{$dom.'.login.'.$item};
721: $is_custom{$item} = 1;
722: }
723: }
1.6 raeburn 724: foreach my $item (@bgs) {
725: if ($designhash{$dom.'.login.'.$item} ne '') {
726: $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item};
727: $is_custom{$item} = 1;
728: }
729: }
730: foreach my $item (@links) {
731: if ($designhash{$dom.'.login.'.$item} ne '') {
732: $designs{'links'}{$item} = $designhash{$dom.'.login.'.$item};
733: $is_custom{$item} = 1;
734: }
735: }
1.1 raeburn 736: }
1.6 raeburn 737: my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
738: logo => 'Institution Logo',
1.41 raeburn 739: domlogo => 'Domain Logo',
740: login => 'Login box');
1.6 raeburn 741: my $itemcount = 1;
1.42 raeburn 742: my ($css_class,$datatable);
743: foreach my $item (@toggles) {
744: $css_class = $itemcount%2?' class="LC_odd_row"':'';
745: $datatable .=
746: '<tr'.$css_class.'><td colspan="2">'.$choices{$item}.
747: '</td><td>'.
748: '<span class="LC_nobreak"><label><input type="radio" name="'.
749: $item.'"'.$checkedon{$item}.' value="1" />'.&mt('Yes').
750: '</label> <label><input type="radio" name="'.$item.'"'.
751: $checkedoff{$item}.' value="0" />'.&mt('No').'</label></span></td>'.
752: '</tr>';
753: $itemcount ++;
754: }
1.41 raeburn 755: $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext,$loginheader);
1.6 raeburn 756: $datatable .= '</tr></table></td></tr>';
757: return $datatable;
758: }
759:
760: sub login_choices {
761: my %choices =
762: &Apache::lonlocal::texthash (
763: coursecatalog => 'Display Course Catalog link?',
764: adminmail => "Display Administrator's E-mail Address?",
1.43 raeburn 765: newuser => "Link to create a user account",
1.6 raeburn 766: img => "Header",
767: logo => "Main Logo",
768: domlogo => "Domain Logo",
1.41 raeburn 769: login => "Log-in Header",
770: textcol => "Text color",
771: bgcol => "Box color",
1.6 raeburn 772: bgs => "Background colors",
773: links => "Link colors",
774: font => "Font color",
775: pgbg => "Page",
776: mainbg => "Main panel",
777: sidebg => "Side panel",
778: link => "Link",
779: alink => "Active link",
780: vlink => "Visited link",
781: );
782: return %choices;
783: }
784:
785: sub print_rolecolors {
1.30 raeburn 786: my ($phase,$role,$dom,$confname,$settings,$rowtotal) = @_;
1.6 raeburn 787: my %choices = &color_font_choices();
788: my @bgs = ('pgbg','tabbg','sidebg');
789: my @links = ('link','alink','vlink');
790: my @images = ('img');
791: my %alt_text = &Apache::lonlocal::texthash(img => "Banner for $role role");
1.7 albertel 792: my %designhash = &Apache::loncommon::get_domainconf($dom);
1.6 raeburn 793: my %defaultdesign = %Apache::loncommon::defaultdesign;
794: my (%is_custom,%designs);
795: my %defaults = (
796: img => $defaultdesign{$role.'.img'},
797: font => $defaultdesign{$role.'.font'},
798: );
799: foreach my $item (@bgs) {
800: $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
801: }
802: foreach my $item (@links) {
803: $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
804: }
805: if (ref($settings) eq 'HASH') {
806: if (ref($settings->{$role}) eq 'HASH') {
807: if ($settings->{$role}->{'img'} ne '') {
808: $designs{'img'} = $settings->{$role}->{'img'};
809: $is_custom{'img'} = 1;
810: }
811: if ($settings->{$role}->{'font'} ne '') {
812: $designs{'font'} = $settings->{$role}->{'font'};
813: $is_custom{'font'} = 1;
814: }
815: foreach my $item (@bgs) {
816: if ($settings->{$role}->{$item} ne '') {
817: $designs{'bgs'}{$item} = $settings->{$role}->{$item};
818: $is_custom{$item} = 1;
819: }
820: }
821: foreach my $item (@links) {
822: if ($settings->{$role}->{$item} ne '') {
823: $designs{'links'}{$item} = $settings->{$role}->{$item};
824: $is_custom{$item} = 1;
825: }
826: }
827: }
828: } else {
829: if ($designhash{$dom.'.'.$role.'.img'} ne '') {
830: $designs{img} = $designhash{$dom.'.'.$role.'.img'};
831: $is_custom{'img'} = 1;
832: }
833: if ($designhash{$dom.'.'.$role.'.font'} ne '') {
834: $designs{font} = $designhash{$dom.'.'.$role.'.font'};
835: $is_custom{'font'} = 1;
836: }
837: foreach my $item (@bgs) {
838: if ($designhash{$dom.'.'.$role.'.'.$item} ne '') {
839: $designs{'bgs'}{$item} = $designhash{$dom.'.'.$role.'.'.$item};
840: $is_custom{$item} = 1;
841:
842: }
843: }
844: foreach my $item (@links) {
845: if ($designhash{$dom.'.'.$role.'.'.$item} ne '') {
846: $designs{'links'}{$item} = $designhash{$dom.'.'.$role.'.'.$item};
847: $is_custom{$item} = 1;
848: }
849: }
850: }
851: my $itemcount = 1;
1.30 raeburn 852: my $datatable = &display_color_options($dom,$confname,$phase,$role,$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal);
1.6 raeburn 853: $datatable .= '</tr></table></td></tr>';
854: return $datatable;
855: }
856:
857: sub display_color_options {
1.9 raeburn 858: my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
1.41 raeburn 859: $images,$bgs,$links,$alt_text,$rowtotal,$logintext,$loginheader) = @_;
1.6 raeburn 860: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
861: my $datatable = '<tr'.$css_class.'>'.
862: '<td>'.$choices->{'font'}.'</td>';
863: if (!$is_custom->{'font'}) {
1.30 raeburn 864: $datatable .= '<td>'.&mt('Default in use:').' <span id="css_default_'.$role.'_font" style="color: '.$defaults->{'font'}.';">'.$defaults->{'font'}.'</span></td>';
1.6 raeburn 865: } else {
866: $datatable .= '<td> </td>';
867: }
868: my $fontlink = &color_pick($phase,$role,'font',$choices->{'font'},$designs->{'font'});
1.8 raeburn 869: $datatable .= '<td><span class="LC_nobreak">'.
1.6 raeburn 870: '<input type="text" size="10" name="'.$role.'_font"'.
1.8 raeburn 871: ' value="'.$designs->{'font'}.'" /> '.$fontlink.
1.30 raeburn 872: ' <span id="css_'.$role.'_font" style="background-color: '.
873: $designs->{'font'}.';"> </span>'.
1.8 raeburn 874: '</span></td></tr>';
1.9 raeburn 875: my $switchserver = &check_switchserver($dom,$confname);
1.6 raeburn 876: foreach my $img (@{$images}) {
1.18 albertel 877: $itemcount ++;
1.6 raeburn 878: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.8 raeburn 879: $datatable .= '<tr'.$css_class.'>'.
1.6 raeburn 880: '<td>'.$choices->{$img}.'</td>';
1.41 raeburn 881: my ($imgfile,$img_import,$login_hdr_pick,$logincolors);
1.6 raeburn 882: if ($designs->{$img} ne '') {
883: $imgfile = $designs->{$img};
1.18 albertel 884: $img_import = ($imgfile =~ m{^/adm/});
1.6 raeburn 885: } else {
886: $imgfile = $defaults->{$img};
887: }
1.41 raeburn 888: if ($img eq 'login') {
889: $login_hdr_pick = &login_header_options($img,$role,$defaults,$is_custom,$choices,
890: $loginheader);
891: $logincolors =
892: &login_text_colors($img,$role,$logintext,$phase,$choices,$designs);
893: }
1.6 raeburn 894: if ($imgfile) {
1.9 raeburn 895: my ($showfile,$fullsize);
896: if ($imgfile =~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
1.6 raeburn 897: my $urldir = $1;
898: my $filename = $2;
899: my @info = &Apache::lonnet::stat_file($designs->{$img});
900: if (@info) {
901: my $thumbfile = 'tn-'.$filename;
902: my @thumb=&Apache::lonnet::stat_file($urldir.'/'.$thumbfile);
903: if (@thumb) {
904: $showfile = $urldir.'/'.$thumbfile;
905: } else {
906: $showfile = $imgfile;
907: }
908: } else {
909: $showfile = '';
910: }
911: } elsif ($imgfile =~ m-^/(adm/[^/]+)/([^/]+)$-) {
1.16 raeburn 912: $showfile = $imgfile;
1.6 raeburn 913: my $imgdir = $1;
914: my $filename = $2;
915: if (-e "/home/httpd/html/$imgdir/tn-".$filename) {
916: $showfile = "/$imgdir/tn-".$filename;
917: } else {
918: my $input = "/home/httpd/html".$imgfile;
919: my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename;
920: if (!-e $output) {
1.9 raeburn 921: my ($width,$height) = &thumb_dimensions();
1.16 raeburn 922: my ($fullwidth,$fullheight) = &check_dimensions($input);
923: if ($fullwidth ne '' && $fullheight ne '') {
924: if ($fullwidth > $width && $fullheight > $height) {
925: my $size = $width.'x'.$height;
926: system("convert -sample $size $input $output");
927: $showfile = '/'.$imgdir.'/tn-'.$filename;
928: }
929: }
1.6 raeburn 930: }
931: }
1.16 raeburn 932: }
1.6 raeburn 933: if ($showfile) {
1.40 raeburn 934: if ($showfile =~ m{^/(adm|res)/}) {
935: if ($showfile =~ m{^/res/}) {
936: my $local_showfile =
937: &Apache::lonnet::filelocation('',$showfile);
938: &Apache::lonnet::repcopy($local_showfile);
939: }
940: $showfile = &Apache::loncommon::lonhttpdurl($showfile);
941: }
942: if ($imgfile) {
943: if ($imgfile =~ m{^/(adm|res)/}) {
944: if ($imgfile =~ m{^/res/}) {
945: my $local_imgfile =
946: &Apache::lonnet::filelocation('',$imgfile);
947: &Apache::lonnet::repcopy($local_imgfile);
948: }
949: $fullsize = &Apache::loncommon::lonhttpdurl($imgfile);
950: } else {
951: $fullsize = $imgfile;
952: }
953: }
1.41 raeburn 954: $datatable .= '<td>';
955: if ($img eq 'login') {
956: $datatable .= $login_hdr_pick;
1.6 raeburn 957: }
1.41 raeburn 958: $datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import,
959: $showfile,$fullsize,$role,$img,$imgfile,$logincolors);
1.6 raeburn 960: } else {
961: $datatable .= '<td colspan="2" class="LC_right_item"><br />'.
962: &mt('Upload:');
963: }
964: } else {
965: $datatable .= '<td colspan="2" class="LC_right_item"><br />'.
966: &mt('Upload:');
967: }
1.9 raeburn 968: if ($switchserver) {
969: $datatable .= &mt('Upload to library server: [_1]',$switchserver);
970: } else {
971: $datatable .=' <input type="file" name="'.$role.'_'.$img.'" />';
972: }
973: $datatable .= '</td></tr>';
1.6 raeburn 974: }
975: $itemcount ++;
976: $css_class = $itemcount%2?' class="LC_odd_row"':'';
977: $datatable .= '<tr'.$css_class.'>'.
978: '<td>'.$choices->{'bgs'}.'</td>';
979: my $bgs_def;
980: foreach my $item (@{$bgs}) {
981: if (!$is_custom->{$item}) {
1.30 raeburn 982: $bgs_def .= '<td>'.$choices->{$item}.' <span id="css_default_'.$role.'_'.$item.'" style="background-color: '.$defaults->{'bgs'}{$item}.';"> </span><br />'.$defaults->{'bgs'}{$item}.'</td>';
1.6 raeburn 983: }
984: }
985: if ($bgs_def) {
1.8 raeburn 986: $datatable .= '<td>'.&mt('Default(s) in use:').'<br /><table border="0"><tr>'.$bgs_def.'</tr></table></td>';
1.6 raeburn 987: } else {
988: $datatable .= '<td> </td>';
989: }
990: $datatable .= '<td class="LC_right_item">'.
991: '<table border="0"><tr>';
992: foreach my $item (@{$bgs}) {
993: my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'bgs'}{$item});
994: $datatable .= '<td align="center">'.$link;
995: if ($designs->{'bgs'}{$item}) {
1.30 raeburn 996: $datatable .= ' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'bgs'}{$item}.';"> </span>';
1.6 raeburn 997: }
998: $datatable .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.$designs->{'bgs'}{$item}.
1.41 raeburn 999: '" onblur = "javascript:colchg_span('."'css_".$role.'_'.$item."'".',this);" /></td>';
1.6 raeburn 1000: }
1001: $datatable .= '</tr></table></td></tr>';
1002: $itemcount ++;
1003: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1004: $datatable .= '<tr'.$css_class.'>'.
1005: '<td>'.$choices->{'links'}.'</td>';
1006: my $links_def;
1007: foreach my $item (@{$links}) {
1008: if (!$is_custom->{$item}) {
1.30 raeburn 1009: $links_def .= '<td>'.$choices->{$item}.'<br /><span id="css_default_'.$role.'_'.$item.'" style="color: '.$defaults->{'links'}{$item}.';">'.$defaults->{'links'}{$item}.'</span></td>';
1.6 raeburn 1010: }
1011: }
1012: if ($links_def) {
1.8 raeburn 1013: $datatable .= '<td>'.&mt('Default(s) in use:').'<br /><table border="0"><tr>'.$links_def.'</tr></table></td>';
1.6 raeburn 1014: } else {
1015: $datatable .= '<td> </td>';
1016: }
1017: $datatable .= '<td class="LC_right_item">'.
1018: '<table border="0"><tr>';
1019: foreach my $item (@{$links}) {
1.30 raeburn 1020: $datatable .= '<td align="center">'."\n".
1021: &color_pick($phase,$role,$item,$choices->{$item},
1022: $designs->{'links'}{$item});
1.6 raeburn 1023: if ($designs->{'links'}{$item}) {
1.30 raeburn 1024: $datatable.=' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'links'}{$item}.';"> </span>';
1.6 raeburn 1025: }
1026: $datatable .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.$designs->{'links'}{$item}.
1027: '" /></td>';
1028: }
1.30 raeburn 1029: $$rowtotal += $itemcount;
1.3 raeburn 1030: return $datatable;
1031: }
1032:
1.41 raeburn 1033: sub login_header_options {
1034: my ($img,$role,$defaults,$is_custom,$choices,$loginheader) = @_;
1035: my $image_checked = ' checked="checked" ';
1036: my $text_checked = ' ';
1037: if ($loginheader eq 'text') {
1038: $image_checked = ' ';
1039: $text_checked = ' checked="checked" ';
1040: }
1041: my $output = '<span class="LC_nobreak"><label><input type="radio" name="'.
1042: 'loginheader" value="image" '.$image_checked.'/>'.
1043: &mt('use image').'</label> '.
1044: '<label><input type="radio" name="loginheader" value="text"'.
1045: $text_checked.'/>'.&mt('use text').'</label><br />'."\n";
1046: if ((!$is_custom->{'textcol'}) || (!$is_custom->{'bgcol'})) {
1047: $output .= &mt('Text default(s)').':<br />';
1048: if (!$is_custom->{'textcol'}) {
1049: $output .= $choices->{'textcol'}.': '.$defaults->{'logintext'}{'textcol'}.
1050: ' ';
1051: }
1052: if (!$is_custom->{'bgcol'}) {
1053: $output .= $choices->{'bgcol'}.': '.
1054: '<span id="css_'.$role.'_font" style="background-color: '.
1055: $defaults->{'logintext'}{'bgcol'}.';"> </span>';
1056: }
1057: $output .= '<br />';
1058: }
1059: $output .='<br />';
1060: return $output;
1061: }
1062:
1063: sub login_text_colors {
1064: my ($img,$role,$logintext,$phase,$choices,$designs) = @_;
1065: my $color_menu = '<table border="0"><tr>';
1066: foreach my $item (@{$logintext}) {
1067: my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'logintext'}{$item});
1068: $color_menu .= '<td align="center">'.$link;
1069: if ($designs->{'logintext'}{$item}) {
1070: $color_menu .= ' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'logintext'}{$item}.';"> </span>';
1071: }
1072: $color_menu .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.
1073: $designs->{'logintext'}{$item}.'" onblur = "javascript:colchg_span('."'css_".$role.'_'.$item."'".',this);" /></td>'.
1074: '<td> </td>';
1075: }
1076: $color_menu .= '</tr></table><br />';
1077: return $color_menu;
1078: }
1079:
1080: sub image_changes {
1081: my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;
1082: my $output;
1083: if (!$is_custom) {
1084: if ($img eq 'login') {
1085: $output .= &mt('Default image:').'<br />';
1086: } else {
1087: $output .= &mt('Default in use:').'<br />';
1088: }
1089: }
1090: if ($img_import) {
1091: $output .= '<input type="hidden" name="'.$role.'_import_'.$img.'" value="'.$imgfile.'" />';
1092: }
1093: $output .= '<a href="'.$fullsize.'" target="_blank"><img src="'.
1094: $showfile.'" alt="'.$alt_text.'" border="0" /></a></td>';
1095: if ($is_custom) {
1096: $output .= '<td>'.$logincolors.'<span class="LC_nobreak"><label>'.
1097: '<input type="checkbox" name="'.
1098: $role.'_del_'.$img.'" value="1" />'.&mt('Delete?').
1099: '</label> '.&mt('Replace:').'</span><br />';
1100: } else {
1101: $output .= '<td valign="bottom">'.$logincolors.&mt('Upload:').'<br />';
1102: }
1103: return $output;
1104: }
1105:
1.6 raeburn 1106: sub color_pick {
1107: my ($phase,$role,$item,$desc,$curcol) = @_;
1108: my $link = '<a href="javascript:pjump('."'color_custom','".$desc.
1109: "','".$curcol."','".$role.'_'.$item."','parmform.pres','psub'".
1110: ');">'.$desc.'</a>';
1111: return $link;
1112: }
1113:
1114: sub color_pick_js {
1115: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1116: my $output = <<"ENDCOL";
1117: function pclose() {
1118: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms","height=350,width=350,scrollbars=no,menubar=no");
1119: parmwin.close();
1120: }
1121:
1122: $pjump_def
1123:
1124: function psub() {
1125: pclose();
1126: if (document.parmform.pres_marker.value!='') {
1127: if (document.parmform.pres_type.value!='') {
1128: eval('document.display.'+
1129: document.parmform.pres_marker.value+
1130: '.value=document.parmform.pres_value.value;');
1131: }
1132: } else {
1133: document.parmform.pres_value.value='';
1134: document.parmform.pres_marker.value='';
1135: }
1136: }
1.41 raeburn 1137:
1138: function get_id (span_id) {
1139: if (document.getElementById) {
1140: return document.getElementById(span_id);
1141: }
1142: if (document.all) {
1143: return document.all[span_id];
1144: }
1145: return false;
1146: }
1147:
1148: function colchg_span (span_id_str,new_color_item) {
1149: var span_ref = get_id(span_id_str);
1150: if (span_ref.style) { span_ref = span_ref.style; }
1151: span_ref.background = new_color_item.value;
1152: span_ref.backgroundColor = new_color_item.value;
1153: span_ref.bgColor = new_color_item.value;
1154: }
1155:
1.6 raeburn 1156: ENDCOL
1157: return $output;
1158: }
1159:
1.3 raeburn 1160: sub print_quotas {
1.30 raeburn 1161: my ($dom,$settings,$rowtotal) = @_;
1.3 raeburn 1162: my $datatable;
1.44 raeburn 1163: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.3 raeburn 1164: my $typecount = 0;
1165: my $css_class;
1.26 raeburn 1166: if (ref($types) eq 'ARRAY') {
1.23 raeburn 1167: foreach my $type (@{$types}) {
1.3 raeburn 1168: if (defined($usertypes->{$type})) {
1169: $typecount ++;
1170: $css_class = $typecount%2?' class="LC_odd_row"':'';
1171: $datatable .= '<tr'.$css_class.'>'.
1172: '<td>'.$usertypes->{$type}.'</td>'.
1.8 raeburn 1173: '<td class="LC_right_item"><span class="LC_nobreak">'.
1.3 raeburn 1174: '<input type="text" name="quota_'.$type.
1175: '" value="'.$settings->{$type}.
1.8 raeburn 1176: '" size="5" /> Mb</span></td></tr>';
1.3 raeburn 1177: }
1178: }
1179: }
1180: my $defaultquota = '20';
1181: if (ref($settings) eq 'HASH') {
1182: if (defined($settings->{'default'})) {
1183: $defaultquota = $settings->{'default'};
1184: }
1185: }
1186: $typecount ++;
1187: $css_class = $typecount%2?' class="LC_odd_row"':'';
1188: $datatable .= '<tr'.$css_class.'>'.
1.26 raeburn 1189: '<td>'.$othertitle.'</td>'.
1.8 raeburn 1190: '<td class="LC_right_item"><span class="LC_nobreak">'.
1.15 raeburn 1191: '<input type="text" name="defaultquota" value="'.
1.8 raeburn 1192: $defaultquota.'" size="5" /> Mb</span></td></tr>';
1.30 raeburn 1193: $$rowtotal += $typecount;
1.3 raeburn 1194: return $datatable;
1195: }
1196:
1197: sub print_autoenroll {
1.30 raeburn 1198: my ($dom,$settings,$rowtotal) = @_;
1.3 raeburn 1199: my $autorun = &Apache::lonnet::auto_run(undef,$dom),
1.17 raeburn 1200: my ($defdom,$runon,$runoff);
1.3 raeburn 1201: if (ref($settings) eq 'HASH') {
1202: if (exists($settings->{'run'})) {
1203: if ($settings->{'run'} eq '0') {
1204: $runoff = ' checked="checked" ';
1205: $runon = ' ';
1206: } else {
1207: $runon = ' checked="checked" ';
1208: $runoff = ' ';
1209: }
1210: } else {
1211: if ($autorun) {
1212: $runon = ' checked="checked" ';
1213: $runoff = ' ';
1214: } else {
1215: $runoff = ' checked="checked" ';
1216: $runon = ' ';
1217: }
1218: }
1219: if (exists($settings->{'sender_domain'})) {
1220: $defdom = $settings->{'sender_domain'};
1221: }
1.14 raeburn 1222: } else {
1223: if ($autorun) {
1224: $runon = ' checked="checked" ';
1225: $runoff = ' ';
1226: } else {
1227: $runoff = ' checked="checked" ';
1228: $runon = ' ';
1229: }
1.3 raeburn 1230: }
1231: my $domform = &Apache::loncommon::select_dom_form($defdom,'sender_domain',1);
1.39 raeburn 1232: my $notif_sender;
1233: if (ref($settings) eq 'HASH') {
1234: $notif_sender = $settings->{'sender_uname'};
1235: }
1.3 raeburn 1236: my $datatable='<tr class="LC_odd_row">'.
1237: '<td>'.&mt('Auto-enrollment active?').'</td>'.
1.8 raeburn 1238: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1.3 raeburn 1239: '<input type="radio" name="autoenroll_run"'.
1.8 raeburn 1240: $runon.' value="1" />'.&mt('Yes').'</label> '.
1241: '<label><input type="radio" name="autoenroll_run"'.
1.14 raeburn 1242: $runoff.' value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1243: '</tr><tr>'.
1244: '<td>'.&mt('Notification messages - sender').
1.8 raeburn 1245: '</td><td class="LC_right_item"><span class="LC_nobreak">'.
1.3 raeburn 1246: &mt('username').': '.
1247: '<input type="text" name="sender_uname" value="'.
1.39 raeburn 1248: $notif_sender.'" size="10" /> '.&mt('domain').
1.8 raeburn 1249: ': '.$domform.'</span></td></tr>';
1.30 raeburn 1250: $$rowtotal += 2;
1.3 raeburn 1251: return $datatable;
1252: }
1253:
1254: sub print_autoupdate {
1.30 raeburn 1255: my ($position,$dom,$settings,$rowtotal) = @_;
1.3 raeburn 1256: my $datatable;
1257: if ($position eq 'top') {
1258: my $updateon = ' ';
1259: my $updateoff = ' checked="checked" ';
1260: my $classlistson = ' ';
1261: my $classlistsoff = ' checked="checked" ';
1262: if (ref($settings) eq 'HASH') {
1263: if ($settings->{'run'} eq '1') {
1264: $updateon = $updateoff;
1265: $updateoff = ' ';
1266: }
1267: if ($settings->{'classlists'} eq '1') {
1268: $classlistson = $classlistsoff;
1269: $classlistsoff = ' ';
1270: }
1271: }
1272: my %title = (
1273: run => 'Auto-update active?',
1274: classlists => 'Update information in classlists?',
1275: );
1276: $datatable = '<tr class="LC_odd_row">'.
1277: '<td>'.&mt($title{'run'}).'</td>'.
1.8 raeburn 1278: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1.3 raeburn 1279: '<input type="radio" name="autoupdate_run"'.
1.8 raeburn 1280: $updateon.' value="1" />'.&mt('Yes').'</label> '.
1281: '<label><input type="radio" name="autoupdate_run"'.
1282: $updateoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1283: '</tr><tr>'.
1284: '<td>'.&mt($title{'classlists'}).'</td>'.
1.8 raeburn 1285: '<td class="LC_right_item"><span class="LC_nobreak">'.
1286: '<label><input type="radio" name="classlists"'.
1287: $classlistson.' value="1" />'.&mt('Yes').'</label> '.
1288: '<label><input type="radio" name="classlists"'.
1289: $classlistsoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1290: '</tr>';
1.30 raeburn 1291: $$rowtotal += 2;
1.3 raeburn 1292: } else {
1.44 raeburn 1293: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.20 raeburn 1294: my @fields = ('lastname','firstname','middlename','gen',
1295: 'permanentemail','id');
1.33 raeburn 1296: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
1.3 raeburn 1297: my $numrows = 0;
1.26 raeburn 1298: if (ref($types) eq 'ARRAY') {
1299: if (@{$types} > 0) {
1300: $datatable =
1301: &usertype_update_row($settings,$usertypes,\%fieldtitles,
1302: \@fields,$types,\$numrows);
1.30 raeburn 1303: $$rowtotal += @{$types};
1.26 raeburn 1304: }
1.3 raeburn 1305: }
1306: $datatable .=
1307: &usertype_update_row($settings,{'default' => $othertitle},
1308: \%fieldtitles,\@fields,['default'],
1309: \$numrows);
1.30 raeburn 1310: $$rowtotal ++;
1.3 raeburn 1311: }
1312: return $datatable;
1313: }
1314:
1.23 raeburn 1315: sub print_directorysrch {
1.30 raeburn 1316: my ($dom,$settings,$rowtotal) = @_;
1.23 raeburn 1317: my $srchon = ' ';
1318: my $srchoff = ' checked="checked" ';
1.25 raeburn 1319: my ($exacton,$containson,$beginson);
1.24 raeburn 1320: my $localon = ' ';
1321: my $localoff = ' checked="checked" ';
1.23 raeburn 1322: if (ref($settings) eq 'HASH') {
1323: if ($settings->{'available'} eq '1') {
1324: $srchon = $srchoff;
1325: $srchoff = ' ';
1326: }
1.24 raeburn 1327: if ($settings->{'localonly'} eq '1') {
1328: $localon = $localoff;
1329: $localoff = ' ';
1330: }
1.25 raeburn 1331: if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
1332: foreach my $type (@{$settings->{'searchtypes'}}) {
1333: if ($type eq 'exact') {
1334: $exacton = ' checked="checked" ';
1335: } elsif ($type eq 'contains') {
1336: $containson = ' checked="checked" ';
1337: } elsif ($type eq 'begins') {
1338: $beginson = ' checked="checked" ';
1339: }
1340: }
1341: } else {
1342: if ($settings->{'searchtypes'} eq 'exact') {
1343: $exacton = ' checked="checked" ';
1344: } elsif ($settings->{'searchtypes'} eq 'contains') {
1345: $containson = ' checked="checked" ';
1346: } elsif ($settings->{'searchtypes'} eq 'specify') {
1347: $exacton = ' checked="checked" ';
1348: $containson = ' checked="checked" ';
1349: }
1.23 raeburn 1350: }
1351: }
1352: my ($searchtitles,$titleorder) = &sorted_searchtitles();
1.45 raeburn 1353: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.23 raeburn 1354:
1355: my $numinrow = 4;
1.26 raeburn 1356: my $cansrchrow = 0;
1.23 raeburn 1357: my $datatable='<tr class="LC_odd_row">'.
1.30 raeburn 1358: '<td colspan="2"><span class ="LC_nobreak">'.&mt('Directory search available?').'</span></td>'.
1.23 raeburn 1359: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1360: '<input type="radio" name="dirsrch_available"'.
1361: $srchon.' value="1" />'.&mt('Yes').'</label> '.
1362: '<label><input type="radio" name="dirsrch_available"'.
1363: $srchoff.' value="0" />'.&mt('No').'</label></span></td>'.
1364: '</tr><tr>'.
1.30 raeburn 1365: '<td colspan="2"><span class ="LC_nobreak">'.&mt('Other domains can search?').'</span></td>'.
1.24 raeburn 1366: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1367: '<input type="radio" name="dirsrch_localonly"'.
1368: $localoff.' value="0" />'.&mt('Yes').'</label> '.
1369: '<label><input type="radio" name="dirsrch_localonly"'.
1370: $localon.' value="1" />'.&mt('No').'</label></span></td>'.
1.25 raeburn 1371: '</tr>';
1.30 raeburn 1372: $$rowtotal += 2;
1.26 raeburn 1373: if (ref($usertypes) eq 'HASH') {
1374: if (keys(%{$usertypes}) > 0) {
1375: $datatable .= &users_cansearch_row($settings,$types,$usertypes,$dom,
1376: $numinrow,$othertitle);
1377: $cansrchrow = 1;
1378: }
1379: }
1380: if ($cansrchrow) {
1.30 raeburn 1381: $$rowtotal ++;
1.26 raeburn 1382: $datatable .= '<tr>';
1383: } else {
1384: $datatable .= '<tr class="LC_odd_row">';
1385: }
1.30 raeburn 1386: $datatable .= '<td><span class ="LC_nobreak">'.&mt('Supported search methods').
1387: '</span></td><td class="LC_left_item" colspan="2"><table><tr>';
1.25 raeburn 1388: foreach my $title (@{$titleorder}) {
1389: if (defined($searchtitles->{$title})) {
1390: my $check = ' ';
1.39 raeburn 1391: if (ref($settings) eq 'HASH') {
1392: if (ref($settings->{'searchby'}) eq 'ARRAY') {
1393: if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
1394: $check = ' checked="checked" ';
1395: }
1.25 raeburn 1396: }
1397: }
1398: $datatable .= '<td class="LC_left_item">'.
1399: '<span class="LC_nobreak"><label>'.
1400: '<input type="checkbox" name="searchby" '.
1401: 'value="'.$title.'"'.$check.'/>'.
1402: $searchtitles->{$title}.'</label></span></td>';
1403: }
1404: }
1.26 raeburn 1405: $datatable .= '</tr></table></td></tr>';
1.30 raeburn 1406: $$rowtotal ++;
1.26 raeburn 1407: if ($cansrchrow) {
1408: $datatable .= '<tr class="LC_odd_row">';
1409: } else {
1410: $datatable .= '<tr>';
1411: }
1.30 raeburn 1412: $datatable .= '<td><span class ="LC_nobreak">'.&mt('Search latitude').'</span></td>'.
1.26 raeburn 1413: '<td class="LC_left_item" colspan="2">'.
1.25 raeburn 1414: '<span class="LC_nobreak"><label>'.
1415: '<input type="checkbox" name="searchtypes" '.
1416: $exacton.' value="exact" />'.&mt('Exact match').
1417: '</label> '.
1418: '<label><input type="checkbox" name="searchtypes" '.
1419: $beginson.' value="begins" />'.&mt('Begins with').
1420: '</label> '.
1421: '<label><input type="checkbox" name="searchtypes" '.
1422: $containson.' value="contains" />'.&mt('Contains').
1423: '</label></span></td></tr>';
1.30 raeburn 1424: $$rowtotal ++;
1.25 raeburn 1425: return $datatable;
1426: }
1427:
1.28 raeburn 1428: sub print_contacts {
1.30 raeburn 1429: my ($dom,$settings,$rowtotal) = @_;
1.28 raeburn 1430: my $datatable;
1431: my @contacts = ('adminemail','supportemail');
1432: my (%checked,%to,%otheremails);
1433: my @mailings = ('errormail','packagesmail','helpdeskmail');
1434: foreach my $type (@mailings) {
1435: $otheremails{$type} = '';
1436: }
1437: if (ref($settings) eq 'HASH') {
1438: foreach my $item (@contacts) {
1439: if (exists($settings->{$item})) {
1440: $to{$item} = $settings->{$item};
1441: }
1442: }
1443: foreach my $type (@mailings) {
1444: if (exists($settings->{$type})) {
1445: if (ref($settings->{$type}) eq 'HASH') {
1446: foreach my $item (@contacts) {
1447: if ($settings->{$type}{$item}) {
1448: $checked{$type}{$item} = ' checked="checked" ';
1449: }
1450: }
1451: $otheremails{$type} = $settings->{$type}{'others'};
1452: }
1453: }
1454: }
1455: } else {
1456: $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
1457: $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
1458: $checked{'errormail'}{'adminemail'} = ' checked="checked" ';
1459: $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
1460: $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
1461: }
1462: my ($titles,$short_titles) = &contact_titles();
1463: my $rownum = 0;
1464: my $css_class;
1465: foreach my $item (@contacts) {
1466: if ($rownum%2) {
1467: $css_class = '';
1468: } else {
1469: $css_class = ' class="LC_odd_row" ';
1470: }
1.30 raeburn 1471: $datatable .= '<tr'.$css_class.'>'.
1472: '<td><span class="LC_nobreak">'.$titles->{$item}.
1473: '</span></td><td class="LC_right_item">'.
1.28 raeburn 1474: '<input type="text" name="'.$item.'" value="'.
1475: $to{$item}.'" /></td></tr>';
1476: $rownum ++;
1477: }
1478: foreach my $type (@mailings) {
1479: if ($rownum%2) {
1480: $css_class = '';
1481: } else {
1482: $css_class = ' class="LC_odd_row" ';
1483: }
1484: $datatable .= '<tr'.$css_class.'>'.
1.30 raeburn 1485: '<td><span class="LC_nobreak">'.
1486: $titles->{$type}.': </span></td>'.
1.28 raeburn 1487: '<td class="LC_left_item">'.
1488: '<span class="LC_nobreak">';
1489: foreach my $item (@contacts) {
1490: $datatable .= '<label>'.
1491: '<input type="checkbox" name="'.$type.'"'.
1492: $checked{$type}{$item}.
1493: ' value="'.$item.'" />'.$short_titles->{$item}.
1494: '</label> ';
1495: }
1496: $datatable .= '</span><br />'.&mt('Others').': '.
1497: '<input type="text" name="'.$type.'_others" '.
1498: 'value="'.$otheremails{$type}.'" />'.
1499: '</td></tr>'."\n";
1500: $rownum ++;
1501: }
1.30 raeburn 1502: $$rowtotal += $rownum;
1.28 raeburn 1503: return $datatable;
1504: }
1505:
1506: sub contact_titles {
1507: my %titles = &Apache::lonlocal::texthash (
1508: 'supportemail' => 'Support E-mail address',
1509: 'adminemail' => 'Default Server Admin E-mail address',
1510: 'errormail' => 'Error reports to be e-mailed to',
1511: 'packagesmail' => 'Package update alerts to be e-mailed to',
1512: 'helpdeskmail' => 'Helpdesk requests to be e-mailed to'
1513: );
1514: my %short_titles = &Apache::lonlocal::texthash (
1515: adminemail => 'Admin E-mail address',
1516: supportemail => 'Support E-mail',
1517: );
1518: return (\%titles,\%short_titles);
1519: }
1520:
1.27 raeburn 1521: sub print_usercreation {
1.30 raeburn 1522: my ($position,$dom,$settings,$rowtotal) = @_;
1.27 raeburn 1523: my $numinrow = 4;
1.28 raeburn 1524: my $datatable;
1525: if ($position eq 'top') {
1.30 raeburn 1526: $$rowtotal ++;
1.34 raeburn 1527: my $rowcount = 0;
1.32 raeburn 1528: my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username');
1.28 raeburn 1529: if (ref($rules) eq 'HASH') {
1530: if (keys(%{$rules}) > 0) {
1.32 raeburn 1531: $datatable .= &user_formats_row('username',$settings,$rules,
1532: $ruleorder,$numinrow,$rowcount);
1.30 raeburn 1533: $$rowtotal ++;
1.32 raeburn 1534: $rowcount ++;
1535: }
1536: }
1537: my ($idrules,$idruleorder) = &Apache::lonnet::inst_userrules($dom,'id');
1538: if (ref($idrules) eq 'HASH') {
1539: if (keys(%{$idrules}) > 0) {
1540: $datatable .= &user_formats_row('id',$settings,$idrules,
1541: $idruleorder,$numinrow,$rowcount);
1542: $$rowtotal ++;
1543: $rowcount ++;
1.28 raeburn 1544: }
1545: }
1.43 raeburn 1546: my ($emailrules,$emailruleorder) =
1547: &Apache::lonnet::inst_userrules($dom,'email');
1548: if (ref($emailrules) eq 'HASH') {
1549: if (keys(%{$emailrules}) > 0) {
1550: $datatable .= &user_formats_row('email',$settings,$emailrules,
1551: $emailruleorder,$numinrow,$rowcount);
1552: $$rowtotal ++;
1553: $rowcount ++;
1554: }
1555: }
1.39 raeburn 1556: if ($rowcount == 0) {
1557: $datatable .= '<tr><td colspan="2">'.&mt('No format rules have been defined for usernames or IDs in this domain.').'</td></tr>';
1558: $$rowtotal ++;
1559: $rowcount ++;
1560: }
1.34 raeburn 1561: } elsif ($position eq 'middle') {
1.45 raeburn 1562: my @creators = ('author','course','selfcreate');
1.37 raeburn 1563: my ($rules,$ruleorder) =
1564: &Apache::lonnet::inst_userrules($dom,'username');
1.34 raeburn 1565: my %lt = &usercreation_types();
1566: my %checked;
1.50 raeburn 1567: my @selfcreate;
1.34 raeburn 1568: if (ref($settings) eq 'HASH') {
1569: if (ref($settings->{'cancreate'}) eq 'HASH') {
1570: foreach my $item (@creators) {
1571: $checked{$item} = $settings->{'cancreate'}{$item};
1572: }
1.50 raeburn 1573: if (ref($settings->{'cancreate'}{'selfcreate'}) eq 'ARRAY') {
1574: @selfcreate = @{$settings->{'cancreate'}{'selfcreate'}};
1575: } elsif ($settings->{'cancreate'}{'selfcreate'} ne '') {
1576: if ($settings->{'cancreate'}{'selfcreate'} eq 'any') {
1577: @selfcreate = ('email','login','sso');
1578: } elsif ($settings->{'cancreate'}{'selfcreate'} ne 'none') {
1579: @selfcreate = ($settings->{'cancreate'}{'selfcreate'});
1580: }
1581: }
1.34 raeburn 1582: } elsif (ref($settings->{'cancreate'}) eq 'ARRAY') {
1583: foreach my $item (@creators) {
1584: if (grep(/^\Q$item\E$/,@{$settings->{'cancreate'}})) {
1585: $checked{$item} = 'none';
1586: }
1587: }
1588: }
1589: }
1590: my $rownum = 0;
1591: foreach my $item (@creators) {
1592: $rownum ++;
1.50 raeburn 1593: if ($item ne 'selfcreate') {
1594: if ($checked{$item} eq '') {
1.43 raeburn 1595: $checked{$item} = 'any';
1596: }
1.34 raeburn 1597: }
1598: my $css_class;
1599: if ($rownum%2) {
1600: $css_class = '';
1601: } else {
1602: $css_class = ' class="LC_odd_row" ';
1603: }
1604: $datatable .= '<tr'.$css_class.'>'.
1605: '<td><span class="LC_nobreak">'.$lt{$item}.
1606: '</span></td><td align="right">';
1.50 raeburn 1607: my @options;
1.45 raeburn 1608: if ($item eq 'selfcreate') {
1.43 raeburn 1609: push(@options,('email','login','sso'));
1610: } else {
1.50 raeburn 1611: @options = ('any');
1.43 raeburn 1612: if (ref($rules) eq 'HASH') {
1613: if (keys(%{$rules}) > 0) {
1614: push(@options,('official','unofficial'));
1615: }
1.37 raeburn 1616: }
1.50 raeburn 1617: push(@options,'none');
1.37 raeburn 1618: }
1619: foreach my $option (@options) {
1.50 raeburn 1620: my $type = 'radio';
1.34 raeburn 1621: my $check = ' ';
1.50 raeburn 1622: if ($item eq 'selfcreate') {
1623: $type = 'checkbox';
1624: if (grep(/^\Q$option\E$/,@selfcreate)) {
1625: $check = ' checked="checked" ';
1626: }
1627: } else {
1628: if ($checked{$item} eq $option) {
1629: $check = ' checked="checked" ';
1630: }
1.34 raeburn 1631: }
1632: $datatable .= '<span class="LC_nobreak"><label>'.
1.50 raeburn 1633: '<input type="'.$type.'" name="can_createuser_'.
1.34 raeburn 1634: $item.'" value="'.$option.'"'.$check.'/> '.
1635: $lt{$option}.'</label> </span>';
1636: }
1637: $datatable .= '</td></tr>';
1638: }
1.28 raeburn 1639: } else {
1640: my @contexts = ('author','course','domain');
1641: my @authtypes = ('int','krb4','krb5','loc');
1642: my %checked;
1643: if (ref($settings) eq 'HASH') {
1644: if (ref($settings->{'authtypes'}) eq 'HASH') {
1645: foreach my $item (@contexts) {
1646: if (ref($settings->{'authtypes'}{$item}) eq 'HASH') {
1647: foreach my $auth (@authtypes) {
1648: if ($settings->{'authtypes'}{$item}{$auth}) {
1649: $checked{$item}{$auth} = ' checked="checked" ';
1650: }
1651: }
1652: }
1653: }
1.27 raeburn 1654: }
1.35 raeburn 1655: } else {
1656: foreach my $item (@contexts) {
1.36 raeburn 1657: foreach my $auth (@authtypes) {
1.35 raeburn 1658: $checked{$item}{$auth} = ' checked="checked" ';
1659: }
1660: }
1.27 raeburn 1661: }
1.28 raeburn 1662: my %title = &context_names();
1663: my %authname = &authtype_names();
1664: my $rownum = 0;
1665: my $css_class;
1666: foreach my $item (@contexts) {
1667: if ($rownum%2) {
1668: $css_class = '';
1669: } else {
1670: $css_class = ' class="LC_odd_row" ';
1671: }
1.30 raeburn 1672: $datatable .= '<tr'.$css_class.'>'.
1.28 raeburn 1673: '<td>'.$title{$item}.
1674: '</td><td class="LC_left_item">'.
1675: '<span class="LC_nobreak">';
1676: foreach my $auth (@authtypes) {
1677: $datatable .= '<label>'.
1678: '<input type="checkbox" name="'.$item.'_auth" '.
1679: $checked{$item}{$auth}.' value="'.$auth.'" />'.
1680: $authname{$auth}.'</label> ';
1681: }
1682: $datatable .= '</span></td></tr>';
1683: $rownum ++;
1.27 raeburn 1684: }
1.30 raeburn 1685: $$rowtotal += $rownum;
1.27 raeburn 1686: }
1687: return $datatable;
1688: }
1689:
1.32 raeburn 1690: sub user_formats_row {
1691: my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_;
1692: my $output;
1693: my %text = (
1694: 'username' => 'new usernames',
1695: 'id' => 'IDs',
1.45 raeburn 1696: 'email' => 'self-created accounts (e-mail)',
1.32 raeburn 1697: );
1698: my $css_class = $rowcount%2?' class="LC_odd_row"':'';
1699: $output = '<tr '.$css_class.'>'.
1.63 ! raeburn 1700: '<td><span class="LC_nobreak">';
! 1701: if ($type eq 'email') {
! 1702: $output .= &mt("Formats disallowed for $text{$type}: ");
! 1703: } else {
! 1704: $output .= &mt("Format rules to check for $text{$type}: ");
! 1705: }
! 1706: $output .= '</span></td>'.
! 1707: '<td class="LC_left_item" colspan="2"><table>';
1.27 raeburn 1708: my $rem;
1709: if (ref($ruleorder) eq 'ARRAY') {
1710: for (my $i=0; $i<@{$ruleorder}; $i++) {
1711: if (ref($rules->{$ruleorder->[$i]}) eq 'HASH') {
1712: my $rem = $i%($numinrow);
1713: if ($rem == 0) {
1714: if ($i > 0) {
1715: $output .= '</tr>';
1716: }
1717: $output .= '<tr>';
1718: }
1719: my $check = ' ';
1.39 raeburn 1720: if (ref($settings) eq 'HASH') {
1721: if (ref($settings->{$type.'_rule'}) eq 'ARRAY') {
1722: if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) {
1723: $check = ' checked="checked" ';
1724: }
1.27 raeburn 1725: }
1726: }
1727: $output .= '<td class="LC_left_item">'.
1728: '<span class="LC_nobreak"><label>'.
1.32 raeburn 1729: '<input type="checkbox" name="'.$type.'_rule" '.
1.27 raeburn 1730: 'value="'.$ruleorder->[$i].'"'.$check.'/>'.
1731: $rules->{$ruleorder->[$i]}{'name'}.'</label></span></td>';
1732: }
1733: }
1734: $rem = @{$ruleorder}%($numinrow);
1735: }
1736: my $colsleft = $numinrow - $rem;
1737: if ($colsleft > 1 ) {
1738: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
1739: ' </td>';
1740: } elsif ($colsleft == 1) {
1741: $output .= '<td class="LC_left_item"> </td>';
1742: }
1743: $output .= '</tr></table></td></tr>';
1744: return $output;
1745: }
1746:
1.34 raeburn 1747: sub usercreation_types {
1748: my %lt = &Apache::lonlocal::texthash (
1749: author => 'When adding a co-author',
1750: course => 'When adding a user to a course',
1.45 raeburn 1751: selfcreate => 'User creates own account',
1.34 raeburn 1752: any => 'Any',
1753: official => 'Institutional only ',
1754: unofficial => 'Non-institutional only',
1.43 raeburn 1755: email => 'Email address',
1756: login => 'Institutional Login',
1757: sso => 'SSO',
1.34 raeburn 1758: none => 'None',
1759: );
1760: return %lt;
1.48 raeburn 1761: }
1.34 raeburn 1762:
1.28 raeburn 1763: sub authtype_names {
1764: my %lt = &Apache::lonlocal::texthash(
1765: int => 'Internal',
1766: krb4 => 'Kerberos 4',
1767: krb5 => 'Kerberos 5',
1768: loc => 'Local',
1769: );
1770: return %lt;
1771: }
1772:
1773: sub context_names {
1774: my %context_title = &Apache::lonlocal::texthash(
1775: author => 'Creating users when an Author',
1776: course => 'Creating users when in a course',
1777: domain => 'Creating users when a Domain Coordinator',
1778: );
1779: return %context_title;
1780: }
1781:
1.33 raeburn 1782: sub print_usermodification {
1783: my ($position,$dom,$settings,$rowtotal) = @_;
1784: my $numinrow = 4;
1785: my ($context,$datatable,$rowcount);
1786: if ($position eq 'top') {
1787: $rowcount = 0;
1788: $context = 'author';
1789: foreach my $role ('ca','aa') {
1790: $datatable .= &modifiable_userdata_row($context,$role,$settings,
1791: $numinrow,$rowcount);
1792: $$rowtotal ++;
1793: $rowcount ++;
1794: }
1.63 ! raeburn 1795: } elsif ($position eq 'middle') {
1.33 raeburn 1796: $context = 'course';
1797: $rowcount = 0;
1798: foreach my $role ('st','ep','ta','in','cr') {
1799: $datatable .= &modifiable_userdata_row($context,$role,$settings,
1800: $numinrow,$rowcount);
1801: $$rowtotal ++;
1802: $rowcount ++;
1803: }
1.63 ! raeburn 1804: } elsif ($position eq 'bottom') {
! 1805: $context = 'selfcreate';
! 1806: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
! 1807: $usertypes->{'default'} = $othertitle;
! 1808: if (ref($types) eq 'ARRAY') {
! 1809: push(@{$types},'default');
! 1810: $usertypes->{'default'} = $othertitle;
! 1811: foreach my $status (@{$types}) {
! 1812: $datatable .= &modifiable_userdata_row($context,$status,$settings,
! 1813: $numinrow,$rowcount,$usertypes);
! 1814: $$rowtotal ++;
! 1815: $rowcount ++;
! 1816: }
! 1817: }
1.33 raeburn 1818: }
1819: return $datatable;
1820: }
1821:
1.43 raeburn 1822: sub print_defaults {
1823: my ($dom,$rowtotal) = @_;
1.54 raeburn 1824: my @items = ('auth_def','auth_arg_def','lang_def','timezone_def');
1.43 raeburn 1825: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1826: my $titles = &defaults_titles();
1827: my $rownum = 0;
1828: my ($datatable,$css_class);
1829: foreach my $item (@items) {
1830: if ($rownum%2) {
1831: $css_class = '';
1832: } else {
1833: $css_class = ' class="LC_odd_row" ';
1834: }
1835: $datatable .= '<tr'.$css_class.'>'.
1836: '<td><span class="LC_nobreak">'.$titles->{$item}.
1837: '</span></td><td class="LC_right_item">';
1838: if ($item eq 'auth_def') {
1839: my @authtypes = ('internal','krb4','krb5','localauth');
1840: my %shortauth = (
1841: internal => 'int',
1842: krb4 => 'krb4',
1843: krb5 => 'krb5',
1844: localauth => 'loc'
1845: );
1846: my %authnames = &authtype_names();
1847: foreach my $auth (@authtypes) {
1848: my $checked = ' ';
1849: if ($domdefaults{$item} eq $auth) {
1850: $checked = ' checked="checked" ';
1851: }
1852: $datatable .= '<label><input type="radio" name="'.$item.
1853: '" value="'.$auth.'"'.$checked.'/>'.
1854: $authnames{$shortauth{$auth}}.'</label> ';
1855: }
1.54 raeburn 1856: } elsif ($item eq 'timezone_def') {
1857: my $includeempty = 1;
1858: $datatable .= &Apache::loncommon::select_timezone($item,$domdefaults{$item},undef,$includeempty);
1.43 raeburn 1859: } else {
1860: $datatable .= '<input type="text" name="'.$item.'" value="'.
1861: $domdefaults{$item}.'" />';
1862: }
1863: $datatable .= '</td></tr>';
1864: $rownum ++;
1865: }
1866: $$rowtotal += $rownum;
1867: return $datatable;
1868: }
1869:
1870: sub defaults_titles {
1871: my %titles = &Apache::lonlocal::texthash (
1872: 'auth_def' => 'Default authentication type',
1873: 'auth_arg_def' => 'Default authentication argument',
1874: 'lang_def' => 'Default language',
1.54 raeburn 1875: 'timezone_def' => 'Default timezone',
1.43 raeburn 1876: );
1877: return (\%titles);
1878: }
1879:
1.46 raeburn 1880: sub print_scantronformat {
1881: my ($r,$dom,$confname,$settings,$rowtotal) = @_;
1882: my $itemcount = 1;
1.60 raeburn 1883: my ($datatable,$css_class,$scantronurl,$is_custom,%error,%scantronurls,
1884: %confhash);
1.46 raeburn 1885: my $switchserver = &check_switchserver($dom,$confname);
1886: my %lt = &Apache::lonlocal::texthash (
1887: default => 'Default scantron format file error',
1888: custom => 'Custom scantron format file error',
1889: );
1890: my %scantronfiles = (
1891: default => 'default.tab',
1892: custom => 'custom.tab',
1893: );
1894: foreach my $key (keys(%scantronfiles)) {
1895: $scantronurls{$key} = '/res/'.$dom.'/'.$confname.'/scantron/'
1896: .$scantronfiles{$key};
1897: }
1898: my @defaultinfo = &Apache::lonnet::stat_file($scantronurls{'default'});
1899: if ((!@defaultinfo) || ($defaultinfo[0] eq 'no_such_dir')) {
1900: if (!$switchserver) {
1901: my $servadm = $r->dir_config('lonAdmEMail');
1902: my ($configuserok,$author_ok) = &config_check($dom,$confname,$servadm);
1903: if ($configuserok eq 'ok') {
1904: if ($author_ok eq 'ok') {
1905: my %legacyfile = (
1906: default => $Apache::lonnet::perlvar{'lonTabDir'}.'/default_scantronformat.tab',
1907: custom => $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab',
1908: );
1909: my %md5chk;
1910: foreach my $type (keys(%legacyfile)) {
1.60 raeburn 1911: ($md5chk{$type}) = split(/ /,`md5sum $legacyfile{$type}`);
1912: chomp($md5chk{$type});
1.46 raeburn 1913: }
1914: if ($md5chk{'default'} ne $md5chk{'custom'}) {
1915: foreach my $type (keys(%legacyfile)) {
1.60 raeburn 1916: ($scantronurls{$type},my $error) =
1.46 raeburn 1917: &legacy_scantronformat($r,$dom,$confname,
1918: $type,$legacyfile{$type},
1919: $scantronurls{$type},
1920: $scantronfiles{$type});
1.60 raeburn 1921: if ($error ne '') {
1922: $error{$type} = $error;
1923: }
1924: }
1925: if (keys(%error) == 0) {
1926: $is_custom = 1;
1927: $confhash{'scantron'}{'scantronformat'} =
1928: $scantronurls{'custom'};
1929: my $putresult =
1930: &Apache::lonnet::put_dom('configuration',
1931: \%confhash,$dom);
1932: if ($putresult ne 'ok') {
1933: $error{'custom'} =
1934: '<span class="LC_error">'.
1935: &mt('An error occurred updating the domain configuration: [_1]',$putresult).'</span>';
1936: }
1.46 raeburn 1937: }
1938: } else {
1.60 raeburn 1939: ($scantronurls{'default'},my $error) =
1.46 raeburn 1940: &legacy_scantronformat($r,$dom,$confname,
1941: 'default',$legacyfile{'default'},
1942: $scantronurls{'default'},
1943: $scantronfiles{'default'});
1.60 raeburn 1944: if ($error eq '') {
1945: $confhash{'scantron'}{'scantronformat'} = '';
1946: my $putresult =
1947: &Apache::lonnet::put_dom('configuration',
1948: \%confhash,$dom);
1949: if ($putresult ne 'ok') {
1950: $error{'default'} =
1951: '<span class="LC_error">'.
1952: &mt('An error occurred updating the domain configuration: [_1]',$putresult).'</span>';
1953: }
1954: } else {
1955: $error{'default'} = $error;
1956: }
1.46 raeburn 1957: }
1958: }
1959: }
1960: } else {
1961: $error{'default'} = &mt("Unable to copy default scantron formatfile to domain's RES space: [_1]",$switchserver);
1962: }
1963: }
1964: if (ref($settings) eq 'HASH') {
1965: if ($settings->{'scantronformat'} eq "/res/$dom/$confname/scantron/custom.tab") {
1966: my @info = &Apache::lonnet::stat_file($settings->{'scantronformat'});
1967: if ((!@info) || ($info[0] eq 'no_such_dir')) {
1968: $scantronurl = '';
1969: } else {
1970: $scantronurl = $settings->{'scantronformat'};
1971: }
1972: $is_custom = 1;
1973: } else {
1974: $scantronurl = $scantronurls{'default'};
1975: }
1976: } else {
1.60 raeburn 1977: if ($is_custom) {
1978: $scantronurl = $scantronurls{'custom'};
1979: } else {
1980: $scantronurl = $scantronurls{'default'};
1981: }
1.46 raeburn 1982: }
1983: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1984: $datatable .= '<tr'.$css_class.'>';
1985: if (!$is_custom) {
1986: $datatable .= '<td>'.&mt('Default in use:').'<br />';
1987: if ($scantronurl) {
1988: $datatable .= '<a href="'.$scantronurl.'" target="_blank">'.
1989: &mt('Default scantron format file').'</a>';
1990: } else {
1991: $datatable = &mt('File unavailable for display');
1992: }
1.60 raeburn 1993: $datatable .= '</td>';
1994: if (keys(%error) == 0) {
1995: $datatable .= '<td valign="bottom">';
1996: if (!$switchserver) {
1997: $datatable .= &mt('Upload:').'<br />';
1998: }
1999: } else {
2000: my $errorstr;
2001: foreach my $key (sort(keys(%error))) {
2002: $errorstr .= $lt{$key}.': '.$error{$key}.'<br />';
2003: }
2004: $datatable .= '<td>'.$errorstr;
2005: }
1.46 raeburn 2006: } else {
2007: if (keys(%error) > 0) {
2008: my $errorstr;
2009: foreach my $key (sort(keys(%error))) {
2010: $errorstr .= $lt{$key}.': '.$error{$key}.'<br />';
2011: }
1.60 raeburn 2012: $datatable .= '<td>'.$errorstr.'</td><td> ';
1.46 raeburn 2013: } elsif ($scantronurl) {
1.61 raeburn 2014: $datatable .= '<td><a href="'.$scantronurl.'" target="_blank">'
2015: .&mt('Custom scantron format file').'</a>'
1.46 raeburn 2016: .'<span class="LC_nobreak"><label>'
2017: .'<input type="checkbox" name="scantronformat_del"'
2018: .'" value="1" />'.&mt('Delete?').'</label></td>'
2019: .'<td>'.&mt('Replace:').'</span><br />';
2020: }
2021: }
2022: if (keys(%error) == 0) {
2023: if ($switchserver) {
2024: $datatable .= &mt('Upload to library server: [_1]',$switchserver);
2025: } else {
2026: $datatable .=' <input type="file" name="scantronformat" />';
2027: }
2028: }
2029: $datatable .= '</td></tr>';
2030: $$rowtotal ++;
2031: return $datatable;
2032: }
2033:
2034: sub legacy_scantronformat {
2035: my ($r,$dom,$confname,$file,$legacyfile,$newurl,$newfile) = @_;
2036: my ($url,$error);
2037: my @statinfo = &Apache::lonnet::stat_file($newurl);
2038: if ((!@statinfo) || ($statinfo[0] eq 'no_such_dir')) {
2039: (my $result,$url) =
2040: &publishlogo($r,'copy',$legacyfile,$dom,$confname,'scantron',
2041: '','',$newfile);
2042: if ($result ne 'ok') {
2043: $error = &mt("An error occurred publishing the [_1] scantron format file in RES space. Error was: [_2].",$newfile,$result);
2044: }
2045: }
2046: return ($url,$error);
2047: }
1.43 raeburn 2048:
1.49 raeburn 2049: sub print_coursecategories {
1.57 raeburn 2050: my ($position,$dom,$hdritem,$settings,$rowtotal) = @_;
2051: my $datatable;
2052: if ($position eq 'top') {
2053: my $toggle_cats_crs = ' ';
2054: my $toggle_cats_dom = ' checked="checked" ';
2055: my $can_cat_crs = ' ';
2056: my $can_cat_dom = ' checked="checked" ';
2057: if (ref($settings) eq 'HASH') {
2058: if ($settings->{'togglecats'} eq 'crs') {
2059: $toggle_cats_crs = $toggle_cats_dom;
2060: $toggle_cats_dom = ' ';
2061: }
2062: if ($settings->{'categorize'} eq 'crs') {
2063: $can_cat_crs = $can_cat_dom;
2064: $can_cat_dom = ' ';
2065: }
2066: }
2067: my %title = &Apache::lonlocal::texthash (
2068: togglecats => 'Show/Hide a course in the catalog',
2069: categorize => 'Assign a category to a course',
2070: );
2071: my %level = &Apache::lonlocal::texthash (
2072: dom => 'Set in "Modify Course" (Domain)',
1.60 raeburn 2073: crs => 'Set in "Modify Parameters" (Course)',
1.57 raeburn 2074: );
2075: $datatable = '<tr class="LC_odd_row">'.
2076: '<td>'.$title{'togglecats'}.'</td>'.
2077: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
2078: '<input type="radio" name="togglecats"'.
2079: $toggle_cats_dom.' value="dom" />'.$level{'dom'}.'</label> '.
2080: '<label><input type="radio" name="togglecats"'.
2081: $toggle_cats_crs.' value="crs" />'.$level{'crs'}.'</label></span></td>'.
2082: '</tr><tr>'.
2083: '<td>'.$title{'categorize'}.'</td>'.
2084: '<td class="LC_right_item"><span class="LC_nobreak">'.
2085: '<label><input type="radio" name="categorize"'.
2086: $can_cat_dom.' value="dom" />'.$level{'dom'}.'</label> '.
2087: '<label><input type="radio" name="categorize"'.
2088: $can_cat_crs.'value="crs" />'.$level{'crs'}.'</label></span></td>'.
2089: '</tr>';
2090: $$rowtotal += 2;
2091: } else {
2092: my $css_class;
2093: my $itemcount = 1;
2094: my $cathash;
2095: if (ref($settings) eq 'HASH') {
2096: $cathash = $settings->{'cats'};
2097: }
2098: if (ref($cathash) eq 'HASH') {
2099: my (@cats,@trails,%allitems,%idx,@jsarray);
2100: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
2101: \%allitems,\%idx,\@jsarray);
2102: my $maxdepth = scalar(@cats);
2103: my $colattrib = '';
2104: if ($maxdepth > 2) {
2105: $colattrib = ' colspan="2" ';
2106: }
2107: my @path;
2108: if (@cats > 0) {
2109: if (ref($cats[0]) eq 'ARRAY') {
2110: my $numtop = @{$cats[0]};
2111: my $maxnum = $numtop;
2112: if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
2113: $maxnum ++;
2114: }
2115: my $lastidx;
2116: for (my $i=0; $i<$numtop; $i++) {
2117: my $parent = $cats[0][$i];
2118: $css_class = $itemcount%2?' class="LC_odd_row"':'';
2119: my $item = &escape($parent).'::0';
2120: my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$item','$idx{$item}'".');"';
2121: $lastidx = $idx{$item};
2122: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
2123: .'<select name="'.$item.'"'.$chgstr.'>';
2124: for (my $k=0; $k<=$maxnum; $k++) {
2125: my $vpos = $k+1;
2126: my $selstr;
2127: if ($k == $i) {
2128: $selstr = ' selected="selected" ';
2129: }
2130: $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
2131: }
2132: $datatable .= '</select></td><td>';
2133: if ($parent eq 'instcode') {
2134: $datatable .= '<span class="LC_nobreak">'.&mt('Official courses')
2135: .'</span><br /><span class="LC_nobreak">('
2136: .&mt('with institutional codes').')</span></td>'
2137: .'<td'.$colattrib.'><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" checked="checked" />'
2138: .&mt('Display').'</label> '
2139: .'<label><input type="radio" name="instcode" value="0" />'
2140: .&mt('Do not display').'</label></span></td>';
2141: } else {
2142: $datatable .= $parent
2143: .' <label><input type="checkbox" name="deletecategory" '
2144: .'value="'.$item.'" />'.&mt('Delete').'</label></span></td>';
2145: }
2146: my $depth = 1;
2147: push(@path,$parent);
2148: $datatable .= &build_category_rows($itemcount,\@cats,$depth,$parent,\@path,\%idx);
2149: pop(@path);
2150: $datatable .= '</tr><tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr>';
2151: $itemcount ++;
2152: }
1.48 raeburn 2153: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.57 raeburn 2154: my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','$lastidx'".');"';
2155: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak"><select name="addcategory_pos"'.$chgstr.'>';
1.48 raeburn 2156: for (my $k=0; $k<=$maxnum; $k++) {
2157: my $vpos = $k+1;
2158: my $selstr;
1.57 raeburn 2159: if ($k == $numtop) {
1.48 raeburn 2160: $selstr = ' selected="selected" ';
2161: }
2162: $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
2163: }
1.59 bisitz 2164: $datatable .= '</select></span></td><td colspan="2">'.&mt('Add category:').' '
1.57 raeburn 2165: .'<input type="text" size="20" name="addcategory_name" value="" /></td>'
2166: .'</tr>'."\n";
1.48 raeburn 2167: $itemcount ++;
1.57 raeburn 2168: if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
2169: $css_class = $itemcount%2?' class="LC_odd_row"':'';
2170: my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','$lastidx'".');"';
2171: $datatable .= '<tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr><tr '.$css_class.'><td>'.
2172: '<span class="LC_nobreak"><select name="instcode_pos"'.$chgstr.'>';
2173: for (my $k=0; $k<=$maxnum; $k++) {
2174: my $vpos = $k+1;
2175: my $selstr;
2176: if ($k == $maxnum) {
2177: $selstr = ' selected="selected" ';
2178: }
2179: $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
1.48 raeburn 2180: }
1.57 raeburn 2181: $datatable .= '</select></span></td><td><span class="LC_nobreak">'
2182: .&mt('Official courses').'</span>'.'<br /><span class="LC_nobreak">('
2183: .&mt('with institutional codes').')</span></td>'
2184: .'<td><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" />'
2185: .&mt('Display').'</label> '
2186: .'<label><input type="radio" name="instcode" value="0" checked="checked"/>'
2187: .&mt('Do not display').'</label></span></td></tr>';
1.48 raeburn 2188: }
2189: }
1.57 raeburn 2190: } else {
2191: $datatable .= &initialize_categories($itemcount);
1.48 raeburn 2192: }
2193: } else {
1.57 raeburn 2194: $datatable .= '<td class="LC_right_item">'.$hdritem->{'header'}->[0]->{'col2'}.'</td>'
2195: .&initialize_categories($itemcount);
1.48 raeburn 2196: }
1.57 raeburn 2197: $$rowtotal += $itemcount;
1.48 raeburn 2198: }
2199: return $datatable;
2200: }
2201:
1.49 raeburn 2202: sub coursecategories_javascript {
2203: my ($settings) = @_;
1.57 raeburn 2204: my ($output,$jstext,$cathash);
1.49 raeburn 2205: if (ref($settings) eq 'HASH') {
1.57 raeburn 2206: $cathash = $settings->{'cats'};
2207: }
2208: if (ref($cathash) eq 'HASH') {
1.49 raeburn 2209: my (@cats,@jsarray,%idx);
1.57 raeburn 2210: &Apache::loncommon::gather_categories($cathash,\@cats,\%idx,\@jsarray);
1.49 raeburn 2211: if (@jsarray > 0) {
2212: $jstext = ' var categories = Array('.scalar(@jsarray).');'."\n";
2213: for (my $i=0; $i<@jsarray; $i++) {
2214: if (ref($jsarray[$i]) eq 'ARRAY') {
2215: my $catstr = join('","',@{$jsarray[$i]});
2216: $jstext .= ' categories['.$i.'] = Array("'.$catstr.'");'."\n";
2217: }
2218: }
2219: }
2220: } else {
2221: $jstext = ' var categories = Array(1);'."\n".
2222: ' categories[0] = Array("instcode_pos");'."\n";
2223: }
2224: $output = <<"ENDSCRIPT";
2225: <script type="text/javascript">
2226: function reorderCats(form,parent,item,idx) {
2227: var changedVal;
2228: $jstext
2229: var newpos = 'addcategory_pos';
2230: var current = new Array;
2231: if (parent == '') {
2232: var has_instcode = 0;
2233: var maxtop = categories[idx].length;
2234: for (var j=0; j<maxtop; j++) {
2235: if (categories[idx][j] == 'instcode::0') {
2236: has_instcode == 1;
2237: }
2238: }
2239: if (has_instcode == 0) {
2240: categories[idx][maxtop] = 'instcode_pos';
2241: }
2242: } else {
2243: newpos += '_'+parent;
2244: }
2245: var maxh = 1 + categories[idx].length;
2246: var current = new Array;
2247: var newitemVal = form.elements[newpos].options[form.elements[newpos].selectedIndex].value;
2248: if (item == newpos) {
2249: changedVal = newitemVal;
2250: } else {
2251: changedVal = form.elements[item].options[form.elements[item].selectedIndex].value;
2252: current[newitemVal] = newpos;
2253: }
2254: for (var i=0; i<categories[idx].length; i++) {
2255: var elementName = categories[idx][i];
2256: if (elementName != item) {
2257: if (form.elements[elementName]) {
2258: var currVal = form.elements[elementName].options[form.elements[elementName].selectedIndex].value;
2259: current[currVal] = elementName;
2260: }
2261: }
2262: }
2263: var oldVal;
2264: for (var j=0; j<maxh; j++) {
2265: if (current[j] == undefined) {
2266: oldVal = j;
2267: }
2268: }
2269: if (oldVal < changedVal) {
2270: for (var k=oldVal+1; k<=changedVal ; k++) {
2271: var elementName = current[k];
2272: form.elements[elementName].selectedIndex = form.elements[elementName].selectedIndex - 1;
2273: }
2274: } else {
2275: for (var k=changedVal; k<oldVal; k++) {
2276: var elementName = current[k];
2277: form.elements[elementName].selectedIndex = form.elements[elementName].selectedIndex + 1;
2278: }
2279: }
2280: return;
2281: }
2282: </script>
2283:
2284: ENDSCRIPT
2285: return $output;
2286: }
2287:
1.48 raeburn 2288: sub initialize_categories {
2289: my ($itemcount) = @_;
2290: my $datatable;
2291: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.49 raeburn 2292: my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','0'".');"';
2293:
1.48 raeburn 2294: $datatable = '<tr '.$css_class.'><td><span class="LC_nobreak">'
2295: .'<select name="instcode_pos"><option value="0" selected="selected">1</option>'
2296: .'<option value="1">2</option></select> '
2297: .&mt('Official courses (with institutional codes)')
2298: .'</span></td><td><span class="LC_nobreak">'
2299: .'<label><input type="radio" name="instcode" value="1" checked="checked" />'
2300: .&mt('Display').'</label> <label>'
2301: .'<input type="radio" name="instcode" value="0" />'.&mt('Do not display')
2302: .'</label></span></td></tr>';
2303: $itemcount ++;
2304: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.49 raeburn 2305: $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','0'".');"';
1.48 raeburn 2306: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
1.53 raeburn 2307: .'<select name="addcategory_pos"'.$chgstr.'><option value="0">1</option>'
1.48 raeburn 2308: .'<option value="1" selected="selected">2</option></select> '
2309: .&mt('Add category').'</td><td>'.&mt('Name:')
2310: .' <input type="text" size="20" name="addcategory_name" value="" /></td></tr>';
2311: return $datatable;
2312: }
2313:
2314: sub build_category_rows {
1.49 raeburn 2315: my ($itemcount,$cats,$depth,$parent,$path,$idx) = @_;
2316: my ($text,$name,$item,$chgstr);
1.48 raeburn 2317: if (ref($cats) eq 'ARRAY') {
2318: my $maxdepth = scalar(@{$cats});
2319: if (ref($cats->[$depth]) eq 'HASH') {
2320: if (ref($cats->[$depth]{$parent}) eq 'ARRAY') {
2321: my $numchildren = @{$cats->[$depth]{$parent}};
2322: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
2323: $text .= '<td><table class="LC_datatable">';
1.49 raeburn 2324: my ($idxnum,$parent_name,$parent_item);
2325: my $higher = $depth - 1;
2326: if ($higher == 0) {
2327: $parent_name = &escape($parent).'::'.$higher;
2328: } else {
2329: if (ref($path) eq 'ARRAY') {
2330: $parent_name = &escape($parent).':'.&escape($path->[-2]).':'.$higher;
2331: }
2332: }
2333: $parent_item = 'addcategory_pos_'.$parent_name;
1.48 raeburn 2334: for (my $j=0; $j<=$numchildren; $j++) {
1.49 raeburn 2335: if ($j < $numchildren) {
1.48 raeburn 2336: $name = $cats->[$depth]{$parent}[$j];
2337: $item = &escape($name).':'.&escape($parent).':'.$depth;
1.49 raeburn 2338: $idxnum = $idx->{$item};
2339: } else {
2340: $name = $parent_name;
2341: $item = $parent_item;
1.48 raeburn 2342: }
1.49 raeburn 2343: $chgstr = ' onchange="javascript:reorderCats(this.form,'."'$parent_name','$item','$idxnum'".');"';
2344: $text .= '<tr '.$css_class.'><td><span class="LC_nobreak"><select name="'.$item.'"'.$chgstr.'>';
1.48 raeburn 2345: for (my $i=0; $i<=$numchildren; $i++) {
2346: my $vpos = $i+1;
2347: my $selstr;
2348: if ($j == $i) {
2349: $selstr = ' selected="selected" ';
2350: }
2351: $text .= '<option value="'.$i.'"'.$selstr.'>'.$vpos.'</option>';
2352: }
2353: $text .= '</select> ';
2354: if ($j < $numchildren) {
2355: my $deeper = $depth+1;
2356: $text .= $name.' '
2357: .'<label><input type="checkbox" name="deletecategory" value="'
2358: .$item.'" />'.&mt('Delete').'</label></span></td><td>';
2359: if(ref($path) eq 'ARRAY') {
2360: push(@{$path},$name);
1.49 raeburn 2361: $text .= &build_category_rows($itemcount,$cats,$deeper,$name,$path,$idx);
1.48 raeburn 2362: pop(@{$path});
2363: }
2364: } else {
1.59 bisitz 2365: $text .= &mt('Add subcategory:').' </span><input type="textbox" size="20" name="addcategory_name_';
1.48 raeburn 2366: if ($j == $numchildren) {
2367: $text .= $name;
2368: } else {
2369: $text .= $item;
2370: }
2371: $text .= '" value="" />';
2372: }
2373: $text .= '</td></tr>';
2374: }
2375: $text .= '</table></td>';
2376: } else {
2377: my $higher = $depth-1;
2378: if ($higher == 0) {
2379: $name = &escape($parent).'::'.$higher;
2380: } else {
2381: if (ref($path) eq 'ARRAY') {
2382: $name = &escape($parent).':'.&escape($path->[-2]).':'.$higher;
2383: }
2384: }
2385: my $colspan;
2386: if ($parent ne 'instcode') {
2387: $colspan = $maxdepth - $depth - 1;
2388: $text .= '<td colspan="'.$colspan.'">'.&mt('Add subcategory:').'<input type="textbox" size="20" name="subcat_'.$name.'" value="" /></td>';
2389: }
2390: }
2391: }
2392: }
2393: return $text;
2394: }
2395:
1.33 raeburn 2396: sub modifiable_userdata_row {
1.63 ! raeburn 2397: my ($context,$role,$settings,$numinrow,$rowcount,$usertypes) = @_;
1.33 raeburn 2398: my $rolename;
1.63 ! raeburn 2399: if ($context eq 'selfcreate') {
! 2400: if (ref($usertypes) eq 'HASH') {
! 2401: $rolename = $usertypes->{$role};
! 2402: } else {
! 2403: $rolename = $role;
! 2404: }
1.33 raeburn 2405: } else {
1.63 ! raeburn 2406: if ($role eq 'cr') {
! 2407: $rolename = &mt('Custom role');
! 2408: } else {
! 2409: $rolename = &Apache::lonnet::plaintext($role);
! 2410: }
1.33 raeburn 2411: }
2412: my @fields = ('lastname','firstname','middlename','generation',
2413: 'permanentemail','id');
2414: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
2415: my $output;
2416: my $css_class = $rowcount%2?' class="LC_odd_row"':'';
2417: $output = '<tr '.$css_class.'>'.
2418: '<td><span class="LC_nobreak">'.$rolename.'</span></td>'.
2419: '<td class="LC_left_item" colspan="2"><table>';
2420: my $rem;
2421: my %checks;
2422: if (ref($settings) eq 'HASH') {
2423: if (ref($settings->{$context}) eq 'HASH') {
2424: if (ref($settings->{$context}->{$role}) eq 'HASH') {
2425: foreach my $field (@fields) {
2426: if ($settings->{$context}->{$role}->{$field}) {
2427: $checks{$field} = ' checked="checked" ';
2428: }
2429: }
2430: }
2431: }
2432: }
2433: for (my $i=0; $i<@fields; $i++) {
2434: my $rem = $i%($numinrow);
2435: if ($rem == 0) {
2436: if ($i > 0) {
2437: $output .= '</tr>';
2438: }
2439: $output .= '<tr>';
2440: }
2441: my $check = ' ';
2442: if (exists($checks{$fields[$i]})) {
2443: $check = $checks{$fields[$i]}
2444: } else {
2445: if ($role eq 'st') {
2446: if (ref($settings) ne 'HASH') {
2447: $check = ' checked="checked" ';
2448: }
2449: }
2450: }
2451: $output .= '<td class="LC_left_item">'.
2452: '<span class="LC_nobreak"><label>'.
2453: '<input type="checkbox" name="canmodify_'.$role.'" '.
2454: 'value="'.$fields[$i].'"'.$check.'/>'.$fieldtitles{$fields[$i]}.
2455: '</label></span></td>';
2456: $rem = @fields%($numinrow);
2457: }
2458: my $colsleft = $numinrow - $rem;
2459: if ($colsleft > 1 ) {
2460: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
2461: ' </td>';
2462: } elsif ($colsleft == 1) {
2463: $output .= '<td class="LC_left_item"> </td>';
2464: }
2465: $output .= '</tr></table></td></tr>';
2466: return $output;
2467: }
1.28 raeburn 2468:
1.25 raeburn 2469: sub users_cansearch_row {
2470: my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle) = @_;
2471: my $output = '<tr class="LC_odd_row">'.
1.24 raeburn 2472: '<td>'.&mt('Users allowed to search').' ('.$dom.')'.
2473: '</td><td class="LC_left_item" colspan="2"><table>';
1.26 raeburn 2474: my $rem;
2475: if (ref($types) eq 'ARRAY') {
2476: for (my $i=0; $i<@{$types}; $i++) {
2477: if (defined($usertypes->{$types->[$i]})) {
2478: my $rem = $i%($numinrow);
2479: if ($rem == 0) {
2480: if ($i > 0) {
2481: $output .= '</tr>';
2482: }
2483: $output .= '<tr>';
1.23 raeburn 2484: }
1.26 raeburn 2485: my $check = ' ';
2486: if (ref($settings->{'cansearch'}) eq 'ARRAY') {
2487: if (grep(/^\Q$types->[$i]\E$/,@{$settings->{'cansearch'}})) {
2488: $check = ' checked="checked" ';
2489: }
1.23 raeburn 2490: }
1.26 raeburn 2491: $output .= '<td class="LC_left_item">'.
2492: '<span class="LC_nobreak"><label>'.
2493: '<input type="checkbox" name="cansearch" '.
2494: 'value="'.$types->[$i].'"'.$check.'/>'.
2495: $usertypes->{$types->[$i]}.'</label></span></td>';
1.23 raeburn 2496: }
2497: }
1.26 raeburn 2498:
2499: $rem = @{$types}%($numinrow);
1.23 raeburn 2500: }
2501: my $colsleft = $numinrow - $rem;
2502: if ($colsleft > 1) {
1.25 raeburn 2503: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">';
1.23 raeburn 2504: } else {
1.25 raeburn 2505: $output .= '<td class="LC_left_item">';
1.23 raeburn 2506: }
2507: my $defcheck = ' ';
2508: if (ref($settings->{'cansearch'}) eq 'ARRAY') {
1.26 raeburn 2509: if (grep(/^default$/,@{$settings->{'cansearch'}})) {
2510: $defcheck = ' checked="checked" ';
2511: }
1.23 raeburn 2512: }
1.25 raeburn 2513: $output .= '<span class="LC_nobreak"><label>'.
2514: '<input type="checkbox" name="cansearch" '.
2515: 'value="default"'.$defcheck.'/>'.
2516: $othertitle.'</label></span></td>'.
2517: '</tr></table></td></tr>';
2518: return $output;
1.23 raeburn 2519: }
2520:
2521: sub sorted_searchtitles {
2522: my %searchtitles = &Apache::lonlocal::texthash(
2523: 'uname' => 'username',
2524: 'lastname' => 'last name',
2525: 'lastfirst' => 'last name, first name',
2526: );
2527: my @titleorder = ('uname','lastname','lastfirst');
2528: return (\%searchtitles,\@titleorder);
2529: }
2530:
1.25 raeburn 2531: sub sorted_searchtypes {
2532: my %srchtypes_desc = (
2533: exact => 'is exact match',
2534: contains => 'contains ..',
2535: begins => 'begins with ..',
2536: );
2537: my @srchtypeorder = ('exact','begins','contains');
2538: return (\%srchtypes_desc,\@srchtypeorder);
2539: }
2540:
1.3 raeburn 2541: sub usertype_update_row {
2542: my ($settings,$usertypes,$fieldtitles,$fields,$types,$rownums) = @_;
2543: my $datatable;
2544: my $numinrow = 4;
2545: foreach my $type (@{$types}) {
2546: if (defined($usertypes->{$type})) {
2547: $$rownums ++;
2548: my $css_class = $$rownums%2?' class="LC_odd_row"':'';
2549: $datatable .= '<tr'.$css_class.'><td>'.$usertypes->{$type}.
2550: '</td><td class="LC_left_item"><table>';
2551: for (my $i=0; $i<@{$fields}; $i++) {
2552: my $rem = $i%($numinrow);
2553: if ($rem == 0) {
2554: if ($i > 0) {
2555: $datatable .= '</tr>';
2556: }
2557: $datatable .= '<tr>';
2558: }
2559: my $check = ' ';
1.39 raeburn 2560: if (ref($settings) eq 'HASH') {
2561: if (ref($settings->{'fields'}) eq 'HASH') {
2562: if (ref($settings->{'fields'}{$type}) eq 'ARRAY') {
2563: if (grep(/^\Q$fields->[$i]\E$/,@{$settings->{'fields'}{$type}})) {
2564: $check = ' checked="checked" ';
2565: }
1.3 raeburn 2566: }
2567: }
2568: }
2569:
2570: if ($i == @{$fields}-1) {
2571: my $colsleft = $numinrow - $rem;
2572: if ($colsleft > 1) {
2573: $datatable .= '<td colspan="'.$colsleft.'">';
2574: } else {
2575: $datatable .= '<td>';
2576: }
2577: } else {
2578: $datatable .= '<td>';
2579: }
1.8 raeburn 2580: $datatable .= '<span class="LC_nobreak"><label>'.
2581: '<input type="checkbox" name="updateable_'.$type.
2582: '_'.$fields->[$i].'" value="1"'.$check.'/>'.
2583: $fieldtitles->{$fields->[$i]}.'</label></span></td>';
1.3 raeburn 2584: }
2585: $datatable .= '</tr></table></td></tr>';
2586: }
2587: }
2588: return $datatable;
1.1 raeburn 2589: }
2590:
2591: sub modify_login {
1.9 raeburn 2592: my ($r,$dom,$confname,%domconfig) = @_;
1.6 raeburn 2593: my ($resulttext,$errors,$colchgtext,%changes,%colchanges);
1.1 raeburn 2594: my %title = ( coursecatalog => 'Display course catalog',
1.41 raeburn 2595: adminmail => 'Display administrator E-mail address',
1.43 raeburn 2596: newuser => 'Link for visitors to create a user account',
1.41 raeburn 2597: loginheader => 'Log-in box header');
1.3 raeburn 2598: my @offon = ('off','on');
1.6 raeburn 2599: my %loginhash;
1.9 raeburn 2600: ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
2601: \%domconfig,\%loginhash);
1.43 raeburn 2602: my @toggles = ('coursecatalog','adminmail','newuser');
1.42 raeburn 2603: foreach my $item (@toggles) {
2604: $loginhash{login}{$item} = $env{'form.'.$item};
2605: }
1.41 raeburn 2606: $loginhash{login}{loginheader} = $env{'form.loginheader'};
1.6 raeburn 2607: if (ref($colchanges{'login'}) eq 'HASH') {
2608: $colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
2609: \%loginhash);
2610: }
1.1 raeburn 2611: my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
2612: $dom);
2613: if ($putresult eq 'ok') {
1.43 raeburn 2614: my @toggles = ('coursecatalog','adminmail','newuser');
1.42 raeburn 2615: my %defaultchecked = (
2616: 'coursecatalog' => 'on',
2617: 'adminmail' => 'off',
1.43 raeburn 2618: 'newuser' => 'off',
1.42 raeburn 2619: );
1.55 raeburn 2620: if (ref($domconfig{'login'}) eq 'HASH') {
2621: foreach my $item (@toggles) {
2622: if ($defaultchecked{$item} eq 'on') {
2623: if (($domconfig{'login'}{$item} eq '0') &&
2624: ($env{'form.'.$item} eq '1')) {
2625: $changes{$item} = 1;
2626: } elsif (($domconfig{'login'}{$item} eq '' ||
2627: $domconfig{'login'}{$item} eq '1') &&
2628: ($env{'form.'.$item} eq '0')) {
2629: $changes{$item} = 1;
2630: }
2631: } elsif ($defaultchecked{$item} eq 'off') {
2632: if (($domconfig{'login'}{$item} eq '1') &&
2633: ($env{'form.'.$item} eq '0')) {
2634: $changes{$item} = 1;
2635: } elsif (($domconfig{'login'}{$item} eq '' ||
2636: $domconfig{'login'}{$item} eq '0') &&
2637: ($env{'form.'.$item} eq '1')) {
2638: $changes{$item} = 1;
2639: }
1.42 raeburn 2640: }
2641: }
1.55 raeburn 2642: if (($domconfig{'login'}{'loginheader'} eq 'text') &&
2643: ($env{'form.loginheader'} eq 'image')) {
2644: $changes{'loginheader'} = 1;
2645: } elsif (($domconfig{'login'}{'loginheader'} eq '' ||
2646: $domconfig{'login'}{'loginheader'} eq 'image') &&
2647: ($env{'form.loginheader'} eq 'text')) {
2648: $changes{'loginheader'} = 1;
2649: }
1.41 raeburn 2650: }
1.6 raeburn 2651: if (keys(%changes) > 0 || $colchgtext) {
1.41 raeburn 2652: &Apache::loncommon::devalidate_domconfig_cache($dom);
1.1 raeburn 2653: $resulttext = &mt('Changes made:').'<ul>';
2654: foreach my $item (sort(keys(%changes))) {
1.41 raeburn 2655: if ($item eq 'loginheader') {
2656: $resulttext .= '<li>'.&mt("$title{$item} set to $env{'form.loginheader'}").'</li>';
2657: } else {
2658: $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
2659: }
1.1 raeburn 2660: }
1.6 raeburn 2661: $resulttext .= $colchgtext.'</ul>';
1.1 raeburn 2662: } else {
2663: $resulttext = &mt('No changes made to log-in page settings');
2664: }
2665: } else {
1.11 albertel 2666: $resulttext = '<span class="LC_error">'.
2667: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 2668: }
1.6 raeburn 2669: if ($errors) {
1.9 raeburn 2670: $resulttext .= '<br />'.&mt('The following errors occurred: ').'<ul>'.
1.6 raeburn 2671: $errors.'</ul>';
2672: }
2673: return $resulttext;
2674: }
2675:
2676: sub color_font_choices {
2677: my %choices =
2678: &Apache::lonlocal::texthash (
2679: img => "Header",
2680: bgs => "Background colors",
2681: links => "Link colors",
1.55 raeburn 2682: images => "Images",
1.6 raeburn 2683: font => "Font color",
2684: pgbg => "Page",
2685: tabbg => "Header",
2686: sidebg => "Border",
2687: link => "Link",
2688: alink => "Active link",
2689: vlink => "Visited link",
2690: );
2691: return %choices;
2692: }
2693:
2694: sub modify_rolecolors {
1.9 raeburn 2695: my ($r,$dom,$confname,$roles,%domconfig) = @_;
1.6 raeburn 2696: my ($resulttext,%rolehash);
2697: $rolehash{'rolecolors'} = {};
1.55 raeburn 2698: if (ref($domconfig{'rolecolors'}) ne 'HASH') {
2699: if ($domconfig{'rolecolors'} eq '') {
2700: $domconfig{'rolecolors'} = {};
2701: }
2702: }
1.9 raeburn 2703: my ($errors,%changes) = &modify_colors($r,$dom,$confname,$roles,
1.6 raeburn 2704: $domconfig{'rolecolors'},$rolehash{'rolecolors'});
2705: my $putresult = &Apache::lonnet::put_dom('configuration',\%rolehash,
2706: $dom);
2707: if ($putresult eq 'ok') {
2708: if (keys(%changes) > 0) {
1.41 raeburn 2709: &Apache::loncommon::devalidate_domconfig_cache($dom);
1.6 raeburn 2710: $resulttext = &display_colorchgs($dom,\%changes,$roles,
2711: $rolehash{'rolecolors'});
2712: } else {
2713: $resulttext = &mt('No changes made to default color schemes');
2714: }
2715: } else {
1.11 albertel 2716: $resulttext = '<span class="LC_error">'.
2717: &mt('An error occurred: [_1]',$putresult).'</span>';
1.6 raeburn 2718: }
2719: if ($errors) {
2720: $resulttext .= &mt('The following errors occurred: ').'<ul>'.
2721: $errors.'</ul>';
2722: }
2723: return $resulttext;
2724: }
2725:
2726: sub modify_colors {
1.9 raeburn 2727: my ($r,$dom,$confname,$roles,$domconfig,$confhash) = @_;
1.12 raeburn 2728: my (%changes,%choices);
1.51 raeburn 2729: my @bgs;
1.6 raeburn 2730: my @links = ('link','alink','vlink');
1.41 raeburn 2731: my @logintext;
1.6 raeburn 2732: my @images;
2733: my $servadm = $r->dir_config('lonAdmEMail');
2734: my $errors;
2735: foreach my $role (@{$roles}) {
2736: if ($role eq 'login') {
1.12 raeburn 2737: %choices = &login_choices();
1.41 raeburn 2738: @logintext = ('textcol','bgcol');
1.12 raeburn 2739: } else {
2740: %choices = &color_font_choices();
2741: }
2742: if ($role eq 'login') {
1.41 raeburn 2743: @images = ('img','logo','domlogo','login');
1.51 raeburn 2744: @bgs = ('pgbg','mainbg','sidebg');
1.6 raeburn 2745: } else {
2746: @images = ('img');
1.51 raeburn 2747: @bgs = ('pgbg','tabbg','sidebg');
1.6 raeburn 2748: }
2749: $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
1.41 raeburn 2750: foreach my $item (@bgs,@links,@logintext) {
1.6 raeburn 2751: $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
2752: }
1.46 raeburn 2753: my ($configuserok,$author_ok,$switchserver) =
2754: &config_check($dom,$confname,$servadm);
1.9 raeburn 2755: my ($width,$height) = &thumb_dimensions();
1.40 raeburn 2756: if (ref($domconfig->{$role}) ne 'HASH') {
2757: $domconfig->{$role} = {};
2758: }
1.8 raeburn 2759: foreach my $img (@images) {
1.18 albertel 2760: if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
2761: && !defined($domconfig->{$role}{$img})
2762: && !$env{'form.'.$role.'_del_'.$img}
2763: && $env{'form.'.$role.'_import_'.$img}) {
2764: # import the old configured image from the .tab setting
2765: # if they haven't provided a new one
2766: $domconfig->{$role}{$img} =
2767: $env{'form.'.$role.'_import_'.$img};
2768: }
1.6 raeburn 2769: if ($env{'form.'.$role.'_'.$img.'.filename'} ne '') {
1.9 raeburn 2770: my $error;
1.6 raeburn 2771: if ($configuserok eq 'ok') {
1.9 raeburn 2772: if ($switchserver) {
1.12 raeburn 2773: $error = &mt("Upload of [_1] image for $role page(s) is not permitted to this server: [_2]",$choices{$img},$switchserver);
1.9 raeburn 2774: } else {
2775: if ($author_ok eq 'ok') {
2776: my ($result,$logourl) =
2777: &publishlogo($r,'upload',$role.'_'.$img,
2778: $dom,$confname,$img,$width,$height);
2779: if ($result eq 'ok') {
2780: $confhash->{$role}{$img} = $logourl;
1.12 raeburn 2781: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 2782: } else {
1.12 raeburn 2783: $error = &mt("Upload of [_1] image for $role page(s) failed because an error occurred publishing the file in RES space. Error was: [_2].",$choices{img},$result);
1.9 raeburn 2784: }
2785: } else {
1.46 raeburn 2786: $error = &mt("Upload of [_1] image for $role page(s) failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$choices{$img},$confname,$dom,$author_ok);
1.6 raeburn 2787: }
2788: }
2789: } else {
1.46 raeburn 2790: $error = &mt("Upload of [_1] image for $role page(s) failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$choices{$img},$confname,$dom,$configuserok);
1.9 raeburn 2791: }
2792: if ($error) {
1.8 raeburn 2793: &Apache::lonnet::logthis($error);
1.11 albertel 2794: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
1.8 raeburn 2795: }
2796: } elsif ($domconfig->{$role}{$img} ne '') {
1.9 raeburn 2797: if ($domconfig->{$role}{$img} !~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
2798: my $error;
2799: if ($configuserok eq 'ok') {
2800: # is confname an author?
2801: if ($switchserver eq '') {
2802: if ($author_ok eq 'ok') {
2803: my ($result,$logourl) =
2804: &publishlogo($r,'copy',$domconfig->{$role}{$img},
2805: $dom,$confname,$img,$width,$height);
2806: if ($result eq 'ok') {
2807: $confhash->{$role}{$img} = $logourl;
1.18 albertel 2808: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 2809: }
2810: }
2811: }
2812: }
1.6 raeburn 2813: }
2814: }
2815: }
2816: if (ref($domconfig) eq 'HASH') {
2817: if (ref($domconfig->{$role}) eq 'HASH') {
2818: foreach my $img (@images) {
2819: if ($domconfig->{$role}{$img} ne '') {
2820: if ($env{'form.'.$role.'_del_'.$img}) {
2821: $confhash->{$role}{$img} = '';
1.12 raeburn 2822: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 2823: } else {
1.9 raeburn 2824: if ($confhash->{$role}{$img} eq '') {
2825: $confhash->{$role}{$img} = $domconfig->{$role}{$img};
2826: }
1.6 raeburn 2827: }
2828: } else {
2829: if ($env{'form.'.$role.'_del_'.$img}) {
2830: $confhash->{$role}{$img} = '';
1.12 raeburn 2831: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 2832: }
2833: }
2834: }
2835: if ($domconfig->{$role}{'font'} ne '') {
2836: if ($confhash->{$role}{'font'} ne $domconfig->{$role}{'font'}) {
2837: $changes{$role}{'font'} = 1;
2838: }
2839: } else {
2840: if ($confhash->{$role}{'font'}) {
2841: $changes{$role}{'font'} = 1;
2842: }
2843: }
2844: foreach my $item (@bgs) {
2845: if ($domconfig->{$role}{$item} ne '') {
2846: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
2847: $changes{$role}{'bgs'}{$item} = 1;
2848: }
2849: } else {
2850: if ($confhash->{$role}{$item}) {
2851: $changes{$role}{'bgs'}{$item} = 1;
2852: }
2853: }
2854: }
2855: foreach my $item (@links) {
2856: if ($domconfig->{$role}{$item} ne '') {
2857: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
2858: $changes{$role}{'links'}{$item} = 1;
2859: }
2860: } else {
2861: if ($confhash->{$role}{$item}) {
2862: $changes{$role}{'links'}{$item} = 1;
2863: }
2864: }
2865: }
1.41 raeburn 2866: foreach my $item (@logintext) {
2867: if ($domconfig->{$role}{$item} ne '') {
2868: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
2869: $changes{$role}{'logintext'}{$item} = 1;
2870: }
2871: } else {
2872: if ($confhash->{$role}{$item}) {
2873: $changes{$role}{'logintext'}{$item} = 1;
2874: }
2875: }
2876: }
1.6 raeburn 2877: } else {
2878: &default_change_checker($role,\@images,\@links,\@bgs,
1.41 raeburn 2879: \@logintext,$confhash,\%changes);
1.6 raeburn 2880: }
2881: } else {
2882: &default_change_checker($role,\@images,\@links,\@bgs,
1.41 raeburn 2883: \@logintext,$confhash,\%changes);
1.6 raeburn 2884: }
2885: }
2886: return ($errors,%changes);
2887: }
2888:
1.46 raeburn 2889: sub config_check {
2890: my ($dom,$confname,$servadm) = @_;
2891: my ($configuserok,$author_ok,$switchserver,%currroles);
2892: my $uhome = &Apache::lonnet::homeserver($confname,$dom,1);
2893: ($configuserok,%currroles) = &check_configuser($uhome,$dom,
2894: $confname,$servadm);
2895: if ($configuserok eq 'ok') {
2896: $switchserver = &check_switchserver($dom,$confname);
2897: if ($switchserver eq '') {
2898: $author_ok = &check_authorstatus($dom,$confname,%currroles);
2899: }
2900: }
2901: return ($configuserok,$author_ok,$switchserver);
2902: }
2903:
1.6 raeburn 2904: sub default_change_checker {
1.41 raeburn 2905: my ($role,$images,$links,$bgs,$logintext,$confhash,$changes) = @_;
1.6 raeburn 2906: foreach my $item (@{$links}) {
2907: if ($confhash->{$role}{$item}) {
2908: $changes->{$role}{'links'}{$item} = 1;
2909: }
2910: }
2911: foreach my $item (@{$bgs}) {
2912: if ($confhash->{$role}{$item}) {
2913: $changes->{$role}{'bgs'}{$item} = 1;
2914: }
2915: }
1.41 raeburn 2916: foreach my $item (@{$logintext}) {
2917: if ($confhash->{$role}{$item}) {
2918: $changes->{$role}{'logintext'}{$item} = 1;
2919: }
2920: }
1.6 raeburn 2921: foreach my $img (@{$images}) {
2922: if ($env{'form.'.$role.'_del_'.$img}) {
2923: $confhash->{$role}{$img} = '';
1.12 raeburn 2924: $changes->{$role}{'images'}{$img} = 1;
1.6 raeburn 2925: }
2926: }
2927: if ($confhash->{$role}{'font'}) {
2928: $changes->{$role}{'font'} = 1;
2929: }
1.48 raeburn 2930: }
1.6 raeburn 2931:
2932: sub display_colorchgs {
2933: my ($dom,$changes,$roles,$confhash) = @_;
2934: my (%choices,$resulttext);
2935: if (!grep(/^login$/,@{$roles})) {
2936: $resulttext = &mt('Changes made:').'<br />';
2937: }
2938: foreach my $role (@{$roles}) {
2939: if ($role eq 'login') {
2940: %choices = &login_choices();
2941: } else {
2942: %choices = &color_font_choices();
2943: }
2944: if (ref($changes->{$role}) eq 'HASH') {
2945: if ($role ne 'login') {
2946: $resulttext .= '<h4>'.&mt($role).'</h4>';
2947: }
2948: foreach my $key (sort(keys(%{$changes->{$role}}))) {
2949: if ($role ne 'login') {
2950: $resulttext .= '<ul>';
2951: }
2952: if (ref($changes->{$role}{$key}) eq 'HASH') {
2953: if ($role ne 'login') {
2954: $resulttext .= '<li>'.&mt($choices{$key}).':<ul>';
2955: }
2956: foreach my $item (sort(keys(%{$changes->{$role}{$key}}))) {
2957: if ($confhash->{$role}{$item} eq '') {
2958: $resulttext .= '<li>'.&mt("$choices{$item} set to default").'</li>';
2959: } else {
1.12 raeburn 2960: my $newitem = $confhash->{$role}{$item};
2961: if ($key eq 'images') {
2962: $newitem = '<img src="'.$confhash->{$role}{$item}.'" alt="'.$choices{$item}.'" valign="bottom" />';
2963: }
2964: $resulttext .= '<li>'.&mt("$choices{$item} set to [_1]",$newitem).'</li>';
1.6 raeburn 2965: }
2966: }
2967: if ($role ne 'login') {
2968: $resulttext .= '</ul></li>';
2969: }
2970: } else {
2971: if ($confhash->{$role}{$key} eq '') {
2972: $resulttext .= '<li>'.&mt("$choices{$key} set to default").'</li>';
2973: } else {
2974: $resulttext .= '<li>'.&mt("$choices{$key} set to [_1]",$confhash->{$role}{$key}).'</li>';
2975: }
2976: }
2977: if ($role ne 'login') {
2978: $resulttext .= '</ul>';
2979: }
2980: }
2981: }
2982: }
1.3 raeburn 2983: return $resulttext;
1.1 raeburn 2984: }
2985:
1.9 raeburn 2986: sub thumb_dimensions {
2987: return ('200','50');
2988: }
2989:
1.16 raeburn 2990: sub check_dimensions {
2991: my ($inputfile) = @_;
2992: my ($fullwidth,$fullheight);
2993: if ($inputfile =~ m|^[/\w.\-]+$|) {
2994: if (open(PIPE,"identify $inputfile 2>&1 |")) {
2995: my $imageinfo = <PIPE>;
2996: if (!close(PIPE)) {
2997: &Apache::lonnet::logthis("Failed to close PIPE opened to retrieve image information for $inputfile");
2998: }
2999: chomp($imageinfo);
3000: my ($fullsize) =
1.21 raeburn 3001: ($imageinfo =~ /^\Q$inputfile\E\s+\w+\s+(\d+x\d+)/);
1.16 raeburn 3002: if ($fullsize) {
3003: ($fullwidth,$fullheight) = split(/x/,$fullsize);
3004: }
3005: }
3006: }
3007: return ($fullwidth,$fullheight);
3008: }
3009:
1.9 raeburn 3010: sub check_configuser {
3011: my ($uhome,$dom,$confname,$servadm) = @_;
3012: my ($configuserok,%currroles);
3013: if ($uhome eq 'no_host') {
3014: srand( time() ^ ($$ + ($$ << 15)) ); # Seed rand.
3015: my $configpass = &LONCAPA::Enrollment::create_password();
3016: $configuserok =
3017: &Apache::lonnet::modifyuser($dom,$confname,'','internal',
3018: $configpass,'','','','','',undef,$servadm);
3019: } else {
3020: $configuserok = 'ok';
3021: %currroles =
3022: &Apache::lonnet::get_my_roles($confname,$dom,'userroles');
3023: }
3024: return ($configuserok,%currroles);
3025: }
3026:
3027: sub check_authorstatus {
3028: my ($dom,$confname,%currroles) = @_;
3029: my $author_ok;
1.40 raeburn 3030: if (!$currroles{':'.$dom.':au'}) {
1.9 raeburn 3031: my $start = time;
3032: my $end = 0;
3033: $author_ok =
3034: &Apache::lonnet::assignrole($dom,$confname,'/'.$dom.'/',
1.47 raeburn 3035: 'au',$end,$start,'','','domconfig');
1.9 raeburn 3036: } else {
3037: $author_ok = 'ok';
3038: }
3039: return $author_ok;
3040: }
3041:
3042: sub publishlogo {
1.46 raeburn 3043: my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight,$savefileas) = @_;
1.9 raeburn 3044: my ($output,$fname,$logourl);
3045: if ($action eq 'upload') {
3046: $fname=$env{'form.'.$formname.'.filename'};
3047: chop($env{'form.'.$formname});
3048: } else {
3049: ($fname) = ($formname =~ /([^\/]+)$/);
3050: }
1.46 raeburn 3051: if ($savefileas ne '') {
3052: $fname = $savefileas;
3053: }
1.9 raeburn 3054: $fname=&Apache::lonnet::clean_filename($fname);
3055: # See if there is anything left
3056: unless ($fname) { return ('error: no uploaded file'); }
3057: $fname="$subdir/$fname";
3058: my $filepath='/home/'.$confname.'/public_html';
3059: my ($fnamepath,$file,$fetchthumb);
3060: $file=$fname;
3061: if ($fname=~m|/|) {
3062: ($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
3063: }
3064: my @parts=split(/\//,$filepath.'/'.$fnamepath);
3065: my $count;
3066: for ($count=4;$count<=$#parts;$count++) {
3067: $filepath.="/$parts[$count]";
3068: if ((-e $filepath)!=1) {
3069: mkdir($filepath,02770);
3070: }
3071: }
3072: # Check for bad extension and disallow upload
3073: if ($file=~/\.(\w+)$/ &&
3074: (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
3075: $output =
3076: &mt('Invalid file extension ([_1]) - reserved for LONCAPA use.',$1);
3077: } elsif ($file=~/\.(\w+)$/ &&
3078: !defined(&Apache::loncommon::fileembstyle($1))) {
3079: $output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1);
3080: } elsif ($file=~/\.(\d+)\.(\w+)$/) {
1.46 raeburn 3081: $output = &mt('File name not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
1.9 raeburn 3082: } elsif (-d "$filepath/$file") {
3083: $output = &mt('File name is a directory name - rename the file and re-upload');
3084: } else {
3085: my $source = $filepath.'/'.$file;
3086: my $logfile;
3087: if (!open($logfile,">>$source".'.log')) {
3088: return (&mt('No write permission to Construction Space'));
3089: }
3090: print $logfile
3091: "\n================= Publish ".localtime()." ================\n".
3092: $env{'user.name'}.':'.$env{'user.domain'}."\n";
3093: # Save the file
3094: if (!open(FH,'>'.$source)) {
3095: &Apache::lonnet::logthis('Failed to create '.$source);
3096: return (&mt('Failed to create file'));
3097: }
3098: if ($action eq 'upload') {
3099: if (!print FH ($env{'form.'.$formname})) {
3100: &Apache::lonnet::logthis('Failed to write to '.$source);
3101: return (&mt('Failed to write file'));
3102: }
3103: } else {
3104: my $original = &Apache::lonnet::filelocation('',$formname);
3105: if(!copy($original,$source)) {
3106: &Apache::lonnet::logthis('Failed to copy '.$original.' to '.$source);
3107: return (&mt('Failed to write file'));
3108: }
3109: }
3110: close(FH);
3111: chmod(0660, $source); # Permissions to rw-rw---.
3112:
3113: my $docroot=$r->dir_config('lonDocRoot');
3114: my $targetdir=$docroot.'/res/'.$dom.'/'.$confname .'/'.$fnamepath;
3115: my $copyfile=$targetdir.'/'.$file;
3116:
3117: my @parts=split(/\//,$targetdir);
3118: my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]";
3119: for (my $count=5;$count<=$#parts;$count++) {
3120: $path.="/$parts[$count]";
3121: if (!-e $path) {
3122: print $logfile "\nCreating directory ".$path;
3123: mkdir($path,02770);
3124: }
3125: }
3126: my $versionresult;
3127: if (-e $copyfile) {
3128: $versionresult = &logo_versioning($targetdir,$file,$logfile);
3129: } else {
3130: $versionresult = 'ok';
3131: }
3132: if ($versionresult eq 'ok') {
3133: if (copy($source,$copyfile)) {
3134: print $logfile "\nCopied original source to ".$copyfile."\n";
3135: $output = 'ok';
3136: &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
3137: $logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;
3138: } else {
3139: print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
3140: $output = &mt('Failed to copy file to RES space').", $!";
3141: }
3142: if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) {
3143: my $inputfile = $filepath.'/'.$file;
3144: my $outfile = $filepath.'/'.'tn-'.$file;
1.16 raeburn 3145: my ($fullwidth,$fullheight) = &check_dimensions($inputfile);
3146: if ($fullwidth ne '' && $fullheight ne '') {
3147: if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) {
3148: my $thumbsize = $thumbwidth.'x'.$thumbheight;
3149: system("convert -sample $thumbsize $inputfile $outfile");
3150: chmod(0660, $filepath.'/tn-'.$file);
3151: if (-e $outfile) {
3152: my $copyfile=$targetdir.'/tn-'.$file;
3153: if (copy($outfile,$copyfile)) {
3154: print $logfile "\nCopied source to ".$copyfile."\n";
3155: &write_metadata($dom,$confname,$formname,
3156: $targetdir,'tn-'.$file,$logfile);
3157: } else {
3158: print $logfile "\nUnable to write ".$copyfile.
3159: ':'.$!."\n";
3160: }
3161: }
1.9 raeburn 3162: }
3163: }
3164: }
3165: } else {
3166: $output = $versionresult;
3167: }
3168: }
3169: return ($output,$logourl);
3170: }
3171:
3172: sub logo_versioning {
3173: my ($targetdir,$file,$logfile) = @_;
3174: my $target = $targetdir.'/'.$file;
3175: my ($maxversion,$fn,$extn,$output);
3176: $maxversion = 0;
3177: if ($file =~ /^(.+)\.(\w+)$/) {
3178: $fn=$1;
3179: $extn=$2;
3180: }
3181: opendir(DIR,$targetdir);
3182: while (my $filename=readdir(DIR)) {
3183: if ($filename=~/\Q$fn\E\.(\d+)\.\Q$extn\E$/) {
3184: $maxversion=($1>$maxversion)?$1:$maxversion;
3185: }
3186: }
3187: $maxversion++;
3188: print $logfile "\nCreating old version ".$maxversion."\n";
3189: my $copyfile=$targetdir.'/'.$fn.'.'.$maxversion.'.'.$extn;
3190: if (copy($target,$copyfile)) {
3191: print $logfile "Copied old target to ".$copyfile."\n";
3192: $copyfile=$copyfile.'.meta';
3193: if (copy($target.'.meta',$copyfile)) {
3194: print $logfile "Copied old target metadata to ".$copyfile."\n";
3195: $output = 'ok';
3196: } else {
3197: print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";
3198: $output = &mt('Failed to copy old meta').", $!, ";
3199: }
3200: } else {
3201: print $logfile "Unable to write ".$copyfile.':'.$!."\n";
3202: $output = &mt('Failed to copy old target').", $!, ";
3203: }
3204: return $output;
3205: }
3206:
3207: sub write_metadata {
3208: my ($dom,$confname,$formname,$targetdir,$file,$logfile) = @_;
3209: my (%metadatafields,%metadatakeys,$output);
3210: $metadatafields{'title'}=$formname;
3211: $metadatafields{'creationdate'}=time;
3212: $metadatafields{'lastrevisiondate'}=time;
3213: $metadatafields{'copyright'}='public';
3214: $metadatafields{'modifyinguser'}=$env{'user.name'}.':'.
3215: $env{'user.domain'};
3216: $metadatafields{'authorspace'}=$confname.':'.$dom;
3217: $metadatafields{'domain'}=$dom;
3218: {
3219: print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
3220: my $mfh;
3221: unless (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
3222: $output = &mt('Could not write metadata');
3223: }
3224: foreach (sort keys %metadatafields) {
3225: unless ($_=~/\./) {
3226: my $unikey=$_;
3227: $unikey=~/^([A-Za-z]+)/;
3228: my $tag=$1;
3229: $tag=~tr/A-Z/a-z/;
3230: print $mfh "\n\<$tag";
3231: foreach (split(/\,/,$metadatakeys{$unikey})) {
3232: my $value=$metadatafields{$unikey.'.'.$_};
3233: $value=~s/\"/\'\'/g;
3234: print $mfh ' '.$_.'="'.$value.'"';
3235: }
3236: print $mfh '>'.
3237: &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
3238: .'</'.$tag.'>';
3239: }
3240: }
3241: $output = 'ok';
3242: print $logfile "\nWrote metadata";
3243: close($mfh);
3244: }
3245: }
3246:
3247: sub check_switchserver {
3248: my ($dom,$confname) = @_;
3249: my ($allowed,$switchserver);
3250: my $home = &Apache::lonnet::homeserver($confname,$dom);
3251: if ($home eq 'no_host') {
3252: $home = &Apache::lonnet::domain($dom,'primary');
3253: }
3254: my @ids=&Apache::lonnet::current_machine_ids();
1.10 albertel 3255: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
3256: if (!$allowed) {
3257: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role=dc./'.$dom.'/">'.&mt('Switch Server').'</a>';
1.9 raeburn 3258: }
3259: return $switchserver;
3260: }
3261:
1.30 raeburn 3262: sub javascript_set_colnums {
3263: return <<END;
3264: function setDisplayColumns() {
3265: if (document.pickactions.width.value > 1100) {
3266: document.pickactions.numcols[1].checked = true;
3267: } else {
3268: document.pickactions.numcols[0].checked = true;
3269: }
3270: }
3271: END
3272: }
3273:
1.1 raeburn 3274: sub modify_quotas {
1.3 raeburn 3275: my ($dom,%domconfig) = @_;
1.1 raeburn 3276: my ($resulttext,%changes);
1.44 raeburn 3277: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.1 raeburn 3278: my %formhash;
3279: foreach my $key (keys(%env)) {
3280: if ($key =~ /^form\.quota_(.+)$/) {
3281: $formhash{$1} = $env{$key};
3282: }
3283: }
1.15 raeburn 3284: $formhash{'default'} = $env{'form.defaultquota'};
1.1 raeburn 3285: if (ref($domconfig{'quotas'}) eq 'HASH') {
3286: foreach my $key (keys(%{$domconfig{'quotas'}})) {
3287: if (exists($formhash{$key})) {
3288: if ($formhash{$key} ne $domconfig{'quotas'}{$key}) {
3289: $changes{$key} = 1;
3290: }
3291: } else {
3292: $formhash{$key} = $domconfig{'quotas'}{$key};
3293: }
3294: }
3295: }
3296: foreach my $key (keys(%formhash)) {
3297: if ($formhash{$key} ne '') {
1.55 raeburn 3298: if (ref($domconfig{'quotas'}) eq 'HASH') {
3299: if (!exists($domconfig{'quotas'}{$key})) {
3300: $changes{$key} = 1;
3301: }
3302: } else {
1.1 raeburn 3303: $changes{$key} = 1;
3304: }
3305: }
3306: }
3307: my %quotahash = (
1.3 raeburn 3308: quotas => {%formhash},
1.1 raeburn 3309: );
3310: my $putresult = &Apache::lonnet::put_dom('configuration',\%quotahash,
3311: $dom);
3312: if ($putresult eq 'ok') {
3313: if (keys(%changes) > 0) {
3314: $resulttext = &mt('Changes made:').'<ul>';
1.26 raeburn 3315: foreach my $type (@{$types},'default') {
3316: if (defined($changes{$type})) {
3317: my $typetitle = $usertypes->{$type};
3318: if ($type eq 'default') {
3319: $typetitle = $othertitle;
3320: }
3321: $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$formhash{$type}).'</li>';
3322: }
1.1 raeburn 3323: }
3324: $resulttext .= '</ul>';
3325: } else {
3326: $resulttext = &mt('No changes made to default quotas');
3327: }
3328: } else {
1.11 albertel 3329: $resulttext = '<span class="LC_error">'.
3330: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 3331: }
1.3 raeburn 3332: return $resulttext;
1.1 raeburn 3333: }
3334:
1.3 raeburn 3335: sub modify_autoenroll {
3336: my ($dom,%domconfig) = @_;
1.1 raeburn 3337: my ($resulttext,%changes);
3338: my %currautoenroll;
3339: if (ref($domconfig{'autoenroll'}) eq 'HASH') {
3340: foreach my $key (keys(%{$domconfig{'autoenroll'}})) {
3341: $currautoenroll{$key} = $domconfig{'autoenroll'}{$key};
3342: }
3343: }
3344: my $autorun = &Apache::lonnet::auto_run(undef,$dom),
3345: my %title = ( run => 'Auto-enrollment active',
3346: sender => 'Sender for notification messages');
3347: my @offon = ('off','on');
1.17 raeburn 3348: my $sender_uname = $env{'form.sender_uname'};
3349: my $sender_domain = $env{'form.sender_domain'};
3350: if ($sender_domain eq '') {
3351: $sender_uname = '';
3352: } elsif ($sender_uname eq '') {
3353: $sender_domain = '';
3354: }
1.1 raeburn 3355: my %autoenrollhash = (
3356: autoenroll => { run => $env{'form.autoenroll_run'},
1.17 raeburn 3357: sender_uname => $sender_uname,
3358: sender_domain => $sender_domain,
1.1 raeburn 3359:
3360: }
3361: );
1.4 raeburn 3362: my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
3363: $dom);
1.1 raeburn 3364: if ($putresult eq 'ok') {
3365: if (exists($currautoenroll{'run'})) {
3366: if ($currautoenroll{'run'} ne $env{'form.autoenroll_run'}) {
3367: $changes{'run'} = 1;
3368: }
3369: } elsif ($autorun) {
3370: if ($env{'form.autoenroll_run'} ne '1') {
1.23 raeburn 3371: $changes{'run'} = 1;
1.1 raeburn 3372: }
3373: }
1.17 raeburn 3374: if ($currautoenroll{'sender_uname'} ne $sender_uname) {
1.1 raeburn 3375: $changes{'sender'} = 1;
3376: }
1.17 raeburn 3377: if ($currautoenroll{'sender_domain'} ne $sender_domain) {
1.1 raeburn 3378: $changes{'sender'} = 1;
3379: }
3380: if (keys(%changes) > 0) {
3381: $resulttext = &mt('Changes made:').'<ul>';
1.3 raeburn 3382: if ($changes{'run'}) {
1.1 raeburn 3383: $resulttext .= '<li>'.&mt("$title{'run'} set to $offon[$env{'form.autoenroll_run'}]").'</li>';
3384: }
3385: if ($changes{'sender'}) {
1.17 raeburn 3386: if ($sender_uname eq '' || $sender_domain eq '') {
3387: $resulttext .= '<li>'.&mt("$title{'sender'} set to default (course owner).").'</li>';
3388: } else {
3389: $resulttext .= '<li>'.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'</li>';
3390: }
1.1 raeburn 3391: }
3392: $resulttext .= '</ul>';
3393: } else {
3394: $resulttext = &mt('No changes made to auto-enrollment settings');
3395: }
3396: } else {
1.11 albertel 3397: $resulttext = '<span class="LC_error">'.
3398: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 3399: }
1.3 raeburn 3400: return $resulttext;
1.1 raeburn 3401: }
3402:
3403: sub modify_autoupdate {
1.3 raeburn 3404: my ($dom,%domconfig) = @_;
1.1 raeburn 3405: my ($resulttext,%currautoupdate,%fields,%changes);
3406: if (ref($domconfig{'autoupdate'}) eq 'HASH') {
3407: foreach my $key (keys(%{$domconfig{'autoupdate'}})) {
3408: $currautoupdate{$key} = $domconfig{'autoupdate'}{$key};
3409: }
3410: }
3411: my @offon = ('off','on');
3412: my %title = &Apache::lonlocal::texthash (
3413: run => 'Auto-update:',
3414: classlists => 'Updates to user information in classlists?'
3415: );
1.44 raeburn 3416: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.1 raeburn 3417: my %fieldtitles = &Apache::lonlocal::texthash (
3418: id => 'Student/Employee ID',
1.20 raeburn 3419: permanentemail => 'E-mail address',
1.1 raeburn 3420: lastname => 'Last Name',
3421: firstname => 'First Name',
3422: middlename => 'Middle Name',
3423: gen => 'Generation',
3424: );
3425: my $othertitle = &mt('All users');
3426: if (keys(%{$usertypes}) > 0) {
1.26 raeburn 3427: $othertitle = &mt('Other users');
1.1 raeburn 3428: }
3429: foreach my $key (keys(%env)) {
3430: if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {
3431: push(@{$fields{$1}},$2);
3432: }
3433: }
3434: my %updatehash = (
3435: autoupdate => { run => $env{'form.autoupdate_run'},
3436: classlists => $env{'form.classlists'},
3437: fields => {%fields},
3438: }
3439: );
3440: foreach my $key (keys(%currautoupdate)) {
3441: if (($key eq 'run') || ($key eq 'classlists')) {
3442: if (exists($updatehash{autoupdate}{$key})) {
3443: if ($currautoupdate{$key} ne $updatehash{autoupdate}{$key}) {
3444: $changes{$key} = 1;
3445: }
3446: }
3447: } elsif ($key eq 'fields') {
3448: if (ref($currautoupdate{$key}) eq 'HASH') {
1.26 raeburn 3449: foreach my $item (@{$types},'default') {
1.1 raeburn 3450: if (ref($currautoupdate{$key}{$item}) eq 'ARRAY') {
3451: my $change = 0;
3452: foreach my $type (@{$currautoupdate{$key}{$item}}) {
3453: if (!exists($fields{$item})) {
3454: $change = 1;
3455: } elsif (ref($fields{$item}) eq 'ARRAY') {
1.26 raeburn 3456: if (!grep(/^\Q$type\E$/,@{$fields{$item}})) {
1.1 raeburn 3457: $change = 1;
3458: }
3459: }
3460: }
3461: if ($change) {
3462: push(@{$changes{$key}},$item);
3463: }
1.26 raeburn 3464: }
1.1 raeburn 3465: }
3466: }
3467: }
3468: }
1.26 raeburn 3469: foreach my $item (@{$types},'default') {
3470: if (defined($fields{$item})) {
3471: if (ref($currautoupdate{'fields'}) eq 'HASH') {
3472: if (!exists($currautoupdate{'fields'}{$item})) {
3473: push(@{$changes{'fields'}},$item);
3474: }
3475: } else {
3476: push(@{$changes{'fields'}},$item);
1.1 raeburn 3477: }
3478: }
3479: }
3480: my $putresult = &Apache::lonnet::put_dom('configuration',\%updatehash,
3481: $dom);
3482: if ($putresult eq 'ok') {
3483: if (keys(%changes) > 0) {
3484: $resulttext = &mt('Changes made:').'<ul>';
3485: foreach my $key (sort(keys(%changes))) {
3486: if (ref($changes{$key}) eq 'ARRAY') {
3487: foreach my $item (@{$changes{$key}}) {
3488: my @newvalues;
3489: foreach my $type (@{$fields{$item}}) {
3490: push(@newvalues,$fieldtitles{$type});
3491: }
1.3 raeburn 3492: my $newvaluestr;
3493: if (@newvalues > 0) {
3494: $newvaluestr = join(', ',@newvalues);
3495: } else {
3496: $newvaluestr = &mt('none');
1.6 raeburn 3497: }
1.1 raeburn 3498: if ($item eq 'default') {
1.26 raeburn 3499: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$othertitle,$newvaluestr).'</li>';
1.1 raeburn 3500: } else {
1.26 raeburn 3501: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$usertypes->{$item},$newvaluestr).'</li>';
1.1 raeburn 3502: }
3503: }
3504: } else {
3505: my $newvalue;
3506: if ($key eq 'run') {
3507: $newvalue = $offon[$env{'form.autoupdate_run'}];
3508: } else {
3509: $newvalue = $offon[$env{'form.'.$key}];
1.3 raeburn 3510: }
1.1 raeburn 3511: $resulttext .= '<li>'.&mt("[_1] set to $newvalue",$title{$key}).'</li>';
3512: }
3513: }
3514: $resulttext .= '</ul>';
3515: } else {
1.3 raeburn 3516: $resulttext = &mt('No changes made to autoupdates');
1.1 raeburn 3517: }
3518: } else {
1.11 albertel 3519: $resulttext = '<span class="LC_error">'.
3520: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 3521: }
1.3 raeburn 3522: return $resulttext;
1.1 raeburn 3523: }
3524:
1.23 raeburn 3525: sub modify_directorysrch {
3526: my ($dom,%domconfig) = @_;
3527: my ($resulttext,%changes);
3528: my %currdirsrch;
3529: if (ref($domconfig{'directorysrch'}) eq 'HASH') {
3530: foreach my $key (keys(%{$domconfig{'directorysrch'}})) {
3531: $currdirsrch{$key} = $domconfig{'directorysrch'}{$key};
3532: }
3533: }
3534: my %title = ( available => 'Directory search available',
1.24 raeburn 3535: localonly => 'Other domains can search',
1.23 raeburn 3536: searchby => 'Search types',
3537: searchtypes => 'Search latitude');
3538: my @offon = ('off','on');
1.24 raeburn 3539: my @otherdoms = ('Yes','No');
1.23 raeburn 3540:
1.25 raeburn 3541: my @searchtypes = &Apache::loncommon::get_env_multiple('form.searchtypes');
1.23 raeburn 3542: my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch');
3543: my @searchby = &Apache::loncommon::get_env_multiple('form.searchby');
3544:
1.44 raeburn 3545: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.26 raeburn 3546: if (keys(%{$usertypes}) == 0) {
3547: @cansearch = ('default');
3548: } else {
3549: if (ref($currdirsrch{'cansearch'}) eq 'ARRAY') {
3550: foreach my $type (@{$currdirsrch{'cansearch'}}) {
3551: if (!grep(/^\Q$type\E$/,@cansearch)) {
3552: push(@{$changes{'cansearch'}},$type);
3553: }
1.23 raeburn 3554: }
1.26 raeburn 3555: foreach my $type (@cansearch) {
3556: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'cansearch'}})) {
3557: push(@{$changes{'cansearch'}},$type);
3558: }
1.23 raeburn 3559: }
1.26 raeburn 3560: } else {
3561: push(@{$changes{'cansearch'}},@cansearch);
1.23 raeburn 3562: }
3563: }
3564:
3565: if (ref($currdirsrch{'searchby'}) eq 'ARRAY') {
3566: foreach my $by (@{$currdirsrch{'searchby'}}) {
3567: if (!grep(/^\Q$by\E$/,@searchby)) {
3568: push(@{$changes{'searchby'}},$by);
3569: }
3570: }
3571: foreach my $by (@searchby) {
3572: if (!grep(/^\Q$by\E$/,@{$currdirsrch{'searchby'}})) {
3573: push(@{$changes{'searchby'}},$by);
3574: }
3575: }
3576: } else {
3577: push(@{$changes{'searchby'}},@searchby);
3578: }
1.25 raeburn 3579:
3580: if (ref($currdirsrch{'searchtypes'}) eq 'ARRAY') {
3581: foreach my $type (@{$currdirsrch{'searchtypes'}}) {
3582: if (!grep(/^\Q$type\E$/,@searchtypes)) {
3583: push(@{$changes{'searchtypes'}},$type);
3584: }
3585: }
3586: foreach my $type (@searchtypes) {
3587: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'searchtypes'}})) {
3588: push(@{$changes{'searchtypes'}},$type);
3589: }
3590: }
3591: } else {
3592: if (exists($currdirsrch{'searchtypes'})) {
3593: foreach my $type (@searchtypes) {
3594: if ($type ne $currdirsrch{'searchtypes'}) {
3595: push(@{$changes{'searchtypes'}},$type);
3596: }
3597: }
3598: if (!grep(/^\Q$currdirsrch{'searchtypes'}\E/,@searchtypes)) {
3599: push(@{$changes{'searchtypes'}},$currdirsrch{'searchtypes'});
3600: }
3601: } else {
3602: push(@{$changes{'searchtypes'}},@searchtypes);
3603: }
3604: }
3605:
1.23 raeburn 3606: my %dirsrch_hash = (
3607: directorysrch => { available => $env{'form.dirsrch_available'},
3608: cansearch => \@cansearch,
1.24 raeburn 3609: localonly => $env{'form.dirsrch_localonly'},
1.23 raeburn 3610: searchby => \@searchby,
1.25 raeburn 3611: searchtypes => \@searchtypes,
1.23 raeburn 3612: }
3613: );
3614: my $putresult = &Apache::lonnet::put_dom('configuration',\%dirsrch_hash,
3615: $dom);
3616: if ($putresult eq 'ok') {
3617: if (exists($currdirsrch{'available'})) {
3618: if ($currdirsrch{'available'} ne $env{'form.dirsrch_available'}) {
3619: $changes{'available'} = 1;
3620: }
3621: } else {
3622: if ($env{'form.dirsrch_available'} eq '1') {
3623: $changes{'available'} = 1;
3624: }
3625: }
1.24 raeburn 3626: if (exists($currdirsrch{'localonly'})) {
3627: if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_localonly'}) {
3628: $changes{'localonly'} = 1;
3629: }
3630: } else {
3631: if ($env{'form.dirsrch_localonly'} eq '1') {
3632: $changes{'localonly'} = 1;
3633: }
3634: }
1.23 raeburn 3635: if (keys(%changes) > 0) {
3636: $resulttext = &mt('Changes made:').'<ul>';
3637: if ($changes{'available'}) {
3638: $resulttext .= '<li>'.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").'</li>';
3639: }
1.24 raeburn 3640: if ($changes{'localonly'}) {
3641: $resulttext .= '<li>'.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_localonly'}]").'</li>';
3642: }
3643:
1.23 raeburn 3644: if (ref($changes{'cansearch'}) eq 'ARRAY') {
3645: my $chgtext;
1.26 raeburn 3646: if (ref($usertypes) eq 'HASH') {
3647: if (keys(%{$usertypes}) > 0) {
3648: foreach my $type (@{$types}) {
3649: if (grep(/^\Q$type\E$/,@cansearch)) {
3650: $chgtext .= $usertypes->{$type}.'; ';
3651: }
3652: }
3653: if (grep(/^default$/,@cansearch)) {
3654: $chgtext .= $othertitle;
3655: } else {
3656: $chgtext =~ s/\; $//;
3657: }
3658: $resulttext .= '<li>'.&mt("Users from domain '<span class=\"LC_cusr_emph\">[_1]</span>' permitted to search the institutional directory set to: [_2]",$dom,$chgtext).'</li>';
1.23 raeburn 3659: }
3660: }
3661: }
3662: if (ref($changes{'searchby'}) eq 'ARRAY') {
3663: my ($searchtitles,$titleorder) = &sorted_searchtitles();
3664: my $chgtext;
3665: foreach my $type (@{$titleorder}) {
3666: if (grep(/^\Q$type\E$/,@searchby)) {
3667: if (defined($searchtitles->{$type})) {
3668: $chgtext .= $searchtitles->{$type}.'; ';
3669: }
3670: }
3671: }
3672: $chgtext =~ s/\; $//;
3673: $resulttext .= '<li>'.&mt("$title{'searchby'} set to: [_1]",$chgtext).'</li>';
3674: }
1.25 raeburn 3675: if (ref($changes{'searchtypes'}) eq 'ARRAY') {
3676: my ($srchtypes_desc,$srchtypeorder) = &sorted_searchtypes();
3677: my $chgtext;
3678: foreach my $type (@{$srchtypeorder}) {
3679: if (grep(/^\Q$type\E$/,@searchtypes)) {
3680: if (defined($srchtypes_desc->{$type})) {
3681: $chgtext .= $srchtypes_desc->{$type}.'; ';
3682: }
3683: }
3684: }
3685: $chgtext =~ s/\; $//;
3686: $resulttext .= '<li>'.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).'</li>';
1.23 raeburn 3687: }
3688: $resulttext .= '</ul>';
3689: } else {
3690: $resulttext = &mt('No changes made to institution directory search settings');
3691: }
3692: } else {
3693: $resulttext = '<span class="LC_error">'.
1.27 raeburn 3694: &mt('An error occurred: [_1]',$putresult).'</span>';
3695: }
3696: return $resulttext;
3697: }
3698:
1.28 raeburn 3699: sub modify_contacts {
3700: my ($dom,%domconfig) = @_;
3701: my ($resulttext,%currsetting,%newsetting,%changes,%contacts_hash);
3702: if (ref($domconfig{'contacts'}) eq 'HASH') {
3703: foreach my $key (keys(%{$domconfig{'contacts'}})) {
3704: $currsetting{$key} = $domconfig{'contacts'}{$key};
3705: }
3706: }
3707: my (%others,%to);
3708: my @contacts = ('supportemail','adminemail');
3709: my @mailings = ('errormail','packagesmail','helpdeskmail');
3710: foreach my $type (@mailings) {
3711: @{$newsetting{$type}} =
3712: &Apache::loncommon::get_env_multiple('form.'.$type);
3713: foreach my $item (@contacts) {
3714: if (grep(/^\Q$item\E$/,@{$newsetting{$type}})) {
3715: $contacts_hash{contacts}{$type}{$item} = 1;
3716: } else {
3717: $contacts_hash{contacts}{$type}{$item} = 0;
3718: }
3719: }
3720: $others{$type} = $env{'form.'.$type.'_others'};
3721: $contacts_hash{contacts}{$type}{'others'} = $others{$type};
3722: }
3723: foreach my $item (@contacts) {
3724: $to{$item} = $env{'form.'.$item};
3725: $contacts_hash{'contacts'}{$item} = $to{$item};
3726: }
3727: if (keys(%currsetting) > 0) {
3728: foreach my $item (@contacts) {
3729: if ($to{$item} ne $currsetting{$item}) {
3730: $changes{$item} = 1;
3731: }
3732: }
3733: foreach my $type (@mailings) {
3734: foreach my $item (@contacts) {
3735: if (ref($currsetting{$type}) eq 'HASH') {
3736: if ($currsetting{$type}{$item} ne $contacts_hash{contacts}{$type}{$item}) {
3737: push(@{$changes{$type}},$item);
3738: }
3739: } else {
3740: push(@{$changes{$type}},@{$newsetting{$type}});
3741: }
3742: }
3743: if ($others{$type} ne $currsetting{$type}{'others'}) {
3744: push(@{$changes{$type}},'others');
3745: }
3746: }
3747: } else {
3748: my %default;
3749: $default{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
3750: $default{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
3751: $default{'errormail'} = 'adminemail';
3752: $default{'packagesmail'} = 'adminemail';
3753: $default{'helpdeskmail'} = 'supportemail';
3754: foreach my $item (@contacts) {
3755: if ($to{$item} ne $default{$item}) {
3756: $changes{$item} = 1;
3757: }
3758: }
3759: foreach my $type (@mailings) {
3760: if ((@{$newsetting{$type}} != 1) || ($newsetting{$type}[0] ne $default{$type})) {
3761:
3762: push(@{$changes{$type}},@{$newsetting{$type}});
3763: }
3764: if ($others{$type} ne '') {
3765: push(@{$changes{$type}},'others');
3766: }
3767: }
3768: }
3769: my $putresult = &Apache::lonnet::put_dom('configuration',\%contacts_hash,
3770: $dom);
3771: if ($putresult eq 'ok') {
3772: if (keys(%changes) > 0) {
3773: my ($titles,$short_titles) = &contact_titles();
3774: $resulttext = &mt('Changes made:').'<ul>';
3775: foreach my $item (@contacts) {
3776: if ($changes{$item}) {
3777: $resulttext .= '<li>'.$titles->{$item}.
3778: &mt(' set to: ').
3779: '<span class="LC_cusr_emph">'.
3780: $to{$item}.'</span></li>';
3781: }
3782: }
3783: foreach my $type (@mailings) {
3784: if (ref($changes{$type}) eq 'ARRAY') {
3785: $resulttext .= '<li>'.$titles->{$type}.': ';
3786: my @text;
3787: foreach my $item (@{$newsetting{$type}}) {
3788: push(@text,$short_titles->{$item});
3789: }
3790: if ($others{$type} ne '') {
3791: push(@text,$others{$type});
3792: }
3793: $resulttext .= '<span class="LC_cusr_emph">'.
3794: join(', ',@text).'</span></li>';
3795: }
3796: }
3797: $resulttext .= '</ul>';
3798: } else {
1.34 raeburn 3799: $resulttext = &mt('No changes made to contact information');
1.28 raeburn 3800: }
3801: } else {
3802: $resulttext = '<span class="LC_error">'.
3803: &mt('An error occurred: [_1].',$putresult).'</span>';
3804: }
3805: return $resulttext;
3806: }
3807:
3808: sub modify_usercreation {
1.27 raeburn 3809: my ($dom,%domconfig) = @_;
1.34 raeburn 3810: my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate);
1.43 raeburn 3811: my $warningmsg;
1.27 raeburn 3812: if (ref($domconfig{'usercreation'}) eq 'HASH') {
3813: foreach my $key (keys(%{$domconfig{'usercreation'}})) {
3814: $curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
3815: }
3816: }
3817: my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
1.32 raeburn 3818: my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
1.43 raeburn 3819: my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
1.45 raeburn 3820: my @contexts = ('author','course','selfcreate');
1.34 raeburn 3821: foreach my $item(@contexts) {
1.45 raeburn 3822: if ($item eq 'selfcreate') {
1.50 raeburn 3823: @{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item);
1.43 raeburn 3824: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
3825: if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) {
1.50 raeburn 3826: if (ref($cancreate{$item}) eq 'ARRAY') {
3827: if (grep(/^login$/,@{$cancreate{$item}})) {
3828: $warningmsg = &mt('Although account creation has been set to be available for institutional logins, currently default authentication in this domain has not been set to support this.').' '.&mt('You need to set the default authentication type to Kerberos 4 or 5 (with a Kerberos domain specified), or to Local authentication, if the localauth module has been customized in your domain to authenticate institutional logins.');
3829: }
1.43 raeburn 3830: }
3831: }
1.50 raeburn 3832: } else {
3833: $cancreate{$item} = $env{'form.can_createuser_'.$item};
1.43 raeburn 3834: }
1.34 raeburn 3835: }
3836: if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
3837: foreach my $item (@contexts) {
1.50 raeburn 3838: if ($item eq 'selfcreate') {
3839: if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
3840: foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) {
3841: if (!grep(/^$curr$/,@{$cancreate{$item}})) {
3842: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
3843: push(@{$changes{'cancreate'}},$item);
3844: }
3845: }
3846: }
3847: } else {
3848: if ($curr_usercreation{'cancreate'}{$item} eq '') {
3849: if (@{$cancreate{$item}} > 0) {
3850: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
3851: push(@{$changes{'cancreate'}},$item);
3852: }
3853: }
3854: } else {
3855: if ($curr_usercreation{'cancreate'}{$item} eq 'any') {
3856: if (@{$cancreate{$item}} < 3) {
3857: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
3858: push(@{$changes{'cancreate'}},$item);
3859: }
3860: }
3861: } elsif ($curr_usercreation{'cancreate'}{$item} eq 'none') {
3862: if (@{$cancreate{$item}} > 0) {
3863: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
3864: push(@{$changes{'cancreate'}},$item);
3865: }
3866: }
3867: } elsif (!grep(/^$curr_usercreation{'cancreate'}{$item}$/,@{$cancreate{$item}})) {
3868: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
3869: push(@{$changes{'cancreate'}},$item);
3870: }
3871: }
3872: }
3873: }
3874: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
3875: foreach my $type (@{$cancreate{$item}}) {
3876: if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
3877: if (!grep(/^$type$/,@{$curr_usercreation{'cancreate'}{$item}})) {
3878: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
3879: push(@{$changes{'cancreate'}},$item);
3880: }
3881: }
3882: } elsif (($curr_usercreation{'cancreate'}{$item} ne 'any') &&
3883: ($curr_usercreation{'cancreate'}{$item} ne 'none')) {
3884: if ($curr_usercreation{'cancreate'}{$item} ne $type) {
3885: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
3886: push(@{$changes{'cancreate'}},$item);
3887: }
3888: }
3889: }
3890: }
3891: }
3892: } else {
3893: if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) {
3894: push(@{$changes{'cancreate'}},$item);
3895: }
3896: }
1.27 raeburn 3897: }
1.34 raeburn 3898: } elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
3899: foreach my $item (@contexts) {
1.43 raeburn 3900: if (!grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) {
1.34 raeburn 3901: if ($cancreate{$item} ne 'any') {
3902: push(@{$changes{'cancreate'}},$item);
3903: }
3904: } else {
3905: if ($cancreate{$item} ne 'none') {
3906: push(@{$changes{'cancreate'}},$item);
3907: }
1.27 raeburn 3908: }
3909: }
3910: } else {
1.43 raeburn 3911: foreach my $item (@contexts) {
1.34 raeburn 3912: push(@{$changes{'cancreate'}},$item);
3913: }
1.27 raeburn 3914: }
1.34 raeburn 3915:
1.27 raeburn 3916: if (ref($curr_usercreation{'username_rule'}) eq 'ARRAY') {
3917: foreach my $type (@{$curr_usercreation{'username_rule'}}) {
3918: if (!grep(/^\Q$type\E$/,@username_rule)) {
3919: push(@{$changes{'username_rule'}},$type);
3920: }
3921: }
3922: foreach my $type (@username_rule) {
3923: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'username_rule'}})) {
3924: push(@{$changes{'username_rule'}},$type);
3925: }
3926: }
3927: } else {
3928: push(@{$changes{'username_rule'}},@username_rule);
3929: }
3930:
1.32 raeburn 3931: if (ref($curr_usercreation{'id_rule'}) eq 'ARRAY') {
3932: foreach my $type (@{$curr_usercreation{'id_rule'}}) {
3933: if (!grep(/^\Q$type\E$/,@id_rule)) {
3934: push(@{$changes{'id_rule'}},$type);
3935: }
3936: }
3937: foreach my $type (@id_rule) {
3938: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'id_rule'}})) {
3939: push(@{$changes{'id_rule'}},$type);
3940: }
3941: }
3942: } else {
3943: push(@{$changes{'id_rule'}},@id_rule);
3944: }
3945:
1.43 raeburn 3946: if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') {
3947: foreach my $type (@{$curr_usercreation{'email_rule'}}) {
3948: if (!grep(/^\Q$type\E$/,@email_rule)) {
3949: push(@{$changes{'email_rule'}},$type);
3950: }
3951: }
3952: foreach my $type (@email_rule) {
3953: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'email_rule'}})) {
3954: push(@{$changes{'email_rule'}},$type);
3955: }
3956: }
3957: } else {
3958: push(@{$changes{'email_rule'}},@email_rule);
3959: }
3960:
3961: my @authen_contexts = ('author','course','domain');
1.28 raeburn 3962: my @authtypes = ('int','krb4','krb5','loc');
3963: my %authhash;
1.43 raeburn 3964: foreach my $item (@authen_contexts) {
1.28 raeburn 3965: my @authallowed = &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');
3966: foreach my $auth (@authtypes) {
3967: if (grep(/^\Q$auth\E$/,@authallowed)) {
3968: $authhash{$item}{$auth} = 1;
3969: } else {
3970: $authhash{$item}{$auth} = 0;
3971: }
3972: }
3973: }
3974: if (ref($curr_usercreation{'authtypes'}) eq 'HASH') {
1.43 raeburn 3975: foreach my $item (@authen_contexts) {
1.28 raeburn 3976: if (ref($curr_usercreation{'authtypes'}{$item}) eq 'HASH') {
3977: foreach my $auth (@authtypes) {
3978: if ($authhash{$item}{$auth} ne $curr_usercreation{'authtypes'}{$item}{$auth}) {
3979: push(@{$changes{'authtypes'}},$item);
3980: last;
3981: }
3982: }
3983: }
3984: }
3985: } else {
1.43 raeburn 3986: foreach my $item (@authen_contexts) {
1.28 raeburn 3987: push(@{$changes{'authtypes'}},$item);
3988: }
3989: }
3990:
1.27 raeburn 3991: my %usercreation_hash = (
1.28 raeburn 3992: usercreation => {
1.34 raeburn 3993: cancreate => \%cancreate,
1.27 raeburn 3994: username_rule => \@username_rule,
1.32 raeburn 3995: id_rule => \@id_rule,
1.43 raeburn 3996: email_rule => \@email_rule,
1.32 raeburn 3997: authtypes => \%authhash,
1.27 raeburn 3998: }
3999: );
4000:
4001: my $putresult = &Apache::lonnet::put_dom('configuration',\%usercreation_hash,
4002: $dom);
1.50 raeburn 4003:
4004: my %selfcreatetypes = (
4005: sso => 'users authenticated by institutional single sign on',
4006: login => 'users authenticated by institutional log-in',
4007: email => 'users who provide a valid e-mail address for use as the username',
4008: );
1.27 raeburn 4009: if ($putresult eq 'ok') {
4010: if (keys(%changes) > 0) {
4011: $resulttext = &mt('Changes made:').'<ul>';
4012: if (ref($changes{'cancreate'}) eq 'ARRAY') {
1.34 raeburn 4013: my %lt = &usercreation_types();
4014: foreach my $type (@{$changes{'cancreate'}}) {
1.43 raeburn 4015: my $chgtext = $lt{$type}.', ';
1.45 raeburn 4016: if ($type eq 'selfcreate') {
1.50 raeburn 4017: if (@{$cancreate{$type}} == 0) {
1.43 raeburn 4018: $chgtext .= &mt('creation of a new user account is not permitted.');
1.50 raeburn 4019: } else {
4020: $chgtext .= &mt('creation of a new account is permitted for:<ul>');
4021: foreach my $case (@{$cancreate{$type}}) {
4022: $chgtext .= '<li>'.$selfcreatetypes{$case}.'</li>';
4023: }
4024: $chgtext .= '</ul>';
1.43 raeburn 4025: }
4026: } else {
4027: if ($cancreate{$type} eq 'none') {
4028: $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.');
4029: } elsif ($cancreate{$type} eq 'any') {
4030: $chgtext .= &mt('creation of new users is permitted for both institutional and non-institutional usernames.');
4031: } elsif ($cancreate{$type} eq 'official') {
4032: $chgtext .= &mt('creation of new users is only permitted for institutional usernames.');
4033: } elsif ($cancreate{$type} eq 'unofficial') {
4034: $chgtext .= &mt('creation of new users is only permitted for non-institutional usernames.');
4035: }
1.34 raeburn 4036: }
4037: $resulttext .= '<li>'.$chgtext.'</li>';
1.27 raeburn 4038: }
4039: }
4040: if (ref($changes{'username_rule'}) eq 'ARRAY') {
1.32 raeburn 4041: my ($rules,$ruleorder) =
4042: &Apache::lonnet::inst_userrules($dom,'username');
1.27 raeburn 4043: my $chgtext = '<ul>';
4044: foreach my $type (@username_rule) {
4045: if (ref($rules->{$type}) eq 'HASH') {
4046: $chgtext .= '<li>'.$rules->{$type}{'name'}.'</li>';
4047: }
4048: }
4049: $chgtext .= '</ul>';
4050: if (@username_rule > 0) {
4051: $resulttext .= '<li>'.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
4052: } else {
1.28 raeburn 4053: $resulttext .= '<li>'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'</li>';
1.27 raeburn 4054: }
4055: }
1.32 raeburn 4056: if (ref($changes{'id_rule'}) eq 'ARRAY') {
4057: my ($idrules,$idruleorder) =
4058: &Apache::lonnet::inst_userrules($dom,'id');
4059: my $chgtext = '<ul>';
4060: foreach my $type (@id_rule) {
4061: if (ref($idrules->{$type}) eq 'HASH') {
4062: $chgtext .= '<li>'.$idrules->{$type}{'name'}.'</li>';
4063: }
4064: }
4065: $chgtext .= '</ul>';
4066: if (@id_rule > 0) {
4067: $resulttext .= '<li>'.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
4068: } else {
4069: $resulttext .= '<li>'.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'</li>';
4070: }
4071: }
1.43 raeburn 4072: if (ref($changes{'email_rule'}) eq 'ARRAY') {
4073: my ($emailrules,$emailruleorder) =
4074: &Apache::lonnet::inst_userrules($dom,'email');
4075: my $chgtext = '<ul>';
4076: foreach my $type (@email_rule) {
4077: if (ref($emailrules->{$type}) eq 'HASH') {
4078: $chgtext .= '<li>'.$emailrules->{$type}{'name'}.'</li>';
4079: }
4080: }
4081: $chgtext .= '</ul>';
4082: if (@email_rule > 0) {
4083: $resulttext .= '<li>'.&mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: ').$chgtext.'</li>';
4084: } else {
4085: $resulttext .= '<li>'.&mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.').'</li>';
4086: }
4087: }
4088:
1.28 raeburn 4089: my %authname = &authtype_names();
4090: my %context_title = &context_names();
4091: if (ref($changes{'authtypes'}) eq 'ARRAY') {
4092: my $chgtext = '<ul>';
4093: foreach my $type (@{$changes{'authtypes'}}) {
4094: my @allowed;
4095: $chgtext .= '<li><span class="LC_cusr_emph">'.$context_title{$type}.'</span> - '.&mt('assignable authentication types: ');
4096: foreach my $auth (@authtypes) {
4097: if ($authhash{$type}{$auth}) {
4098: push(@allowed,$authname{$auth});
4099: }
4100: }
1.43 raeburn 4101: if (@allowed > 0) {
4102: $chgtext .= join(', ',@allowed).'</li>';
4103: } else {
4104: $chgtext .= &mt('none').'</li>';
4105: }
1.28 raeburn 4106: }
4107: $chgtext .= '</ul>';
4108: $resulttext .= '<li>'.&mt('Authentication types available for assignment to new users').'<br />'.$chgtext;
4109: $resulttext .= '</li>';
4110: }
1.27 raeburn 4111: $resulttext .= '</ul>';
4112: } else {
1.28 raeburn 4113: $resulttext = &mt('No changes made to user creation settings');
1.27 raeburn 4114: }
4115: } else {
4116: $resulttext = '<span class="LC_error">'.
1.23 raeburn 4117: &mt('An error occurred: [_1]',$putresult).'</span>';
4118: }
1.43 raeburn 4119: if ($warningmsg ne '') {
4120: $resulttext .= '<br /><span class="LC_warning">'.$warningmsg.'</span><br />';
4121: }
1.23 raeburn 4122: return $resulttext;
4123: }
4124:
1.33 raeburn 4125: sub modify_usermodification {
4126: my ($dom,%domconfig) = @_;
4127: my ($resulttext,%curr_usermodification,%changes);
4128: if (ref($domconfig{'usermodification'}) eq 'HASH') {
4129: foreach my $key (keys(%{$domconfig{'usermodification'}})) {
4130: $curr_usermodification{$key} = $domconfig{'usermodification'}{$key};
4131: }
4132: }
1.63 ! raeburn 4133: my @contexts = ('author','course','selfcreate');
1.33 raeburn 4134: my %context_title = (
4135: author => 'In author context',
4136: course => 'In course context',
1.63 ! raeburn 4137: selfcreate => 'When self creating account',
1.33 raeburn 4138: );
4139: my @fields = ('lastname','firstname','middlename','generation',
4140: 'permanentemail','id');
4141: my %roles = (
4142: author => ['ca','aa'],
4143: course => ['st','ep','ta','in','cr'],
4144: );
1.63 ! raeburn 4145: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
! 4146: if (ref($types) eq 'ARRAY') {
! 4147: push(@{$types},'default');
! 4148: $usertypes->{'default'} = $othertitle;
! 4149: }
! 4150: $roles{'selfcreate'} = $types;
1.33 raeburn 4151: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
4152: my %modifyhash;
4153: foreach my $context (@contexts) {
4154: foreach my $role (@{$roles{$context}}) {
4155: my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role);
4156: foreach my $item (@fields) {
4157: if (grep(/^\Q$item\E$/,@modifiable)) {
4158: $modifyhash{$context}{$role}{$item} = 1;
4159: } else {
4160: $modifyhash{$context}{$role}{$item} = 0;
4161: }
4162: }
4163: }
4164: if (ref($curr_usermodification{$context}) eq 'HASH') {
4165: foreach my $role (@{$roles{$context}}) {
4166: if (ref($curr_usermodification{$context}{$role}) eq 'HASH') {
4167: foreach my $field (@fields) {
4168: if ($modifyhash{$context}{$role}{$field} ne
4169: $curr_usermodification{$context}{$role}{$field}) {
4170: push(@{$changes{$context}},$role);
4171: last;
4172: }
4173: }
4174: }
4175: }
4176: } else {
4177: foreach my $context (@contexts) {
4178: foreach my $role (@{$roles{$context}}) {
4179: push(@{$changes{$context}},$role);
4180: }
4181: }
4182: }
4183: }
4184: my %usermodification_hash = (
4185: usermodification => \%modifyhash,
4186: );
4187: my $putresult = &Apache::lonnet::put_dom('configuration',
4188: \%usermodification_hash,$dom);
4189: if ($putresult eq 'ok') {
4190: if (keys(%changes) > 0) {
4191: $resulttext = &mt('Changes made: ').'<ul>';
4192: foreach my $context (@contexts) {
4193: if (ref($changes{$context}) eq 'ARRAY') {
4194: $resulttext .= '<li>'.$context_title{$context}.':<ul>';
4195: if (ref($changes{$context}) eq 'ARRAY') {
4196: foreach my $role (@{$changes{$context}}) {
4197: my $rolename;
1.63 ! raeburn 4198: if ($context eq 'selfcreate') {
! 4199: $rolename = $role;
! 4200: if (ref($usertypes) eq 'HASH') {
! 4201: if ($usertypes->{$role} ne '') {
! 4202: $rolename = $usertypes->{$role};
! 4203: }
! 4204: }
1.33 raeburn 4205: } else {
1.63 ! raeburn 4206: if ($role eq 'cr') {
! 4207: $rolename = &mt('Custom');
! 4208: } else {
! 4209: $rolename = &Apache::lonnet::plaintext($role);
! 4210: }
1.33 raeburn 4211: }
4212: my @modifiable;
1.63 ! raeburn 4213: if ($context eq 'selfcreate') {
! 4214: $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Self-creation of account by users with status: [_1] ',$rolename).'</span> - '.&mt('modifiable fields (if institutional data blank): ');
! 4215: } else {
! 4216: $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');
! 4217: }
1.33 raeburn 4218: foreach my $field (@fields) {
4219: if ($modifyhash{$context}{$role}{$field}) {
4220: push(@modifiable,$fieldtitles{$field});
4221: }
4222: }
4223: if (@modifiable > 0) {
4224: $resulttext .= join(', ',@modifiable);
4225: } else {
4226: $resulttext .= &mt('none');
4227: }
4228: $resulttext .= '</li>';
4229: }
4230: $resulttext .= '</ul></li>';
4231: }
4232: }
4233: }
4234: $resulttext .= '</ul>';
4235: } else {
4236: $resulttext = &mt('No changes made to user modification settings');
4237: }
4238: } else {
4239: $resulttext = '<span class="LC_error">'.
4240: &mt('An error occurred: [_1]',$putresult).'</span>';
4241: }
4242: return $resulttext;
4243: }
4244:
1.43 raeburn 4245: sub modify_defaults {
4246: my ($dom,$r) = @_;
4247: my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
4248: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.54 raeburn 4249: my @items = ('auth_def','auth_arg_def','lang_def','timezone_def');
1.43 raeburn 4250: my @authtypes = ('internal','krb4','krb5','localauth');
4251: foreach my $item (@items) {
4252: $newvalues{$item} = $env{'form.'.$item};
4253: if ($item eq 'auth_def') {
4254: if ($newvalues{$item} ne '') {
4255: if (!grep(/^\Q$newvalues{$item}\E$/,@authtypes)) {
4256: push(@errors,$item);
4257: }
4258: }
4259: } elsif ($item eq 'lang_def') {
4260: if ($newvalues{$item} ne '') {
4261: if ($newvalues{$item} =~ /^(\w+)/) {
4262: my $langcode = $1;
4263: if (code2language($langcode) eq '') {
4264: push(@errors,$item);
4265: }
4266: } else {
4267: push(@errors,$item);
4268: }
4269: }
1.54 raeburn 4270: } elsif ($item eq 'timezone_def') {
4271: if ($newvalues{$item} ne '') {
1.62 raeburn 4272: if (!DateTime::TimeZone->is_valid_name($newvalues{$item})) {
1.54 raeburn 4273: push(@errors,$item);
4274: }
4275: }
1.43 raeburn 4276: }
4277: if (grep(/^\Q$item\E$/,@errors)) {
4278: $newvalues{$item} = $domdefaults{$item};
4279: } elsif ($domdefaults{$item} ne $newvalues{$item}) {
4280: $changes{$item} = 1;
4281: }
4282: }
4283: my %defaults_hash = (
4284: defaults => { auth_def => $newvalues{'auth_def'},
4285: auth_arg_def => $newvalues{'auth_arg_def'},
4286: lang_def => $newvalues{'lang_def'},
1.54 raeburn 4287: timezone_def => $newvalues{'timezone_def'},
1.43 raeburn 4288: }
4289: );
4290: my $title = &defaults_titles();
4291: my $putresult = &Apache::lonnet::put_dom('configuration',\%defaults_hash,
4292: $dom);
4293: if ($putresult eq 'ok') {
4294: if (keys(%changes) > 0) {
4295: $resulttext = &mt('Changes made:').'<ul>';
4296: my $version = $r->dir_config('lonVersion');
4297: my $mailmsgtext = "Changes made to domain settings in a LON-CAPA installation - domain: $dom (running version: $version) - dns_domain.tab needs to be updated with the following changes, to support legacy 2.4, 2.5 and 2.6 versions of LON-CAPA.\n\n";
4298: foreach my $item (sort(keys(%changes))) {
4299: my $value = $env{'form.'.$item};
4300: if ($value eq '') {
4301: $value = &mt('none');
4302: } elsif ($item eq 'auth_def') {
4303: my %authnames = &authtype_names();
4304: my %shortauth = (
4305: internal => 'int',
4306: krb4 => 'krb4',
4307: krb5 => 'krb5',
4308: localauth => 'loc',
4309: );
4310: $value = $authnames{$shortauth{$value}};
4311: }
4312: $resulttext .= '<li>'.&mt('[_1] set to "[_2]"',$title->{$item},$value).'</li>';
4313: $mailmsgtext .= "$title->{$item} set to $value\n";
4314: }
4315: $resulttext .= '</ul>';
4316: $mailmsgtext .= "\n";
4317: my $cachetime = 24*60*60;
4318: &Apache::lonnet::do_cache_new('domdefaults',$dom,
4319: $defaults_hash{'defaults'},$cachetime);
1.54 raeburn 4320: if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'}) {
4321: my $sysmail = $r->dir_config('lonSysEMail');
4322: &Apache::lonmsg::sendemail($sysmail,"LON-CAPA Domain Settings Change - $dom",$mailmsgtext);
4323: }
1.43 raeburn 4324: } else {
1.54 raeburn 4325: $resulttext = &mt('No changes made to default authentication/language/timezone settings');
1.43 raeburn 4326: }
4327: } else {
4328: $resulttext = '<span class="LC_error">'.
4329: &mt('An error occurred: [_1]',$putresult).'</span>';
4330: }
4331: if (@errors > 0) {
4332: $resulttext .= '<br />'.&mt('The following were left unchanged because the values entered were invalid:');
4333: foreach my $item (@errors) {
4334: $resulttext .= ' "'.$title->{$item}.'",';
4335: }
4336: $resulttext =~ s/,$//;
4337: }
4338: return $resulttext;
4339: }
4340:
1.46 raeburn 4341: sub modify_scantron {
1.48 raeburn 4342: my ($r,$dom,$confname,%domconfig) = @_;
1.46 raeburn 4343: my ($resulttext,%confhash,%changes,$errors);
4344: my $custom = 'custom.tab';
4345: my $default = 'default.tab';
4346: my $servadm = $r->dir_config('lonAdmEMail');
4347: my ($configuserok,$author_ok,$switchserver) =
4348: &config_check($dom,$confname,$servadm);
4349: if ($env{'form.scantronformat.filename'} ne '') {
4350: my $error;
4351: if ($configuserok eq 'ok') {
4352: if ($switchserver) {
4353: $error = &mt("Upload of scantron format file is not permitted to this server: [_1]",$switchserver);
4354: } else {
4355: if ($author_ok eq 'ok') {
4356: my ($result,$scantronurl) =
4357: &publishlogo($r,'upload','scantronformat',$dom,
4358: $confname,'scantron','','',$custom);
4359: if ($result eq 'ok') {
4360: $confhash{'scantron'}{'scantronformat'} = $scantronurl;
1.48 raeburn 4361: $changes{'scantronformat'} = 1;
1.46 raeburn 4362: } else {
4363: $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$custom,$result);
4364: }
4365: } else {
4366: $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$custom,$confname,$dom,$author_ok);
4367: }
4368: }
4369: } else {
4370: $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$custom,$confname,$dom,$configuserok);
4371: }
4372: if ($error) {
4373: &Apache::lonnet::logthis($error);
4374: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
4375: }
4376: }
1.48 raeburn 4377: if (ref($domconfig{'scantron'}) eq 'HASH') {
4378: if ($domconfig{'scantron'}{'scantronformat'} ne '') {
4379: if ($env{'form.scantronformat_del'}) {
4380: $confhash{'scantron'}{'scantronformat'} = '';
4381: $changes{'scantronformat'} = 1;
1.46 raeburn 4382: }
4383: }
4384: }
4385: if (keys(%confhash) > 0) {
4386: my $putresult = &Apache::lonnet::put_dom('configuration',\%confhash,
4387: $dom);
4388: if ($putresult eq 'ok') {
4389: if (keys(%changes) > 0) {
1.48 raeburn 4390: if (ref($confhash{'scantron'}) eq 'HASH') {
4391: $resulttext = &mt('Changes made:').'<ul>';
4392: if ($confhash{'scantron'}{'scantronformat'} eq '') {
4393: $resulttext .= '<li>'.&mt('[_1] scantron format file removed; [_2] file will be used for courses in this domain.',$custom,$default).'</li>';
4394: } else {
4395: $resulttext .= '<li>'.&mt('Custom scantron format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>';
1.46 raeburn 4396: }
1.48 raeburn 4397: $resulttext .= '</ul>';
4398: } else {
4399: $resulttext = &mt('Changes made to scantron format file.');
1.46 raeburn 4400: }
4401: $resulttext .= '</ul>';
4402: &Apache::loncommon::devalidate_domconfig_cache($dom);
4403: } else {
4404: $resulttext = &mt('No changes made to scantron format file');
4405: }
4406: } else {
4407: $resulttext = '<span class="LC_error">'.
4408: &mt('An error occurred: [_1]',$putresult).'</span>';
4409: }
4410: } else {
4411: $resulttext = &mt('No changes made to scantron format file');
4412: }
4413: if ($errors) {
4414: $resulttext .= &mt('The following errors occurred: ').'<ul>'.
4415: $errors.'</ul>';
4416: }
4417: return $resulttext;
4418: }
4419:
1.48 raeburn 4420: sub modify_coursecategories {
4421: my ($dom,%domconfig) = @_;
1.57 raeburn 4422: my ($resulttext,%deletions,%reorderings,%needreordering,%adds,%changes,$errors,
4423: $cathash);
1.48 raeburn 4424: my @deletecategory = &Apache::loncommon::get_env_multiple('form.deletecategory');
1.55 raeburn 4425: if (ref($domconfig{'coursecategories'}) eq 'HASH') {
1.57 raeburn 4426: $cathash = $domconfig{'coursecategories'}{'cats'};
4427: if ($domconfig{'coursecategories'}{'togglecats'} ne $env{'form.togglecats'}) {
4428: $changes{'togglecats'} = 1;
4429: $domconfig{'coursecategories'}{'togglecats'} = $env{'form.togglecats'};
4430: }
4431: if ($domconfig{'coursecategories'}{'categorize'} ne $env{'form.categorize'}) {
4432: $changes{'categorize'} = 1;
4433: $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
4434: }
4435: } else {
4436: $changes{'togglecats'} = 1;
4437: $changes{'categorize'} = 1;
4438: $domconfig{'coursecategories'}{'togglecats'} = $env{'form.togglecats'};
4439: $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
4440: }
4441: if (ref($cathash) eq 'HASH') {
4442: if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) {
1.55 raeburn 4443: push (@deletecategory,'instcode::0');
4444: }
1.48 raeburn 4445: }
1.57 raeburn 4446: my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail);
4447: if (ref($cathash) eq 'HASH') {
1.48 raeburn 4448: if (@deletecategory > 0) {
4449: #FIXME Need to remove category from all courses using a deleted category
1.57 raeburn 4450: &Apache::loncommon::extract_categories($cathash,\@predelcats,\@predeltrails,\%predelallitems);
1.48 raeburn 4451: foreach my $item (@deletecategory) {
1.57 raeburn 4452: if ($domconfig{'coursecategories'}{'cats'}{$item} ne '') {
4453: delete($domconfig{'coursecategories'}{'cats'}{$item});
1.48 raeburn 4454: $deletions{$item} = 1;
1.57 raeburn 4455: &recurse_cat_deletes($item,$cathash,\%deletions);
1.48 raeburn 4456: }
4457: }
4458: }
1.57 raeburn 4459: foreach my $item (keys(%{$cathash})) {
1.48 raeburn 4460: my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$item);
1.57 raeburn 4461: if ($cathash->{$item} ne $env{'form.'.$item}) {
1.48 raeburn 4462: $reorderings{$item} = 1;
1.57 raeburn 4463: $domconfig{'coursecategories'}{'cats'}{$item} = $env{'form.'.$item};
1.48 raeburn 4464: }
4465: if ($env{'form.addcategory_name_'.$item} ne '') {
4466: my $newcat = $env{'form.addcategory_name_'.$item};
4467: my $newdepth = $depth+1;
4468: my $newitem = &escape($newcat).':'.&escape($cat).':'.$newdepth;
1.57 raeburn 4469: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos_'.$item};
1.48 raeburn 4470: $adds{$newitem} = 1;
4471: }
4472: if ($env{'form.subcat_'.$item} ne '') {
4473: my $newcat = $env{'form.subcat_'.$item};
4474: my $newdepth = $depth+1;
4475: my $newitem = &escape($newcat).':'.&escape($cat).':'.$newdepth;
1.57 raeburn 4476: $domconfig{'coursecategories'}{'cats'}{$newitem} = 0;
1.48 raeburn 4477: $adds{$newitem} = 1;
4478: }
4479: }
4480: }
4481: if ($env{'form.instcode'} eq '1') {
1.57 raeburn 4482: if (ref($cathash) eq 'HASH') {
1.48 raeburn 4483: my $newitem = 'instcode::0';
1.57 raeburn 4484: if ($cathash->{$newitem} eq '') {
4485: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.instcode_pos'};
1.48 raeburn 4486: $adds{$newitem} = 1;
4487: }
4488: } else {
4489: my $newitem = 'instcode::0';
1.57 raeburn 4490: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.instcode_pos'};
1.48 raeburn 4491: $adds{$newitem} = 1;
4492: }
4493: }
4494: if ($env{'form.addcategory_name'} ne '') {
4495: my $newitem = &escape($env{'form.addcategory_name'}).'::0';
1.57 raeburn 4496: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
1.48 raeburn 4497: $adds{$newitem} = 1;
4498: }
1.57 raeburn 4499: my $putresult;
1.48 raeburn 4500: if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
4501: if (keys(%deletions) > 0) {
4502: foreach my $key (keys(%deletions)) {
4503: if ($predelallitems{$key} ne '') {
4504: $sort_by_deltrail{$predelallitems{$key}} = $predeltrails[$predelallitems{$key}];
4505: }
4506: }
4507: }
4508: my (@chkcats,@chktrails,%chkallitems);
1.57 raeburn 4509: &Apache::loncommon::extract_categories($domconfig{'coursecategories'}{'cats'},\@chkcats,\@chktrails,\%chkallitems);
1.48 raeburn 4510: if (ref($chkcats[0]) eq 'ARRAY') {
4511: my $depth = 0;
4512: my $chg = 0;
4513: for (my $i=0; $i<@{$chkcats[0]}; $i++) {
4514: my $name = $chkcats[0][$i];
4515: my $item;
4516: if ($name eq '') {
4517: $chg ++;
4518: } else {
4519: $item = &escape($name).'::0';
4520: if ($chg) {
1.57 raeburn 4521: $domconfig{'coursecategories'}{'cats'}{$item} -= $chg;
1.48 raeburn 4522: }
4523: $depth ++;
1.57 raeburn 4524: &recurse_check(\@chkcats,$domconfig{'coursecategories'}{'cats'},$depth,$name);
1.48 raeburn 4525: $depth --;
4526: }
4527: }
4528: }
1.57 raeburn 4529: }
4530: if ((keys(%changes) > 0) || (keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
4531: $putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);
1.48 raeburn 4532: if ($putresult eq 'ok') {
1.57 raeburn 4533: my %title = (
4534: togglecats => 'Show/Hide a course in the catalog',
4535: categorize => 'Category assigned to course',
4536: );
4537: my %level = (
4538: dom => 'set from "Modify Course" (Domain)',
4539: crs => 'set from "Parameters" (Course)',
4540: );
1.48 raeburn 4541: $resulttext = &mt('Changes made:').'<ul>';
1.57 raeburn 4542: if ($changes{'togglecats'}) {
4543: $resulttext .= '<li>'.&mt("$title{'togglecats'} $level{$env{'form.togglecats'}}").'</li>';
4544: }
4545: if ($changes{'categorize'}) {
4546: $resulttext .= '<li>'.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'</li>';
1.48 raeburn 4547: }
1.57 raeburn 4548: if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
4549: my $cathash;
4550: if (ref($domconfig{'coursecategories'}) eq 'HASH') {
4551: $cathash = $domconfig{'coursecategories'}{'cats'};
4552: } else {
4553: $cathash = {};
4554: }
4555: my (@cats,@trails,%allitems);
4556: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems);
4557: if (keys(%deletions) > 0) {
4558: $resulttext .= '<li>'.&mt('Deleted categories:').'<ul>';
4559: foreach my $predeltrail (sort {$a <=> $b } (keys(%sort_by_deltrail))) {
4560: $resulttext .= '<li>'.$predeltrails[$predeltrail].'</li>';
4561: }
4562: $resulttext .= '</ul></li>';
4563: }
4564: if (keys(%reorderings) > 0) {
4565: my %sort_by_trail;
4566: $resulttext .= '<li>'.&mt('Reordered categories:').'<ul>';
4567: foreach my $key (keys(%reorderings)) {
4568: if ($allitems{$key} ne '') {
4569: $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
4570: }
1.48 raeburn 4571: }
1.57 raeburn 4572: foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
4573: $resulttext .= '<li>'.$trails[$trail].'</li>';
4574: }
4575: $resulttext .= '</ul></li>';
1.48 raeburn 4576: }
1.57 raeburn 4577: if (keys(%adds) > 0) {
4578: my %sort_by_trail;
4579: $resulttext .= '<li>'.&mt('Added categories:').'<ul>';
4580: foreach my $key (keys(%adds)) {
4581: if ($allitems{$key} ne '') {
4582: $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
4583: }
4584: }
4585: foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
4586: $resulttext .= '<li>'.$trails[$trail].'</li>';
1.48 raeburn 4587: }
1.57 raeburn 4588: $resulttext .= '</ul></li>';
1.48 raeburn 4589: }
4590: }
4591: $resulttext .= '</ul>';
4592: } else {
4593: $resulttext = '<span class="LC_error">'.
1.57 raeburn 4594: &mt('An error occurred: [_1]',$putresult).'</span>';
1.48 raeburn 4595: }
4596: } else {
4597: $resulttext = &mt('No changes made to course categories');
4598: }
4599: return $resulttext;
4600: }
4601:
4602: sub recurse_check {
4603: my ($chkcats,$categories,$depth,$name) = @_;
4604: if (ref($chkcats->[$depth]{$name}) eq 'ARRAY') {
4605: my $chg = 0;
4606: for (my $j=0; $j<@{$chkcats->[$depth]{$name}}; $j++) {
4607: my $category = $chkcats->[$depth]{$name}[$j];
4608: my $item;
4609: if ($category eq '') {
4610: $chg ++;
4611: } else {
4612: my $deeper = $depth + 1;
4613: $item = &escape($category).':'.&escape($name).':'.$depth;
4614: if ($chg) {
4615: $categories->{$item} -= $chg;
4616: }
4617: &recurse_check($chkcats,$categories,$deeper,$category);
4618: $deeper --;
4619: }
4620: }
4621: }
4622: return;
4623: }
4624:
4625: sub recurse_cat_deletes {
4626: my ($item,$coursecategories,$deletions) = @_;
4627: my ($deleted,$container,$depth) = map { &unescape($_); } split(/:/,$item);
4628: my $subdepth = $depth + 1;
4629: if (ref($coursecategories) eq 'HASH') {
4630: foreach my $subitem (keys(%{$coursecategories})) {
4631: my ($child,$parent,$itemdepth) = map { &unescape($_); } split(/:/,$subitem);
4632: if (($parent eq $deleted) && ($itemdepth == $subdepth)) {
4633: delete($coursecategories->{$subitem});
4634: $deletions->{$subitem} = 1;
4635: &recurse_cat_deletes($subitem,$coursecategories,$deletions);
4636: }
4637: }
4638: }
4639: return;
4640: }
4641:
1.3 raeburn 4642: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>