Annotation of loncom/interface/domainprefs.pm, revision 1.38
1.1 raeburn 1: # The LearningOnline Network with CAPA
2: # Handler to set domain-wide configuration settings
3: #
1.38 ! raeburn 4: # $Id: domainprefs.pm,v 1.37 2007/12/21 04:47:24 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;
39: use LONCAPA();
1.6 raeburn 40: use LONCAPA::Enrollment;
1.9 raeburn 41: use File::Copy;
1.1 raeburn 42:
43: sub handler {
44: my $r=shift;
45: if ($r->header_only) {
46: &Apache::loncommon::content_type($r,'text/html');
47: $r->send_http_header;
48: return OK;
49: }
50:
51: my $dom = $env{'request.role.domain'};
1.5 albertel 52: my $domdesc = &Apache::lonnet::domain($dom,'description');
1.1 raeburn 53: if (&Apache::lonnet::allowed('mau',$dom)) {
54: &Apache::loncommon::content_type($r,'text/html');
55: $r->send_http_header;
56: } else {
57: $env{'user.error.msg'}=
58: "/adm/domainprefs:mau:0:0:Cannot modify domain settings";
59: return HTTP_NOT_ACCEPTABLE;
60: }
61: &Apache::lonhtmlcommon::clear_breadcrumbs();
62: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
63: ['phase']);
1.30 raeburn 64: my $phase = 'pickactions';
1.3 raeburn 65: if ( exists($env{'form.phase'}) ) {
66: $phase = $env{'form.phase'};
67: }
68: my %domconfig =
1.6 raeburn 69: &Apache::lonnet::get_dom('configuration',['login','rolecolors',
1.27 raeburn 70: 'quotas','autoenroll','autoupdate','directorysrch',
1.33 raeburn 71: 'usercreation','usermodification','contacts'],$dom);
1.30 raeburn 72: my @prefs_order = ('rolecolors','login','quotas','autoenroll',
73: 'autoupdate','directorysrch','contacts',
1.33 raeburn 74: 'usercreation','usermodification');
1.30 raeburn 75: my %prefs = (
76: 'rolecolors' =>
77: { text => 'Default color schemes',
78: help => 'Default_Color_Schemes',
79: header => [{col1 => 'Student Settings',
80: col2 => '',},
81: {col1 => 'Coordinator Settings',
82: col2 => '',},
83: {col1 => 'Author Settings',
84: col2 => '',},
85: {col1 => 'Administrator Settings',
86: col2 => '',}],
87: },
88: 'login' =>
89: { text => 'Log-in page options',
90: help => 'Domain_Log-in_Page',
91: header => [{col1 => 'Item',
92: col2 => '',}],
93: },
94: 'quotas' =>
95: { text => 'Default quotas for user portfolios',
96: help => 'Default_User_Quota',
97: header => [{col1 => 'User type',
98: col2 => 'Default quota'}],
99: },
100: 'autoenroll' =>
101: { text => 'Auto-enrollment settings',
102: help => 'Domain_Auto_Enrollment',
103: header => [{col1 => 'Configuration setting',
104: col2 => 'Value(s)'}],
105: },
106: 'autoupdate' =>
107: { text => 'Auto-update settings',
108: help => 'Domain_Auto_Update',
109: header => [{col1 => 'Setting',
110: col2 => 'Value',},
111: {col1 => 'User Population',
112: col2 => 'Updataeable user data'}],
113: },
114: 'directorysrch' =>
115: { text => 'Institutional directory searches',
116: help => 'Domain_Directory_Search',
117: header => [{col1 => 'Setting',
118: col2 => 'Value',}],
119: },
120: 'contacts' =>
121: { text => 'Contact Information',
122: help => 'Domain_Contact_Information',
123: header => [{col1 => 'Setting',
124: col2 => 'Value',}],
125: },
126:
127: 'usercreation' =>
128: { text => 'User creation',
129: help => 'Domain_User_Creation',
1.34 raeburn 130: header => [{col1 => 'Format Rule Type',
131: col2 => 'Format Rules in force'},
132: {col1 => 'User account creation',
133: col2 => 'Usernames which may be created',},
1.30 raeburn 134: {col1 => 'Context',
135: col2 => 'Assignable Authentication Types'}],
136: },
1.33 raeburn 137: 'usermodification' =>
138: { text => 'User modification',
139: help => 'Domain_User_Modification',
140: header => [{col1 => 'Target user has role',
141: col2 => 'User information updateable in author context'},
142: {col1 => 'Target user has role',
143: col2 => 'User information updateable in course context'}],
144: },
1.3 raeburn 145: );
1.6 raeburn 146: my @roles = ('student','coordinator','author','admin');
1.30 raeburn 147: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
1.3 raeburn 148: &Apache::lonhtmlcommon::add_breadcrumb
1.30 raeburn 149: ({href=>"javascript:changePage(document.$phase,'pickactions')",
150: text=>"Pick functionality"});
1.9 raeburn 151: my $confname = $dom.'-domainconfig';
1.3 raeburn 152: if ($phase eq 'process') {
1.1 raeburn 153: &Apache::lonhtmlcommon::add_breadcrumb
1.30 raeburn 154: ({href=>"javascript:changePage(document.$phase,'display')",
155: text=>"Domain Configuration"},
156: {href=>"javascript:changePage(document.$phase,'$phase')",
1.3 raeburn 157: text=>"Updated"});
158: &print_header($r,$phase);
1.30 raeburn 159: foreach my $item (@prefs_order) {
160: if (grep(/^\Q$item\E$/,@actions)) {
161: $r->print('<h3>'.&mt($prefs{$item}{'text'}).'</h3>'.
162: &process_changes($r,$dom,$confname,$item,
163: \@roles,%domconfig));
164: }
1.3 raeburn 165: }
166: $r->print('<p>');
1.30 raeburn 167: &print_footer($r,$phase,'display','Back to configuration display',
168: \@actions);
1.3 raeburn 169: $r->print('</p>');
1.30 raeburn 170: } elsif ($phase eq 'display') {
171: &Apache::lonhtmlcommon::add_breadcrumb
172: ({href=>"javascript:changePage(document.$phase,'display')",
173: text=>"Domain Configuration"});
174: &print_header($r,$phase);
175: if (@actions > 0) {
176: my $rowsum = 0;
177: my (%output,%rowtotal,@items);
178: my $halfway = @actions/2;
179: foreach my $item (@prefs_order) {
180: if (grep(/^\Q$item\E$/,@actions)) {
181: push(@items,$item);
182: ($output{$item},$rowtotal{$item}) =
183: &print_config_box($r,$dom,$confname,$phase,
184: $item,$prefs{$item},
185: $domconfig{$item});
186: $rowsum += $rowtotal{$item};
187: }
188: }
189: my $colend;
190: my $halfway = $rowsum/2;
191: my $aggregate = 0;
192: my $sumleft = 0;
193: my $sumright = 0;
194: my $crossover;
195: for (my $i=0; $i<@items; $i++) {
196: $aggregate += $rowtotal{$items[$i]};
197: if ($aggregate > $halfway) {
198: $crossover = $i;
199: last;
200: }
201: }
202: for (my $i=0; $i<$crossover; $i++) {
203: $sumleft += $rowtotal{$items[$i]};
204: }
205: for (my $i=$crossover+1; $i<@items; $i++) {
206: $sumright += $rowtotal{$items[$i]};
207: }
208: if ((@items > 1) && ($env{'form.numcols'} == 2)) {
209: my $sumdiff = $sumright - $sumleft;
210: if ($sumdiff > 0) {
211: $colend = $crossover + 1;
212: } else {
213: $colend = $crossover;
214: }
215: } else {
216: $colend = @items;
217: }
218: $r->print('<p><table class="LC_double_column"><tr><td class="LC_left_col">');
219: for (my $i=0; $i<$colend; $i++) {
220: $r->print($output{$items[$i]});
221: }
222: $r->print('</td><td></td><td class="LC_right_col">');
223: if ($colend < @items) {
224: for (my $i=$colend; $i<@items; $i++) {
225: $r->print($output{$items[$i]});
226: }
227: }
228: $r->print('</td></tr></table></p>');
229: $r->print(&print_footer($r,$phase,'process','Save',\@actions));
230: } else {
231: $r->print('<input type="hidden" name="phase" value="" />'.
232: '<input type="hidden" name="numcols" value="'.
233: $env{'form.numcols'}.'" />'."\n".
234: '<span clas="LC_error">'.&mt('No settings chosen').
235: '</span>');
236: }
237: $r->print('</form>');
238: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 239: } else {
1.3 raeburn 240: if ($phase eq '') {
1.30 raeburn 241: $phase = 'pickactions';
1.1 raeburn 242: }
1.30 raeburn 243: my %helphash;
1.3 raeburn 244: &print_header($r,$phase);
1.21 raeburn 245: if (keys(%domconfig) == 0) {
246: my $primarylibserv = &Apache::lonnet::domain($dom,'primary');
1.29 raeburn 247: my @ids=&Apache::lonnet::current_machine_ids();
248: if (!grep(/^\Q$primarylibserv\E$/,@ids)) {
1.21 raeburn 249: my %designhash = &Apache::loncommon::get_domainconf($dom);
250: my @loginimages = ('img','logo','domlogo');
251: my $custom_img_count = 0;
252: foreach my $img (@loginimages) {
253: if ($designhash{$dom.'.login.'.$img} ne '') {
254: $custom_img_count ++;
255: }
256: }
257: foreach my $role (@roles) {
258: if ($designhash{$dom.'.'.$role.'.img'} ne '') {
259: $custom_img_count ++;
260: }
261: }
262: if ($custom_img_count > 0) {
263: my $switch_server = &check_switchserver($dom,$confname);
1.29 raeburn 264: $r->print(
265: &mt('Domain configuration settings have yet to be saved for this domain via the web-based domain preferences interface.').'<br />'.
266: &mt("While this remains so, you must switch to the domain's primary library server in order to update settings.").'<br /><br />'.
267: &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 />'.
268: &mt("However, you will still need to switch to the domain's primary library server to upload new images or logos.").'<br /><br />');
269: if ($switch_server) {
1.30 raeburn 270: $r->print($switch_server.' '.&mt('to primary library server for domain: [_1]',$dom));
1.29 raeburn 271: }
1.21 raeburn 272: return OK;
273: }
274: }
275: }
1.30 raeburn 276: $r->print('<h3>'.&mt('Functionality to display/modify').'</h3>');
277: $r->print('<script type="text/javascript">'."\n".
278: &Apache::loncommon::check_uncheck_jscript()."\n".
279: '</script>'."\n".'<p><input type="button" value="check all" '.
280: 'onclick="javascript:checkAll(document.pickactions.actions)"'.
281: ' /> '.
282: '<input type="button" value="uncheck all" '.
283: 'onclick="javascript:uncheckAll(document.pickactions.actions)"'.
1.38 ! raeburn 284: ' /></p><div class="LC_left_float">');
! 285: my ($numitems,$midpoint,$seconddiv,$count);
! 286: $numitems = @prefs_order;
! 287: $midpoint = int($numitems/2);
! 288: if ($numitems%2) {
! 289: $midpoint ++;
! 290: }
! 291: $count = 0;
1.30 raeburn 292: foreach my $item (@prefs_order) {
1.38 ! raeburn 293: $r->print('<h4><label><input type="checkbox" name="actions" value="'.$item.'" /> '.$prefs{$item}->{'text'}.'</label></h4>');
! 294: $count ++;
! 295: if ((!$seconddiv) && ($count >= $midpoint)) {
! 296: $r->print('</div>'."\n".'<div class="LC_left_float">'."\n");
! 297: $seconddiv = 1;
! 298: }
1.30 raeburn 299: }
1.38 ! raeburn 300: $r->print('</div><div class="LC_clear_float_footer"></div><h3>'.
! 301: &mt('Display options').'</h3>'."\n".
1.30 raeburn 302: '<p><span class="LC_nobreak">'.&mt('Display using: ')."\n".
303: '<label><input type="radio" name="numcols" value="1">'.
304: &mt('one column').'</label> '.
305: '<input type="radio" name="numcols" value="2">'.
306: &mt('two columns').'</label></span></p>');
307: $r->print(&print_footer($r,$phase,'display','Go'));
308: $r->print('</form>');
309: $r->print(&Apache::loncommon::end_page());
1.3 raeburn 310: }
311: return OK;
312: }
313:
314: sub process_changes {
1.9 raeburn 315: my ($r,$dom,$confname,$action,$roles,%domconfig) = @_;
1.3 raeburn 316: my $output;
317: if ($action eq 'login') {
1.9 raeburn 318: $output = &modify_login($r,$dom,$confname,%domconfig);
1.6 raeburn 319: } elsif ($action eq 'rolecolors') {
1.9 raeburn 320: $output = &modify_rolecolors($r,$dom,$confname,$roles,
321: %domconfig);
1.3 raeburn 322: } elsif ($action eq 'quotas') {
323: $output = &modify_quotas($dom,%domconfig);
324: } elsif ($action eq 'autoenroll') {
325: $output = &modify_autoenroll($dom,%domconfig);
326: } elsif ($action eq 'autoupdate') {
327: $output = &modify_autoupdate($dom,%domconfig);
1.23 raeburn 328: } elsif ($action eq 'directorysrch') {
329: $output = &modify_directorysrch($dom,%domconfig);
1.27 raeburn 330: } elsif ($action eq 'usercreation') {
1.28 raeburn 331: $output = &modify_usercreation($dom,%domconfig);
1.33 raeburn 332: } elsif ($action eq 'usermodification') {
333: $output = &modify_usermodification($dom,%domconfig);
1.28 raeburn 334: } elsif ($action eq 'contacts') {
335: $output = &modify_contacts($dom,%domconfig);
1.3 raeburn 336: }
337: return $output;
338: }
339:
340: sub print_config_box {
1.9 raeburn 341: my ($r,$dom,$confname,$phase,$action,$item,$settings) = @_;
1.30 raeburn 342: my $rowtotal = 0;
343: my $output =
344: '<table class="LC_nested_outer">
1.3 raeburn 345: <tr>
1.30 raeburn 346: <th align="left"><span class="LC_nobreak">'.&mt($item->{text}).
347: ' </span></th></tr>';
1.22 raeburn 348: #
349: # FIXME - put the help link back in when the help files exist
350: # <th>'.&mt($item->{text}).' '.
351: # &Apache::loncommon::help_open_topic($item->{'help'}).'</th>
352: # </tr>');
1.30 raeburn 353: $rowtotal ++;
1.28 raeburn 354: if (($action eq 'autoupdate') || ($action eq 'rolecolors') ||
1.33 raeburn 355: ($action eq 'usercreation') || ($action eq 'usermodification')) {
1.6 raeburn 356: my $colspan = ($action eq 'rolecolors')?' colspan="2"':'';
1.30 raeburn 357: $output .= '
1.3 raeburn 358: <tr>
359: <td>
360: <table class="LC_nested">
361: <tr class="LC_info_row">
1.6 raeburn 362: <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[0]->{'col1'}.'</td>
1.3 raeburn 363: <td class="LC_right_item">'.$item->{'header'}->[0]->{'col2'}.'</td>
1.30 raeburn 364: </tr>';
365: $rowtotal ++;
1.6 raeburn 366: if ($action eq 'autoupdate') {
1.30 raeburn 367: $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal);
1.28 raeburn 368: } elsif ($action eq 'usercreation') {
1.33 raeburn 369: $output .= &print_usercreation('top',$dom,$settings,\$rowtotal);
370: } elsif ($action eq 'usermodification') {
371: $output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
1.6 raeburn 372: } else {
1.30 raeburn 373: $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
1.6 raeburn 374: }
1.30 raeburn 375: $output .= '
1.6 raeburn 376: </table>
377: </td>
378: </tr>
379: <tr>
380: <td>
381: <table class="LC_nested">
382: <tr class="LC_info_row">
383: <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[1]->{'col1'}.'</td>
384: <td class="LC_right_item">'.$item->{'header'}->[1]->{'col2'}.'</td>
1.30 raeburn 385: </tr>';
386: $rowtotal ++;
1.6 raeburn 387: if ($action eq 'autoupdate') {
1.30 raeburn 388: $output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
1.28 raeburn 389: } elsif ($action eq 'usercreation') {
1.34 raeburn 390: $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'
391: </table>
392: </td>
393: </tr>
394: <tr>
395: <td>
396: <table class="LC_nested">
397: <tr class="LC_info_row">
398: <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[2]->{'col1'}.'</td>
399: <td class="LC_right_item">'.$item->{'header'}->[2]->{'col2'}.'</td> </tr>'.
400: &print_usercreation('bottom',$dom,$settings,\$rowtotal);
401: $rowtotal ++;
1.33 raeburn 402: } elsif ($action eq 'usermodification') {
403: $output .= &print_usermodification('bottom',$dom,$settings,\$rowtotal);
1.6 raeburn 404: } else {
1.30 raeburn 405: $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
1.6 raeburn 406: </table>
407: </td>
408: </tr>
409: <tr>
410: <td>
411: <table class="LC_nested">
412: <tr class="LC_info_row">
413: <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[2]->{'col1'}.'</td>
414: <td class="LC_right_item">'.$item->{'header'}->[2]->{'col2'}.'</td>
1.3 raeburn 415: </tr>'.
1.30 raeburn 416: &print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'
1.3 raeburn 417: </table>
418: </td>
419: </tr>
420: <tr>
421: <td>
422: <table class="LC_nested">
423: <tr class="LC_info_row">
1.6 raeburn 424: <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[3]->{'col1'}.'</td>
425: <td class="LC_right_item">'.$item->{'header'}->[3]->{'col2'}.'</td>
1.3 raeburn 426: </tr>'.
1.30 raeburn 427: &print_rolecolors($phase,'admin',$dom,$confname,$settings,\$rowtotal);
428: $rowtotal += 2;
1.6 raeburn 429: }
1.3 raeburn 430: } else {
1.30 raeburn 431: $output .= '
1.3 raeburn 432: <tr>
433: <td>
434: <table class="LC_nested">
1.30 raeburn 435: <tr class="LC_info_row">';
1.24 raeburn 436: if (($action eq 'login') || ($action eq 'directorysrch')) {
1.30 raeburn 437: $output .= '
438: <td class="LC_left_item" colspan="2">'.$item->{'header'}->[0]->{'col1'}.'</td>';
1.6 raeburn 439: } else {
1.30 raeburn 440: $output .= '
441: <td class="LC_left_item">'.$item->{'header'}->[0]->{'col1'}.'</td>';
1.6 raeburn 442: }
1.30 raeburn 443: $output .= '
1.3 raeburn 444: <td class="LC_right_item">'.$item->{'header'}->[0]->{'col2'}.'</td>
1.30 raeburn 445: </tr>';
446: $rowtotal ++;
1.3 raeburn 447: if ($action eq 'login') {
1.30 raeburn 448: $output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal);
1.3 raeburn 449: } elsif ($action eq 'quotas') {
1.30 raeburn 450: $output .= &print_quotas($dom,$settings,\$rowtotal);
1.3 raeburn 451: } elsif ($action eq 'autoenroll') {
1.30 raeburn 452: $output .= &print_autoenroll($dom,$settings,\$rowtotal);
1.23 raeburn 453: } elsif ($action eq 'directorysrch') {
1.30 raeburn 454: $output .= &print_directorysrch($dom,$settings,\$rowtotal);
1.28 raeburn 455: } elsif ($action eq 'contacts') {
1.30 raeburn 456: $output .= &print_contacts($dom,$settings,\$rowtotal);
1.27 raeburn 457: }
1.3 raeburn 458: }
1.30 raeburn 459: $output .= '
1.3 raeburn 460: </table>
461: </td>
462: </tr>
1.30 raeburn 463: </table><br />';
464: return ($output,$rowtotal);
1.1 raeburn 465: }
466:
467: sub print_header {
1.3 raeburn 468: my ($r,$phase) = @_;
1.30 raeburn 469: my $alert = &mt('You must select at least one functionality type to display.');
1.6 raeburn 470: my $js = '
1.1 raeburn 471: <script type="text/javascript">
472: function changePage(formname,newphase) {
473: formname.phase.value = newphase;
1.30 raeburn 474: numchecked = 0;
475: if (formname == document.pickactions) {
476: if (formname.actions.length > 0) {
477: for (var i = 0; i <formname.actions.length; i++) {
478: if (formname.actions[i].checked) {
479: numchecked ++;
480: }
481: }
482: } else {
483: if (formname.actions.checked) {
484: numchecked ++;
485: }
486: }
487: if (numchecked > 0) {
488: formname.submit();
489: } else {
490: alert("'.$alert.'");
491: return;
492: }
493: }
1.1 raeburn 494: formname.submit();
1.30 raeburn 495: }'."\n";
496: if ($phase eq 'pickactions') {
497: $js .=
498: &Apache::lonhtmlcommon::set_form_elements({actions => 'checkbox',numcols => 'radio',})."\n".
499: &javascript_set_colnums();
500: } elsif ($phase eq 'display') {
501: $js .= &color_pick_js()."\n";
502: }
1.31 raeburn 503: $js .= &Apache::loncommon::viewport_size_js().'
1.1 raeburn 504: </script>
1.6 raeburn 505: ';
1.30 raeburn 506: my $additem;
507: if ($phase eq 'pickactions') {
508: my %loaditems = (
1.31 raeburn 509: 'onload' => "javascript:getViewportDims(document.$phase.width,document.$phase.height);setDisplayColumns();setFormElements(document.pickactions);",
1.30 raeburn 510: );
511: $additem = {'add_entries' => \%loaditems,};
512: } else {
513: my %loaditems = (
1.31 raeburn 514: 'onload' => "javascript:getViewportDims(document.$phase.width,document.$phase.height);",
1.30 raeburn 515: );
516: $additem = {'add_entries' => \%loaditems,};
517: }
1.2 albertel 518: $r->print(&Apache::loncommon::start_page('View/Modify Domain Settings',
1.30 raeburn 519: $js,$additem));
1.3 raeburn 520: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Domain Settings'));
1.6 raeburn 521: $r->print('
1.8 raeburn 522: <form name="parmform" action="">
1.6 raeburn 523: <input type="hidden" name="pres_marker" />
524: <input type="hidden" name="pres_type" />
525: <input type="hidden" name="pres_value" />
526: </form>
527: ');
528: $r->print('<form method="post" name="'.$phase.'" action="/adm/domainprefs"'.
529: ' enctype="multipart/form-data">');
1.1 raeburn 530: return;
531: }
532:
533: sub print_footer {
1.30 raeburn 534: my ($r,$phase,$newphase,$button_text,$actions) = @_;
1.3 raeburn 535: $button_text = &mt($button_text);
1.30 raeburn 536: $r->print('<input type="hidden" name="phase" value="" />'.
537: '<input type="hidden" name="width" value="'.
538: $env{'form.width'}.'" />'.
539: '<input type="hidden" name="height" value="'.
540: $env{'form.height'}.'" />');
541: if (($phase eq 'display') || ($phase eq 'process')) {
542: if (ref($actions) eq 'ARRAY') {
543: foreach my $item (@{$actions}) {
544: $r->print('<input type="hidden" name="actions" value="'.$item.'" />')."\n";
545: }
546: }
547: $r->print('<input type="hidden" name="numcols" value="'.$env{'form.numcols'}.'" />');
548: }
1.3 raeburn 549: my $dest='"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
550: if ($phase eq 'process') {
1.30 raeburn 551: $r->print('<p><a href='.$dest.'>'.$button_text.'</a></p>');
1.3 raeburn 552: } else {
1.30 raeburn 553: my $onclick;
554: if ($phase eq 'display') {
555: $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
556: } else {
557: $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
558: }
559: $r->print('<p><input type="button" name="store" value="'.
560: $button_text.'" onclick='.$onclick.' /></p>');
561: }
562: if ($phase eq 'process') {
563: $r->print('</form>'.&Apache::loncommon::end_page());
1.3 raeburn 564: }
1.1 raeburn 565: return;
566: }
567:
1.3 raeburn 568: sub print_login {
1.30 raeburn 569: my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
1.6 raeburn 570: my %choices = &login_choices();
571: my ($catalogon,$catalogoff,$adminmailon,$adminmailoff);
572: $catalogon = ' checked="checked" ';
573: $adminmailoff = ' checked="checked" ';
574: my @images = ('img','logo','domlogo');
575: my @bgs = ('pgbg','mainbg','sidebg');
576: my @links = ('link','alink','vlink');
1.7 albertel 577: my %designhash = &Apache::loncommon::get_domainconf($dom);
1.6 raeburn 578: my %defaultdesign = %Apache::loncommon::defaultdesign;
579: my (%is_custom,%designs);
580: my %defaults = (
581: font => $defaultdesign{'login.font'},
582: );
583: foreach my $item (@images) {
584: $defaults{$item} = $defaultdesign{'login.'.$item};
585: }
586: foreach my $item (@bgs) {
587: $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
588: }
589: foreach my $item (@links) {
590: $defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
591: }
1.3 raeburn 592: if (ref($settings) eq 'HASH') {
593: if ($settings->{'coursecatalog'} eq '0') {
1.1 raeburn 594: $catalogoff = $catalogon;
595: $catalogon = ' ';
596: }
1.3 raeburn 597: if ($settings->{'adminmail'} eq '1') {
1.1 raeburn 598: $adminmailon = $adminmailoff;
599: $adminmailoff = ' ';
600: }
1.6 raeburn 601: foreach my $item (@images) {
602: if ($settings->{$item} ne '') {
603: $designs{$item} = $settings->{$item};
604: $is_custom{$item} = 1;
605: }
606: }
607: if ($settings->{'font'} ne '') {
608: $designs{'font'} = $settings->{'font'};
609: $is_custom{'font'} = 1;
610: }
611: foreach my $item (@bgs) {
612: if ($settings->{$item} ne '') {
613: $designs{'bgs'}{$item} = $settings->{$item};
614: $is_custom{$item} = 1;
615: }
616: }
617: foreach my $item (@links) {
618: if ($settings->{$item} ne '') {
619: $designs{'links'}{$item} = $settings->{$item};
620: $is_custom{$item} = 1;
621: }
622: }
623: } else {
624: if ($designhash{$dom.'.login.font'} ne '') {
625: $designs{'font'} = $designhash{$dom.'.login.font'};
626: $is_custom{'font'} = 1;
627: }
1.8 raeburn 628: foreach my $item (@images) {
629: if ($designhash{$dom.'.login.'.$item} ne '') {
630: $designs{$item} = $designhash{$dom.'.login.'.$item};
631: $is_custom{$item} = 1;
632: }
633: }
1.6 raeburn 634: foreach my $item (@bgs) {
635: if ($designhash{$dom.'.login.'.$item} ne '') {
636: $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item};
637: $is_custom{$item} = 1;
638: }
639: }
640: foreach my $item (@links) {
641: if ($designhash{$dom.'.login.'.$item} ne '') {
642: $designs{'links'}{$item} = $designhash{$dom.'.login.'.$item};
643: $is_custom{$item} = 1;
644: }
645: }
1.1 raeburn 646: }
1.6 raeburn 647: my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
648: logo => 'Institution Logo',
649: domlogo => 'Domain Logo');
650: my $itemcount = 1;
651: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.3 raeburn 652: my $datatable =
1.6 raeburn 653: '<tr'.$css_class.'><td colspan="2">'.$choices{'coursecatalog'}.
654: '</td><td>'.
1.8 raeburn 655: '<span class="LC_nobreak"><label><input type="radio" name="coursecatalog"'.
656: $catalogon.' value="1" />'.&mt('Yes').'</label> '.
657: '<label><input type="radio" name="coursecatalog"'.
658: $catalogoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.6 raeburn 659: '</tr>';
660: $itemcount ++;
661: $css_class = $itemcount%2?' class="LC_odd_row"':'';
662: $datatable .= '<tr'.$css_class.'>'.
663: '<td colspan="2">'.$choices{'adminmail'}.'</td>'.
1.8 raeburn 664: '<td><span class="LC_nobreak">'.
665: '<label><input type="radio" name="adminmail"'.
666: $adminmailon.' value="1" />'.&mt('Yes').'</label> '.
667: '<label><input type="radio" name="adminmail"'.
668: $adminmailoff.'value="0" />'.&mt('No').'</label></span></td></tr>';
1.6 raeburn 669: $itemcount ++;
1.30 raeburn 670: $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal);
1.6 raeburn 671: $datatable .= '</tr></table></td></tr>';
672: return $datatable;
673: }
674:
675: sub login_choices {
676: my %choices =
677: &Apache::lonlocal::texthash (
678: coursecatalog => 'Display Course Catalog link?',
679: adminmail => "Display Administrator's E-mail Address?",
680: img => "Header",
681: logo => "Main Logo",
682: domlogo => "Domain Logo",
683: bgs => "Background colors",
684: links => "Link colors",
685: font => "Font color",
686: pgbg => "Page",
687: mainbg => "Main panel",
688: sidebg => "Side panel",
689: link => "Link",
690: alink => "Active link",
691: vlink => "Visited link",
692: );
693: return %choices;
694: }
695:
696: sub print_rolecolors {
1.30 raeburn 697: my ($phase,$role,$dom,$confname,$settings,$rowtotal) = @_;
1.6 raeburn 698: my %choices = &color_font_choices();
699: my @bgs = ('pgbg','tabbg','sidebg');
700: my @links = ('link','alink','vlink');
701: my @images = ('img');
702: my %alt_text = &Apache::lonlocal::texthash(img => "Banner for $role role");
1.7 albertel 703: my %designhash = &Apache::loncommon::get_domainconf($dom);
1.6 raeburn 704: my %defaultdesign = %Apache::loncommon::defaultdesign;
705: my (%is_custom,%designs);
706: my %defaults = (
707: img => $defaultdesign{$role.'.img'},
708: font => $defaultdesign{$role.'.font'},
709: );
710: foreach my $item (@bgs) {
711: $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
712: }
713: foreach my $item (@links) {
714: $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
715: }
716: if (ref($settings) eq 'HASH') {
717: if (ref($settings->{$role}) eq 'HASH') {
718: if ($settings->{$role}->{'img'} ne '') {
719: $designs{'img'} = $settings->{$role}->{'img'};
720: $is_custom{'img'} = 1;
721: }
722: if ($settings->{$role}->{'font'} ne '') {
723: $designs{'font'} = $settings->{$role}->{'font'};
724: $is_custom{'font'} = 1;
725: }
726: foreach my $item (@bgs) {
727: if ($settings->{$role}->{$item} ne '') {
728: $designs{'bgs'}{$item} = $settings->{$role}->{$item};
729: $is_custom{$item} = 1;
730: }
731: }
732: foreach my $item (@links) {
733: if ($settings->{$role}->{$item} ne '') {
734: $designs{'links'}{$item} = $settings->{$role}->{$item};
735: $is_custom{$item} = 1;
736: }
737: }
738: }
739: } else {
740: if ($designhash{$dom.'.'.$role.'.img'} ne '') {
741: $designs{img} = $designhash{$dom.'.'.$role.'.img'};
742: $is_custom{'img'} = 1;
743: }
744: if ($designhash{$dom.'.'.$role.'.font'} ne '') {
745: $designs{font} = $designhash{$dom.'.'.$role.'.font'};
746: $is_custom{'font'} = 1;
747: }
748: foreach my $item (@bgs) {
749: if ($designhash{$dom.'.'.$role.'.'.$item} ne '') {
750: $designs{'bgs'}{$item} = $designhash{$dom.'.'.$role.'.'.$item};
751: $is_custom{$item} = 1;
752:
753: }
754: }
755: foreach my $item (@links) {
756: if ($designhash{$dom.'.'.$role.'.'.$item} ne '') {
757: $designs{'links'}{$item} = $designhash{$dom.'.'.$role.'.'.$item};
758: $is_custom{$item} = 1;
759: }
760: }
761: }
762: my $itemcount = 1;
1.30 raeburn 763: my $datatable = &display_color_options($dom,$confname,$phase,$role,$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal);
1.6 raeburn 764: $datatable .= '</tr></table></td></tr>';
765: return $datatable;
766: }
767:
768: sub display_color_options {
1.9 raeburn 769: my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
1.30 raeburn 770: $images,$bgs,$links,$alt_text,$rowtotal) = @_;
1.6 raeburn 771: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
772: my $datatable = '<tr'.$css_class.'>'.
773: '<td>'.$choices->{'font'}.'</td>';
774: if (!$is_custom->{'font'}) {
1.30 raeburn 775: $datatable .= '<td>'.&mt('Default in use:').' <span id="css_default_'.$role.'_font" style="color: '.$defaults->{'font'}.';">'.$defaults->{'font'}.'</span></td>';
1.6 raeburn 776: } else {
777: $datatable .= '<td> </td>';
778: }
779: my $fontlink = &color_pick($phase,$role,'font',$choices->{'font'},$designs->{'font'});
1.8 raeburn 780: $datatable .= '<td><span class="LC_nobreak">'.
1.6 raeburn 781: '<input type="text" size="10" name="'.$role.'_font"'.
1.8 raeburn 782: ' value="'.$designs->{'font'}.'" /> '.$fontlink.
1.30 raeburn 783: ' <span id="css_'.$role.'_font" style="background-color: '.
784: $designs->{'font'}.';"> </span>'.
1.8 raeburn 785: '</span></td></tr>';
1.9 raeburn 786: my $switchserver = &check_switchserver($dom,$confname);
1.6 raeburn 787: foreach my $img (@{$images}) {
1.18 albertel 788: $itemcount ++;
1.6 raeburn 789: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.8 raeburn 790: $datatable .= '<tr'.$css_class.'>'.
1.6 raeburn 791: '<td>'.$choices->{$img}.'</td>';
1.18 albertel 792: my ($imgfile, $img_import);
1.6 raeburn 793: if ($designs->{$img} ne '') {
794: $imgfile = $designs->{$img};
1.18 albertel 795: $img_import = ($imgfile =~ m{^/adm/});
1.6 raeburn 796: } else {
797: $imgfile = $defaults->{$img};
798: }
799: if ($imgfile) {
1.9 raeburn 800: my ($showfile,$fullsize);
801: if ($imgfile =~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
1.6 raeburn 802: my $urldir = $1;
803: my $filename = $2;
804: my @info = &Apache::lonnet::stat_file($designs->{$img});
805: if (@info) {
806: my $thumbfile = 'tn-'.$filename;
807: my @thumb=&Apache::lonnet::stat_file($urldir.'/'.$thumbfile);
808: if (@thumb) {
809: $showfile = $urldir.'/'.$thumbfile;
810: } else {
811: $showfile = $imgfile;
812: }
813: } else {
814: $showfile = '';
815: }
816: } elsif ($imgfile =~ m-^/(adm/[^/]+)/([^/]+)$-) {
1.16 raeburn 817: $showfile = $imgfile;
1.6 raeburn 818: my $imgdir = $1;
819: my $filename = $2;
820: if (-e "/home/httpd/html/$imgdir/tn-".$filename) {
821: $showfile = "/$imgdir/tn-".$filename;
822: } else {
823: my $input = "/home/httpd/html".$imgfile;
824: my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename;
825: if (!-e $output) {
1.9 raeburn 826: my ($width,$height) = &thumb_dimensions();
1.16 raeburn 827: my ($fullwidth,$fullheight) = &check_dimensions($input);
828: if ($fullwidth ne '' && $fullheight ne '') {
829: if ($fullwidth > $width && $fullheight > $height) {
830: my $size = $width.'x'.$height;
831: system("convert -sample $size $input $output");
832: $showfile = '/'.$imgdir.'/tn-'.$filename;
833: }
834: }
1.6 raeburn 835: }
836: }
1.16 raeburn 837: }
1.6 raeburn 838: if ($showfile) {
1.9 raeburn 839: $showfile = &Apache::loncommon::lonhttpdurl($showfile);
840: $fullsize = &Apache::loncommon::lonhttpdurl($imgfile);
1.6 raeburn 841: $datatable.= '<td>';
842: if (!$is_custom->{$img}) {
843: $datatable .= &mt('Default in use:').'<br />';
844: }
1.18 albertel 845: if ($img_import) {
846: $datatable.= '<input type="hidden" name="'.$role.'_import_'.$img.'" value="'.$imgfile.'" />';
847: }
1.9 raeburn 848: $datatable.= '<a href="'.$fullsize.'" target="_blank"><img src="'.
849: $showfile.'" alt="'.$alt_text->{$img}.
850: '" border="0" /></a></td>';
1.6 raeburn 851: if ($is_custom->{$img}) {
1.8 raeburn 852: $datatable.='<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
853: $role.'_del_'.$img.'" value="1" />'.&mt('Delete?').
854: '</label> '.&mt('Replace:').'</span><br />';
1.6 raeburn 855: } else {
856: $datatable.='<td valign="bottom">'.&mt('Upload:').'<br />';
857: }
858: } else {
859: $datatable .= '<td colspan="2" class="LC_right_item"><br />'.
860: &mt('Upload:');
861: }
862: } else {
863: $datatable .= '<td colspan="2" class="LC_right_item"><br />'.
864: &mt('Upload:');
865: }
1.9 raeburn 866: if ($switchserver) {
867: $datatable .= &mt('Upload to library server: [_1]',$switchserver);
868: } else {
869: $datatable .=' <input type="file" name="'.$role.'_'.$img.'" />';
870: }
871: $datatable .= '</td></tr>';
1.6 raeburn 872: }
873: $itemcount ++;
874: $css_class = $itemcount%2?' class="LC_odd_row"':'';
875: $datatable .= '<tr'.$css_class.'>'.
876: '<td>'.$choices->{'bgs'}.'</td>';
877: my $bgs_def;
878: foreach my $item (@{$bgs}) {
879: if (!$is_custom->{$item}) {
1.30 raeburn 880: $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 881: }
882: }
883: if ($bgs_def) {
1.8 raeburn 884: $datatable .= '<td>'.&mt('Default(s) in use:').'<br /><table border="0"><tr>'.$bgs_def.'</tr></table></td>';
1.6 raeburn 885: } else {
886: $datatable .= '<td> </td>';
887: }
888: $datatable .= '<td class="LC_right_item">'.
889: '<table border="0"><tr>';
890: foreach my $item (@{$bgs}) {
891: my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'bgs'}{$item});
892: $datatable .= '<td align="center">'.$link;
893: if ($designs->{'bgs'}{$item}) {
1.30 raeburn 894: $datatable .= ' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'bgs'}{$item}.';"> </span>';
1.6 raeburn 895: }
896: $datatable .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.$designs->{'bgs'}{$item}.
1.30 raeburn 897: '" onblur = "javascript:document.display.css_'.$role.'_'.$item.'.style.background-color = document.display.'.$role.'_'.$item.'.value;"/></td>';
1.6 raeburn 898: }
899: $datatable .= '</tr></table></td></tr>';
900: $itemcount ++;
901: $css_class = $itemcount%2?' class="LC_odd_row"':'';
902: $datatable .= '<tr'.$css_class.'>'.
903: '<td>'.$choices->{'links'}.'</td>';
904: my $links_def;
905: foreach my $item (@{$links}) {
906: if (!$is_custom->{$item}) {
1.30 raeburn 907: $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 908: }
909: }
910: if ($links_def) {
1.8 raeburn 911: $datatable .= '<td>'.&mt('Default(s) in use:').'<br /><table border="0"><tr>'.$links_def.'</tr></table></td>';
1.6 raeburn 912: } else {
913: $datatable .= '<td> </td>';
914: }
915: $datatable .= '<td class="LC_right_item">'.
916: '<table border="0"><tr>';
917: foreach my $item (@{$links}) {
1.30 raeburn 918: $datatable .= '<td align="center">'."\n".
919: &color_pick($phase,$role,$item,$choices->{$item},
920: $designs->{'links'}{$item});
1.6 raeburn 921: if ($designs->{'links'}{$item}) {
1.30 raeburn 922: $datatable.=' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'links'}{$item}.';"> </span>';
1.6 raeburn 923: }
924: $datatable .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.$designs->{'links'}{$item}.
925: '" /></td>';
926: }
1.30 raeburn 927: $$rowtotal += $itemcount;
1.3 raeburn 928: return $datatable;
929: }
930:
1.6 raeburn 931: sub color_pick {
932: my ($phase,$role,$item,$desc,$curcol) = @_;
933: my $link = '<a href="javascript:pjump('."'color_custom','".$desc.
934: "','".$curcol."','".$role.'_'.$item."','parmform.pres','psub'".
935: ');">'.$desc.'</a>';
936: return $link;
937: }
938:
939: sub color_pick_js {
940: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
941: my $output = <<"ENDCOL";
942: function pclose() {
943: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms","height=350,width=350,scrollbars=no,menubar=no");
944: parmwin.close();
945: }
946:
947: $pjump_def
948:
949: function psub() {
950: pclose();
951: if (document.parmform.pres_marker.value!='') {
952: if (document.parmform.pres_type.value!='') {
953: eval('document.display.'+
954: document.parmform.pres_marker.value+
955: '.value=document.parmform.pres_value.value;');
956: }
957: } else {
958: document.parmform.pres_value.value='';
959: document.parmform.pres_marker.value='';
960: }
961: }
962: ENDCOL
963: return $output;
964: }
965:
1.3 raeburn 966: sub print_quotas {
1.30 raeburn 967: my ($dom,$settings,$rowtotal) = @_;
1.3 raeburn 968: my $datatable;
1.23 raeburn 969: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.3 raeburn 970: my $typecount = 0;
971: my $css_class;
1.26 raeburn 972: if (ref($types) eq 'ARRAY') {
1.23 raeburn 973: foreach my $type (@{$types}) {
1.3 raeburn 974: if (defined($usertypes->{$type})) {
975: $typecount ++;
976: $css_class = $typecount%2?' class="LC_odd_row"':'';
977: $datatable .= '<tr'.$css_class.'>'.
978: '<td>'.$usertypes->{$type}.'</td>'.
1.8 raeburn 979: '<td class="LC_right_item"><span class="LC_nobreak">'.
1.3 raeburn 980: '<input type="text" name="quota_'.$type.
981: '" value="'.$settings->{$type}.
1.8 raeburn 982: '" size="5" /> Mb</span></td></tr>';
1.3 raeburn 983: }
984: }
985: }
986: my $defaultquota = '20';
987: if (ref($settings) eq 'HASH') {
988: if (defined($settings->{'default'})) {
989: $defaultquota = $settings->{'default'};
990: }
991: }
992: $typecount ++;
993: $css_class = $typecount%2?' class="LC_odd_row"':'';
994: $datatable .= '<tr'.$css_class.'>'.
1.26 raeburn 995: '<td>'.$othertitle.'</td>'.
1.8 raeburn 996: '<td class="LC_right_item"><span class="LC_nobreak">'.
1.15 raeburn 997: '<input type="text" name="defaultquota" value="'.
1.8 raeburn 998: $defaultquota.'" size="5" /> Mb</span></td></tr>';
1.30 raeburn 999: $$rowtotal += $typecount;
1.3 raeburn 1000: return $datatable;
1001: }
1002:
1003: sub print_autoenroll {
1.30 raeburn 1004: my ($dom,$settings,$rowtotal) = @_;
1.3 raeburn 1005: my $autorun = &Apache::lonnet::auto_run(undef,$dom),
1.17 raeburn 1006: my ($defdom,$runon,$runoff);
1.3 raeburn 1007: if (ref($settings) eq 'HASH') {
1008: if (exists($settings->{'run'})) {
1009: if ($settings->{'run'} eq '0') {
1010: $runoff = ' checked="checked" ';
1011: $runon = ' ';
1012: } else {
1013: $runon = ' checked="checked" ';
1014: $runoff = ' ';
1015: }
1016: } else {
1017: if ($autorun) {
1018: $runon = ' checked="checked" ';
1019: $runoff = ' ';
1020: } else {
1021: $runoff = ' checked="checked" ';
1022: $runon = ' ';
1023: }
1024: }
1025: if (exists($settings->{'sender_domain'})) {
1026: $defdom = $settings->{'sender_domain'};
1027: }
1.14 raeburn 1028: } else {
1029: if ($autorun) {
1030: $runon = ' checked="checked" ';
1031: $runoff = ' ';
1032: } else {
1033: $runoff = ' checked="checked" ';
1034: $runon = ' ';
1035: }
1.3 raeburn 1036: }
1037: my $domform = &Apache::loncommon::select_dom_form($defdom,'sender_domain',1);
1038: my $datatable='<tr class="LC_odd_row">'.
1039: '<td>'.&mt('Auto-enrollment active?').'</td>'.
1.8 raeburn 1040: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1.3 raeburn 1041: '<input type="radio" name="autoenroll_run"'.
1.8 raeburn 1042: $runon.' value="1" />'.&mt('Yes').'</label> '.
1043: '<label><input type="radio" name="autoenroll_run"'.
1.14 raeburn 1044: $runoff.' value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1045: '</tr><tr>'.
1046: '<td>'.&mt('Notification messages - sender').
1.8 raeburn 1047: '</td><td class="LC_right_item"><span class="LC_nobreak">'.
1.3 raeburn 1048: &mt('username').': '.
1049: '<input type="text" name="sender_uname" value="'.
1050: $settings->{'sender_uname'}.
1051: '" size="10" /> '.&mt('domain').
1.8 raeburn 1052: ': '.$domform.'</span></td></tr>';
1.30 raeburn 1053: $$rowtotal += 2;
1.3 raeburn 1054: return $datatable;
1055: }
1056:
1057: sub print_autoupdate {
1.30 raeburn 1058: my ($position,$dom,$settings,$rowtotal) = @_;
1.3 raeburn 1059: my $datatable;
1060: if ($position eq 'top') {
1061: my $updateon = ' ';
1062: my $updateoff = ' checked="checked" ';
1063: my $classlistson = ' ';
1064: my $classlistsoff = ' checked="checked" ';
1065: if (ref($settings) eq 'HASH') {
1066: if ($settings->{'run'} eq '1') {
1067: $updateon = $updateoff;
1068: $updateoff = ' ';
1069: }
1070: if ($settings->{'classlists'} eq '1') {
1071: $classlistson = $classlistsoff;
1072: $classlistsoff = ' ';
1073: }
1074: }
1075: my %title = (
1076: run => 'Auto-update active?',
1077: classlists => 'Update information in classlists?',
1078: );
1079: $datatable = '<tr class="LC_odd_row">'.
1080: '<td>'.&mt($title{'run'}).'</td>'.
1.8 raeburn 1081: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1.3 raeburn 1082: '<input type="radio" name="autoupdate_run"'.
1.8 raeburn 1083: $updateon.' value="1" />'.&mt('Yes').'</label> '.
1084: '<label><input type="radio" name="autoupdate_run"'.
1085: $updateoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1086: '</tr><tr>'.
1087: '<td>'.&mt($title{'classlists'}).'</td>'.
1.8 raeburn 1088: '<td class="LC_right_item"><span class="LC_nobreak">'.
1089: '<label><input type="radio" name="classlists"'.
1090: $classlistson.' value="1" />'.&mt('Yes').'</label> '.
1091: '<label><input type="radio" name="classlists"'.
1092: $classlistsoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1093: '</tr>';
1.30 raeburn 1094: $$rowtotal += 2;
1.3 raeburn 1095: } else {
1.23 raeburn 1096: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.20 raeburn 1097: my @fields = ('lastname','firstname','middlename','gen',
1098: 'permanentemail','id');
1.33 raeburn 1099: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
1.3 raeburn 1100: my $numrows = 0;
1.26 raeburn 1101: if (ref($types) eq 'ARRAY') {
1102: if (@{$types} > 0) {
1103: $datatable =
1104: &usertype_update_row($settings,$usertypes,\%fieldtitles,
1105: \@fields,$types,\$numrows);
1.30 raeburn 1106: $$rowtotal += @{$types};
1.26 raeburn 1107: }
1.3 raeburn 1108: }
1109: $datatable .=
1110: &usertype_update_row($settings,{'default' => $othertitle},
1111: \%fieldtitles,\@fields,['default'],
1112: \$numrows);
1.30 raeburn 1113: $$rowtotal ++;
1.3 raeburn 1114: }
1115: return $datatable;
1116: }
1117:
1.23 raeburn 1118: sub print_directorysrch {
1.30 raeburn 1119: my ($dom,$settings,$rowtotal) = @_;
1.23 raeburn 1120: my $srchon = ' ';
1121: my $srchoff = ' checked="checked" ';
1.25 raeburn 1122: my ($exacton,$containson,$beginson);
1.24 raeburn 1123: my $localon = ' ';
1124: my $localoff = ' checked="checked" ';
1.23 raeburn 1125: if (ref($settings) eq 'HASH') {
1126: if ($settings->{'available'} eq '1') {
1127: $srchon = $srchoff;
1128: $srchoff = ' ';
1129: }
1.24 raeburn 1130: if ($settings->{'localonly'} eq '1') {
1131: $localon = $localoff;
1132: $localoff = ' ';
1133: }
1.25 raeburn 1134: if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
1135: foreach my $type (@{$settings->{'searchtypes'}}) {
1136: if ($type eq 'exact') {
1137: $exacton = ' checked="checked" ';
1138: } elsif ($type eq 'contains') {
1139: $containson = ' checked="checked" ';
1140: } elsif ($type eq 'begins') {
1141: $beginson = ' checked="checked" ';
1142: }
1143: }
1144: } else {
1145: if ($settings->{'searchtypes'} eq 'exact') {
1146: $exacton = ' checked="checked" ';
1147: } elsif ($settings->{'searchtypes'} eq 'contains') {
1148: $containson = ' checked="checked" ';
1149: } elsif ($settings->{'searchtypes'} eq 'specify') {
1150: $exacton = ' checked="checked" ';
1151: $containson = ' checked="checked" ';
1152: }
1.23 raeburn 1153: }
1154: }
1155: my ($searchtitles,$titleorder) = &sorted_searchtitles();
1156: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1157:
1158: my $numinrow = 4;
1.26 raeburn 1159: my $cansrchrow = 0;
1.23 raeburn 1160: my $datatable='<tr class="LC_odd_row">'.
1.30 raeburn 1161: '<td colspan="2"><span class ="LC_nobreak">'.&mt('Directory search available?').'</span></td>'.
1.23 raeburn 1162: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1163: '<input type="radio" name="dirsrch_available"'.
1164: $srchon.' value="1" />'.&mt('Yes').'</label> '.
1165: '<label><input type="radio" name="dirsrch_available"'.
1166: $srchoff.' value="0" />'.&mt('No').'</label></span></td>'.
1167: '</tr><tr>'.
1.30 raeburn 1168: '<td colspan="2"><span class ="LC_nobreak">'.&mt('Other domains can search?').'</span></td>'.
1.24 raeburn 1169: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1170: '<input type="radio" name="dirsrch_localonly"'.
1171: $localoff.' value="0" />'.&mt('Yes').'</label> '.
1172: '<label><input type="radio" name="dirsrch_localonly"'.
1173: $localon.' value="1" />'.&mt('No').'</label></span></td>'.
1.25 raeburn 1174: '</tr>';
1.30 raeburn 1175: $$rowtotal += 2;
1.26 raeburn 1176: if (ref($usertypes) eq 'HASH') {
1177: if (keys(%{$usertypes}) > 0) {
1178: $datatable .= &users_cansearch_row($settings,$types,$usertypes,$dom,
1179: $numinrow,$othertitle);
1180: $cansrchrow = 1;
1181: }
1182: }
1183: if ($cansrchrow) {
1.30 raeburn 1184: $$rowtotal ++;
1.26 raeburn 1185: $datatable .= '<tr>';
1186: } else {
1187: $datatable .= '<tr class="LC_odd_row">';
1188: }
1.30 raeburn 1189: $datatable .= '<td><span class ="LC_nobreak">'.&mt('Supported search methods').
1190: '</span></td><td class="LC_left_item" colspan="2"><table><tr>';
1.25 raeburn 1191: foreach my $title (@{$titleorder}) {
1192: if (defined($searchtitles->{$title})) {
1193: my $check = ' ';
1194: if (ref($settings->{'searchby'}) eq 'ARRAY') {
1195: if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
1196: $check = ' checked="checked" ';
1197: }
1198: }
1199: $datatable .= '<td class="LC_left_item">'.
1200: '<span class="LC_nobreak"><label>'.
1201: '<input type="checkbox" name="searchby" '.
1202: 'value="'.$title.'"'.$check.'/>'.
1203: $searchtitles->{$title}.'</label></span></td>';
1204: }
1205: }
1.26 raeburn 1206: $datatable .= '</tr></table></td></tr>';
1.30 raeburn 1207: $$rowtotal ++;
1.26 raeburn 1208: if ($cansrchrow) {
1209: $datatable .= '<tr class="LC_odd_row">';
1210: } else {
1211: $datatable .= '<tr>';
1212: }
1.30 raeburn 1213: $datatable .= '<td><span class ="LC_nobreak">'.&mt('Search latitude').'</span></td>'.
1.26 raeburn 1214: '<td class="LC_left_item" colspan="2">'.
1.25 raeburn 1215: '<span class="LC_nobreak"><label>'.
1216: '<input type="checkbox" name="searchtypes" '.
1217: $exacton.' value="exact" />'.&mt('Exact match').
1218: '</label> '.
1219: '<label><input type="checkbox" name="searchtypes" '.
1220: $beginson.' value="begins" />'.&mt('Begins with').
1221: '</label> '.
1222: '<label><input type="checkbox" name="searchtypes" '.
1223: $containson.' value="contains" />'.&mt('Contains').
1224: '</label></span></td></tr>';
1.30 raeburn 1225: $$rowtotal ++;
1.25 raeburn 1226: return $datatable;
1227: }
1228:
1.28 raeburn 1229: sub print_contacts {
1.30 raeburn 1230: my ($dom,$settings,$rowtotal) = @_;
1.28 raeburn 1231: my $datatable;
1232: my @contacts = ('adminemail','supportemail');
1233: my (%checked,%to,%otheremails);
1234: my @mailings = ('errormail','packagesmail','helpdeskmail');
1235: foreach my $type (@mailings) {
1236: $otheremails{$type} = '';
1237: }
1238: if (ref($settings) eq 'HASH') {
1239: foreach my $item (@contacts) {
1240: if (exists($settings->{$item})) {
1241: $to{$item} = $settings->{$item};
1242: }
1243: }
1244: foreach my $type (@mailings) {
1245: if (exists($settings->{$type})) {
1246: if (ref($settings->{$type}) eq 'HASH') {
1247: foreach my $item (@contacts) {
1248: if ($settings->{$type}{$item}) {
1249: $checked{$type}{$item} = ' checked="checked" ';
1250: }
1251: }
1252: $otheremails{$type} = $settings->{$type}{'others'};
1253: }
1254: }
1255: }
1256: } else {
1257: $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
1258: $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
1259: $checked{'errormail'}{'adminemail'} = ' checked="checked" ';
1260: $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
1261: $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
1262: }
1263: my ($titles,$short_titles) = &contact_titles();
1264: my $rownum = 0;
1265: my $css_class;
1266: foreach my $item (@contacts) {
1267: if ($rownum%2) {
1268: $css_class = '';
1269: } else {
1270: $css_class = ' class="LC_odd_row" ';
1271: }
1.30 raeburn 1272: $datatable .= '<tr'.$css_class.'>'.
1273: '<td><span class="LC_nobreak">'.$titles->{$item}.
1274: '</span></td><td class="LC_right_item">'.
1.28 raeburn 1275: '<input type="text" name="'.$item.'" value="'.
1276: $to{$item}.'" /></td></tr>';
1277: $rownum ++;
1278: }
1279: foreach my $type (@mailings) {
1280: if ($rownum%2) {
1281: $css_class = '';
1282: } else {
1283: $css_class = ' class="LC_odd_row" ';
1284: }
1285: $datatable .= '<tr'.$css_class.'>'.
1.30 raeburn 1286: '<td><span class="LC_nobreak">'.
1287: $titles->{$type}.': </span></td>'.
1.28 raeburn 1288: '<td class="LC_left_item">'.
1289: '<span class="LC_nobreak">';
1290: foreach my $item (@contacts) {
1291: $datatable .= '<label>'.
1292: '<input type="checkbox" name="'.$type.'"'.
1293: $checked{$type}{$item}.
1294: ' value="'.$item.'" />'.$short_titles->{$item}.
1295: '</label> ';
1296: }
1297: $datatable .= '</span><br />'.&mt('Others').': '.
1298: '<input type="text" name="'.$type.'_others" '.
1299: 'value="'.$otheremails{$type}.'" />'.
1300: '</td></tr>'."\n";
1301: $rownum ++;
1302: }
1.30 raeburn 1303: $$rowtotal += $rownum;
1.28 raeburn 1304: return $datatable;
1305: }
1306:
1307: sub contact_titles {
1308: my %titles = &Apache::lonlocal::texthash (
1309: 'supportemail' => 'Support E-mail address',
1310: 'adminemail' => 'Default Server Admin E-mail address',
1311: 'errormail' => 'Error reports to be e-mailed to',
1312: 'packagesmail' => 'Package update alerts to be e-mailed to',
1313: 'helpdeskmail' => 'Helpdesk requests to be e-mailed to'
1314: );
1315: my %short_titles = &Apache::lonlocal::texthash (
1316: adminemail => 'Admin E-mail address',
1317: supportemail => 'Support E-mail',
1318: );
1319: return (\%titles,\%short_titles);
1320: }
1321:
1.27 raeburn 1322: sub print_usercreation {
1.30 raeburn 1323: my ($position,$dom,$settings,$rowtotal) = @_;
1.27 raeburn 1324: my $numinrow = 4;
1.28 raeburn 1325: my $datatable;
1326: if ($position eq 'top') {
1.30 raeburn 1327: $$rowtotal ++;
1.34 raeburn 1328: my $rowcount = 0;
1.32 raeburn 1329: my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username');
1.28 raeburn 1330: if (ref($rules) eq 'HASH') {
1331: if (keys(%{$rules}) > 0) {
1.32 raeburn 1332: $datatable .= &user_formats_row('username',$settings,$rules,
1333: $ruleorder,$numinrow,$rowcount);
1.30 raeburn 1334: $$rowtotal ++;
1.32 raeburn 1335: $rowcount ++;
1336: }
1337: }
1338: my ($idrules,$idruleorder) = &Apache::lonnet::inst_userrules($dom,'id');
1339: if (ref($idrules) eq 'HASH') {
1340: if (keys(%{$idrules}) > 0) {
1341: $datatable .= &user_formats_row('id',$settings,$idrules,
1342: $idruleorder,$numinrow,$rowcount);
1343: $$rowtotal ++;
1344: $rowcount ++;
1.28 raeburn 1345: }
1346: }
1.34 raeburn 1347: } elsif ($position eq 'middle') {
1348: my @creators = ('author','course');
1.37 raeburn 1349: my ($rules,$ruleorder) =
1350: &Apache::lonnet::inst_userrules($dom,'username');
1.34 raeburn 1351: my %lt = &usercreation_types();
1352: my %checked;
1353: if (ref($settings) eq 'HASH') {
1354: if (ref($settings->{'cancreate'}) eq 'HASH') {
1355: foreach my $item (@creators) {
1356: $checked{$item} = $settings->{'cancreate'}{$item};
1357: }
1358: } elsif (ref($settings->{'cancreate'}) eq 'ARRAY') {
1359: foreach my $item (@creators) {
1360: if (grep(/^\Q$item\E$/,@{$settings->{'cancreate'}})) {
1361: $checked{$item} = 'none';
1362: }
1363: }
1364: }
1365: }
1366: my $rownum = 0;
1367: foreach my $item (@creators) {
1368: $rownum ++;
1369: if ($checked{$item} eq '') {
1370: $checked{$item} = 'any';
1371: }
1372: my $css_class;
1373: if ($rownum%2) {
1374: $css_class = '';
1375: } else {
1376: $css_class = ' class="LC_odd_row" ';
1377: }
1378: $datatable .= '<tr'.$css_class.'>'.
1379: '<td><span class="LC_nobreak">'.$lt{$item}.
1380: '</span></td><td align="right">';
1.37 raeburn 1381: my @options = ('any');
1382: if (ref($rules) eq 'HASH') {
1383: if (keys(%{$rules}) > 0) {
1384: push(@options,('official','unofficial'));
1385: }
1386: }
1387: push(@options,'none');
1388: foreach my $option (@options) {
1.34 raeburn 1389: my $check = ' ';
1390: if ($checked{$item} eq $option) {
1391: $check = ' checked="checked" ';
1392: }
1393: $datatable .= '<span class="LC_nobreak"><label>'.
1394: '<input type="radio" name="can_createuser_'.
1395: $item.'" value="'.$option.'"'.$check.'/> '.
1396: $lt{$option}.'</label> </span>';
1397: }
1398: $datatable .= '</td></tr>';
1399: }
1.28 raeburn 1400: } else {
1401: my @contexts = ('author','course','domain');
1402: my @authtypes = ('int','krb4','krb5','loc');
1403: my %checked;
1404: if (ref($settings) eq 'HASH') {
1405: if (ref($settings->{'authtypes'}) eq 'HASH') {
1406: foreach my $item (@contexts) {
1407: if (ref($settings->{'authtypes'}{$item}) eq 'HASH') {
1408: foreach my $auth (@authtypes) {
1409: if ($settings->{'authtypes'}{$item}{$auth}) {
1410: $checked{$item}{$auth} = ' checked="checked" ';
1411: }
1412: }
1413: }
1414: }
1.27 raeburn 1415: }
1.35 raeburn 1416: } else {
1417: foreach my $item (@contexts) {
1.36 raeburn 1418: foreach my $auth (@authtypes) {
1.35 raeburn 1419: $checked{$item}{$auth} = ' checked="checked" ';
1420: }
1421: }
1.27 raeburn 1422: }
1.28 raeburn 1423: my %title = &context_names();
1424: my %authname = &authtype_names();
1425: my $rownum = 0;
1426: my $css_class;
1427: foreach my $item (@contexts) {
1428: if ($rownum%2) {
1429: $css_class = '';
1430: } else {
1431: $css_class = ' class="LC_odd_row" ';
1432: }
1.30 raeburn 1433: $datatable .= '<tr'.$css_class.'>'.
1.28 raeburn 1434: '<td>'.$title{$item}.
1435: '</td><td class="LC_left_item">'.
1436: '<span class="LC_nobreak">';
1437: foreach my $auth (@authtypes) {
1438: $datatable .= '<label>'.
1439: '<input type="checkbox" name="'.$item.'_auth" '.
1440: $checked{$item}{$auth}.' value="'.$auth.'" />'.
1441: $authname{$auth}.'</label> ';
1442: }
1443: $datatable .= '</span></td></tr>';
1444: $rownum ++;
1.27 raeburn 1445: }
1.30 raeburn 1446: $$rowtotal += $rownum;
1.27 raeburn 1447: }
1448: return $datatable;
1449: }
1450:
1.32 raeburn 1451: sub user_formats_row {
1452: my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_;
1453: my $output;
1454: my %text = (
1455: 'username' => 'new usernames',
1456: 'id' => 'IDs',
1457: );
1458: my $css_class = $rowcount%2?' class="LC_odd_row"':'';
1459: $output = '<tr '.$css_class.'>'.
1460: '<td><span class="LC_nobreak">'.
1461: &mt("Format rules to check for $text{$type}: ").
1462: '</span></td>'.
1463: '<td class="LC_left_item" colspan="2"><table>';
1.27 raeburn 1464: my $rem;
1465: if (ref($ruleorder) eq 'ARRAY') {
1466: for (my $i=0; $i<@{$ruleorder}; $i++) {
1467: if (ref($rules->{$ruleorder->[$i]}) eq 'HASH') {
1468: my $rem = $i%($numinrow);
1469: if ($rem == 0) {
1470: if ($i > 0) {
1471: $output .= '</tr>';
1472: }
1473: $output .= '<tr>';
1474: }
1475: my $check = ' ';
1.32 raeburn 1476: if (ref($settings->{$type.'_rule'}) eq 'ARRAY') {
1477: if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) {
1.27 raeburn 1478: $check = ' checked="checked" ';
1479: }
1480: }
1481: $output .= '<td class="LC_left_item">'.
1482: '<span class="LC_nobreak"><label>'.
1.32 raeburn 1483: '<input type="checkbox" name="'.$type.'_rule" '.
1.27 raeburn 1484: 'value="'.$ruleorder->[$i].'"'.$check.'/>'.
1485: $rules->{$ruleorder->[$i]}{'name'}.'</label></span></td>';
1486: }
1487: }
1488: $rem = @{$ruleorder}%($numinrow);
1489: }
1490: my $colsleft = $numinrow - $rem;
1491: if ($colsleft > 1 ) {
1492: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
1493: ' </td>';
1494: } elsif ($colsleft == 1) {
1495: $output .= '<td class="LC_left_item"> </td>';
1496: }
1497: $output .= '</tr></table></td></tr>';
1498: return $output;
1499: }
1500:
1.34 raeburn 1501: sub usercreation_types {
1502: my %lt = &Apache::lonlocal::texthash (
1503: author => 'When adding a co-author',
1504: course => 'When adding a user to a course',
1505: any => 'Any',
1506: official => 'Institutional only ',
1507: unofficial => 'Non-institutional only',
1508: none => 'None',
1509: );
1510: return %lt;
1511: }
1512:
1.28 raeburn 1513: sub authtype_names {
1514: my %lt = &Apache::lonlocal::texthash(
1515: int => 'Internal',
1516: krb4 => 'Kerberos 4',
1517: krb5 => 'Kerberos 5',
1518: loc => 'Local',
1519: );
1520: return %lt;
1521: }
1522:
1523: sub context_names {
1524: my %context_title = &Apache::lonlocal::texthash(
1525: author => 'Creating users when an Author',
1526: course => 'Creating users when in a course',
1527: domain => 'Creating users when a Domain Coordinator',
1528: );
1529: return %context_title;
1530: }
1531:
1.33 raeburn 1532: sub print_usermodification {
1533: my ($position,$dom,$settings,$rowtotal) = @_;
1534: my $numinrow = 4;
1535: my ($context,$datatable,$rowcount);
1536: if ($position eq 'top') {
1537: $rowcount = 0;
1538: $context = 'author';
1539: foreach my $role ('ca','aa') {
1540: $datatable .= &modifiable_userdata_row($context,$role,$settings,
1541: $numinrow,$rowcount);
1542: $$rowtotal ++;
1543: $rowcount ++;
1544: }
1545: } else {
1546: $context = 'course';
1547: $rowcount = 0;
1548: foreach my $role ('st','ep','ta','in','cr') {
1549: $datatable .= &modifiable_userdata_row($context,$role,$settings,
1550: $numinrow,$rowcount);
1551: $$rowtotal ++;
1552: $rowcount ++;
1553: }
1554: }
1555: return $datatable;
1556: }
1557:
1558: sub modifiable_userdata_row {
1559: my ($context,$role,$settings,$numinrow,$rowcount) = @_;
1560: my $rolename;
1561: if ($role eq 'cr') {
1562: $rolename = &mt('Custom role');
1563: } else {
1564: $rolename = &Apache::lonnet::plaintext($role);
1565: }
1566: my @fields = ('lastname','firstname','middlename','generation',
1567: 'permanentemail','id');
1568: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
1569: my $output;
1570: my $css_class = $rowcount%2?' class="LC_odd_row"':'';
1571: $output = '<tr '.$css_class.'>'.
1572: '<td><span class="LC_nobreak">'.$rolename.'</span></td>'.
1573: '<td class="LC_left_item" colspan="2"><table>';
1574: my $rem;
1575: my %checks;
1576: if (ref($settings) eq 'HASH') {
1577: if (ref($settings->{$context}) eq 'HASH') {
1578: if (ref($settings->{$context}->{$role}) eq 'HASH') {
1579: foreach my $field (@fields) {
1580: if ($settings->{$context}->{$role}->{$field}) {
1581: $checks{$field} = ' checked="checked" ';
1582: }
1583: }
1584: }
1585: }
1586: }
1587: for (my $i=0; $i<@fields; $i++) {
1588: my $rem = $i%($numinrow);
1589: if ($rem == 0) {
1590: if ($i > 0) {
1591: $output .= '</tr>';
1592: }
1593: $output .= '<tr>';
1594: }
1595: my $check = ' ';
1596: if (exists($checks{$fields[$i]})) {
1597: $check = $checks{$fields[$i]}
1598: } else {
1599: if ($role eq 'st') {
1600: if (ref($settings) ne 'HASH') {
1601: $check = ' checked="checked" ';
1602: }
1603: }
1604: }
1605: $output .= '<td class="LC_left_item">'.
1606: '<span class="LC_nobreak"><label>'.
1607: '<input type="checkbox" name="canmodify_'.$role.'" '.
1608: 'value="'.$fields[$i].'"'.$check.'/>'.$fieldtitles{$fields[$i]}.
1609: '</label></span></td>';
1610: $rem = @fields%($numinrow);
1611: }
1612: my $colsleft = $numinrow - $rem;
1613: if ($colsleft > 1 ) {
1614: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
1615: ' </td>';
1616: } elsif ($colsleft == 1) {
1617: $output .= '<td class="LC_left_item"> </td>';
1618: }
1619: $output .= '</tr></table></td></tr>';
1620: return $output;
1621: }
1.28 raeburn 1622:
1.25 raeburn 1623: sub users_cansearch_row {
1624: my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle) = @_;
1625: my $output = '<tr class="LC_odd_row">'.
1.24 raeburn 1626: '<td>'.&mt('Users allowed to search').' ('.$dom.')'.
1627: '</td><td class="LC_left_item" colspan="2"><table>';
1.26 raeburn 1628: my $rem;
1629: if (ref($types) eq 'ARRAY') {
1630: for (my $i=0; $i<@{$types}; $i++) {
1631: if (defined($usertypes->{$types->[$i]})) {
1632: my $rem = $i%($numinrow);
1633: if ($rem == 0) {
1634: if ($i > 0) {
1635: $output .= '</tr>';
1636: }
1637: $output .= '<tr>';
1.23 raeburn 1638: }
1.26 raeburn 1639: my $check = ' ';
1640: if (ref($settings->{'cansearch'}) eq 'ARRAY') {
1641: if (grep(/^\Q$types->[$i]\E$/,@{$settings->{'cansearch'}})) {
1642: $check = ' checked="checked" ';
1643: }
1.23 raeburn 1644: }
1.26 raeburn 1645: $output .= '<td class="LC_left_item">'.
1646: '<span class="LC_nobreak"><label>'.
1647: '<input type="checkbox" name="cansearch" '.
1648: 'value="'.$types->[$i].'"'.$check.'/>'.
1649: $usertypes->{$types->[$i]}.'</label></span></td>';
1.23 raeburn 1650: }
1651: }
1.26 raeburn 1652:
1653: $rem = @{$types}%($numinrow);
1.23 raeburn 1654: }
1655: my $colsleft = $numinrow - $rem;
1656: if ($colsleft > 1) {
1.25 raeburn 1657: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">';
1.23 raeburn 1658: } else {
1.25 raeburn 1659: $output .= '<td class="LC_left_item">';
1.23 raeburn 1660: }
1661: my $defcheck = ' ';
1662: if (ref($settings->{'cansearch'}) eq 'ARRAY') {
1.26 raeburn 1663: if (grep(/^default$/,@{$settings->{'cansearch'}})) {
1664: $defcheck = ' checked="checked" ';
1665: }
1.23 raeburn 1666: }
1.25 raeburn 1667: $output .= '<span class="LC_nobreak"><label>'.
1668: '<input type="checkbox" name="cansearch" '.
1669: 'value="default"'.$defcheck.'/>'.
1670: $othertitle.'</label></span></td>'.
1671: '</tr></table></td></tr>';
1672: return $output;
1.23 raeburn 1673: }
1674:
1675: sub sorted_inst_types {
1676: my ($dom) = @_;
1677: my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
1.26 raeburn 1678: my $othertitle = &mt('All users');
1.23 raeburn 1679: my @types;
1680: if (ref($order) eq 'ARRAY') {
1681: @types = @{$order};
1682: }
1683: if (@types == 0) {
1684: if (ref($usertypes) eq 'HASH') {
1685: @types = sort(keys(%{$usertypes}));
1686: }
1687: }
1688: if (keys(%{$usertypes}) > 0) {
1689: $othertitle = &mt('Other users');
1690: }
1691: return ($othertitle,$usertypes,\@types);
1692: }
1693:
1694: sub sorted_searchtitles {
1695: my %searchtitles = &Apache::lonlocal::texthash(
1696: 'uname' => 'username',
1697: 'lastname' => 'last name',
1698: 'lastfirst' => 'last name, first name',
1699: );
1700: my @titleorder = ('uname','lastname','lastfirst');
1701: return (\%searchtitles,\@titleorder);
1702: }
1703:
1.25 raeburn 1704: sub sorted_searchtypes {
1705: my %srchtypes_desc = (
1706: exact => 'is exact match',
1707: contains => 'contains ..',
1708: begins => 'begins with ..',
1709: );
1710: my @srchtypeorder = ('exact','begins','contains');
1711: return (\%srchtypes_desc,\@srchtypeorder);
1712: }
1713:
1.3 raeburn 1714: sub usertype_update_row {
1715: my ($settings,$usertypes,$fieldtitles,$fields,$types,$rownums) = @_;
1716: my $datatable;
1717: my $numinrow = 4;
1718: foreach my $type (@{$types}) {
1719: if (defined($usertypes->{$type})) {
1720: $$rownums ++;
1721: my $css_class = $$rownums%2?' class="LC_odd_row"':'';
1722: $datatable .= '<tr'.$css_class.'><td>'.$usertypes->{$type}.
1723: '</td><td class="LC_left_item"><table>';
1724: for (my $i=0; $i<@{$fields}; $i++) {
1725: my $rem = $i%($numinrow);
1726: if ($rem == 0) {
1727: if ($i > 0) {
1728: $datatable .= '</tr>';
1729: }
1730: $datatable .= '<tr>';
1731: }
1732: my $check = ' ';
1733: if (ref($settings->{'fields'}) eq 'HASH') {
1734: if (ref($settings->{'fields'}{$type}) eq 'ARRAY') {
1735: if (grep(/^\Q$fields->[$i]\E$/,@{$settings->{'fields'}{$type}})) {
1736: $check = ' checked="checked" ';
1737: }
1738: }
1739: }
1740:
1741: if ($i == @{$fields}-1) {
1742: my $colsleft = $numinrow - $rem;
1743: if ($colsleft > 1) {
1744: $datatable .= '<td colspan="'.$colsleft.'">';
1745: } else {
1746: $datatable .= '<td>';
1747: }
1748: } else {
1749: $datatable .= '<td>';
1750: }
1.8 raeburn 1751: $datatable .= '<span class="LC_nobreak"><label>'.
1752: '<input type="checkbox" name="updateable_'.$type.
1753: '_'.$fields->[$i].'" value="1"'.$check.'/>'.
1754: $fieldtitles->{$fields->[$i]}.'</label></span></td>';
1.3 raeburn 1755: }
1756: $datatable .= '</tr></table></td></tr>';
1757: }
1758: }
1759: return $datatable;
1.1 raeburn 1760: }
1761:
1762: sub modify_login {
1.9 raeburn 1763: my ($r,$dom,$confname,%domconfig) = @_;
1.6 raeburn 1764: my ($resulttext,$errors,$colchgtext,%changes,%colchanges);
1.1 raeburn 1765: my %title = ( coursecatalog => 'Display course catalog',
1766: adminmail => 'Display administrator E-mail address');
1.3 raeburn 1767: my @offon = ('off','on');
1.6 raeburn 1768: my %loginhash;
1.9 raeburn 1769: ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
1770: \%domconfig,\%loginhash);
1.6 raeburn 1771: $loginhash{login}{coursecatalog} = $env{'form.coursecatalog'};
1772: $loginhash{login}{adminmail} = $env{'form.adminmail'};
1773: if (ref($colchanges{'login'}) eq 'HASH') {
1774: $colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
1775: \%loginhash);
1776: }
1.1 raeburn 1777: my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
1778: $dom);
1779: if ($putresult eq 'ok') {
1.3 raeburn 1780: if (($domconfig{'login'}{'coursecatalog'} eq '0') &&
1.1 raeburn 1781: ($env{'form.coursecatalog'} eq '1')) {
1782: $changes{'coursecatalog'} = 1;
1.3 raeburn 1783: } elsif (($domconfig{'login'}{'coursecatalog'} eq '' ||
1784: $domconfig{'login'}{'coursecatalog'} eq '1') &&
1.1 raeburn 1785: ($env{'form.coursecatalog'} eq '0')) {
1786: $changes{'coursecatalog'} = 1;
1787: }
1.3 raeburn 1788: if (($domconfig{'login'}{'adminmail'} eq '1') &&
1.1 raeburn 1789: ($env{'form.adminmail'} eq '0')) {
1790: $changes{'adminmail'} = 1;
1791: } elsif (($domconfig{'login'}{'adminmail'} eq '' ||
1792: $domconfig{'login'}{'adminmail'} eq '0') &&
1793: ($env{'form.adminmail'} eq '1')) {
1794: $changes{'adminmail'} = 1;
1795: }
1.6 raeburn 1796: if (keys(%changes) > 0 || $colchgtext) {
1.1 raeburn 1797: $resulttext = &mt('Changes made:').'<ul>';
1798: foreach my $item (sort(keys(%changes))) {
1799: $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
1800: }
1.6 raeburn 1801: $resulttext .= $colchgtext.'</ul>';
1.1 raeburn 1802: } else {
1803: $resulttext = &mt('No changes made to log-in page settings');
1804: }
1805: } else {
1.11 albertel 1806: $resulttext = '<span class="LC_error">'.
1807: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 1808: }
1.6 raeburn 1809: if ($errors) {
1.9 raeburn 1810: $resulttext .= '<br />'.&mt('The following errors occurred: ').'<ul>'.
1.6 raeburn 1811: $errors.'</ul>';
1812: }
1813: return $resulttext;
1814: }
1815:
1816: sub color_font_choices {
1817: my %choices =
1818: &Apache::lonlocal::texthash (
1819: img => "Header",
1820: bgs => "Background colors",
1821: links => "Link colors",
1822: font => "Font color",
1823: pgbg => "Page",
1824: tabbg => "Header",
1825: sidebg => "Border",
1826: link => "Link",
1827: alink => "Active link",
1828: vlink => "Visited link",
1829: );
1830: return %choices;
1831: }
1832:
1833: sub modify_rolecolors {
1.9 raeburn 1834: my ($r,$dom,$confname,$roles,%domconfig) = @_;
1.6 raeburn 1835: my ($resulttext,%rolehash);
1836: $rolehash{'rolecolors'} = {};
1.9 raeburn 1837: my ($errors,%changes) = &modify_colors($r,$dom,$confname,$roles,
1.6 raeburn 1838: $domconfig{'rolecolors'},$rolehash{'rolecolors'});
1839: my $putresult = &Apache::lonnet::put_dom('configuration',\%rolehash,
1840: $dom);
1841: if ($putresult eq 'ok') {
1842: if (keys(%changes) > 0) {
1843: $resulttext = &display_colorchgs($dom,\%changes,$roles,
1844: $rolehash{'rolecolors'});
1845: } else {
1846: $resulttext = &mt('No changes made to default color schemes');
1847: }
1848: } else {
1.11 albertel 1849: $resulttext = '<span class="LC_error">'.
1850: &mt('An error occurred: [_1]',$putresult).'</span>';
1.6 raeburn 1851: }
1852: if ($errors) {
1853: $resulttext .= &mt('The following errors occurred: ').'<ul>'.
1854: $errors.'</ul>';
1855: }
1856: return $resulttext;
1857: }
1858:
1859: sub modify_colors {
1.9 raeburn 1860: my ($r,$dom,$confname,$roles,$domconfig,$confhash) = @_;
1.12 raeburn 1861: my (%changes,%choices);
1.6 raeburn 1862: my @bgs = ('pgbg','mainbg','sidebg');
1863: my @links = ('link','alink','vlink');
1864: my @images;
1865: my $servadm = $r->dir_config('lonAdmEMail');
1866: my $errors;
1867: foreach my $role (@{$roles}) {
1868: if ($role eq 'login') {
1.12 raeburn 1869: %choices = &login_choices();
1870: } else {
1871: %choices = &color_font_choices();
1872: }
1873: if ($role eq 'login') {
1.6 raeburn 1874: @images = ('img','logo','domlogo');
1875: } else {
1876: @images = ('img');
1877: }
1878: $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
1879: foreach my $item (@bgs,@links) {
1880: $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
1881: }
1.9 raeburn 1882: my ($configuserok,$author_ok,$switchserver,%currroles);
1883: my $uhome = &Apache::lonnet::homeserver($confname,$dom,1);
1884: ($configuserok,%currroles) = &check_configuser($uhome,$dom,
1885: $confname,$servadm);
1886: if ($configuserok eq 'ok') {
1887: $switchserver = &check_switchserver($dom,$confname);
1888: if ($switchserver eq '') {
1889: $author_ok = &check_authorstatus($dom,$confname,%currroles);
1890: }
1891: }
1892: my ($width,$height) = &thumb_dimensions();
1.8 raeburn 1893: foreach my $img (@images) {
1.18 albertel 1894: if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
1895: && !defined($domconfig->{$role}{$img})
1896: && !$env{'form.'.$role.'_del_'.$img}
1897: && $env{'form.'.$role.'_import_'.$img}) {
1898: # import the old configured image from the .tab setting
1899: # if they haven't provided a new one
1900: $domconfig->{$role}{$img} =
1901: $env{'form.'.$role.'_import_'.$img};
1902: }
1.6 raeburn 1903: if ($env{'form.'.$role.'_'.$img.'.filename'} ne '') {
1.9 raeburn 1904: my $error;
1.6 raeburn 1905: if ($configuserok eq 'ok') {
1.9 raeburn 1906: if ($switchserver) {
1.12 raeburn 1907: $error = &mt("Upload of [_1] image for $role page(s) is not permitted to this server: [_2]",$choices{$img},$switchserver);
1.9 raeburn 1908: } else {
1909: if ($author_ok eq 'ok') {
1910: my ($result,$logourl) =
1911: &publishlogo($r,'upload',$role.'_'.$img,
1912: $dom,$confname,$img,$width,$height);
1913: if ($result eq 'ok') {
1914: $confhash->{$role}{$img} = $logourl;
1.12 raeburn 1915: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 1916: } else {
1.12 raeburn 1917: $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 1918: }
1919: } else {
1.12 raeburn 1920: $error = &mt("Upload of [_1] image for $role page(s) failed because an author role could not be assigned to a Domain Configuation user ([_2]) in domain: [_3]. Error was: [_4].",$choices{$img},$confname,$dom,$author_ok);
1.6 raeburn 1921: }
1922: }
1923: } else {
1.12 raeburn 1924: $error = &mt("Upload of [_1] image for $role page(s) failed because a Domain Configuation user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$choices{$img},$confname,$dom,$configuserok);
1.9 raeburn 1925: }
1926: if ($error) {
1.8 raeburn 1927: &Apache::lonnet::logthis($error);
1.11 albertel 1928: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
1.8 raeburn 1929: }
1930: } elsif ($domconfig->{$role}{$img} ne '') {
1.9 raeburn 1931: if ($domconfig->{$role}{$img} !~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
1932: my $error;
1933: if ($configuserok eq 'ok') {
1934: # is confname an author?
1935: if ($switchserver eq '') {
1936: if ($author_ok eq 'ok') {
1937: my ($result,$logourl) =
1938: &publishlogo($r,'copy',$domconfig->{$role}{$img},
1939: $dom,$confname,$img,$width,$height);
1940: if ($result eq 'ok') {
1941: $confhash->{$role}{$img} = $logourl;
1.18 albertel 1942: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 1943: }
1944: }
1945: }
1946: }
1.6 raeburn 1947: }
1948: }
1949: }
1950: if (ref($domconfig) eq 'HASH') {
1951: if (ref($domconfig->{$role}) eq 'HASH') {
1952: foreach my $img (@images) {
1953: if ($domconfig->{$role}{$img} ne '') {
1954: if ($env{'form.'.$role.'_del_'.$img}) {
1955: $confhash->{$role}{$img} = '';
1.12 raeburn 1956: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 1957: } else {
1.9 raeburn 1958: if ($confhash->{$role}{$img} eq '') {
1959: $confhash->{$role}{$img} = $domconfig->{$role}{$img};
1960: }
1.6 raeburn 1961: }
1962: } else {
1963: if ($env{'form.'.$role.'_del_'.$img}) {
1964: $confhash->{$role}{$img} = '';
1.12 raeburn 1965: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 1966: }
1967: }
1968: }
1969: if ($domconfig->{$role}{'font'} ne '') {
1970: if ($confhash->{$role}{'font'} ne $domconfig->{$role}{'font'}) {
1971: $changes{$role}{'font'} = 1;
1972: }
1973: } else {
1974: if ($confhash->{$role}{'font'}) {
1975: $changes{$role}{'font'} = 1;
1976: }
1977: }
1978: foreach my $item (@bgs) {
1979: if ($domconfig->{$role}{$item} ne '') {
1980: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
1981: $changes{$role}{'bgs'}{$item} = 1;
1982: }
1983: } else {
1984: if ($confhash->{$role}{$item}) {
1985: $changes{$role}{'bgs'}{$item} = 1;
1986: }
1987: }
1988: }
1989: foreach my $item (@links) {
1990: if ($domconfig->{$role}{$item} ne '') {
1991: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
1992: $changes{$role}{'links'}{$item} = 1;
1993: }
1994: } else {
1995: if ($confhash->{$role}{$item}) {
1996: $changes{$role}{'links'}{$item} = 1;
1997: }
1998: }
1999: }
2000: } else {
2001: &default_change_checker($role,\@images,\@links,\@bgs,
2002: $confhash,\%changes);
2003: }
2004: } else {
2005: &default_change_checker($role,\@images,\@links,\@bgs,
2006: $confhash,\%changes);
2007: }
2008: }
2009: return ($errors,%changes);
2010: }
2011:
2012: sub default_change_checker {
2013: my ($role,$images,$links,$bgs,$confhash,$changes) = @_;
2014: foreach my $item (@{$links}) {
2015: if ($confhash->{$role}{$item}) {
2016: $changes->{$role}{'links'}{$item} = 1;
2017: }
2018: }
2019: foreach my $item (@{$bgs}) {
2020: if ($confhash->{$role}{$item}) {
2021: $changes->{$role}{'bgs'}{$item} = 1;
2022: }
2023: }
2024: foreach my $img (@{$images}) {
2025: if ($env{'form.'.$role.'_del_'.$img}) {
2026: $confhash->{$role}{$img} = '';
1.12 raeburn 2027: $changes->{$role}{'images'}{$img} = 1;
1.6 raeburn 2028: }
2029: }
2030: if ($confhash->{$role}{'font'}) {
2031: $changes->{$role}{'font'} = 1;
2032: }
2033: }
2034:
2035: sub display_colorchgs {
2036: my ($dom,$changes,$roles,$confhash) = @_;
2037: my (%choices,$resulttext);
1.7 albertel 2038: &Apache::loncommon::devalidate_domconfig_cache($dom);
1.6 raeburn 2039: if (!grep(/^login$/,@{$roles})) {
2040: $resulttext = &mt('Changes made:').'<br />';
2041: }
2042: foreach my $role (@{$roles}) {
2043: if ($role eq 'login') {
2044: %choices = &login_choices();
2045: } else {
2046: %choices = &color_font_choices();
2047: }
2048: if (ref($changes->{$role}) eq 'HASH') {
2049: if ($role ne 'login') {
2050: $resulttext .= '<h4>'.&mt($role).'</h4>';
2051: }
2052: foreach my $key (sort(keys(%{$changes->{$role}}))) {
2053: if ($role ne 'login') {
2054: $resulttext .= '<ul>';
2055: }
2056: if (ref($changes->{$role}{$key}) eq 'HASH') {
2057: if ($role ne 'login') {
2058: $resulttext .= '<li>'.&mt($choices{$key}).':<ul>';
2059: }
2060: foreach my $item (sort(keys(%{$changes->{$role}{$key}}))) {
2061: if ($confhash->{$role}{$item} eq '') {
2062: $resulttext .= '<li>'.&mt("$choices{$item} set to default").'</li>';
2063: } else {
1.12 raeburn 2064: my $newitem = $confhash->{$role}{$item};
2065: if ($key eq 'images') {
2066: $newitem = '<img src="'.$confhash->{$role}{$item}.'" alt="'.$choices{$item}.'" valign="bottom" />';
2067: }
2068: $resulttext .= '<li>'.&mt("$choices{$item} set to [_1]",$newitem).'</li>';
1.6 raeburn 2069: }
2070: }
2071: if ($role ne 'login') {
2072: $resulttext .= '</ul></li>';
2073: }
2074: } else {
2075: if ($confhash->{$role}{$key} eq '') {
2076: $resulttext .= '<li>'.&mt("$choices{$key} set to default").'</li>';
2077: } else {
2078: $resulttext .= '<li>'.&mt("$choices{$key} set to [_1]",$confhash->{$role}{$key}).'</li>';
2079: }
2080: }
2081: if ($role ne 'login') {
2082: $resulttext .= '</ul>';
2083: }
2084: }
2085: }
2086: }
1.3 raeburn 2087: return $resulttext;
1.1 raeburn 2088: }
2089:
1.9 raeburn 2090: sub thumb_dimensions {
2091: return ('200','50');
2092: }
2093:
1.16 raeburn 2094: sub check_dimensions {
2095: my ($inputfile) = @_;
2096: my ($fullwidth,$fullheight);
2097: if ($inputfile =~ m|^[/\w.\-]+$|) {
2098: if (open(PIPE,"identify $inputfile 2>&1 |")) {
2099: my $imageinfo = <PIPE>;
2100: if (!close(PIPE)) {
2101: &Apache::lonnet::logthis("Failed to close PIPE opened to retrieve image information for $inputfile");
2102: }
2103: chomp($imageinfo);
2104: my ($fullsize) =
1.21 raeburn 2105: ($imageinfo =~ /^\Q$inputfile\E\s+\w+\s+(\d+x\d+)/);
1.16 raeburn 2106: if ($fullsize) {
2107: ($fullwidth,$fullheight) = split(/x/,$fullsize);
2108: }
2109: }
2110: }
2111: return ($fullwidth,$fullheight);
2112: }
2113:
1.9 raeburn 2114: sub check_configuser {
2115: my ($uhome,$dom,$confname,$servadm) = @_;
2116: my ($configuserok,%currroles);
2117: if ($uhome eq 'no_host') {
2118: srand( time() ^ ($$ + ($$ << 15)) ); # Seed rand.
2119: my $configpass = &LONCAPA::Enrollment::create_password();
2120: $configuserok =
2121: &Apache::lonnet::modifyuser($dom,$confname,'','internal',
2122: $configpass,'','','','','',undef,$servadm);
2123: } else {
2124: $configuserok = 'ok';
2125: %currroles =
2126: &Apache::lonnet::get_my_roles($confname,$dom,'userroles');
2127: }
2128: return ($configuserok,%currroles);
2129: }
2130:
2131: sub check_authorstatus {
2132: my ($dom,$confname,%currroles) = @_;
2133: my $author_ok;
1.37 raeburn 2134: if (!$currroles{$confname.':'.$dom.':au'}) {
1.9 raeburn 2135: my $start = time;
2136: my $end = 0;
2137: $author_ok =
2138: &Apache::lonnet::assignrole($dom,$confname,'/'.$dom.'/',
2139: 'au',$end,$start);
2140: } else {
2141: $author_ok = 'ok';
2142: }
2143: return $author_ok;
2144: }
2145:
2146: sub publishlogo {
2147: my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight) = @_;
2148: my ($output,$fname,$logourl);
2149: if ($action eq 'upload') {
2150: $fname=$env{'form.'.$formname.'.filename'};
2151: chop($env{'form.'.$formname});
2152: } else {
2153: ($fname) = ($formname =~ /([^\/]+)$/);
2154: }
2155: $fname=&Apache::lonnet::clean_filename($fname);
2156: # See if there is anything left
2157: unless ($fname) { return ('error: no uploaded file'); }
2158: $fname="$subdir/$fname";
2159: my $filepath='/home/'.$confname.'/public_html';
2160: my ($fnamepath,$file,$fetchthumb);
2161: $file=$fname;
2162: if ($fname=~m|/|) {
2163: ($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
2164: }
2165: my @parts=split(/\//,$filepath.'/'.$fnamepath);
2166: my $count;
2167: for ($count=4;$count<=$#parts;$count++) {
2168: $filepath.="/$parts[$count]";
2169: if ((-e $filepath)!=1) {
2170: mkdir($filepath,02770);
2171: }
2172: }
2173: # Check for bad extension and disallow upload
2174: if ($file=~/\.(\w+)$/ &&
2175: (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
2176: $output =
2177: &mt('Invalid file extension ([_1]) - reserved for LONCAPA use.',$1);
2178: } elsif ($file=~/\.(\w+)$/ &&
2179: !defined(&Apache::loncommon::fileembstyle($1))) {
2180: $output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1);
2181: } elsif ($file=~/\.(\d+)\.(\w+)$/) {
2182: $output = &mt('File name not allowed a rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
2183: } elsif (-d "$filepath/$file") {
2184: $output = &mt('File name is a directory name - rename the file and re-upload');
2185: } else {
2186: my $source = $filepath.'/'.$file;
2187: my $logfile;
2188: if (!open($logfile,">>$source".'.log')) {
2189: return (&mt('No write permission to Construction Space'));
2190: }
2191: print $logfile
2192: "\n================= Publish ".localtime()." ================\n".
2193: $env{'user.name'}.':'.$env{'user.domain'}."\n";
2194: # Save the file
2195: if (!open(FH,'>'.$source)) {
2196: &Apache::lonnet::logthis('Failed to create '.$source);
2197: return (&mt('Failed to create file'));
2198: }
2199: if ($action eq 'upload') {
2200: if (!print FH ($env{'form.'.$formname})) {
2201: &Apache::lonnet::logthis('Failed to write to '.$source);
2202: return (&mt('Failed to write file'));
2203: }
2204: } else {
2205: my $original = &Apache::lonnet::filelocation('',$formname);
2206: if(!copy($original,$source)) {
2207: &Apache::lonnet::logthis('Failed to copy '.$original.' to '.$source);
2208: return (&mt('Failed to write file'));
2209: }
2210: }
2211: close(FH);
2212: chmod(0660, $source); # Permissions to rw-rw---.
2213:
2214: my $docroot=$r->dir_config('lonDocRoot');
2215: my $targetdir=$docroot.'/res/'.$dom.'/'.$confname .'/'.$fnamepath;
2216: my $copyfile=$targetdir.'/'.$file;
2217:
2218: my @parts=split(/\//,$targetdir);
2219: my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]";
2220: for (my $count=5;$count<=$#parts;$count++) {
2221: $path.="/$parts[$count]";
2222: if (!-e $path) {
2223: print $logfile "\nCreating directory ".$path;
2224: mkdir($path,02770);
2225: }
2226: }
2227: my $versionresult;
2228: if (-e $copyfile) {
2229: $versionresult = &logo_versioning($targetdir,$file,$logfile);
2230: } else {
2231: $versionresult = 'ok';
2232: }
2233: if ($versionresult eq 'ok') {
2234: if (copy($source,$copyfile)) {
2235: print $logfile "\nCopied original source to ".$copyfile."\n";
2236: $output = 'ok';
2237: &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
2238: $logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;
2239: } else {
2240: print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
2241: $output = &mt('Failed to copy file to RES space').", $!";
2242: }
2243: if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) {
2244: my $inputfile = $filepath.'/'.$file;
2245: my $outfile = $filepath.'/'.'tn-'.$file;
1.16 raeburn 2246: my ($fullwidth,$fullheight) = &check_dimensions($inputfile);
2247: if ($fullwidth ne '' && $fullheight ne '') {
2248: if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) {
2249: my $thumbsize = $thumbwidth.'x'.$thumbheight;
2250: system("convert -sample $thumbsize $inputfile $outfile");
2251: chmod(0660, $filepath.'/tn-'.$file);
2252: if (-e $outfile) {
2253: my $copyfile=$targetdir.'/tn-'.$file;
2254: if (copy($outfile,$copyfile)) {
2255: print $logfile "\nCopied source to ".$copyfile."\n";
2256: &write_metadata($dom,$confname,$formname,
2257: $targetdir,'tn-'.$file,$logfile);
2258: } else {
2259: print $logfile "\nUnable to write ".$copyfile.
2260: ':'.$!."\n";
2261: }
2262: }
1.9 raeburn 2263: }
2264: }
2265: }
2266: } else {
2267: $output = $versionresult;
2268: }
2269: }
2270: return ($output,$logourl);
2271: }
2272:
2273: sub logo_versioning {
2274: my ($targetdir,$file,$logfile) = @_;
2275: my $target = $targetdir.'/'.$file;
2276: my ($maxversion,$fn,$extn,$output);
2277: $maxversion = 0;
2278: if ($file =~ /^(.+)\.(\w+)$/) {
2279: $fn=$1;
2280: $extn=$2;
2281: }
2282: opendir(DIR,$targetdir);
2283: while (my $filename=readdir(DIR)) {
2284: if ($filename=~/\Q$fn\E\.(\d+)\.\Q$extn\E$/) {
2285: $maxversion=($1>$maxversion)?$1:$maxversion;
2286: }
2287: }
2288: $maxversion++;
2289: print $logfile "\nCreating old version ".$maxversion."\n";
2290: my $copyfile=$targetdir.'/'.$fn.'.'.$maxversion.'.'.$extn;
2291: if (copy($target,$copyfile)) {
2292: print $logfile "Copied old target to ".$copyfile."\n";
2293: $copyfile=$copyfile.'.meta';
2294: if (copy($target.'.meta',$copyfile)) {
2295: print $logfile "Copied old target metadata to ".$copyfile."\n";
2296: $output = 'ok';
2297: } else {
2298: print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";
2299: $output = &mt('Failed to copy old meta').", $!, ";
2300: }
2301: } else {
2302: print $logfile "Unable to write ".$copyfile.':'.$!."\n";
2303: $output = &mt('Failed to copy old target').", $!, ";
2304: }
2305: return $output;
2306: }
2307:
2308: sub write_metadata {
2309: my ($dom,$confname,$formname,$targetdir,$file,$logfile) = @_;
2310: my (%metadatafields,%metadatakeys,$output);
2311: $metadatafields{'title'}=$formname;
2312: $metadatafields{'creationdate'}=time;
2313: $metadatafields{'lastrevisiondate'}=time;
2314: $metadatafields{'copyright'}='public';
2315: $metadatafields{'modifyinguser'}=$env{'user.name'}.':'.
2316: $env{'user.domain'};
2317: $metadatafields{'authorspace'}=$confname.':'.$dom;
2318: $metadatafields{'domain'}=$dom;
2319: {
2320: print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
2321: my $mfh;
2322: unless (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
2323: $output = &mt('Could not write metadata');
2324: }
2325: foreach (sort keys %metadatafields) {
2326: unless ($_=~/\./) {
2327: my $unikey=$_;
2328: $unikey=~/^([A-Za-z]+)/;
2329: my $tag=$1;
2330: $tag=~tr/A-Z/a-z/;
2331: print $mfh "\n\<$tag";
2332: foreach (split(/\,/,$metadatakeys{$unikey})) {
2333: my $value=$metadatafields{$unikey.'.'.$_};
2334: $value=~s/\"/\'\'/g;
2335: print $mfh ' '.$_.'="'.$value.'"';
2336: }
2337: print $mfh '>'.
2338: &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
2339: .'</'.$tag.'>';
2340: }
2341: }
2342: $output = 'ok';
2343: print $logfile "\nWrote metadata";
2344: close($mfh);
2345: }
2346: }
2347:
2348: sub check_switchserver {
2349: my ($dom,$confname) = @_;
2350: my ($allowed,$switchserver);
2351: my $home = &Apache::lonnet::homeserver($confname,$dom);
2352: if ($home eq 'no_host') {
2353: $home = &Apache::lonnet::domain($dom,'primary');
2354: }
2355: my @ids=&Apache::lonnet::current_machine_ids();
1.10 albertel 2356: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
2357: if (!$allowed) {
2358: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role=dc./'.$dom.'/">'.&mt('Switch Server').'</a>';
1.9 raeburn 2359: }
2360: return $switchserver;
2361: }
2362:
1.30 raeburn 2363: sub javascript_set_colnums {
2364: return <<END;
2365: function setDisplayColumns() {
2366: if (document.pickactions.width.value > 1100) {
2367: document.pickactions.numcols[1].checked = true;
2368: } else {
2369: document.pickactions.numcols[0].checked = true;
2370: }
2371: }
2372: END
2373: }
2374:
1.1 raeburn 2375: sub modify_quotas {
1.3 raeburn 2376: my ($dom,%domconfig) = @_;
1.1 raeburn 2377: my ($resulttext,%changes);
1.26 raeburn 2378: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.1 raeburn 2379: my %formhash;
2380: foreach my $key (keys(%env)) {
2381: if ($key =~ /^form\.quota_(.+)$/) {
2382: $formhash{$1} = $env{$key};
2383: }
2384: }
1.15 raeburn 2385: $formhash{'default'} = $env{'form.defaultquota'};
1.1 raeburn 2386: if (ref($domconfig{'quotas'}) eq 'HASH') {
2387: foreach my $key (keys(%{$domconfig{'quotas'}})) {
2388: if (exists($formhash{$key})) {
2389: if ($formhash{$key} ne $domconfig{'quotas'}{$key}) {
2390: $changes{$key} = 1;
2391: }
2392: } else {
2393: $formhash{$key} = $domconfig{'quotas'}{$key};
2394: }
2395: }
2396: }
2397: foreach my $key (keys(%formhash)) {
2398: if ($formhash{$key} ne '') {
1.3 raeburn 2399: if (!exists($domconfig{'quotas'}{$key})) {
1.1 raeburn 2400: $changes{$key} = 1;
2401: }
2402: }
2403: }
2404: my %quotahash = (
1.3 raeburn 2405: quotas => {%formhash},
1.1 raeburn 2406: );
2407: my $putresult = &Apache::lonnet::put_dom('configuration',\%quotahash,
2408: $dom);
2409: if ($putresult eq 'ok') {
2410: if (keys(%changes) > 0) {
2411: $resulttext = &mt('Changes made:').'<ul>';
1.26 raeburn 2412: foreach my $type (@{$types},'default') {
2413: if (defined($changes{$type})) {
2414: my $typetitle = $usertypes->{$type};
2415: if ($type eq 'default') {
2416: $typetitle = $othertitle;
2417: }
2418: $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$formhash{$type}).'</li>';
2419: }
1.1 raeburn 2420: }
2421: $resulttext .= '</ul>';
2422: } else {
2423: $resulttext = &mt('No changes made to default quotas');
2424: }
2425: } else {
1.11 albertel 2426: $resulttext = '<span class="LC_error">'.
2427: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 2428: }
1.3 raeburn 2429: return $resulttext;
1.1 raeburn 2430: }
2431:
1.3 raeburn 2432: sub modify_autoenroll {
2433: my ($dom,%domconfig) = @_;
1.1 raeburn 2434: my ($resulttext,%changes);
2435: my %currautoenroll;
2436: if (ref($domconfig{'autoenroll'}) eq 'HASH') {
2437: foreach my $key (keys(%{$domconfig{'autoenroll'}})) {
2438: $currautoenroll{$key} = $domconfig{'autoenroll'}{$key};
2439: }
2440: }
2441: my $autorun = &Apache::lonnet::auto_run(undef,$dom),
2442: my %title = ( run => 'Auto-enrollment active',
2443: sender => 'Sender for notification messages');
2444: my @offon = ('off','on');
1.17 raeburn 2445: my $sender_uname = $env{'form.sender_uname'};
2446: my $sender_domain = $env{'form.sender_domain'};
2447: if ($sender_domain eq '') {
2448: $sender_uname = '';
2449: } elsif ($sender_uname eq '') {
2450: $sender_domain = '';
2451: }
1.1 raeburn 2452: my %autoenrollhash = (
2453: autoenroll => { run => $env{'form.autoenroll_run'},
1.17 raeburn 2454: sender_uname => $sender_uname,
2455: sender_domain => $sender_domain,
1.1 raeburn 2456:
2457: }
2458: );
1.4 raeburn 2459: my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
2460: $dom);
1.1 raeburn 2461: if ($putresult eq 'ok') {
2462: if (exists($currautoenroll{'run'})) {
2463: if ($currautoenroll{'run'} ne $env{'form.autoenroll_run'}) {
2464: $changes{'run'} = 1;
2465: }
2466: } elsif ($autorun) {
2467: if ($env{'form.autoenroll_run'} ne '1') {
1.23 raeburn 2468: $changes{'run'} = 1;
1.1 raeburn 2469: }
2470: }
1.17 raeburn 2471: if ($currautoenroll{'sender_uname'} ne $sender_uname) {
1.1 raeburn 2472: $changes{'sender'} = 1;
2473: }
1.17 raeburn 2474: if ($currautoenroll{'sender_domain'} ne $sender_domain) {
1.1 raeburn 2475: $changes{'sender'} = 1;
2476: }
2477: if (keys(%changes) > 0) {
2478: $resulttext = &mt('Changes made:').'<ul>';
1.3 raeburn 2479: if ($changes{'run'}) {
1.1 raeburn 2480: $resulttext .= '<li>'.&mt("$title{'run'} set to $offon[$env{'form.autoenroll_run'}]").'</li>';
2481: }
2482: if ($changes{'sender'}) {
1.17 raeburn 2483: if ($sender_uname eq '' || $sender_domain eq '') {
2484: $resulttext .= '<li>'.&mt("$title{'sender'} set to default (course owner).").'</li>';
2485: } else {
2486: $resulttext .= '<li>'.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'</li>';
2487: }
1.1 raeburn 2488: }
2489: $resulttext .= '</ul>';
2490: } else {
2491: $resulttext = &mt('No changes made to auto-enrollment settings');
2492: }
2493: } else {
1.11 albertel 2494: $resulttext = '<span class="LC_error">'.
2495: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 2496: }
1.3 raeburn 2497: return $resulttext;
1.1 raeburn 2498: }
2499:
2500: sub modify_autoupdate {
1.3 raeburn 2501: my ($dom,%domconfig) = @_;
1.1 raeburn 2502: my ($resulttext,%currautoupdate,%fields,%changes);
2503: if (ref($domconfig{'autoupdate'}) eq 'HASH') {
2504: foreach my $key (keys(%{$domconfig{'autoupdate'}})) {
2505: $currautoupdate{$key} = $domconfig{'autoupdate'}{$key};
2506: }
2507: }
2508: my @offon = ('off','on');
2509: my %title = &Apache::lonlocal::texthash (
2510: run => 'Auto-update:',
2511: classlists => 'Updates to user information in classlists?'
2512: );
1.26 raeburn 2513: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.1 raeburn 2514: my %fieldtitles = &Apache::lonlocal::texthash (
2515: id => 'Student/Employee ID',
1.20 raeburn 2516: permanentemail => 'E-mail address',
1.1 raeburn 2517: lastname => 'Last Name',
2518: firstname => 'First Name',
2519: middlename => 'Middle Name',
2520: gen => 'Generation',
2521: );
2522: my $othertitle = &mt('All users');
2523: if (keys(%{$usertypes}) > 0) {
1.26 raeburn 2524: $othertitle = &mt('Other users');
1.1 raeburn 2525: }
2526: foreach my $key (keys(%env)) {
2527: if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {
2528: push(@{$fields{$1}},$2);
2529: }
2530: }
2531: my %updatehash = (
2532: autoupdate => { run => $env{'form.autoupdate_run'},
2533: classlists => $env{'form.classlists'},
2534: fields => {%fields},
2535: }
2536: );
2537: foreach my $key (keys(%currautoupdate)) {
2538: if (($key eq 'run') || ($key eq 'classlists')) {
2539: if (exists($updatehash{autoupdate}{$key})) {
2540: if ($currautoupdate{$key} ne $updatehash{autoupdate}{$key}) {
2541: $changes{$key} = 1;
2542: }
2543: }
2544: } elsif ($key eq 'fields') {
2545: if (ref($currautoupdate{$key}) eq 'HASH') {
1.26 raeburn 2546: foreach my $item (@{$types},'default') {
1.1 raeburn 2547: if (ref($currautoupdate{$key}{$item}) eq 'ARRAY') {
2548: my $change = 0;
2549: foreach my $type (@{$currautoupdate{$key}{$item}}) {
2550: if (!exists($fields{$item})) {
2551: $change = 1;
2552: } elsif (ref($fields{$item}) eq 'ARRAY') {
1.26 raeburn 2553: if (!grep(/^\Q$type\E$/,@{$fields{$item}})) {
1.1 raeburn 2554: $change = 1;
2555: }
2556: }
2557: }
2558: if ($change) {
2559: push(@{$changes{$key}},$item);
2560: }
1.26 raeburn 2561: }
1.1 raeburn 2562: }
2563: }
2564: }
2565: }
1.26 raeburn 2566: foreach my $item (@{$types},'default') {
2567: if (defined($fields{$item})) {
2568: if (ref($currautoupdate{'fields'}) eq 'HASH') {
2569: if (!exists($currautoupdate{'fields'}{$item})) {
2570: push(@{$changes{'fields'}},$item);
2571: }
2572: } else {
2573: push(@{$changes{'fields'}},$item);
1.1 raeburn 2574: }
2575: }
2576: }
2577: my $putresult = &Apache::lonnet::put_dom('configuration',\%updatehash,
2578: $dom);
2579: if ($putresult eq 'ok') {
2580: if (keys(%changes) > 0) {
2581: $resulttext = &mt('Changes made:').'<ul>';
2582: foreach my $key (sort(keys(%changes))) {
2583: if (ref($changes{$key}) eq 'ARRAY') {
2584: foreach my $item (@{$changes{$key}}) {
2585: my @newvalues;
2586: foreach my $type (@{$fields{$item}}) {
2587: push(@newvalues,$fieldtitles{$type});
2588: }
1.3 raeburn 2589: my $newvaluestr;
2590: if (@newvalues > 0) {
2591: $newvaluestr = join(', ',@newvalues);
2592: } else {
2593: $newvaluestr = &mt('none');
1.6 raeburn 2594: }
1.1 raeburn 2595: if ($item eq 'default') {
1.26 raeburn 2596: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$othertitle,$newvaluestr).'</li>';
1.1 raeburn 2597: } else {
1.26 raeburn 2598: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$usertypes->{$item},$newvaluestr).'</li>';
1.1 raeburn 2599: }
2600: }
2601: } else {
2602: my $newvalue;
2603: if ($key eq 'run') {
2604: $newvalue = $offon[$env{'form.autoupdate_run'}];
2605: } else {
2606: $newvalue = $offon[$env{'form.'.$key}];
1.3 raeburn 2607: }
1.1 raeburn 2608: $resulttext .= '<li>'.&mt("[_1] set to $newvalue",$title{$key}).'</li>';
2609: }
2610: }
2611: $resulttext .= '</ul>';
2612: } else {
1.3 raeburn 2613: $resulttext = &mt('No changes made to autoupdates');
1.1 raeburn 2614: }
2615: } else {
1.11 albertel 2616: $resulttext = '<span class="LC_error">'.
2617: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 2618: }
1.3 raeburn 2619: return $resulttext;
1.1 raeburn 2620: }
2621:
1.23 raeburn 2622: sub modify_directorysrch {
2623: my ($dom,%domconfig) = @_;
2624: my ($resulttext,%changes);
2625: my %currdirsrch;
2626: if (ref($domconfig{'directorysrch'}) eq 'HASH') {
2627: foreach my $key (keys(%{$domconfig{'directorysrch'}})) {
2628: $currdirsrch{$key} = $domconfig{'directorysrch'}{$key};
2629: }
2630: }
2631: my %title = ( available => 'Directory search available',
1.24 raeburn 2632: localonly => 'Other domains can search',
1.23 raeburn 2633: searchby => 'Search types',
2634: searchtypes => 'Search latitude');
2635: my @offon = ('off','on');
1.24 raeburn 2636: my @otherdoms = ('Yes','No');
1.23 raeburn 2637:
1.25 raeburn 2638: my @searchtypes = &Apache::loncommon::get_env_multiple('form.searchtypes');
1.23 raeburn 2639: my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch');
2640: my @searchby = &Apache::loncommon::get_env_multiple('form.searchby');
2641:
1.26 raeburn 2642: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
2643: if (keys(%{$usertypes}) == 0) {
2644: @cansearch = ('default');
2645: } else {
2646: if (ref($currdirsrch{'cansearch'}) eq 'ARRAY') {
2647: foreach my $type (@{$currdirsrch{'cansearch'}}) {
2648: if (!grep(/^\Q$type\E$/,@cansearch)) {
2649: push(@{$changes{'cansearch'}},$type);
2650: }
1.23 raeburn 2651: }
1.26 raeburn 2652: foreach my $type (@cansearch) {
2653: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'cansearch'}})) {
2654: push(@{$changes{'cansearch'}},$type);
2655: }
1.23 raeburn 2656: }
1.26 raeburn 2657: } else {
2658: push(@{$changes{'cansearch'}},@cansearch);
1.23 raeburn 2659: }
2660: }
2661:
2662: if (ref($currdirsrch{'searchby'}) eq 'ARRAY') {
2663: foreach my $by (@{$currdirsrch{'searchby'}}) {
2664: if (!grep(/^\Q$by\E$/,@searchby)) {
2665: push(@{$changes{'searchby'}},$by);
2666: }
2667: }
2668: foreach my $by (@searchby) {
2669: if (!grep(/^\Q$by\E$/,@{$currdirsrch{'searchby'}})) {
2670: push(@{$changes{'searchby'}},$by);
2671: }
2672: }
2673: } else {
2674: push(@{$changes{'searchby'}},@searchby);
2675: }
1.25 raeburn 2676:
2677: if (ref($currdirsrch{'searchtypes'}) eq 'ARRAY') {
2678: foreach my $type (@{$currdirsrch{'searchtypes'}}) {
2679: if (!grep(/^\Q$type\E$/,@searchtypes)) {
2680: push(@{$changes{'searchtypes'}},$type);
2681: }
2682: }
2683: foreach my $type (@searchtypes) {
2684: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'searchtypes'}})) {
2685: push(@{$changes{'searchtypes'}},$type);
2686: }
2687: }
2688: } else {
2689: if (exists($currdirsrch{'searchtypes'})) {
2690: foreach my $type (@searchtypes) {
2691: if ($type ne $currdirsrch{'searchtypes'}) {
2692: push(@{$changes{'searchtypes'}},$type);
2693: }
2694: }
2695: if (!grep(/^\Q$currdirsrch{'searchtypes'}\E/,@searchtypes)) {
2696: push(@{$changes{'searchtypes'}},$currdirsrch{'searchtypes'});
2697: }
2698: } else {
2699: push(@{$changes{'searchtypes'}},@searchtypes);
2700: }
2701: }
2702:
1.23 raeburn 2703: my %dirsrch_hash = (
2704: directorysrch => { available => $env{'form.dirsrch_available'},
2705: cansearch => \@cansearch,
1.24 raeburn 2706: localonly => $env{'form.dirsrch_localonly'},
1.23 raeburn 2707: searchby => \@searchby,
1.25 raeburn 2708: searchtypes => \@searchtypes,
1.23 raeburn 2709: }
2710: );
2711: my $putresult = &Apache::lonnet::put_dom('configuration',\%dirsrch_hash,
2712: $dom);
2713: if ($putresult eq 'ok') {
2714: if (exists($currdirsrch{'available'})) {
2715: if ($currdirsrch{'available'} ne $env{'form.dirsrch_available'}) {
2716: $changes{'available'} = 1;
2717: }
2718: } else {
2719: if ($env{'form.dirsrch_available'} eq '1') {
2720: $changes{'available'} = 1;
2721: }
2722: }
1.24 raeburn 2723: if (exists($currdirsrch{'localonly'})) {
2724: if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_localonly'}) {
2725: $changes{'localonly'} = 1;
2726: }
2727: } else {
2728: if ($env{'form.dirsrch_localonly'} eq '1') {
2729: $changes{'localonly'} = 1;
2730: }
2731: }
1.23 raeburn 2732: if (keys(%changes) > 0) {
2733: $resulttext = &mt('Changes made:').'<ul>';
2734: if ($changes{'available'}) {
2735: $resulttext .= '<li>'.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").'</li>';
2736: }
1.24 raeburn 2737: if ($changes{'localonly'}) {
2738: $resulttext .= '<li>'.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_localonly'}]").'</li>';
2739: }
2740:
1.23 raeburn 2741: if (ref($changes{'cansearch'}) eq 'ARRAY') {
2742: my $chgtext;
1.26 raeburn 2743: if (ref($usertypes) eq 'HASH') {
2744: if (keys(%{$usertypes}) > 0) {
2745: foreach my $type (@{$types}) {
2746: if (grep(/^\Q$type\E$/,@cansearch)) {
2747: $chgtext .= $usertypes->{$type}.'; ';
2748: }
2749: }
2750: if (grep(/^default$/,@cansearch)) {
2751: $chgtext .= $othertitle;
2752: } else {
2753: $chgtext =~ s/\; $//;
2754: }
2755: $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 2756: }
2757: }
2758: }
2759: if (ref($changes{'searchby'}) eq 'ARRAY') {
2760: my ($searchtitles,$titleorder) = &sorted_searchtitles();
2761: my $chgtext;
2762: foreach my $type (@{$titleorder}) {
2763: if (grep(/^\Q$type\E$/,@searchby)) {
2764: if (defined($searchtitles->{$type})) {
2765: $chgtext .= $searchtitles->{$type}.'; ';
2766: }
2767: }
2768: }
2769: $chgtext =~ s/\; $//;
2770: $resulttext .= '<li>'.&mt("$title{'searchby'} set to: [_1]",$chgtext).'</li>';
2771: }
1.25 raeburn 2772: if (ref($changes{'searchtypes'}) eq 'ARRAY') {
2773: my ($srchtypes_desc,$srchtypeorder) = &sorted_searchtypes();
2774: my $chgtext;
2775: foreach my $type (@{$srchtypeorder}) {
2776: if (grep(/^\Q$type\E$/,@searchtypes)) {
2777: if (defined($srchtypes_desc->{$type})) {
2778: $chgtext .= $srchtypes_desc->{$type}.'; ';
2779: }
2780: }
2781: }
2782: $chgtext =~ s/\; $//;
2783: $resulttext .= '<li>'.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).'</li>';
1.23 raeburn 2784: }
2785: $resulttext .= '</ul>';
2786: } else {
2787: $resulttext = &mt('No changes made to institution directory search settings');
2788: }
2789: } else {
2790: $resulttext = '<span class="LC_error">'.
1.27 raeburn 2791: &mt('An error occurred: [_1]',$putresult).'</span>';
2792: }
2793: return $resulttext;
2794: }
2795:
1.28 raeburn 2796: sub modify_contacts {
2797: my ($dom,%domconfig) = @_;
2798: my ($resulttext,%currsetting,%newsetting,%changes,%contacts_hash);
2799: if (ref($domconfig{'contacts'}) eq 'HASH') {
2800: foreach my $key (keys(%{$domconfig{'contacts'}})) {
2801: $currsetting{$key} = $domconfig{'contacts'}{$key};
2802: }
2803: }
2804: my (%others,%to);
2805: my @contacts = ('supportemail','adminemail');
2806: my @mailings = ('errormail','packagesmail','helpdeskmail');
2807: foreach my $type (@mailings) {
2808: @{$newsetting{$type}} =
2809: &Apache::loncommon::get_env_multiple('form.'.$type);
2810: foreach my $item (@contacts) {
2811: if (grep(/^\Q$item\E$/,@{$newsetting{$type}})) {
2812: $contacts_hash{contacts}{$type}{$item} = 1;
2813: } else {
2814: $contacts_hash{contacts}{$type}{$item} = 0;
2815: }
2816: }
2817: $others{$type} = $env{'form.'.$type.'_others'};
2818: $contacts_hash{contacts}{$type}{'others'} = $others{$type};
2819: }
2820: foreach my $item (@contacts) {
2821: $to{$item} = $env{'form.'.$item};
2822: $contacts_hash{'contacts'}{$item} = $to{$item};
2823: }
2824: if (keys(%currsetting) > 0) {
2825: foreach my $item (@contacts) {
2826: if ($to{$item} ne $currsetting{$item}) {
2827: $changes{$item} = 1;
2828: }
2829: }
2830: foreach my $type (@mailings) {
2831: foreach my $item (@contacts) {
2832: if (ref($currsetting{$type}) eq 'HASH') {
2833: if ($currsetting{$type}{$item} ne $contacts_hash{contacts}{$type}{$item}) {
2834: push(@{$changes{$type}},$item);
2835: }
2836: } else {
2837: push(@{$changes{$type}},@{$newsetting{$type}});
2838: }
2839: }
2840: if ($others{$type} ne $currsetting{$type}{'others'}) {
2841: push(@{$changes{$type}},'others');
2842: }
2843: }
2844: } else {
2845: my %default;
2846: $default{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
2847: $default{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
2848: $default{'errormail'} = 'adminemail';
2849: $default{'packagesmail'} = 'adminemail';
2850: $default{'helpdeskmail'} = 'supportemail';
2851: foreach my $item (@contacts) {
2852: if ($to{$item} ne $default{$item}) {
2853: $changes{$item} = 1;
2854: }
2855: }
2856: foreach my $type (@mailings) {
2857: if ((@{$newsetting{$type}} != 1) || ($newsetting{$type}[0] ne $default{$type})) {
2858:
2859: push(@{$changes{$type}},@{$newsetting{$type}});
2860: }
2861: if ($others{$type} ne '') {
2862: push(@{$changes{$type}},'others');
2863: }
2864: }
2865: }
2866: my $putresult = &Apache::lonnet::put_dom('configuration',\%contacts_hash,
2867: $dom);
2868: if ($putresult eq 'ok') {
2869: if (keys(%changes) > 0) {
2870: my ($titles,$short_titles) = &contact_titles();
2871: $resulttext = &mt('Changes made:').'<ul>';
2872: foreach my $item (@contacts) {
2873: if ($changes{$item}) {
2874: $resulttext .= '<li>'.$titles->{$item}.
2875: &mt(' set to: ').
2876: '<span class="LC_cusr_emph">'.
2877: $to{$item}.'</span></li>';
2878: }
2879: }
2880: foreach my $type (@mailings) {
2881: if (ref($changes{$type}) eq 'ARRAY') {
2882: $resulttext .= '<li>'.$titles->{$type}.': ';
2883: my @text;
2884: foreach my $item (@{$newsetting{$type}}) {
2885: push(@text,$short_titles->{$item});
2886: }
2887: if ($others{$type} ne '') {
2888: push(@text,$others{$type});
2889: }
2890: $resulttext .= '<span class="LC_cusr_emph">'.
2891: join(', ',@text).'</span></li>';
2892: }
2893: }
2894: $resulttext .= '</ul>';
2895: } else {
1.34 raeburn 2896: $resulttext = &mt('No changes made to contact information');
1.28 raeburn 2897: }
2898: } else {
2899: $resulttext = '<span class="LC_error">'.
2900: &mt('An error occurred: [_1].',$putresult).'</span>';
2901: }
2902: return $resulttext;
2903: }
2904:
2905: sub modify_usercreation {
1.27 raeburn 2906: my ($dom,%domconfig) = @_;
1.34 raeburn 2907: my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate);
1.27 raeburn 2908: if (ref($domconfig{'usercreation'}) eq 'HASH') {
2909: foreach my $key (keys(%{$domconfig{'usercreation'}})) {
2910: $curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
2911: }
2912: }
2913: my %title = &Apache::lonlocal::texthash (
2914: author => 'adding co-authors/assistant authors',
2915: course => 'adding users to a course',
2916: );
2917: my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
1.32 raeburn 2918: my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
1.34 raeburn 2919: my @contexts = ('author','course');
2920: foreach my $item(@contexts) {
2921: $cancreate{$item} = $env{'form.can_createuser_'.$item};
2922: }
2923: if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
2924: foreach my $item (@contexts) {
2925: if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) {
2926: push(@{$changes{'cancreate'}},$item);
2927: }
1.27 raeburn 2928: }
1.34 raeburn 2929: } elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
2930: foreach my $item (@contexts) {
2931: if (grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) {
2932: if ($cancreate{$item} ne 'any') {
2933: push(@{$changes{'cancreate'}},$item);
2934: }
2935: } else {
2936: if ($cancreate{$item} ne 'none') {
2937: push(@{$changes{'cancreate'}},$item);
2938: }
1.27 raeburn 2939: }
2940: }
2941: } else {
1.34 raeburn 2942: foreach my $item ('author','course') {
2943: push(@{$changes{'cancreate'}},$item);
2944: }
1.27 raeburn 2945: }
1.34 raeburn 2946:
1.27 raeburn 2947: if (ref($curr_usercreation{'username_rule'}) eq 'ARRAY') {
2948: foreach my $type (@{$curr_usercreation{'username_rule'}}) {
2949: if (!grep(/^\Q$type\E$/,@username_rule)) {
2950: push(@{$changes{'username_rule'}},$type);
2951: }
2952: }
2953: foreach my $type (@username_rule) {
2954: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'username_rule'}})) {
2955: push(@{$changes{'username_rule'}},$type);
2956: }
2957: }
2958: } else {
2959: push(@{$changes{'username_rule'}},@username_rule);
2960: }
2961:
1.32 raeburn 2962: if (ref($curr_usercreation{'id_rule'}) eq 'ARRAY') {
2963: foreach my $type (@{$curr_usercreation{'id_rule'}}) {
2964: if (!grep(/^\Q$type\E$/,@id_rule)) {
2965: push(@{$changes{'id_rule'}},$type);
2966: }
2967: }
2968: foreach my $type (@id_rule) {
2969: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'id_rule'}})) {
2970: push(@{$changes{'id_rule'}},$type);
2971: }
2972: }
2973: } else {
2974: push(@{$changes{'id_rule'}},@id_rule);
2975: }
2976:
1.28 raeburn 2977: my @contexts = ('author','course','domain');
2978: my @authtypes = ('int','krb4','krb5','loc');
2979: my %authhash;
2980: foreach my $item (@contexts) {
2981: my @authallowed = &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');
2982: foreach my $auth (@authtypes) {
2983: if (grep(/^\Q$auth\E$/,@authallowed)) {
2984: $authhash{$item}{$auth} = 1;
2985: } else {
2986: $authhash{$item}{$auth} = 0;
2987: }
2988: }
2989: }
2990: if (ref($curr_usercreation{'authtypes'}) eq 'HASH') {
2991: foreach my $item (@contexts) {
2992: if (ref($curr_usercreation{'authtypes'}{$item}) eq 'HASH') {
2993: foreach my $auth (@authtypes) {
2994: if ($authhash{$item}{$auth} ne $curr_usercreation{'authtypes'}{$item}{$auth}) {
2995: push(@{$changes{'authtypes'}},$item);
2996: last;
2997: }
2998: }
2999: }
3000: }
3001: } else {
3002: foreach my $item (@contexts) {
3003: push(@{$changes{'authtypes'}},$item);
3004: }
3005: }
3006:
1.27 raeburn 3007: my %usercreation_hash = (
1.28 raeburn 3008: usercreation => {
1.34 raeburn 3009: cancreate => \%cancreate,
1.27 raeburn 3010: username_rule => \@username_rule,
1.32 raeburn 3011: id_rule => \@id_rule,
3012: authtypes => \%authhash,
1.27 raeburn 3013: }
3014: );
3015:
3016: my $putresult = &Apache::lonnet::put_dom('configuration',\%usercreation_hash,
3017: $dom);
3018: if ($putresult eq 'ok') {
3019: if (keys(%changes) > 0) {
3020: $resulttext = &mt('Changes made:').'<ul>';
3021: if (ref($changes{'cancreate'}) eq 'ARRAY') {
1.34 raeburn 3022: my %lt = &usercreation_types();
3023: foreach my $type (@{$changes{'cancreate'}}) {
3024: my $chgtext;
3025: if ($cancreate{$type} eq 'none') {
3026: $chgtext = $lt{$type}.' '.&mt('creation of new users is not permitted, except by a Domain Coordinator.');
3027: } elsif ($cancreate{$type} eq 'any') {
3028: $chgtext = $lt{$type}.' '.&mt('creation of new users is permitted for both institutional and non-institutional usernames.');
3029: } elsif ($cancreate{$type} eq 'official') {
3030: $chgtext = $lt{$type}.' '.&mt('creation of new users is only permitted for institutional usernames.',$lt{$type});
3031: } elsif ($cancreate{$type} eq 'unofficial') {
3032: $chgtext = $lt{$type}.' '.&mt('creation of new users is only permitted for non-institutional usernames.',$lt{$type});
3033: }
3034: $resulttext .= '<li>'.$chgtext.'</li>';
1.27 raeburn 3035: }
3036: }
3037: if (ref($changes{'username_rule'}) eq 'ARRAY') {
1.32 raeburn 3038: my ($rules,$ruleorder) =
3039: &Apache::lonnet::inst_userrules($dom,'username');
1.27 raeburn 3040: my $chgtext = '<ul>';
3041: foreach my $type (@username_rule) {
3042: if (ref($rules->{$type}) eq 'HASH') {
3043: $chgtext .= '<li>'.$rules->{$type}{'name'}.'</li>';
3044: }
3045: }
3046: $chgtext .= '</ul>';
3047: if (@username_rule > 0) {
3048: $resulttext .= '<li>'.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
3049: } else {
1.28 raeburn 3050: $resulttext .= '<li>'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'</li>';
1.27 raeburn 3051: }
3052: }
1.32 raeburn 3053: if (ref($changes{'id_rule'}) eq 'ARRAY') {
3054: my ($idrules,$idruleorder) =
3055: &Apache::lonnet::inst_userrules($dom,'id');
3056: my $chgtext = '<ul>';
3057: foreach my $type (@id_rule) {
3058: if (ref($idrules->{$type}) eq 'HASH') {
3059: $chgtext .= '<li>'.$idrules->{$type}{'name'}.'</li>';
3060: }
3061: }
3062: $chgtext .= '</ul>';
3063: if (@id_rule > 0) {
3064: $resulttext .= '<li>'.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
3065: } else {
3066: $resulttext .= '<li>'.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'</li>';
3067: }
3068: }
1.28 raeburn 3069: my %authname = &authtype_names();
3070: my %context_title = &context_names();
3071: if (ref($changes{'authtypes'}) eq 'ARRAY') {
3072: my $chgtext = '<ul>';
3073: foreach my $type (@{$changes{'authtypes'}}) {
3074: my @allowed;
3075: $chgtext .= '<li><span class="LC_cusr_emph">'.$context_title{$type}.'</span> - '.&mt('assignable authentication types: ');
3076: foreach my $auth (@authtypes) {
3077: if ($authhash{$type}{$auth}) {
3078: push(@allowed,$authname{$auth});
3079: }
3080: }
3081: $chgtext .= join(', ',@allowed).'</li>';
3082: }
3083: $chgtext .= '</ul>';
3084: $resulttext .= '<li>'.&mt('Authentication types available for assignment to new users').'<br />'.$chgtext;
3085: $resulttext .= '</li>';
3086: }
1.27 raeburn 3087: $resulttext .= '</ul>';
3088: } else {
1.28 raeburn 3089: $resulttext = &mt('No changes made to user creation settings');
1.27 raeburn 3090: }
3091: } else {
3092: $resulttext = '<span class="LC_error">'.
1.23 raeburn 3093: &mt('An error occurred: [_1]',$putresult).'</span>';
3094: }
3095: return $resulttext;
3096: }
3097:
1.33 raeburn 3098: sub modify_usermodification {
3099: my ($dom,%domconfig) = @_;
3100: my ($resulttext,%curr_usermodification,%changes);
3101: if (ref($domconfig{'usermodification'}) eq 'HASH') {
3102: foreach my $key (keys(%{$domconfig{'usermodification'}})) {
3103: $curr_usermodification{$key} = $domconfig{'usermodification'}{$key};
3104: }
3105: }
3106: my @contexts = ('author','course');
3107: my %context_title = (
3108: author => 'In author context',
3109: course => 'In course context',
3110: );
3111: my @fields = ('lastname','firstname','middlename','generation',
3112: 'permanentemail','id');
3113: my %roles = (
3114: author => ['ca','aa'],
3115: course => ['st','ep','ta','in','cr'],
3116: );
3117: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
3118: my %modifyhash;
3119: foreach my $context (@contexts) {
3120: foreach my $role (@{$roles{$context}}) {
3121: my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role);
3122: foreach my $item (@fields) {
3123: if (grep(/^\Q$item\E$/,@modifiable)) {
3124: $modifyhash{$context}{$role}{$item} = 1;
3125: } else {
3126: $modifyhash{$context}{$role}{$item} = 0;
3127: }
3128: }
3129: }
3130: if (ref($curr_usermodification{$context}) eq 'HASH') {
3131: foreach my $role (@{$roles{$context}}) {
3132: if (ref($curr_usermodification{$context}{$role}) eq 'HASH') {
3133: foreach my $field (@fields) {
3134: if ($modifyhash{$context}{$role}{$field} ne
3135: $curr_usermodification{$context}{$role}{$field}) {
3136: push(@{$changes{$context}},$role);
3137: last;
3138: }
3139: }
3140: }
3141: }
3142: } else {
3143: foreach my $context (@contexts) {
3144: foreach my $role (@{$roles{$context}}) {
3145: push(@{$changes{$context}},$role);
3146: }
3147: }
3148: }
3149: }
3150: my %usermodification_hash = (
3151: usermodification => \%modifyhash,
3152: );
3153: my $putresult = &Apache::lonnet::put_dom('configuration',
3154: \%usermodification_hash,$dom);
3155: if ($putresult eq 'ok') {
3156: if (keys(%changes) > 0) {
3157: $resulttext = &mt('Changes made: ').'<ul>';
3158: foreach my $context (@contexts) {
3159: if (ref($changes{$context}) eq 'ARRAY') {
3160: $resulttext .= '<li>'.$context_title{$context}.':<ul>';
3161: if (ref($changes{$context}) eq 'ARRAY') {
3162: foreach my $role (@{$changes{$context}}) {
3163: my $rolename;
3164: if ($role eq 'cr') {
3165: $rolename = &mt('Custom');
3166: } else {
3167: $rolename = &Apache::lonnet::plaintext($role);
3168: }
3169: my @modifiable;
3170: $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');
3171: foreach my $field (@fields) {
3172: if ($modifyhash{$context}{$role}{$field}) {
3173: push(@modifiable,$fieldtitles{$field});
3174: }
3175: }
3176: if (@modifiable > 0) {
3177: $resulttext .= join(', ',@modifiable);
3178: } else {
3179: $resulttext .= &mt('none');
3180: }
3181: $resulttext .= '</li>';
3182: }
3183: $resulttext .= '</ul></li>';
3184: }
3185: }
3186: }
3187: $resulttext .= '</ul>';
3188: } else {
3189: $resulttext = &mt('No changes made to user modification settings');
3190: }
3191: } else {
3192: $resulttext = '<span class="LC_error">'.
3193: &mt('An error occurred: [_1]',$putresult).'</span>';
3194: }
3195: return $resulttext;
3196: }
3197:
1.3 raeburn 3198: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>