Annotation of loncom/interface/domainprefs.pm, revision 1.39
1.1 raeburn 1: # The LearningOnline Network with CAPA
2: # Handler to set domain-wide configuration settings
3: #
1.39 ! raeburn 4: # $Id: domainprefs.pm,v 1.38 2008/01/01 18:48:17 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);
1.39 ! raeburn 1038: my $notif_sender;
! 1039: if (ref($settings) eq 'HASH') {
! 1040: $notif_sender = $settings->{'sender_uname'};
! 1041: }
1.3 raeburn 1042: my $datatable='<tr class="LC_odd_row">'.
1043: '<td>'.&mt('Auto-enrollment active?').'</td>'.
1.8 raeburn 1044: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1.3 raeburn 1045: '<input type="radio" name="autoenroll_run"'.
1.8 raeburn 1046: $runon.' value="1" />'.&mt('Yes').'</label> '.
1047: '<label><input type="radio" name="autoenroll_run"'.
1.14 raeburn 1048: $runoff.' value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1049: '</tr><tr>'.
1050: '<td>'.&mt('Notification messages - sender').
1.8 raeburn 1051: '</td><td class="LC_right_item"><span class="LC_nobreak">'.
1.3 raeburn 1052: &mt('username').': '.
1053: '<input type="text" name="sender_uname" value="'.
1.39 ! raeburn 1054: $notif_sender.'" size="10" /> '.&mt('domain').
1.8 raeburn 1055: ': '.$domform.'</span></td></tr>';
1.30 raeburn 1056: $$rowtotal += 2;
1.3 raeburn 1057: return $datatable;
1058: }
1059:
1060: sub print_autoupdate {
1.30 raeburn 1061: my ($position,$dom,$settings,$rowtotal) = @_;
1.3 raeburn 1062: my $datatable;
1063: if ($position eq 'top') {
1064: my $updateon = ' ';
1065: my $updateoff = ' checked="checked" ';
1066: my $classlistson = ' ';
1067: my $classlistsoff = ' checked="checked" ';
1068: if (ref($settings) eq 'HASH') {
1069: if ($settings->{'run'} eq '1') {
1070: $updateon = $updateoff;
1071: $updateoff = ' ';
1072: }
1073: if ($settings->{'classlists'} eq '1') {
1074: $classlistson = $classlistsoff;
1075: $classlistsoff = ' ';
1076: }
1077: }
1078: my %title = (
1079: run => 'Auto-update active?',
1080: classlists => 'Update information in classlists?',
1081: );
1082: $datatable = '<tr class="LC_odd_row">'.
1083: '<td>'.&mt($title{'run'}).'</td>'.
1.8 raeburn 1084: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1.3 raeburn 1085: '<input type="radio" name="autoupdate_run"'.
1.8 raeburn 1086: $updateon.' value="1" />'.&mt('Yes').'</label> '.
1087: '<label><input type="radio" name="autoupdate_run"'.
1088: $updateoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1089: '</tr><tr>'.
1090: '<td>'.&mt($title{'classlists'}).'</td>'.
1.8 raeburn 1091: '<td class="LC_right_item"><span class="LC_nobreak">'.
1092: '<label><input type="radio" name="classlists"'.
1093: $classlistson.' value="1" />'.&mt('Yes').'</label> '.
1094: '<label><input type="radio" name="classlists"'.
1095: $classlistsoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1096: '</tr>';
1.30 raeburn 1097: $$rowtotal += 2;
1.3 raeburn 1098: } else {
1.23 raeburn 1099: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.20 raeburn 1100: my @fields = ('lastname','firstname','middlename','gen',
1101: 'permanentemail','id');
1.33 raeburn 1102: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
1.3 raeburn 1103: my $numrows = 0;
1.26 raeburn 1104: if (ref($types) eq 'ARRAY') {
1105: if (@{$types} > 0) {
1106: $datatable =
1107: &usertype_update_row($settings,$usertypes,\%fieldtitles,
1108: \@fields,$types,\$numrows);
1.30 raeburn 1109: $$rowtotal += @{$types};
1.26 raeburn 1110: }
1.3 raeburn 1111: }
1112: $datatable .=
1113: &usertype_update_row($settings,{'default' => $othertitle},
1114: \%fieldtitles,\@fields,['default'],
1115: \$numrows);
1.30 raeburn 1116: $$rowtotal ++;
1.3 raeburn 1117: }
1118: return $datatable;
1119: }
1120:
1.23 raeburn 1121: sub print_directorysrch {
1.30 raeburn 1122: my ($dom,$settings,$rowtotal) = @_;
1.23 raeburn 1123: my $srchon = ' ';
1124: my $srchoff = ' checked="checked" ';
1.25 raeburn 1125: my ($exacton,$containson,$beginson);
1.24 raeburn 1126: my $localon = ' ';
1127: my $localoff = ' checked="checked" ';
1.23 raeburn 1128: if (ref($settings) eq 'HASH') {
1129: if ($settings->{'available'} eq '1') {
1130: $srchon = $srchoff;
1131: $srchoff = ' ';
1132: }
1.24 raeburn 1133: if ($settings->{'localonly'} eq '1') {
1134: $localon = $localoff;
1135: $localoff = ' ';
1136: }
1.25 raeburn 1137: if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
1138: foreach my $type (@{$settings->{'searchtypes'}}) {
1139: if ($type eq 'exact') {
1140: $exacton = ' checked="checked" ';
1141: } elsif ($type eq 'contains') {
1142: $containson = ' checked="checked" ';
1143: } elsif ($type eq 'begins') {
1144: $beginson = ' checked="checked" ';
1145: }
1146: }
1147: } else {
1148: if ($settings->{'searchtypes'} eq 'exact') {
1149: $exacton = ' checked="checked" ';
1150: } elsif ($settings->{'searchtypes'} eq 'contains') {
1151: $containson = ' checked="checked" ';
1152: } elsif ($settings->{'searchtypes'} eq 'specify') {
1153: $exacton = ' checked="checked" ';
1154: $containson = ' checked="checked" ';
1155: }
1.23 raeburn 1156: }
1157: }
1158: my ($searchtitles,$titleorder) = &sorted_searchtitles();
1159: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1160:
1161: my $numinrow = 4;
1.26 raeburn 1162: my $cansrchrow = 0;
1.23 raeburn 1163: my $datatable='<tr class="LC_odd_row">'.
1.30 raeburn 1164: '<td colspan="2"><span class ="LC_nobreak">'.&mt('Directory search available?').'</span></td>'.
1.23 raeburn 1165: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1166: '<input type="radio" name="dirsrch_available"'.
1167: $srchon.' value="1" />'.&mt('Yes').'</label> '.
1168: '<label><input type="radio" name="dirsrch_available"'.
1169: $srchoff.' value="0" />'.&mt('No').'</label></span></td>'.
1170: '</tr><tr>'.
1.30 raeburn 1171: '<td colspan="2"><span class ="LC_nobreak">'.&mt('Other domains can search?').'</span></td>'.
1.24 raeburn 1172: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1173: '<input type="radio" name="dirsrch_localonly"'.
1174: $localoff.' value="0" />'.&mt('Yes').'</label> '.
1175: '<label><input type="radio" name="dirsrch_localonly"'.
1176: $localon.' value="1" />'.&mt('No').'</label></span></td>'.
1.25 raeburn 1177: '</tr>';
1.30 raeburn 1178: $$rowtotal += 2;
1.26 raeburn 1179: if (ref($usertypes) eq 'HASH') {
1180: if (keys(%{$usertypes}) > 0) {
1181: $datatable .= &users_cansearch_row($settings,$types,$usertypes,$dom,
1182: $numinrow,$othertitle);
1183: $cansrchrow = 1;
1184: }
1185: }
1186: if ($cansrchrow) {
1.30 raeburn 1187: $$rowtotal ++;
1.26 raeburn 1188: $datatable .= '<tr>';
1189: } else {
1190: $datatable .= '<tr class="LC_odd_row">';
1191: }
1.30 raeburn 1192: $datatable .= '<td><span class ="LC_nobreak">'.&mt('Supported search methods').
1193: '</span></td><td class="LC_left_item" colspan="2"><table><tr>';
1.25 raeburn 1194: foreach my $title (@{$titleorder}) {
1195: if (defined($searchtitles->{$title})) {
1196: my $check = ' ';
1.39 ! raeburn 1197: if (ref($settings) eq 'HASH') {
! 1198: if (ref($settings->{'searchby'}) eq 'ARRAY') {
! 1199: if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
! 1200: $check = ' checked="checked" ';
! 1201: }
1.25 raeburn 1202: }
1203: }
1204: $datatable .= '<td class="LC_left_item">'.
1205: '<span class="LC_nobreak"><label>'.
1206: '<input type="checkbox" name="searchby" '.
1207: 'value="'.$title.'"'.$check.'/>'.
1208: $searchtitles->{$title}.'</label></span></td>';
1209: }
1210: }
1.26 raeburn 1211: $datatable .= '</tr></table></td></tr>';
1.30 raeburn 1212: $$rowtotal ++;
1.26 raeburn 1213: if ($cansrchrow) {
1214: $datatable .= '<tr class="LC_odd_row">';
1215: } else {
1216: $datatable .= '<tr>';
1217: }
1.30 raeburn 1218: $datatable .= '<td><span class ="LC_nobreak">'.&mt('Search latitude').'</span></td>'.
1.26 raeburn 1219: '<td class="LC_left_item" colspan="2">'.
1.25 raeburn 1220: '<span class="LC_nobreak"><label>'.
1221: '<input type="checkbox" name="searchtypes" '.
1222: $exacton.' value="exact" />'.&mt('Exact match').
1223: '</label> '.
1224: '<label><input type="checkbox" name="searchtypes" '.
1225: $beginson.' value="begins" />'.&mt('Begins with').
1226: '</label> '.
1227: '<label><input type="checkbox" name="searchtypes" '.
1228: $containson.' value="contains" />'.&mt('Contains').
1229: '</label></span></td></tr>';
1.30 raeburn 1230: $$rowtotal ++;
1.25 raeburn 1231: return $datatable;
1232: }
1233:
1.28 raeburn 1234: sub print_contacts {
1.30 raeburn 1235: my ($dom,$settings,$rowtotal) = @_;
1.28 raeburn 1236: my $datatable;
1237: my @contacts = ('adminemail','supportemail');
1238: my (%checked,%to,%otheremails);
1239: my @mailings = ('errormail','packagesmail','helpdeskmail');
1240: foreach my $type (@mailings) {
1241: $otheremails{$type} = '';
1242: }
1243: if (ref($settings) eq 'HASH') {
1244: foreach my $item (@contacts) {
1245: if (exists($settings->{$item})) {
1246: $to{$item} = $settings->{$item};
1247: }
1248: }
1249: foreach my $type (@mailings) {
1250: if (exists($settings->{$type})) {
1251: if (ref($settings->{$type}) eq 'HASH') {
1252: foreach my $item (@contacts) {
1253: if ($settings->{$type}{$item}) {
1254: $checked{$type}{$item} = ' checked="checked" ';
1255: }
1256: }
1257: $otheremails{$type} = $settings->{$type}{'others'};
1258: }
1259: }
1260: }
1261: } else {
1262: $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
1263: $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
1264: $checked{'errormail'}{'adminemail'} = ' checked="checked" ';
1265: $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
1266: $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
1267: }
1268: my ($titles,$short_titles) = &contact_titles();
1269: my $rownum = 0;
1270: my $css_class;
1271: foreach my $item (@contacts) {
1272: if ($rownum%2) {
1273: $css_class = '';
1274: } else {
1275: $css_class = ' class="LC_odd_row" ';
1276: }
1.30 raeburn 1277: $datatable .= '<tr'.$css_class.'>'.
1278: '<td><span class="LC_nobreak">'.$titles->{$item}.
1279: '</span></td><td class="LC_right_item">'.
1.28 raeburn 1280: '<input type="text" name="'.$item.'" value="'.
1281: $to{$item}.'" /></td></tr>';
1282: $rownum ++;
1283: }
1284: foreach my $type (@mailings) {
1285: if ($rownum%2) {
1286: $css_class = '';
1287: } else {
1288: $css_class = ' class="LC_odd_row" ';
1289: }
1290: $datatable .= '<tr'.$css_class.'>'.
1.30 raeburn 1291: '<td><span class="LC_nobreak">'.
1292: $titles->{$type}.': </span></td>'.
1.28 raeburn 1293: '<td class="LC_left_item">'.
1294: '<span class="LC_nobreak">';
1295: foreach my $item (@contacts) {
1296: $datatable .= '<label>'.
1297: '<input type="checkbox" name="'.$type.'"'.
1298: $checked{$type}{$item}.
1299: ' value="'.$item.'" />'.$short_titles->{$item}.
1300: '</label> ';
1301: }
1302: $datatable .= '</span><br />'.&mt('Others').': '.
1303: '<input type="text" name="'.$type.'_others" '.
1304: 'value="'.$otheremails{$type}.'" />'.
1305: '</td></tr>'."\n";
1306: $rownum ++;
1307: }
1.30 raeburn 1308: $$rowtotal += $rownum;
1.28 raeburn 1309: return $datatable;
1310: }
1311:
1312: sub contact_titles {
1313: my %titles = &Apache::lonlocal::texthash (
1314: 'supportemail' => 'Support E-mail address',
1315: 'adminemail' => 'Default Server Admin E-mail address',
1316: 'errormail' => 'Error reports to be e-mailed to',
1317: 'packagesmail' => 'Package update alerts to be e-mailed to',
1318: 'helpdeskmail' => 'Helpdesk requests to be e-mailed to'
1319: );
1320: my %short_titles = &Apache::lonlocal::texthash (
1321: adminemail => 'Admin E-mail address',
1322: supportemail => 'Support E-mail',
1323: );
1324: return (\%titles,\%short_titles);
1325: }
1326:
1.27 raeburn 1327: sub print_usercreation {
1.30 raeburn 1328: my ($position,$dom,$settings,$rowtotal) = @_;
1.27 raeburn 1329: my $numinrow = 4;
1.28 raeburn 1330: my $datatable;
1331: if ($position eq 'top') {
1.30 raeburn 1332: $$rowtotal ++;
1.34 raeburn 1333: my $rowcount = 0;
1.32 raeburn 1334: my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username');
1.28 raeburn 1335: if (ref($rules) eq 'HASH') {
1336: if (keys(%{$rules}) > 0) {
1.32 raeburn 1337: $datatable .= &user_formats_row('username',$settings,$rules,
1338: $ruleorder,$numinrow,$rowcount);
1.30 raeburn 1339: $$rowtotal ++;
1.32 raeburn 1340: $rowcount ++;
1341: }
1342: }
1343: my ($idrules,$idruleorder) = &Apache::lonnet::inst_userrules($dom,'id');
1344: if (ref($idrules) eq 'HASH') {
1345: if (keys(%{$idrules}) > 0) {
1346: $datatable .= &user_formats_row('id',$settings,$idrules,
1347: $idruleorder,$numinrow,$rowcount);
1348: $$rowtotal ++;
1349: $rowcount ++;
1.28 raeburn 1350: }
1351: }
1.39 ! raeburn 1352: if ($rowcount == 0) {
! 1353: $datatable .= '<tr><td colspan="2">'.&mt('No format rules have been defined for usernames or IDs in this domain.').'</td></tr>';
! 1354: $$rowtotal ++;
! 1355: $rowcount ++;
! 1356: }
1.34 raeburn 1357: } elsif ($position eq 'middle') {
1358: my @creators = ('author','course');
1.37 raeburn 1359: my ($rules,$ruleorder) =
1360: &Apache::lonnet::inst_userrules($dom,'username');
1.34 raeburn 1361: my %lt = &usercreation_types();
1362: my %checked;
1363: if (ref($settings) eq 'HASH') {
1364: if (ref($settings->{'cancreate'}) eq 'HASH') {
1365: foreach my $item (@creators) {
1366: $checked{$item} = $settings->{'cancreate'}{$item};
1367: }
1368: } elsif (ref($settings->{'cancreate'}) eq 'ARRAY') {
1369: foreach my $item (@creators) {
1370: if (grep(/^\Q$item\E$/,@{$settings->{'cancreate'}})) {
1371: $checked{$item} = 'none';
1372: }
1373: }
1374: }
1375: }
1376: my $rownum = 0;
1377: foreach my $item (@creators) {
1378: $rownum ++;
1379: if ($checked{$item} eq '') {
1380: $checked{$item} = 'any';
1381: }
1382: my $css_class;
1383: if ($rownum%2) {
1384: $css_class = '';
1385: } else {
1386: $css_class = ' class="LC_odd_row" ';
1387: }
1388: $datatable .= '<tr'.$css_class.'>'.
1389: '<td><span class="LC_nobreak">'.$lt{$item}.
1390: '</span></td><td align="right">';
1.37 raeburn 1391: my @options = ('any');
1392: if (ref($rules) eq 'HASH') {
1393: if (keys(%{$rules}) > 0) {
1394: push(@options,('official','unofficial'));
1395: }
1396: }
1397: push(@options,'none');
1398: foreach my $option (@options) {
1.34 raeburn 1399: my $check = ' ';
1400: if ($checked{$item} eq $option) {
1401: $check = ' checked="checked" ';
1402: }
1403: $datatable .= '<span class="LC_nobreak"><label>'.
1404: '<input type="radio" name="can_createuser_'.
1405: $item.'" value="'.$option.'"'.$check.'/> '.
1406: $lt{$option}.'</label> </span>';
1407: }
1408: $datatable .= '</td></tr>';
1409: }
1.28 raeburn 1410: } else {
1411: my @contexts = ('author','course','domain');
1412: my @authtypes = ('int','krb4','krb5','loc');
1413: my %checked;
1414: if (ref($settings) eq 'HASH') {
1415: if (ref($settings->{'authtypes'}) eq 'HASH') {
1416: foreach my $item (@contexts) {
1417: if (ref($settings->{'authtypes'}{$item}) eq 'HASH') {
1418: foreach my $auth (@authtypes) {
1419: if ($settings->{'authtypes'}{$item}{$auth}) {
1420: $checked{$item}{$auth} = ' checked="checked" ';
1421: }
1422: }
1423: }
1424: }
1.27 raeburn 1425: }
1.35 raeburn 1426: } else {
1427: foreach my $item (@contexts) {
1.36 raeburn 1428: foreach my $auth (@authtypes) {
1.35 raeburn 1429: $checked{$item}{$auth} = ' checked="checked" ';
1430: }
1431: }
1.27 raeburn 1432: }
1.28 raeburn 1433: my %title = &context_names();
1434: my %authname = &authtype_names();
1435: my $rownum = 0;
1436: my $css_class;
1437: foreach my $item (@contexts) {
1438: if ($rownum%2) {
1439: $css_class = '';
1440: } else {
1441: $css_class = ' class="LC_odd_row" ';
1442: }
1.30 raeburn 1443: $datatable .= '<tr'.$css_class.'>'.
1.28 raeburn 1444: '<td>'.$title{$item}.
1445: '</td><td class="LC_left_item">'.
1446: '<span class="LC_nobreak">';
1447: foreach my $auth (@authtypes) {
1448: $datatable .= '<label>'.
1449: '<input type="checkbox" name="'.$item.'_auth" '.
1450: $checked{$item}{$auth}.' value="'.$auth.'" />'.
1451: $authname{$auth}.'</label> ';
1452: }
1453: $datatable .= '</span></td></tr>';
1454: $rownum ++;
1.27 raeburn 1455: }
1.30 raeburn 1456: $$rowtotal += $rownum;
1.27 raeburn 1457: }
1458: return $datatable;
1459: }
1460:
1.32 raeburn 1461: sub user_formats_row {
1462: my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_;
1463: my $output;
1464: my %text = (
1465: 'username' => 'new usernames',
1466: 'id' => 'IDs',
1467: );
1468: my $css_class = $rowcount%2?' class="LC_odd_row"':'';
1469: $output = '<tr '.$css_class.'>'.
1470: '<td><span class="LC_nobreak">'.
1471: &mt("Format rules to check for $text{$type}: ").
1472: '</span></td>'.
1473: '<td class="LC_left_item" colspan="2"><table>';
1.27 raeburn 1474: my $rem;
1475: if (ref($ruleorder) eq 'ARRAY') {
1476: for (my $i=0; $i<@{$ruleorder}; $i++) {
1477: if (ref($rules->{$ruleorder->[$i]}) eq 'HASH') {
1478: my $rem = $i%($numinrow);
1479: if ($rem == 0) {
1480: if ($i > 0) {
1481: $output .= '</tr>';
1482: }
1483: $output .= '<tr>';
1484: }
1485: my $check = ' ';
1.39 ! raeburn 1486: if (ref($settings) eq 'HASH') {
! 1487: if (ref($settings->{$type.'_rule'}) eq 'ARRAY') {
! 1488: if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) {
! 1489: $check = ' checked="checked" ';
! 1490: }
1.27 raeburn 1491: }
1492: }
1493: $output .= '<td class="LC_left_item">'.
1494: '<span class="LC_nobreak"><label>'.
1.32 raeburn 1495: '<input type="checkbox" name="'.$type.'_rule" '.
1.27 raeburn 1496: 'value="'.$ruleorder->[$i].'"'.$check.'/>'.
1497: $rules->{$ruleorder->[$i]}{'name'}.'</label></span></td>';
1498: }
1499: }
1500: $rem = @{$ruleorder}%($numinrow);
1501: }
1502: my $colsleft = $numinrow - $rem;
1503: if ($colsleft > 1 ) {
1504: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
1505: ' </td>';
1506: } elsif ($colsleft == 1) {
1507: $output .= '<td class="LC_left_item"> </td>';
1508: }
1509: $output .= '</tr></table></td></tr>';
1510: return $output;
1511: }
1512:
1.34 raeburn 1513: sub usercreation_types {
1514: my %lt = &Apache::lonlocal::texthash (
1515: author => 'When adding a co-author',
1516: course => 'When adding a user to a course',
1517: any => 'Any',
1518: official => 'Institutional only ',
1519: unofficial => 'Non-institutional only',
1520: none => 'None',
1521: );
1522: return %lt;
1523: }
1524:
1.28 raeburn 1525: sub authtype_names {
1526: my %lt = &Apache::lonlocal::texthash(
1527: int => 'Internal',
1528: krb4 => 'Kerberos 4',
1529: krb5 => 'Kerberos 5',
1530: loc => 'Local',
1531: );
1532: return %lt;
1533: }
1534:
1535: sub context_names {
1536: my %context_title = &Apache::lonlocal::texthash(
1537: author => 'Creating users when an Author',
1538: course => 'Creating users when in a course',
1539: domain => 'Creating users when a Domain Coordinator',
1540: );
1541: return %context_title;
1542: }
1543:
1.33 raeburn 1544: sub print_usermodification {
1545: my ($position,$dom,$settings,$rowtotal) = @_;
1546: my $numinrow = 4;
1547: my ($context,$datatable,$rowcount);
1548: if ($position eq 'top') {
1549: $rowcount = 0;
1550: $context = 'author';
1551: foreach my $role ('ca','aa') {
1552: $datatable .= &modifiable_userdata_row($context,$role,$settings,
1553: $numinrow,$rowcount);
1554: $$rowtotal ++;
1555: $rowcount ++;
1556: }
1557: } else {
1558: $context = 'course';
1559: $rowcount = 0;
1560: foreach my $role ('st','ep','ta','in','cr') {
1561: $datatable .= &modifiable_userdata_row($context,$role,$settings,
1562: $numinrow,$rowcount);
1563: $$rowtotal ++;
1564: $rowcount ++;
1565: }
1566: }
1567: return $datatable;
1568: }
1569:
1570: sub modifiable_userdata_row {
1571: my ($context,$role,$settings,$numinrow,$rowcount) = @_;
1572: my $rolename;
1573: if ($role eq 'cr') {
1574: $rolename = &mt('Custom role');
1575: } else {
1576: $rolename = &Apache::lonnet::plaintext($role);
1577: }
1578: my @fields = ('lastname','firstname','middlename','generation',
1579: 'permanentemail','id');
1580: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
1581: my $output;
1582: my $css_class = $rowcount%2?' class="LC_odd_row"':'';
1583: $output = '<tr '.$css_class.'>'.
1584: '<td><span class="LC_nobreak">'.$rolename.'</span></td>'.
1585: '<td class="LC_left_item" colspan="2"><table>';
1586: my $rem;
1587: my %checks;
1588: if (ref($settings) eq 'HASH') {
1589: if (ref($settings->{$context}) eq 'HASH') {
1590: if (ref($settings->{$context}->{$role}) eq 'HASH') {
1591: foreach my $field (@fields) {
1592: if ($settings->{$context}->{$role}->{$field}) {
1593: $checks{$field} = ' checked="checked" ';
1594: }
1595: }
1596: }
1597: }
1598: }
1599: for (my $i=0; $i<@fields; $i++) {
1600: my $rem = $i%($numinrow);
1601: if ($rem == 0) {
1602: if ($i > 0) {
1603: $output .= '</tr>';
1604: }
1605: $output .= '<tr>';
1606: }
1607: my $check = ' ';
1608: if (exists($checks{$fields[$i]})) {
1609: $check = $checks{$fields[$i]}
1610: } else {
1611: if ($role eq 'st') {
1612: if (ref($settings) ne 'HASH') {
1613: $check = ' checked="checked" ';
1614: }
1615: }
1616: }
1617: $output .= '<td class="LC_left_item">'.
1618: '<span class="LC_nobreak"><label>'.
1619: '<input type="checkbox" name="canmodify_'.$role.'" '.
1620: 'value="'.$fields[$i].'"'.$check.'/>'.$fieldtitles{$fields[$i]}.
1621: '</label></span></td>';
1622: $rem = @fields%($numinrow);
1623: }
1624: my $colsleft = $numinrow - $rem;
1625: if ($colsleft > 1 ) {
1626: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
1627: ' </td>';
1628: } elsif ($colsleft == 1) {
1629: $output .= '<td class="LC_left_item"> </td>';
1630: }
1631: $output .= '</tr></table></td></tr>';
1632: return $output;
1633: }
1.28 raeburn 1634:
1.25 raeburn 1635: sub users_cansearch_row {
1636: my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle) = @_;
1637: my $output = '<tr class="LC_odd_row">'.
1.24 raeburn 1638: '<td>'.&mt('Users allowed to search').' ('.$dom.')'.
1639: '</td><td class="LC_left_item" colspan="2"><table>';
1.26 raeburn 1640: my $rem;
1641: if (ref($types) eq 'ARRAY') {
1642: for (my $i=0; $i<@{$types}; $i++) {
1643: if (defined($usertypes->{$types->[$i]})) {
1644: my $rem = $i%($numinrow);
1645: if ($rem == 0) {
1646: if ($i > 0) {
1647: $output .= '</tr>';
1648: }
1649: $output .= '<tr>';
1.23 raeburn 1650: }
1.26 raeburn 1651: my $check = ' ';
1652: if (ref($settings->{'cansearch'}) eq 'ARRAY') {
1653: if (grep(/^\Q$types->[$i]\E$/,@{$settings->{'cansearch'}})) {
1654: $check = ' checked="checked" ';
1655: }
1.23 raeburn 1656: }
1.26 raeburn 1657: $output .= '<td class="LC_left_item">'.
1658: '<span class="LC_nobreak"><label>'.
1659: '<input type="checkbox" name="cansearch" '.
1660: 'value="'.$types->[$i].'"'.$check.'/>'.
1661: $usertypes->{$types->[$i]}.'</label></span></td>';
1.23 raeburn 1662: }
1663: }
1.26 raeburn 1664:
1665: $rem = @{$types}%($numinrow);
1.23 raeburn 1666: }
1667: my $colsleft = $numinrow - $rem;
1668: if ($colsleft > 1) {
1.25 raeburn 1669: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">';
1.23 raeburn 1670: } else {
1.25 raeburn 1671: $output .= '<td class="LC_left_item">';
1.23 raeburn 1672: }
1673: my $defcheck = ' ';
1674: if (ref($settings->{'cansearch'}) eq 'ARRAY') {
1.26 raeburn 1675: if (grep(/^default$/,@{$settings->{'cansearch'}})) {
1676: $defcheck = ' checked="checked" ';
1677: }
1.23 raeburn 1678: }
1.25 raeburn 1679: $output .= '<span class="LC_nobreak"><label>'.
1680: '<input type="checkbox" name="cansearch" '.
1681: 'value="default"'.$defcheck.'/>'.
1682: $othertitle.'</label></span></td>'.
1683: '</tr></table></td></tr>';
1684: return $output;
1.23 raeburn 1685: }
1686:
1687: sub sorted_inst_types {
1688: my ($dom) = @_;
1689: my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
1.26 raeburn 1690: my $othertitle = &mt('All users');
1.23 raeburn 1691: my @types;
1692: if (ref($order) eq 'ARRAY') {
1693: @types = @{$order};
1694: }
1695: if (@types == 0) {
1696: if (ref($usertypes) eq 'HASH') {
1697: @types = sort(keys(%{$usertypes}));
1698: }
1699: }
1700: if (keys(%{$usertypes}) > 0) {
1701: $othertitle = &mt('Other users');
1702: }
1703: return ($othertitle,$usertypes,\@types);
1704: }
1705:
1706: sub sorted_searchtitles {
1707: my %searchtitles = &Apache::lonlocal::texthash(
1708: 'uname' => 'username',
1709: 'lastname' => 'last name',
1710: 'lastfirst' => 'last name, first name',
1711: );
1712: my @titleorder = ('uname','lastname','lastfirst');
1713: return (\%searchtitles,\@titleorder);
1714: }
1715:
1.25 raeburn 1716: sub sorted_searchtypes {
1717: my %srchtypes_desc = (
1718: exact => 'is exact match',
1719: contains => 'contains ..',
1720: begins => 'begins with ..',
1721: );
1722: my @srchtypeorder = ('exact','begins','contains');
1723: return (\%srchtypes_desc,\@srchtypeorder);
1724: }
1725:
1.3 raeburn 1726: sub usertype_update_row {
1727: my ($settings,$usertypes,$fieldtitles,$fields,$types,$rownums) = @_;
1728: my $datatable;
1729: my $numinrow = 4;
1730: foreach my $type (@{$types}) {
1731: if (defined($usertypes->{$type})) {
1732: $$rownums ++;
1733: my $css_class = $$rownums%2?' class="LC_odd_row"':'';
1734: $datatable .= '<tr'.$css_class.'><td>'.$usertypes->{$type}.
1735: '</td><td class="LC_left_item"><table>';
1736: for (my $i=0; $i<@{$fields}; $i++) {
1737: my $rem = $i%($numinrow);
1738: if ($rem == 0) {
1739: if ($i > 0) {
1740: $datatable .= '</tr>';
1741: }
1742: $datatable .= '<tr>';
1743: }
1744: my $check = ' ';
1.39 ! raeburn 1745: if (ref($settings) eq 'HASH') {
! 1746: if (ref($settings->{'fields'}) eq 'HASH') {
! 1747: if (ref($settings->{'fields'}{$type}) eq 'ARRAY') {
! 1748: if (grep(/^\Q$fields->[$i]\E$/,@{$settings->{'fields'}{$type}})) {
! 1749: $check = ' checked="checked" ';
! 1750: }
1.3 raeburn 1751: }
1752: }
1753: }
1754:
1755: if ($i == @{$fields}-1) {
1756: my $colsleft = $numinrow - $rem;
1757: if ($colsleft > 1) {
1758: $datatable .= '<td colspan="'.$colsleft.'">';
1759: } else {
1760: $datatable .= '<td>';
1761: }
1762: } else {
1763: $datatable .= '<td>';
1764: }
1.8 raeburn 1765: $datatable .= '<span class="LC_nobreak"><label>'.
1766: '<input type="checkbox" name="updateable_'.$type.
1767: '_'.$fields->[$i].'" value="1"'.$check.'/>'.
1768: $fieldtitles->{$fields->[$i]}.'</label></span></td>';
1.3 raeburn 1769: }
1770: $datatable .= '</tr></table></td></tr>';
1771: }
1772: }
1773: return $datatable;
1.1 raeburn 1774: }
1775:
1776: sub modify_login {
1.9 raeburn 1777: my ($r,$dom,$confname,%domconfig) = @_;
1.6 raeburn 1778: my ($resulttext,$errors,$colchgtext,%changes,%colchanges);
1.1 raeburn 1779: my %title = ( coursecatalog => 'Display course catalog',
1780: adminmail => 'Display administrator E-mail address');
1.3 raeburn 1781: my @offon = ('off','on');
1.6 raeburn 1782: my %loginhash;
1.9 raeburn 1783: ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
1784: \%domconfig,\%loginhash);
1.6 raeburn 1785: $loginhash{login}{coursecatalog} = $env{'form.coursecatalog'};
1786: $loginhash{login}{adminmail} = $env{'form.adminmail'};
1787: if (ref($colchanges{'login'}) eq 'HASH') {
1788: $colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
1789: \%loginhash);
1790: }
1.1 raeburn 1791: my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
1792: $dom);
1793: if ($putresult eq 'ok') {
1.3 raeburn 1794: if (($domconfig{'login'}{'coursecatalog'} eq '0') &&
1.1 raeburn 1795: ($env{'form.coursecatalog'} eq '1')) {
1796: $changes{'coursecatalog'} = 1;
1.3 raeburn 1797: } elsif (($domconfig{'login'}{'coursecatalog'} eq '' ||
1798: $domconfig{'login'}{'coursecatalog'} eq '1') &&
1.1 raeburn 1799: ($env{'form.coursecatalog'} eq '0')) {
1800: $changes{'coursecatalog'} = 1;
1801: }
1.3 raeburn 1802: if (($domconfig{'login'}{'adminmail'} eq '1') &&
1.1 raeburn 1803: ($env{'form.adminmail'} eq '0')) {
1804: $changes{'adminmail'} = 1;
1805: } elsif (($domconfig{'login'}{'adminmail'} eq '' ||
1806: $domconfig{'login'}{'adminmail'} eq '0') &&
1807: ($env{'form.adminmail'} eq '1')) {
1808: $changes{'adminmail'} = 1;
1809: }
1.6 raeburn 1810: if (keys(%changes) > 0 || $colchgtext) {
1.1 raeburn 1811: $resulttext = &mt('Changes made:').'<ul>';
1812: foreach my $item (sort(keys(%changes))) {
1813: $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
1814: }
1.6 raeburn 1815: $resulttext .= $colchgtext.'</ul>';
1.1 raeburn 1816: } else {
1817: $resulttext = &mt('No changes made to log-in page settings');
1818: }
1819: } else {
1.11 albertel 1820: $resulttext = '<span class="LC_error">'.
1821: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 1822: }
1.6 raeburn 1823: if ($errors) {
1.9 raeburn 1824: $resulttext .= '<br />'.&mt('The following errors occurred: ').'<ul>'.
1.6 raeburn 1825: $errors.'</ul>';
1826: }
1827: return $resulttext;
1828: }
1829:
1830: sub color_font_choices {
1831: my %choices =
1832: &Apache::lonlocal::texthash (
1833: img => "Header",
1834: bgs => "Background colors",
1835: links => "Link colors",
1836: font => "Font color",
1837: pgbg => "Page",
1838: tabbg => "Header",
1839: sidebg => "Border",
1840: link => "Link",
1841: alink => "Active link",
1842: vlink => "Visited link",
1843: );
1844: return %choices;
1845: }
1846:
1847: sub modify_rolecolors {
1.9 raeburn 1848: my ($r,$dom,$confname,$roles,%domconfig) = @_;
1.6 raeburn 1849: my ($resulttext,%rolehash);
1850: $rolehash{'rolecolors'} = {};
1.9 raeburn 1851: my ($errors,%changes) = &modify_colors($r,$dom,$confname,$roles,
1.6 raeburn 1852: $domconfig{'rolecolors'},$rolehash{'rolecolors'});
1853: my $putresult = &Apache::lonnet::put_dom('configuration',\%rolehash,
1854: $dom);
1855: if ($putresult eq 'ok') {
1856: if (keys(%changes) > 0) {
1857: $resulttext = &display_colorchgs($dom,\%changes,$roles,
1858: $rolehash{'rolecolors'});
1859: } else {
1860: $resulttext = &mt('No changes made to default color schemes');
1861: }
1862: } else {
1.11 albertel 1863: $resulttext = '<span class="LC_error">'.
1864: &mt('An error occurred: [_1]',$putresult).'</span>';
1.6 raeburn 1865: }
1866: if ($errors) {
1867: $resulttext .= &mt('The following errors occurred: ').'<ul>'.
1868: $errors.'</ul>';
1869: }
1870: return $resulttext;
1871: }
1872:
1873: sub modify_colors {
1.9 raeburn 1874: my ($r,$dom,$confname,$roles,$domconfig,$confhash) = @_;
1.12 raeburn 1875: my (%changes,%choices);
1.6 raeburn 1876: my @bgs = ('pgbg','mainbg','sidebg');
1877: my @links = ('link','alink','vlink');
1878: my @images;
1879: my $servadm = $r->dir_config('lonAdmEMail');
1880: my $errors;
1881: foreach my $role (@{$roles}) {
1882: if ($role eq 'login') {
1.12 raeburn 1883: %choices = &login_choices();
1884: } else {
1885: %choices = &color_font_choices();
1886: }
1887: if ($role eq 'login') {
1.6 raeburn 1888: @images = ('img','logo','domlogo');
1889: } else {
1890: @images = ('img');
1891: }
1892: $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
1893: foreach my $item (@bgs,@links) {
1894: $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
1895: }
1.9 raeburn 1896: my ($configuserok,$author_ok,$switchserver,%currroles);
1897: my $uhome = &Apache::lonnet::homeserver($confname,$dom,1);
1898: ($configuserok,%currroles) = &check_configuser($uhome,$dom,
1899: $confname,$servadm);
1900: if ($configuserok eq 'ok') {
1901: $switchserver = &check_switchserver($dom,$confname);
1902: if ($switchserver eq '') {
1903: $author_ok = &check_authorstatus($dom,$confname,%currroles);
1904: }
1905: }
1906: my ($width,$height) = &thumb_dimensions();
1.8 raeburn 1907: foreach my $img (@images) {
1.18 albertel 1908: if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
1909: && !defined($domconfig->{$role}{$img})
1910: && !$env{'form.'.$role.'_del_'.$img}
1911: && $env{'form.'.$role.'_import_'.$img}) {
1912: # import the old configured image from the .tab setting
1913: # if they haven't provided a new one
1914: $domconfig->{$role}{$img} =
1915: $env{'form.'.$role.'_import_'.$img};
1916: }
1.6 raeburn 1917: if ($env{'form.'.$role.'_'.$img.'.filename'} ne '') {
1.9 raeburn 1918: my $error;
1.6 raeburn 1919: if ($configuserok eq 'ok') {
1.9 raeburn 1920: if ($switchserver) {
1.12 raeburn 1921: $error = &mt("Upload of [_1] image for $role page(s) is not permitted to this server: [_2]",$choices{$img},$switchserver);
1.9 raeburn 1922: } else {
1923: if ($author_ok eq 'ok') {
1924: my ($result,$logourl) =
1925: &publishlogo($r,'upload',$role.'_'.$img,
1926: $dom,$confname,$img,$width,$height);
1927: if ($result eq 'ok') {
1928: $confhash->{$role}{$img} = $logourl;
1.12 raeburn 1929: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 1930: } else {
1.12 raeburn 1931: $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 1932: }
1933: } else {
1.12 raeburn 1934: $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 1935: }
1936: }
1937: } else {
1.12 raeburn 1938: $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 1939: }
1940: if ($error) {
1.8 raeburn 1941: &Apache::lonnet::logthis($error);
1.11 albertel 1942: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
1.8 raeburn 1943: }
1944: } elsif ($domconfig->{$role}{$img} ne '') {
1.9 raeburn 1945: if ($domconfig->{$role}{$img} !~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
1946: my $error;
1947: if ($configuserok eq 'ok') {
1948: # is confname an author?
1949: if ($switchserver eq '') {
1950: if ($author_ok eq 'ok') {
1951: my ($result,$logourl) =
1952: &publishlogo($r,'copy',$domconfig->{$role}{$img},
1953: $dom,$confname,$img,$width,$height);
1954: if ($result eq 'ok') {
1955: $confhash->{$role}{$img} = $logourl;
1.18 albertel 1956: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 1957: }
1958: }
1959: }
1960: }
1.6 raeburn 1961: }
1962: }
1963: }
1964: if (ref($domconfig) eq 'HASH') {
1965: if (ref($domconfig->{$role}) eq 'HASH') {
1966: foreach my $img (@images) {
1967: if ($domconfig->{$role}{$img} ne '') {
1968: if ($env{'form.'.$role.'_del_'.$img}) {
1969: $confhash->{$role}{$img} = '';
1.12 raeburn 1970: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 1971: } else {
1.9 raeburn 1972: if ($confhash->{$role}{$img} eq '') {
1973: $confhash->{$role}{$img} = $domconfig->{$role}{$img};
1974: }
1.6 raeburn 1975: }
1976: } else {
1977: if ($env{'form.'.$role.'_del_'.$img}) {
1978: $confhash->{$role}{$img} = '';
1.12 raeburn 1979: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 1980: }
1981: }
1982: }
1983: if ($domconfig->{$role}{'font'} ne '') {
1984: if ($confhash->{$role}{'font'} ne $domconfig->{$role}{'font'}) {
1985: $changes{$role}{'font'} = 1;
1986: }
1987: } else {
1988: if ($confhash->{$role}{'font'}) {
1989: $changes{$role}{'font'} = 1;
1990: }
1991: }
1992: foreach my $item (@bgs) {
1993: if ($domconfig->{$role}{$item} ne '') {
1994: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
1995: $changes{$role}{'bgs'}{$item} = 1;
1996: }
1997: } else {
1998: if ($confhash->{$role}{$item}) {
1999: $changes{$role}{'bgs'}{$item} = 1;
2000: }
2001: }
2002: }
2003: foreach my $item (@links) {
2004: if ($domconfig->{$role}{$item} ne '') {
2005: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
2006: $changes{$role}{'links'}{$item} = 1;
2007: }
2008: } else {
2009: if ($confhash->{$role}{$item}) {
2010: $changes{$role}{'links'}{$item} = 1;
2011: }
2012: }
2013: }
2014: } else {
2015: &default_change_checker($role,\@images,\@links,\@bgs,
2016: $confhash,\%changes);
2017: }
2018: } else {
2019: &default_change_checker($role,\@images,\@links,\@bgs,
2020: $confhash,\%changes);
2021: }
2022: }
2023: return ($errors,%changes);
2024: }
2025:
2026: sub default_change_checker {
2027: my ($role,$images,$links,$bgs,$confhash,$changes) = @_;
2028: foreach my $item (@{$links}) {
2029: if ($confhash->{$role}{$item}) {
2030: $changes->{$role}{'links'}{$item} = 1;
2031: }
2032: }
2033: foreach my $item (@{$bgs}) {
2034: if ($confhash->{$role}{$item}) {
2035: $changes->{$role}{'bgs'}{$item} = 1;
2036: }
2037: }
2038: foreach my $img (@{$images}) {
2039: if ($env{'form.'.$role.'_del_'.$img}) {
2040: $confhash->{$role}{$img} = '';
1.12 raeburn 2041: $changes->{$role}{'images'}{$img} = 1;
1.6 raeburn 2042: }
2043: }
2044: if ($confhash->{$role}{'font'}) {
2045: $changes->{$role}{'font'} = 1;
2046: }
2047: }
2048:
2049: sub display_colorchgs {
2050: my ($dom,$changes,$roles,$confhash) = @_;
2051: my (%choices,$resulttext);
1.7 albertel 2052: &Apache::loncommon::devalidate_domconfig_cache($dom);
1.6 raeburn 2053: if (!grep(/^login$/,@{$roles})) {
2054: $resulttext = &mt('Changes made:').'<br />';
2055: }
2056: foreach my $role (@{$roles}) {
2057: if ($role eq 'login') {
2058: %choices = &login_choices();
2059: } else {
2060: %choices = &color_font_choices();
2061: }
2062: if (ref($changes->{$role}) eq 'HASH') {
2063: if ($role ne 'login') {
2064: $resulttext .= '<h4>'.&mt($role).'</h4>';
2065: }
2066: foreach my $key (sort(keys(%{$changes->{$role}}))) {
2067: if ($role ne 'login') {
2068: $resulttext .= '<ul>';
2069: }
2070: if (ref($changes->{$role}{$key}) eq 'HASH') {
2071: if ($role ne 'login') {
2072: $resulttext .= '<li>'.&mt($choices{$key}).':<ul>';
2073: }
2074: foreach my $item (sort(keys(%{$changes->{$role}{$key}}))) {
2075: if ($confhash->{$role}{$item} eq '') {
2076: $resulttext .= '<li>'.&mt("$choices{$item} set to default").'</li>';
2077: } else {
1.12 raeburn 2078: my $newitem = $confhash->{$role}{$item};
2079: if ($key eq 'images') {
2080: $newitem = '<img src="'.$confhash->{$role}{$item}.'" alt="'.$choices{$item}.'" valign="bottom" />';
2081: }
2082: $resulttext .= '<li>'.&mt("$choices{$item} set to [_1]",$newitem).'</li>';
1.6 raeburn 2083: }
2084: }
2085: if ($role ne 'login') {
2086: $resulttext .= '</ul></li>';
2087: }
2088: } else {
2089: if ($confhash->{$role}{$key} eq '') {
2090: $resulttext .= '<li>'.&mt("$choices{$key} set to default").'</li>';
2091: } else {
2092: $resulttext .= '<li>'.&mt("$choices{$key} set to [_1]",$confhash->{$role}{$key}).'</li>';
2093: }
2094: }
2095: if ($role ne 'login') {
2096: $resulttext .= '</ul>';
2097: }
2098: }
2099: }
2100: }
1.3 raeburn 2101: return $resulttext;
1.1 raeburn 2102: }
2103:
1.9 raeburn 2104: sub thumb_dimensions {
2105: return ('200','50');
2106: }
2107:
1.16 raeburn 2108: sub check_dimensions {
2109: my ($inputfile) = @_;
2110: my ($fullwidth,$fullheight);
2111: if ($inputfile =~ m|^[/\w.\-]+$|) {
2112: if (open(PIPE,"identify $inputfile 2>&1 |")) {
2113: my $imageinfo = <PIPE>;
2114: if (!close(PIPE)) {
2115: &Apache::lonnet::logthis("Failed to close PIPE opened to retrieve image information for $inputfile");
2116: }
2117: chomp($imageinfo);
2118: my ($fullsize) =
1.21 raeburn 2119: ($imageinfo =~ /^\Q$inputfile\E\s+\w+\s+(\d+x\d+)/);
1.16 raeburn 2120: if ($fullsize) {
2121: ($fullwidth,$fullheight) = split(/x/,$fullsize);
2122: }
2123: }
2124: }
2125: return ($fullwidth,$fullheight);
2126: }
2127:
1.9 raeburn 2128: sub check_configuser {
2129: my ($uhome,$dom,$confname,$servadm) = @_;
2130: my ($configuserok,%currroles);
2131: if ($uhome eq 'no_host') {
2132: srand( time() ^ ($$ + ($$ << 15)) ); # Seed rand.
2133: my $configpass = &LONCAPA::Enrollment::create_password();
2134: $configuserok =
2135: &Apache::lonnet::modifyuser($dom,$confname,'','internal',
2136: $configpass,'','','','','',undef,$servadm);
2137: } else {
2138: $configuserok = 'ok';
2139: %currroles =
2140: &Apache::lonnet::get_my_roles($confname,$dom,'userroles');
2141: }
2142: return ($configuserok,%currroles);
2143: }
2144:
2145: sub check_authorstatus {
2146: my ($dom,$confname,%currroles) = @_;
2147: my $author_ok;
1.37 raeburn 2148: if (!$currroles{$confname.':'.$dom.':au'}) {
1.9 raeburn 2149: my $start = time;
2150: my $end = 0;
2151: $author_ok =
2152: &Apache::lonnet::assignrole($dom,$confname,'/'.$dom.'/',
2153: 'au',$end,$start);
2154: } else {
2155: $author_ok = 'ok';
2156: }
2157: return $author_ok;
2158: }
2159:
2160: sub publishlogo {
2161: my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight) = @_;
2162: my ($output,$fname,$logourl);
2163: if ($action eq 'upload') {
2164: $fname=$env{'form.'.$formname.'.filename'};
2165: chop($env{'form.'.$formname});
2166: } else {
2167: ($fname) = ($formname =~ /([^\/]+)$/);
2168: }
2169: $fname=&Apache::lonnet::clean_filename($fname);
2170: # See if there is anything left
2171: unless ($fname) { return ('error: no uploaded file'); }
2172: $fname="$subdir/$fname";
2173: my $filepath='/home/'.$confname.'/public_html';
2174: my ($fnamepath,$file,$fetchthumb);
2175: $file=$fname;
2176: if ($fname=~m|/|) {
2177: ($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
2178: }
2179: my @parts=split(/\//,$filepath.'/'.$fnamepath);
2180: my $count;
2181: for ($count=4;$count<=$#parts;$count++) {
2182: $filepath.="/$parts[$count]";
2183: if ((-e $filepath)!=1) {
2184: mkdir($filepath,02770);
2185: }
2186: }
2187: # Check for bad extension and disallow upload
2188: if ($file=~/\.(\w+)$/ &&
2189: (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
2190: $output =
2191: &mt('Invalid file extension ([_1]) - reserved for LONCAPA use.',$1);
2192: } elsif ($file=~/\.(\w+)$/ &&
2193: !defined(&Apache::loncommon::fileembstyle($1))) {
2194: $output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1);
2195: } elsif ($file=~/\.(\d+)\.(\w+)$/) {
2196: $output = &mt('File name not allowed a rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
2197: } elsif (-d "$filepath/$file") {
2198: $output = &mt('File name is a directory name - rename the file and re-upload');
2199: } else {
2200: my $source = $filepath.'/'.$file;
2201: my $logfile;
2202: if (!open($logfile,">>$source".'.log')) {
2203: return (&mt('No write permission to Construction Space'));
2204: }
2205: print $logfile
2206: "\n================= Publish ".localtime()." ================\n".
2207: $env{'user.name'}.':'.$env{'user.domain'}."\n";
2208: # Save the file
2209: if (!open(FH,'>'.$source)) {
2210: &Apache::lonnet::logthis('Failed to create '.$source);
2211: return (&mt('Failed to create file'));
2212: }
2213: if ($action eq 'upload') {
2214: if (!print FH ($env{'form.'.$formname})) {
2215: &Apache::lonnet::logthis('Failed to write to '.$source);
2216: return (&mt('Failed to write file'));
2217: }
2218: } else {
2219: my $original = &Apache::lonnet::filelocation('',$formname);
2220: if(!copy($original,$source)) {
2221: &Apache::lonnet::logthis('Failed to copy '.$original.' to '.$source);
2222: return (&mt('Failed to write file'));
2223: }
2224: }
2225: close(FH);
2226: chmod(0660, $source); # Permissions to rw-rw---.
2227:
2228: my $docroot=$r->dir_config('lonDocRoot');
2229: my $targetdir=$docroot.'/res/'.$dom.'/'.$confname .'/'.$fnamepath;
2230: my $copyfile=$targetdir.'/'.$file;
2231:
2232: my @parts=split(/\//,$targetdir);
2233: my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]";
2234: for (my $count=5;$count<=$#parts;$count++) {
2235: $path.="/$parts[$count]";
2236: if (!-e $path) {
2237: print $logfile "\nCreating directory ".$path;
2238: mkdir($path,02770);
2239: }
2240: }
2241: my $versionresult;
2242: if (-e $copyfile) {
2243: $versionresult = &logo_versioning($targetdir,$file,$logfile);
2244: } else {
2245: $versionresult = 'ok';
2246: }
2247: if ($versionresult eq 'ok') {
2248: if (copy($source,$copyfile)) {
2249: print $logfile "\nCopied original source to ".$copyfile."\n";
2250: $output = 'ok';
2251: &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
2252: $logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;
2253: } else {
2254: print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
2255: $output = &mt('Failed to copy file to RES space').", $!";
2256: }
2257: if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) {
2258: my $inputfile = $filepath.'/'.$file;
2259: my $outfile = $filepath.'/'.'tn-'.$file;
1.16 raeburn 2260: my ($fullwidth,$fullheight) = &check_dimensions($inputfile);
2261: if ($fullwidth ne '' && $fullheight ne '') {
2262: if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) {
2263: my $thumbsize = $thumbwidth.'x'.$thumbheight;
2264: system("convert -sample $thumbsize $inputfile $outfile");
2265: chmod(0660, $filepath.'/tn-'.$file);
2266: if (-e $outfile) {
2267: my $copyfile=$targetdir.'/tn-'.$file;
2268: if (copy($outfile,$copyfile)) {
2269: print $logfile "\nCopied source to ".$copyfile."\n";
2270: &write_metadata($dom,$confname,$formname,
2271: $targetdir,'tn-'.$file,$logfile);
2272: } else {
2273: print $logfile "\nUnable to write ".$copyfile.
2274: ':'.$!."\n";
2275: }
2276: }
1.9 raeburn 2277: }
2278: }
2279: }
2280: } else {
2281: $output = $versionresult;
2282: }
2283: }
2284: return ($output,$logourl);
2285: }
2286:
2287: sub logo_versioning {
2288: my ($targetdir,$file,$logfile) = @_;
2289: my $target = $targetdir.'/'.$file;
2290: my ($maxversion,$fn,$extn,$output);
2291: $maxversion = 0;
2292: if ($file =~ /^(.+)\.(\w+)$/) {
2293: $fn=$1;
2294: $extn=$2;
2295: }
2296: opendir(DIR,$targetdir);
2297: while (my $filename=readdir(DIR)) {
2298: if ($filename=~/\Q$fn\E\.(\d+)\.\Q$extn\E$/) {
2299: $maxversion=($1>$maxversion)?$1:$maxversion;
2300: }
2301: }
2302: $maxversion++;
2303: print $logfile "\nCreating old version ".$maxversion."\n";
2304: my $copyfile=$targetdir.'/'.$fn.'.'.$maxversion.'.'.$extn;
2305: if (copy($target,$copyfile)) {
2306: print $logfile "Copied old target to ".$copyfile."\n";
2307: $copyfile=$copyfile.'.meta';
2308: if (copy($target.'.meta',$copyfile)) {
2309: print $logfile "Copied old target metadata to ".$copyfile."\n";
2310: $output = 'ok';
2311: } else {
2312: print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";
2313: $output = &mt('Failed to copy old meta').", $!, ";
2314: }
2315: } else {
2316: print $logfile "Unable to write ".$copyfile.':'.$!."\n";
2317: $output = &mt('Failed to copy old target').", $!, ";
2318: }
2319: return $output;
2320: }
2321:
2322: sub write_metadata {
2323: my ($dom,$confname,$formname,$targetdir,$file,$logfile) = @_;
2324: my (%metadatafields,%metadatakeys,$output);
2325: $metadatafields{'title'}=$formname;
2326: $metadatafields{'creationdate'}=time;
2327: $metadatafields{'lastrevisiondate'}=time;
2328: $metadatafields{'copyright'}='public';
2329: $metadatafields{'modifyinguser'}=$env{'user.name'}.':'.
2330: $env{'user.domain'};
2331: $metadatafields{'authorspace'}=$confname.':'.$dom;
2332: $metadatafields{'domain'}=$dom;
2333: {
2334: print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
2335: my $mfh;
2336: unless (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
2337: $output = &mt('Could not write metadata');
2338: }
2339: foreach (sort keys %metadatafields) {
2340: unless ($_=~/\./) {
2341: my $unikey=$_;
2342: $unikey=~/^([A-Za-z]+)/;
2343: my $tag=$1;
2344: $tag=~tr/A-Z/a-z/;
2345: print $mfh "\n\<$tag";
2346: foreach (split(/\,/,$metadatakeys{$unikey})) {
2347: my $value=$metadatafields{$unikey.'.'.$_};
2348: $value=~s/\"/\'\'/g;
2349: print $mfh ' '.$_.'="'.$value.'"';
2350: }
2351: print $mfh '>'.
2352: &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
2353: .'</'.$tag.'>';
2354: }
2355: }
2356: $output = 'ok';
2357: print $logfile "\nWrote metadata";
2358: close($mfh);
2359: }
2360: }
2361:
2362: sub check_switchserver {
2363: my ($dom,$confname) = @_;
2364: my ($allowed,$switchserver);
2365: my $home = &Apache::lonnet::homeserver($confname,$dom);
2366: if ($home eq 'no_host') {
2367: $home = &Apache::lonnet::domain($dom,'primary');
2368: }
2369: my @ids=&Apache::lonnet::current_machine_ids();
1.10 albertel 2370: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
2371: if (!$allowed) {
2372: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role=dc./'.$dom.'/">'.&mt('Switch Server').'</a>';
1.9 raeburn 2373: }
2374: return $switchserver;
2375: }
2376:
1.30 raeburn 2377: sub javascript_set_colnums {
2378: return <<END;
2379: function setDisplayColumns() {
2380: if (document.pickactions.width.value > 1100) {
2381: document.pickactions.numcols[1].checked = true;
2382: } else {
2383: document.pickactions.numcols[0].checked = true;
2384: }
2385: }
2386: END
2387: }
2388:
1.1 raeburn 2389: sub modify_quotas {
1.3 raeburn 2390: my ($dom,%domconfig) = @_;
1.1 raeburn 2391: my ($resulttext,%changes);
1.26 raeburn 2392: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.1 raeburn 2393: my %formhash;
2394: foreach my $key (keys(%env)) {
2395: if ($key =~ /^form\.quota_(.+)$/) {
2396: $formhash{$1} = $env{$key};
2397: }
2398: }
1.15 raeburn 2399: $formhash{'default'} = $env{'form.defaultquota'};
1.1 raeburn 2400: if (ref($domconfig{'quotas'}) eq 'HASH') {
2401: foreach my $key (keys(%{$domconfig{'quotas'}})) {
2402: if (exists($formhash{$key})) {
2403: if ($formhash{$key} ne $domconfig{'quotas'}{$key}) {
2404: $changes{$key} = 1;
2405: }
2406: } else {
2407: $formhash{$key} = $domconfig{'quotas'}{$key};
2408: }
2409: }
2410: }
2411: foreach my $key (keys(%formhash)) {
2412: if ($formhash{$key} ne '') {
1.3 raeburn 2413: if (!exists($domconfig{'quotas'}{$key})) {
1.1 raeburn 2414: $changes{$key} = 1;
2415: }
2416: }
2417: }
2418: my %quotahash = (
1.3 raeburn 2419: quotas => {%formhash},
1.1 raeburn 2420: );
2421: my $putresult = &Apache::lonnet::put_dom('configuration',\%quotahash,
2422: $dom);
2423: if ($putresult eq 'ok') {
2424: if (keys(%changes) > 0) {
2425: $resulttext = &mt('Changes made:').'<ul>';
1.26 raeburn 2426: foreach my $type (@{$types},'default') {
2427: if (defined($changes{$type})) {
2428: my $typetitle = $usertypes->{$type};
2429: if ($type eq 'default') {
2430: $typetitle = $othertitle;
2431: }
2432: $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$formhash{$type}).'</li>';
2433: }
1.1 raeburn 2434: }
2435: $resulttext .= '</ul>';
2436: } else {
2437: $resulttext = &mt('No changes made to default quotas');
2438: }
2439: } else {
1.11 albertel 2440: $resulttext = '<span class="LC_error">'.
2441: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 2442: }
1.3 raeburn 2443: return $resulttext;
1.1 raeburn 2444: }
2445:
1.3 raeburn 2446: sub modify_autoenroll {
2447: my ($dom,%domconfig) = @_;
1.1 raeburn 2448: my ($resulttext,%changes);
2449: my %currautoenroll;
2450: if (ref($domconfig{'autoenroll'}) eq 'HASH') {
2451: foreach my $key (keys(%{$domconfig{'autoenroll'}})) {
2452: $currautoenroll{$key} = $domconfig{'autoenroll'}{$key};
2453: }
2454: }
2455: my $autorun = &Apache::lonnet::auto_run(undef,$dom),
2456: my %title = ( run => 'Auto-enrollment active',
2457: sender => 'Sender for notification messages');
2458: my @offon = ('off','on');
1.17 raeburn 2459: my $sender_uname = $env{'form.sender_uname'};
2460: my $sender_domain = $env{'form.sender_domain'};
2461: if ($sender_domain eq '') {
2462: $sender_uname = '';
2463: } elsif ($sender_uname eq '') {
2464: $sender_domain = '';
2465: }
1.1 raeburn 2466: my %autoenrollhash = (
2467: autoenroll => { run => $env{'form.autoenroll_run'},
1.17 raeburn 2468: sender_uname => $sender_uname,
2469: sender_domain => $sender_domain,
1.1 raeburn 2470:
2471: }
2472: );
1.4 raeburn 2473: my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
2474: $dom);
1.1 raeburn 2475: if ($putresult eq 'ok') {
2476: if (exists($currautoenroll{'run'})) {
2477: if ($currautoenroll{'run'} ne $env{'form.autoenroll_run'}) {
2478: $changes{'run'} = 1;
2479: }
2480: } elsif ($autorun) {
2481: if ($env{'form.autoenroll_run'} ne '1') {
1.23 raeburn 2482: $changes{'run'} = 1;
1.1 raeburn 2483: }
2484: }
1.17 raeburn 2485: if ($currautoenroll{'sender_uname'} ne $sender_uname) {
1.1 raeburn 2486: $changes{'sender'} = 1;
2487: }
1.17 raeburn 2488: if ($currautoenroll{'sender_domain'} ne $sender_domain) {
1.1 raeburn 2489: $changes{'sender'} = 1;
2490: }
2491: if (keys(%changes) > 0) {
2492: $resulttext = &mt('Changes made:').'<ul>';
1.3 raeburn 2493: if ($changes{'run'}) {
1.1 raeburn 2494: $resulttext .= '<li>'.&mt("$title{'run'} set to $offon[$env{'form.autoenroll_run'}]").'</li>';
2495: }
2496: if ($changes{'sender'}) {
1.17 raeburn 2497: if ($sender_uname eq '' || $sender_domain eq '') {
2498: $resulttext .= '<li>'.&mt("$title{'sender'} set to default (course owner).").'</li>';
2499: } else {
2500: $resulttext .= '<li>'.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'</li>';
2501: }
1.1 raeburn 2502: }
2503: $resulttext .= '</ul>';
2504: } else {
2505: $resulttext = &mt('No changes made to auto-enrollment settings');
2506: }
2507: } else {
1.11 albertel 2508: $resulttext = '<span class="LC_error">'.
2509: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 2510: }
1.3 raeburn 2511: return $resulttext;
1.1 raeburn 2512: }
2513:
2514: sub modify_autoupdate {
1.3 raeburn 2515: my ($dom,%domconfig) = @_;
1.1 raeburn 2516: my ($resulttext,%currautoupdate,%fields,%changes);
2517: if (ref($domconfig{'autoupdate'}) eq 'HASH') {
2518: foreach my $key (keys(%{$domconfig{'autoupdate'}})) {
2519: $currautoupdate{$key} = $domconfig{'autoupdate'}{$key};
2520: }
2521: }
2522: my @offon = ('off','on');
2523: my %title = &Apache::lonlocal::texthash (
2524: run => 'Auto-update:',
2525: classlists => 'Updates to user information in classlists?'
2526: );
1.26 raeburn 2527: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.1 raeburn 2528: my %fieldtitles = &Apache::lonlocal::texthash (
2529: id => 'Student/Employee ID',
1.20 raeburn 2530: permanentemail => 'E-mail address',
1.1 raeburn 2531: lastname => 'Last Name',
2532: firstname => 'First Name',
2533: middlename => 'Middle Name',
2534: gen => 'Generation',
2535: );
2536: my $othertitle = &mt('All users');
2537: if (keys(%{$usertypes}) > 0) {
1.26 raeburn 2538: $othertitle = &mt('Other users');
1.1 raeburn 2539: }
2540: foreach my $key (keys(%env)) {
2541: if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {
2542: push(@{$fields{$1}},$2);
2543: }
2544: }
2545: my %updatehash = (
2546: autoupdate => { run => $env{'form.autoupdate_run'},
2547: classlists => $env{'form.classlists'},
2548: fields => {%fields},
2549: }
2550: );
2551: foreach my $key (keys(%currautoupdate)) {
2552: if (($key eq 'run') || ($key eq 'classlists')) {
2553: if (exists($updatehash{autoupdate}{$key})) {
2554: if ($currautoupdate{$key} ne $updatehash{autoupdate}{$key}) {
2555: $changes{$key} = 1;
2556: }
2557: }
2558: } elsif ($key eq 'fields') {
2559: if (ref($currautoupdate{$key}) eq 'HASH') {
1.26 raeburn 2560: foreach my $item (@{$types},'default') {
1.1 raeburn 2561: if (ref($currautoupdate{$key}{$item}) eq 'ARRAY') {
2562: my $change = 0;
2563: foreach my $type (@{$currautoupdate{$key}{$item}}) {
2564: if (!exists($fields{$item})) {
2565: $change = 1;
2566: } elsif (ref($fields{$item}) eq 'ARRAY') {
1.26 raeburn 2567: if (!grep(/^\Q$type\E$/,@{$fields{$item}})) {
1.1 raeburn 2568: $change = 1;
2569: }
2570: }
2571: }
2572: if ($change) {
2573: push(@{$changes{$key}},$item);
2574: }
1.26 raeburn 2575: }
1.1 raeburn 2576: }
2577: }
2578: }
2579: }
1.26 raeburn 2580: foreach my $item (@{$types},'default') {
2581: if (defined($fields{$item})) {
2582: if (ref($currautoupdate{'fields'}) eq 'HASH') {
2583: if (!exists($currautoupdate{'fields'}{$item})) {
2584: push(@{$changes{'fields'}},$item);
2585: }
2586: } else {
2587: push(@{$changes{'fields'}},$item);
1.1 raeburn 2588: }
2589: }
2590: }
2591: my $putresult = &Apache::lonnet::put_dom('configuration',\%updatehash,
2592: $dom);
2593: if ($putresult eq 'ok') {
2594: if (keys(%changes) > 0) {
2595: $resulttext = &mt('Changes made:').'<ul>';
2596: foreach my $key (sort(keys(%changes))) {
2597: if (ref($changes{$key}) eq 'ARRAY') {
2598: foreach my $item (@{$changes{$key}}) {
2599: my @newvalues;
2600: foreach my $type (@{$fields{$item}}) {
2601: push(@newvalues,$fieldtitles{$type});
2602: }
1.3 raeburn 2603: my $newvaluestr;
2604: if (@newvalues > 0) {
2605: $newvaluestr = join(', ',@newvalues);
2606: } else {
2607: $newvaluestr = &mt('none');
1.6 raeburn 2608: }
1.1 raeburn 2609: if ($item eq 'default') {
1.26 raeburn 2610: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$othertitle,$newvaluestr).'</li>';
1.1 raeburn 2611: } else {
1.26 raeburn 2612: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$usertypes->{$item},$newvaluestr).'</li>';
1.1 raeburn 2613: }
2614: }
2615: } else {
2616: my $newvalue;
2617: if ($key eq 'run') {
2618: $newvalue = $offon[$env{'form.autoupdate_run'}];
2619: } else {
2620: $newvalue = $offon[$env{'form.'.$key}];
1.3 raeburn 2621: }
1.1 raeburn 2622: $resulttext .= '<li>'.&mt("[_1] set to $newvalue",$title{$key}).'</li>';
2623: }
2624: }
2625: $resulttext .= '</ul>';
2626: } else {
1.3 raeburn 2627: $resulttext = &mt('No changes made to autoupdates');
1.1 raeburn 2628: }
2629: } else {
1.11 albertel 2630: $resulttext = '<span class="LC_error">'.
2631: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 2632: }
1.3 raeburn 2633: return $resulttext;
1.1 raeburn 2634: }
2635:
1.23 raeburn 2636: sub modify_directorysrch {
2637: my ($dom,%domconfig) = @_;
2638: my ($resulttext,%changes);
2639: my %currdirsrch;
2640: if (ref($domconfig{'directorysrch'}) eq 'HASH') {
2641: foreach my $key (keys(%{$domconfig{'directorysrch'}})) {
2642: $currdirsrch{$key} = $domconfig{'directorysrch'}{$key};
2643: }
2644: }
2645: my %title = ( available => 'Directory search available',
1.24 raeburn 2646: localonly => 'Other domains can search',
1.23 raeburn 2647: searchby => 'Search types',
2648: searchtypes => 'Search latitude');
2649: my @offon = ('off','on');
1.24 raeburn 2650: my @otherdoms = ('Yes','No');
1.23 raeburn 2651:
1.25 raeburn 2652: my @searchtypes = &Apache::loncommon::get_env_multiple('form.searchtypes');
1.23 raeburn 2653: my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch');
2654: my @searchby = &Apache::loncommon::get_env_multiple('form.searchby');
2655:
1.26 raeburn 2656: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
2657: if (keys(%{$usertypes}) == 0) {
2658: @cansearch = ('default');
2659: } else {
2660: if (ref($currdirsrch{'cansearch'}) eq 'ARRAY') {
2661: foreach my $type (@{$currdirsrch{'cansearch'}}) {
2662: if (!grep(/^\Q$type\E$/,@cansearch)) {
2663: push(@{$changes{'cansearch'}},$type);
2664: }
1.23 raeburn 2665: }
1.26 raeburn 2666: foreach my $type (@cansearch) {
2667: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'cansearch'}})) {
2668: push(@{$changes{'cansearch'}},$type);
2669: }
1.23 raeburn 2670: }
1.26 raeburn 2671: } else {
2672: push(@{$changes{'cansearch'}},@cansearch);
1.23 raeburn 2673: }
2674: }
2675:
2676: if (ref($currdirsrch{'searchby'}) eq 'ARRAY') {
2677: foreach my $by (@{$currdirsrch{'searchby'}}) {
2678: if (!grep(/^\Q$by\E$/,@searchby)) {
2679: push(@{$changes{'searchby'}},$by);
2680: }
2681: }
2682: foreach my $by (@searchby) {
2683: if (!grep(/^\Q$by\E$/,@{$currdirsrch{'searchby'}})) {
2684: push(@{$changes{'searchby'}},$by);
2685: }
2686: }
2687: } else {
2688: push(@{$changes{'searchby'}},@searchby);
2689: }
1.25 raeburn 2690:
2691: if (ref($currdirsrch{'searchtypes'}) eq 'ARRAY') {
2692: foreach my $type (@{$currdirsrch{'searchtypes'}}) {
2693: if (!grep(/^\Q$type\E$/,@searchtypes)) {
2694: push(@{$changes{'searchtypes'}},$type);
2695: }
2696: }
2697: foreach my $type (@searchtypes) {
2698: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'searchtypes'}})) {
2699: push(@{$changes{'searchtypes'}},$type);
2700: }
2701: }
2702: } else {
2703: if (exists($currdirsrch{'searchtypes'})) {
2704: foreach my $type (@searchtypes) {
2705: if ($type ne $currdirsrch{'searchtypes'}) {
2706: push(@{$changes{'searchtypes'}},$type);
2707: }
2708: }
2709: if (!grep(/^\Q$currdirsrch{'searchtypes'}\E/,@searchtypes)) {
2710: push(@{$changes{'searchtypes'}},$currdirsrch{'searchtypes'});
2711: }
2712: } else {
2713: push(@{$changes{'searchtypes'}},@searchtypes);
2714: }
2715: }
2716:
1.23 raeburn 2717: my %dirsrch_hash = (
2718: directorysrch => { available => $env{'form.dirsrch_available'},
2719: cansearch => \@cansearch,
1.24 raeburn 2720: localonly => $env{'form.dirsrch_localonly'},
1.23 raeburn 2721: searchby => \@searchby,
1.25 raeburn 2722: searchtypes => \@searchtypes,
1.23 raeburn 2723: }
2724: );
2725: my $putresult = &Apache::lonnet::put_dom('configuration',\%dirsrch_hash,
2726: $dom);
2727: if ($putresult eq 'ok') {
2728: if (exists($currdirsrch{'available'})) {
2729: if ($currdirsrch{'available'} ne $env{'form.dirsrch_available'}) {
2730: $changes{'available'} = 1;
2731: }
2732: } else {
2733: if ($env{'form.dirsrch_available'} eq '1') {
2734: $changes{'available'} = 1;
2735: }
2736: }
1.24 raeburn 2737: if (exists($currdirsrch{'localonly'})) {
2738: if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_localonly'}) {
2739: $changes{'localonly'} = 1;
2740: }
2741: } else {
2742: if ($env{'form.dirsrch_localonly'} eq '1') {
2743: $changes{'localonly'} = 1;
2744: }
2745: }
1.23 raeburn 2746: if (keys(%changes) > 0) {
2747: $resulttext = &mt('Changes made:').'<ul>';
2748: if ($changes{'available'}) {
2749: $resulttext .= '<li>'.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").'</li>';
2750: }
1.24 raeburn 2751: if ($changes{'localonly'}) {
2752: $resulttext .= '<li>'.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_localonly'}]").'</li>';
2753: }
2754:
1.23 raeburn 2755: if (ref($changes{'cansearch'}) eq 'ARRAY') {
2756: my $chgtext;
1.26 raeburn 2757: if (ref($usertypes) eq 'HASH') {
2758: if (keys(%{$usertypes}) > 0) {
2759: foreach my $type (@{$types}) {
2760: if (grep(/^\Q$type\E$/,@cansearch)) {
2761: $chgtext .= $usertypes->{$type}.'; ';
2762: }
2763: }
2764: if (grep(/^default$/,@cansearch)) {
2765: $chgtext .= $othertitle;
2766: } else {
2767: $chgtext =~ s/\; $//;
2768: }
2769: $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 2770: }
2771: }
2772: }
2773: if (ref($changes{'searchby'}) eq 'ARRAY') {
2774: my ($searchtitles,$titleorder) = &sorted_searchtitles();
2775: my $chgtext;
2776: foreach my $type (@{$titleorder}) {
2777: if (grep(/^\Q$type\E$/,@searchby)) {
2778: if (defined($searchtitles->{$type})) {
2779: $chgtext .= $searchtitles->{$type}.'; ';
2780: }
2781: }
2782: }
2783: $chgtext =~ s/\; $//;
2784: $resulttext .= '<li>'.&mt("$title{'searchby'} set to: [_1]",$chgtext).'</li>';
2785: }
1.25 raeburn 2786: if (ref($changes{'searchtypes'}) eq 'ARRAY') {
2787: my ($srchtypes_desc,$srchtypeorder) = &sorted_searchtypes();
2788: my $chgtext;
2789: foreach my $type (@{$srchtypeorder}) {
2790: if (grep(/^\Q$type\E$/,@searchtypes)) {
2791: if (defined($srchtypes_desc->{$type})) {
2792: $chgtext .= $srchtypes_desc->{$type}.'; ';
2793: }
2794: }
2795: }
2796: $chgtext =~ s/\; $//;
2797: $resulttext .= '<li>'.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).'</li>';
1.23 raeburn 2798: }
2799: $resulttext .= '</ul>';
2800: } else {
2801: $resulttext = &mt('No changes made to institution directory search settings');
2802: }
2803: } else {
2804: $resulttext = '<span class="LC_error">'.
1.27 raeburn 2805: &mt('An error occurred: [_1]',$putresult).'</span>';
2806: }
2807: return $resulttext;
2808: }
2809:
1.28 raeburn 2810: sub modify_contacts {
2811: my ($dom,%domconfig) = @_;
2812: my ($resulttext,%currsetting,%newsetting,%changes,%contacts_hash);
2813: if (ref($domconfig{'contacts'}) eq 'HASH') {
2814: foreach my $key (keys(%{$domconfig{'contacts'}})) {
2815: $currsetting{$key} = $domconfig{'contacts'}{$key};
2816: }
2817: }
2818: my (%others,%to);
2819: my @contacts = ('supportemail','adminemail');
2820: my @mailings = ('errormail','packagesmail','helpdeskmail');
2821: foreach my $type (@mailings) {
2822: @{$newsetting{$type}} =
2823: &Apache::loncommon::get_env_multiple('form.'.$type);
2824: foreach my $item (@contacts) {
2825: if (grep(/^\Q$item\E$/,@{$newsetting{$type}})) {
2826: $contacts_hash{contacts}{$type}{$item} = 1;
2827: } else {
2828: $contacts_hash{contacts}{$type}{$item} = 0;
2829: }
2830: }
2831: $others{$type} = $env{'form.'.$type.'_others'};
2832: $contacts_hash{contacts}{$type}{'others'} = $others{$type};
2833: }
2834: foreach my $item (@contacts) {
2835: $to{$item} = $env{'form.'.$item};
2836: $contacts_hash{'contacts'}{$item} = $to{$item};
2837: }
2838: if (keys(%currsetting) > 0) {
2839: foreach my $item (@contacts) {
2840: if ($to{$item} ne $currsetting{$item}) {
2841: $changes{$item} = 1;
2842: }
2843: }
2844: foreach my $type (@mailings) {
2845: foreach my $item (@contacts) {
2846: if (ref($currsetting{$type}) eq 'HASH') {
2847: if ($currsetting{$type}{$item} ne $contacts_hash{contacts}{$type}{$item}) {
2848: push(@{$changes{$type}},$item);
2849: }
2850: } else {
2851: push(@{$changes{$type}},@{$newsetting{$type}});
2852: }
2853: }
2854: if ($others{$type} ne $currsetting{$type}{'others'}) {
2855: push(@{$changes{$type}},'others');
2856: }
2857: }
2858: } else {
2859: my %default;
2860: $default{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
2861: $default{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
2862: $default{'errormail'} = 'adminemail';
2863: $default{'packagesmail'} = 'adminemail';
2864: $default{'helpdeskmail'} = 'supportemail';
2865: foreach my $item (@contacts) {
2866: if ($to{$item} ne $default{$item}) {
2867: $changes{$item} = 1;
2868: }
2869: }
2870: foreach my $type (@mailings) {
2871: if ((@{$newsetting{$type}} != 1) || ($newsetting{$type}[0] ne $default{$type})) {
2872:
2873: push(@{$changes{$type}},@{$newsetting{$type}});
2874: }
2875: if ($others{$type} ne '') {
2876: push(@{$changes{$type}},'others');
2877: }
2878: }
2879: }
2880: my $putresult = &Apache::lonnet::put_dom('configuration',\%contacts_hash,
2881: $dom);
2882: if ($putresult eq 'ok') {
2883: if (keys(%changes) > 0) {
2884: my ($titles,$short_titles) = &contact_titles();
2885: $resulttext = &mt('Changes made:').'<ul>';
2886: foreach my $item (@contacts) {
2887: if ($changes{$item}) {
2888: $resulttext .= '<li>'.$titles->{$item}.
2889: &mt(' set to: ').
2890: '<span class="LC_cusr_emph">'.
2891: $to{$item}.'</span></li>';
2892: }
2893: }
2894: foreach my $type (@mailings) {
2895: if (ref($changes{$type}) eq 'ARRAY') {
2896: $resulttext .= '<li>'.$titles->{$type}.': ';
2897: my @text;
2898: foreach my $item (@{$newsetting{$type}}) {
2899: push(@text,$short_titles->{$item});
2900: }
2901: if ($others{$type} ne '') {
2902: push(@text,$others{$type});
2903: }
2904: $resulttext .= '<span class="LC_cusr_emph">'.
2905: join(', ',@text).'</span></li>';
2906: }
2907: }
2908: $resulttext .= '</ul>';
2909: } else {
1.34 raeburn 2910: $resulttext = &mt('No changes made to contact information');
1.28 raeburn 2911: }
2912: } else {
2913: $resulttext = '<span class="LC_error">'.
2914: &mt('An error occurred: [_1].',$putresult).'</span>';
2915: }
2916: return $resulttext;
2917: }
2918:
2919: sub modify_usercreation {
1.27 raeburn 2920: my ($dom,%domconfig) = @_;
1.34 raeburn 2921: my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate);
1.27 raeburn 2922: if (ref($domconfig{'usercreation'}) eq 'HASH') {
2923: foreach my $key (keys(%{$domconfig{'usercreation'}})) {
2924: $curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
2925: }
2926: }
2927: my %title = &Apache::lonlocal::texthash (
2928: author => 'adding co-authors/assistant authors',
2929: course => 'adding users to a course',
2930: );
2931: my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
1.32 raeburn 2932: my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
1.34 raeburn 2933: my @contexts = ('author','course');
2934: foreach my $item(@contexts) {
2935: $cancreate{$item} = $env{'form.can_createuser_'.$item};
2936: }
2937: if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
2938: foreach my $item (@contexts) {
2939: if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) {
2940: push(@{$changes{'cancreate'}},$item);
2941: }
1.27 raeburn 2942: }
1.34 raeburn 2943: } elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
2944: foreach my $item (@contexts) {
2945: if (grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) {
2946: if ($cancreate{$item} ne 'any') {
2947: push(@{$changes{'cancreate'}},$item);
2948: }
2949: } else {
2950: if ($cancreate{$item} ne 'none') {
2951: push(@{$changes{'cancreate'}},$item);
2952: }
1.27 raeburn 2953: }
2954: }
2955: } else {
1.34 raeburn 2956: foreach my $item ('author','course') {
2957: push(@{$changes{'cancreate'}},$item);
2958: }
1.27 raeburn 2959: }
1.34 raeburn 2960:
1.27 raeburn 2961: if (ref($curr_usercreation{'username_rule'}) eq 'ARRAY') {
2962: foreach my $type (@{$curr_usercreation{'username_rule'}}) {
2963: if (!grep(/^\Q$type\E$/,@username_rule)) {
2964: push(@{$changes{'username_rule'}},$type);
2965: }
2966: }
2967: foreach my $type (@username_rule) {
2968: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'username_rule'}})) {
2969: push(@{$changes{'username_rule'}},$type);
2970: }
2971: }
2972: } else {
2973: push(@{$changes{'username_rule'}},@username_rule);
2974: }
2975:
1.32 raeburn 2976: if (ref($curr_usercreation{'id_rule'}) eq 'ARRAY') {
2977: foreach my $type (@{$curr_usercreation{'id_rule'}}) {
2978: if (!grep(/^\Q$type\E$/,@id_rule)) {
2979: push(@{$changes{'id_rule'}},$type);
2980: }
2981: }
2982: foreach my $type (@id_rule) {
2983: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'id_rule'}})) {
2984: push(@{$changes{'id_rule'}},$type);
2985: }
2986: }
2987: } else {
2988: push(@{$changes{'id_rule'}},@id_rule);
2989: }
2990:
1.28 raeburn 2991: my @contexts = ('author','course','domain');
2992: my @authtypes = ('int','krb4','krb5','loc');
2993: my %authhash;
2994: foreach my $item (@contexts) {
2995: my @authallowed = &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');
2996: foreach my $auth (@authtypes) {
2997: if (grep(/^\Q$auth\E$/,@authallowed)) {
2998: $authhash{$item}{$auth} = 1;
2999: } else {
3000: $authhash{$item}{$auth} = 0;
3001: }
3002: }
3003: }
3004: if (ref($curr_usercreation{'authtypes'}) eq 'HASH') {
3005: foreach my $item (@contexts) {
3006: if (ref($curr_usercreation{'authtypes'}{$item}) eq 'HASH') {
3007: foreach my $auth (@authtypes) {
3008: if ($authhash{$item}{$auth} ne $curr_usercreation{'authtypes'}{$item}{$auth}) {
3009: push(@{$changes{'authtypes'}},$item);
3010: last;
3011: }
3012: }
3013: }
3014: }
3015: } else {
3016: foreach my $item (@contexts) {
3017: push(@{$changes{'authtypes'}},$item);
3018: }
3019: }
3020:
1.27 raeburn 3021: my %usercreation_hash = (
1.28 raeburn 3022: usercreation => {
1.34 raeburn 3023: cancreate => \%cancreate,
1.27 raeburn 3024: username_rule => \@username_rule,
1.32 raeburn 3025: id_rule => \@id_rule,
3026: authtypes => \%authhash,
1.27 raeburn 3027: }
3028: );
3029:
3030: my $putresult = &Apache::lonnet::put_dom('configuration',\%usercreation_hash,
3031: $dom);
3032: if ($putresult eq 'ok') {
3033: if (keys(%changes) > 0) {
3034: $resulttext = &mt('Changes made:').'<ul>';
3035: if (ref($changes{'cancreate'}) eq 'ARRAY') {
1.34 raeburn 3036: my %lt = &usercreation_types();
3037: foreach my $type (@{$changes{'cancreate'}}) {
3038: my $chgtext;
3039: if ($cancreate{$type} eq 'none') {
3040: $chgtext = $lt{$type}.' '.&mt('creation of new users is not permitted, except by a Domain Coordinator.');
3041: } elsif ($cancreate{$type} eq 'any') {
3042: $chgtext = $lt{$type}.' '.&mt('creation of new users is permitted for both institutional and non-institutional usernames.');
3043: } elsif ($cancreate{$type} eq 'official') {
3044: $chgtext = $lt{$type}.' '.&mt('creation of new users is only permitted for institutional usernames.',$lt{$type});
3045: } elsif ($cancreate{$type} eq 'unofficial') {
3046: $chgtext = $lt{$type}.' '.&mt('creation of new users is only permitted for non-institutional usernames.',$lt{$type});
3047: }
3048: $resulttext .= '<li>'.$chgtext.'</li>';
1.27 raeburn 3049: }
3050: }
3051: if (ref($changes{'username_rule'}) eq 'ARRAY') {
1.32 raeburn 3052: my ($rules,$ruleorder) =
3053: &Apache::lonnet::inst_userrules($dom,'username');
1.27 raeburn 3054: my $chgtext = '<ul>';
3055: foreach my $type (@username_rule) {
3056: if (ref($rules->{$type}) eq 'HASH') {
3057: $chgtext .= '<li>'.$rules->{$type}{'name'}.'</li>';
3058: }
3059: }
3060: $chgtext .= '</ul>';
3061: if (@username_rule > 0) {
3062: $resulttext .= '<li>'.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
3063: } else {
1.28 raeburn 3064: $resulttext .= '<li>'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'</li>';
1.27 raeburn 3065: }
3066: }
1.32 raeburn 3067: if (ref($changes{'id_rule'}) eq 'ARRAY') {
3068: my ($idrules,$idruleorder) =
3069: &Apache::lonnet::inst_userrules($dom,'id');
3070: my $chgtext = '<ul>';
3071: foreach my $type (@id_rule) {
3072: if (ref($idrules->{$type}) eq 'HASH') {
3073: $chgtext .= '<li>'.$idrules->{$type}{'name'}.'</li>';
3074: }
3075: }
3076: $chgtext .= '</ul>';
3077: if (@id_rule > 0) {
3078: $resulttext .= '<li>'.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
3079: } else {
3080: $resulttext .= '<li>'.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'</li>';
3081: }
3082: }
1.28 raeburn 3083: my %authname = &authtype_names();
3084: my %context_title = &context_names();
3085: if (ref($changes{'authtypes'}) eq 'ARRAY') {
3086: my $chgtext = '<ul>';
3087: foreach my $type (@{$changes{'authtypes'}}) {
3088: my @allowed;
3089: $chgtext .= '<li><span class="LC_cusr_emph">'.$context_title{$type}.'</span> - '.&mt('assignable authentication types: ');
3090: foreach my $auth (@authtypes) {
3091: if ($authhash{$type}{$auth}) {
3092: push(@allowed,$authname{$auth});
3093: }
3094: }
3095: $chgtext .= join(', ',@allowed).'</li>';
3096: }
3097: $chgtext .= '</ul>';
3098: $resulttext .= '<li>'.&mt('Authentication types available for assignment to new users').'<br />'.$chgtext;
3099: $resulttext .= '</li>';
3100: }
1.27 raeburn 3101: $resulttext .= '</ul>';
3102: } else {
1.28 raeburn 3103: $resulttext = &mt('No changes made to user creation settings');
1.27 raeburn 3104: }
3105: } else {
3106: $resulttext = '<span class="LC_error">'.
1.23 raeburn 3107: &mt('An error occurred: [_1]',$putresult).'</span>';
3108: }
3109: return $resulttext;
3110: }
3111:
1.33 raeburn 3112: sub modify_usermodification {
3113: my ($dom,%domconfig) = @_;
3114: my ($resulttext,%curr_usermodification,%changes);
3115: if (ref($domconfig{'usermodification'}) eq 'HASH') {
3116: foreach my $key (keys(%{$domconfig{'usermodification'}})) {
3117: $curr_usermodification{$key} = $domconfig{'usermodification'}{$key};
3118: }
3119: }
3120: my @contexts = ('author','course');
3121: my %context_title = (
3122: author => 'In author context',
3123: course => 'In course context',
3124: );
3125: my @fields = ('lastname','firstname','middlename','generation',
3126: 'permanentemail','id');
3127: my %roles = (
3128: author => ['ca','aa'],
3129: course => ['st','ep','ta','in','cr'],
3130: );
3131: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
3132: my %modifyhash;
3133: foreach my $context (@contexts) {
3134: foreach my $role (@{$roles{$context}}) {
3135: my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role);
3136: foreach my $item (@fields) {
3137: if (grep(/^\Q$item\E$/,@modifiable)) {
3138: $modifyhash{$context}{$role}{$item} = 1;
3139: } else {
3140: $modifyhash{$context}{$role}{$item} = 0;
3141: }
3142: }
3143: }
3144: if (ref($curr_usermodification{$context}) eq 'HASH') {
3145: foreach my $role (@{$roles{$context}}) {
3146: if (ref($curr_usermodification{$context}{$role}) eq 'HASH') {
3147: foreach my $field (@fields) {
3148: if ($modifyhash{$context}{$role}{$field} ne
3149: $curr_usermodification{$context}{$role}{$field}) {
3150: push(@{$changes{$context}},$role);
3151: last;
3152: }
3153: }
3154: }
3155: }
3156: } else {
3157: foreach my $context (@contexts) {
3158: foreach my $role (@{$roles{$context}}) {
3159: push(@{$changes{$context}},$role);
3160: }
3161: }
3162: }
3163: }
3164: my %usermodification_hash = (
3165: usermodification => \%modifyhash,
3166: );
3167: my $putresult = &Apache::lonnet::put_dom('configuration',
3168: \%usermodification_hash,$dom);
3169: if ($putresult eq 'ok') {
3170: if (keys(%changes) > 0) {
3171: $resulttext = &mt('Changes made: ').'<ul>';
3172: foreach my $context (@contexts) {
3173: if (ref($changes{$context}) eq 'ARRAY') {
3174: $resulttext .= '<li>'.$context_title{$context}.':<ul>';
3175: if (ref($changes{$context}) eq 'ARRAY') {
3176: foreach my $role (@{$changes{$context}}) {
3177: my $rolename;
3178: if ($role eq 'cr') {
3179: $rolename = &mt('Custom');
3180: } else {
3181: $rolename = &Apache::lonnet::plaintext($role);
3182: }
3183: my @modifiable;
3184: $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');
3185: foreach my $field (@fields) {
3186: if ($modifyhash{$context}{$role}{$field}) {
3187: push(@modifiable,$fieldtitles{$field});
3188: }
3189: }
3190: if (@modifiable > 0) {
3191: $resulttext .= join(', ',@modifiable);
3192: } else {
3193: $resulttext .= &mt('none');
3194: }
3195: $resulttext .= '</li>';
3196: }
3197: $resulttext .= '</ul></li>';
3198: }
3199: }
3200: }
3201: $resulttext .= '</ul>';
3202: } else {
3203: $resulttext = &mt('No changes made to user modification settings');
3204: }
3205: } else {
3206: $resulttext = '<span class="LC_error">'.
3207: &mt('An error occurred: [_1]',$putresult).'</span>';
3208: }
3209: return $resulttext;
3210: }
3211:
1.3 raeburn 3212: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>