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