Annotation of loncom/interface/domainprefs.pm, revision 1.26
1.1 raeburn 1: # The LearningOnline Network with CAPA
2: # Handler to set domain-wide configuration settings
3: #
1.26 ! raeburn 4: # $Id: domainprefs.pm,v 1.25 2007/08/26 15:31:03 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.3 raeburn 64: my $phase = "display";
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.23 raeburn 70: 'quotas','autoenroll','autoupdate','directorysrch'],$dom);
1.3 raeburn 71: my @prefs = (
1.6 raeburn 72: { text => 'Default color schemes',
73: help => 'Default_Color_Schemes',
74: action => 'rolecolors',
75: header => [{col1 => 'Student Settings',
76: col2 => '',},
77: {col1 => 'Coordinator Settings',
78: col2 => '',},
79: {col1 => 'Author Settings',
80: col2 => '',},
81: {col1 => 'Administrator Settings',
82: col2 => '',}],
83: },
1.3 raeburn 84: { text => 'Log-in page options',
85: help => 'Domain_Log-in_Page',
86: action => 'login',
87: header => [{col1 => 'Item',
1.6 raeburn 88: col2 => '',}],
1.3 raeburn 89: },
90: { text => 'Default quotas for user portfolios',
91: help => 'Default_User_Quota',
92: action => 'quotas',
93: header => [{col1 => 'User type',
94: col2 => 'Default quota'}],
95: },
96: { text => 'Auto-enrollment settings',
97: help => 'Domain_Auto_Enrollment',
98: action => 'autoenroll',
99: header => [{col1 => 'Configuration setting',
100: col2 => 'Value(s)'}],
101: },
102: { text => 'Auto-update settings',
103: help => 'Domain_Auto_Update',
104: action => 'autoupdate',
105: header => [{col1 => 'Setting',
106: col2 => 'Value',},
107: {col1 => 'User Population',
108: col2 => 'Updataeable user data'}],
1.23 raeburn 109: },
110: { text => 'Institutional directory searches',
111: help => 'Domain_Directory_Search',
112: action => 'directorysrch',
113: header => [{col1 => 'Setting',
114: col2 => 'Value',}],
115: },
1.3 raeburn 116: );
1.6 raeburn 117: my @roles = ('student','coordinator','author','admin');
1.3 raeburn 118: &Apache::lonhtmlcommon::add_breadcrumb
119: ({href=>"javascript:changePage(document.$phase,'display')",
120: text=>"Domain Configuration"});
1.9 raeburn 121: my $confname = $dom.'-domainconfig';
1.3 raeburn 122: if ($phase eq 'process') {
1.1 raeburn 123: &Apache::lonhtmlcommon::add_breadcrumb
1.3 raeburn 124: ({href=>"javascript:changePage(document.$phase,'$phase')",
125: text=>"Updated"});
126: &print_header($r,$phase);
127: foreach my $item (@prefs) {
128: $r->print('<h3>'.&mt($item->{'text'}).'</h3>'.
1.9 raeburn 129: &process_changes($r,$dom,$confname,
130: $item->{'action'},\@roles,%domconfig));
1.3 raeburn 131: }
132: $r->print('<p>');
133: &print_footer($r,$phase,'display','Back to actions menu');
134: $r->print('</p>');
1.1 raeburn 135: } else {
1.3 raeburn 136: if ($phase eq '') {
137: $phase = 'display';
1.1 raeburn 138: }
1.3 raeburn 139: my %helphash;
140: my $numprefs = @prefs;
141: &print_header($r,$phase);
1.21 raeburn 142: if (keys(%domconfig) == 0) {
143: my $primarylibserv = &Apache::lonnet::domain($dom,'primary');
144: my $perlvarref = &LONCAPA::Configuration::read_conf('loncapa.conf');
145: my $hostid = $perlvarref->{'lonHostID'};
146: if ($hostid ne $primarylibserv) {
147: my %designhash = &Apache::loncommon::get_domainconf($dom);
148: my @loginimages = ('img','logo','domlogo');
149: my $custom_img_count = 0;
150: foreach my $img (@loginimages) {
151: if ($designhash{$dom.'.login.'.$img} ne '') {
152: $custom_img_count ++;
153: }
154: }
155: foreach my $role (@roles) {
156: if ($designhash{$dom.'.'.$role.'.img'} ne '') {
157: $custom_img_count ++;
158: }
159: }
160: if ($custom_img_count > 0) {
161: my $switch_server = &check_switchserver($dom,$confname);
162: $r->print(&mt('Domain configuration settings have yet to be saved for this domain via the web-based domain preferences interface.').'<br />'.&mt("While this remains so, you must switch to the domain's primary library server in order to update settings.").'<br /><br />'.&mt("Thereafter, you will be able to update settings from this screen when logged in to any server in the LON-CAPA network (with a DC role selected in the domain), although you will still need to switch to the domain's primary library server to upload new images or logos.").'<br /><br />'.$switch_server.' '.&mt('to primary library server for domain: [_1]',$dom));
163: return OK;
164: }
165: }
166: }
1.3 raeburn 167: $r->print('<table border="0" width="100%" cellpadding="2" cellspacing="4"><tr><td align="left" valign="top" width="45%">');
168: foreach my $item (@prefs) {
1.6 raeburn 169: if ($item->{'action'} eq 'login') {
1.3 raeburn 170: $r->print('</td><td width="6%"> </td><td align="left" valign="top" width="47%">');
171: }
1.9 raeburn 172: &print_config_box($r,$dom,$confname,$phase,$item->{'action'},
1.6 raeburn 173: $item,$domconfig{$item->{'action'}});
1.3 raeburn 174: }
175: $r->print('
176: </td>
177: </tr>
178: </table>');
1.13 albertel 179: &print_footer($r,$phase,'process','Save changes');
1.3 raeburn 180: }
181: return OK;
182: }
183:
184: sub process_changes {
1.9 raeburn 185: my ($r,$dom,$confname,$action,$roles,%domconfig) = @_;
1.3 raeburn 186: my $output;
187: if ($action eq 'login') {
1.9 raeburn 188: $output = &modify_login($r,$dom,$confname,%domconfig);
1.6 raeburn 189: } elsif ($action eq 'rolecolors') {
1.9 raeburn 190: $output = &modify_rolecolors($r,$dom,$confname,$roles,
191: %domconfig);
1.3 raeburn 192: } elsif ($action eq 'quotas') {
193: $output = &modify_quotas($dom,%domconfig);
194: } elsif ($action eq 'autoenroll') {
195: $output = &modify_autoenroll($dom,%domconfig);
196: } elsif ($action eq 'autoupdate') {
197: $output = &modify_autoupdate($dom,%domconfig);
1.23 raeburn 198: } elsif ($action eq 'directorysrch') {
199: $output = &modify_directorysrch($dom,%domconfig);
1.3 raeburn 200: }
201: return $output;
202: }
203:
204: sub print_config_box {
1.9 raeburn 205: my ($r,$dom,$confname,$phase,$action,$item,$settings) = @_;
1.3 raeburn 206: $r->print('
207: <table class="LC_nested_outer">
208: <tr>
1.22 raeburn 209: <th>'.&mt($item->{text}).' </th></tr>');
210: #
211: # FIXME - put the help link back in when the help files exist
212: # <th>'.&mt($item->{text}).' '.
213: # &Apache::loncommon::help_open_topic($item->{'help'}).'</th>
214: # </tr>');
1.6 raeburn 215: if (($action eq 'autoupdate') || ($action eq 'rolecolors')) {
216: my $colspan = ($action eq 'rolecolors')?' colspan="2"':'';
1.3 raeburn 217: $r->print('
218: <tr>
219: <td>
220: <table class="LC_nested">
221: <tr class="LC_info_row">
1.6 raeburn 222: <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[0]->{'col1'}.'</td>
1.3 raeburn 223: <td class="LC_right_item">'.$item->{'header'}->[0]->{'col2'}.'</td>
1.6 raeburn 224: </tr>');
225: if ($action eq 'autoupdate') {
226: $r->print(&print_autoupdate('top',$dom,$settings));
227: } else {
1.9 raeburn 228: $r->print(&print_rolecolors($phase,'student',$dom,$confname,$settings));
1.6 raeburn 229: }
230: $r->print('
231: </table>
232: </td>
233: </tr>
234: <tr>
235: <td>
236: <table class="LC_nested">
237: <tr class="LC_info_row">
238: <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[1]->{'col1'}.'</td>
239: <td class="LC_right_item">'.$item->{'header'}->[1]->{'col2'}.'</td>
240: </tr>');
241: if ($action eq 'autoupdate') {
242: $r->print(&print_autoupdate('bottom',$dom,$settings));
243: } else {
1.9 raeburn 244: $r->print(&print_rolecolors($phase,'coordinator',$dom,$confname,$settings).'
1.6 raeburn 245: </table>
246: </td>
247: </tr>
248: <tr>
249: <td>
250: <table class="LC_nested">
251: <tr class="LC_info_row">
252: <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[2]->{'col1'}.'</td>
253: <td class="LC_right_item">'.$item->{'header'}->[2]->{'col2'}.'</td>
1.3 raeburn 254: </tr>'.
1.9 raeburn 255: &print_rolecolors($phase,'author',$dom,$confname,$settings).'
1.3 raeburn 256: </table>
257: </td>
258: </tr>
259: <tr>
260: <td>
261: <table class="LC_nested">
262: <tr class="LC_info_row">
1.6 raeburn 263: <td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[3]->{'col1'}.'</td>
264: <td class="LC_right_item">'.$item->{'header'}->[3]->{'col2'}.'</td>
1.3 raeburn 265: </tr>'.
1.9 raeburn 266: &print_rolecolors($phase,'admin',$dom,$confname,$settings));
1.6 raeburn 267: }
1.3 raeburn 268: } else {
269: $r->print('
270: <tr>
271: <td>
272: <table class="LC_nested">
1.6 raeburn 273: <tr class="LC_info_row">');
1.24 raeburn 274: if (($action eq 'login') || ($action eq 'directorysrch')) {
1.6 raeburn 275: $r->print('
276: <td class="LC_left_item" colspan="2">'.$item->{'header'}->[0]->{'col1'}.'</td>');
277: } else {
278: $r->print('
279: <td class="LC_left_item">'.$item->{'header'}->[0]->{'col1'}.'</td>');
280: }
281: $r->print('
1.3 raeburn 282: <td class="LC_right_item">'.$item->{'header'}->[0]->{'col2'}.'</td>
283: </tr>');
284: if ($action eq 'login') {
1.9 raeburn 285: $r->print(&print_login($dom,$confname,$phase,$settings));
1.3 raeburn 286: } elsif ($action eq 'quotas') {
287: $r->print(&print_quotas($dom,$settings));
288: } elsif ($action eq 'autoenroll') {
289: $r->print(&print_autoenroll($dom,$settings));
1.23 raeburn 290: } elsif ($action eq 'directorysrch') {
291: $r->print(&print_directorysrch($dom,$settings));
1.3 raeburn 292: }
293: }
294: $r->print('
295: </table>
296: </td>
297: </tr>
298: </table><br />');
1.1 raeburn 299: return;
300: }
301:
302: sub print_header {
1.3 raeburn 303: my ($r,$phase) = @_;
1.6 raeburn 304: my $js = '
1.1 raeburn 305: <script type="text/javascript">
306: function changePage(formname,newphase) {
307: formname.phase.value = newphase;
308: formname.submit();
309: }
1.6 raeburn 310: '.
311: &color_pick_js().'
1.1 raeburn 312: </script>
1.6 raeburn 313: ';
1.2 albertel 314: $r->print(&Apache::loncommon::start_page('View/Modify Domain Settings',
1.3 raeburn 315: $js));
316: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Domain Settings'));
1.6 raeburn 317: $r->print('
1.8 raeburn 318: <form name="parmform" action="">
1.6 raeburn 319: <input type="hidden" name="pres_marker" />
320: <input type="hidden" name="pres_type" />
321: <input type="hidden" name="pres_value" />
322: </form>
323: ');
324: $r->print('<form method="post" name="'.$phase.'" action="/adm/domainprefs"'.
325: ' enctype="multipart/form-data">');
1.1 raeburn 326: return;
327: }
328:
329: sub print_footer {
1.3 raeburn 330: my ($r,$phase,$newphase,$button_text) = @_;
331: $button_text = &mt($button_text);
332: $r->print('<input type="hidden" name="phase" value="" />');
333: my $dest='"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
334: if ($phase eq 'process') {
335: $r->print('<a href='.$dest.'>'.$button_text.'</a>');
336: } else {
337: $r->print('<input type="button" name="store" value="'.
338: $button_text.'" onclick='.$dest.' />');
339: }
340: $r->print('</form>');
1.1 raeburn 341: $r->print('<br />'.&Apache::loncommon::end_page());
342: return;
343: }
344:
1.3 raeburn 345: sub print_login {
1.9 raeburn 346: my ($dom,$confname,$phase,$settings) = @_;
1.6 raeburn 347: my %choices = &login_choices();
348: my ($catalogon,$catalogoff,$adminmailon,$adminmailoff);
349: $catalogon = ' checked="checked" ';
350: $adminmailoff = ' checked="checked" ';
351: my @images = ('img','logo','domlogo');
352: my @bgs = ('pgbg','mainbg','sidebg');
353: my @links = ('link','alink','vlink');
1.7 albertel 354: my %designhash = &Apache::loncommon::get_domainconf($dom);
1.6 raeburn 355: my %defaultdesign = %Apache::loncommon::defaultdesign;
356: my (%is_custom,%designs);
357: my %defaults = (
358: font => $defaultdesign{'login.font'},
359: );
360: foreach my $item (@images) {
361: $defaults{$item} = $defaultdesign{'login.'.$item};
362: }
363: foreach my $item (@bgs) {
364: $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
365: }
366: foreach my $item (@links) {
367: $defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
368: }
1.3 raeburn 369: if (ref($settings) eq 'HASH') {
370: if ($settings->{'coursecatalog'} eq '0') {
1.1 raeburn 371: $catalogoff = $catalogon;
372: $catalogon = ' ';
373: }
1.3 raeburn 374: if ($settings->{'adminmail'} eq '1') {
1.1 raeburn 375: $adminmailon = $adminmailoff;
376: $adminmailoff = ' ';
377: }
1.6 raeburn 378: foreach my $item (@images) {
379: if ($settings->{$item} ne '') {
380: $designs{$item} = $settings->{$item};
381: $is_custom{$item} = 1;
382: }
383: }
384: if ($settings->{'font'} ne '') {
385: $designs{'font'} = $settings->{'font'};
386: $is_custom{'font'} = 1;
387: }
388: foreach my $item (@bgs) {
389: if ($settings->{$item} ne '') {
390: $designs{'bgs'}{$item} = $settings->{$item};
391: $is_custom{$item} = 1;
392: }
393: }
394: foreach my $item (@links) {
395: if ($settings->{$item} ne '') {
396: $designs{'links'}{$item} = $settings->{$item};
397: $is_custom{$item} = 1;
398: }
399: }
400: } else {
401: if ($designhash{$dom.'.login.font'} ne '') {
402: $designs{'font'} = $designhash{$dom.'.login.font'};
403: $is_custom{'font'} = 1;
404: }
1.8 raeburn 405: foreach my $item (@images) {
406: if ($designhash{$dom.'.login.'.$item} ne '') {
407: $designs{$item} = $designhash{$dom.'.login.'.$item};
408: $is_custom{$item} = 1;
409: }
410: }
1.6 raeburn 411: foreach my $item (@bgs) {
412: if ($designhash{$dom.'.login.'.$item} ne '') {
413: $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item};
414: $is_custom{$item} = 1;
415: }
416: }
417: foreach my $item (@links) {
418: if ($designhash{$dom.'.login.'.$item} ne '') {
419: $designs{'links'}{$item} = $designhash{$dom.'.login.'.$item};
420: $is_custom{$item} = 1;
421: }
422: }
1.1 raeburn 423: }
1.6 raeburn 424: my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
425: logo => 'Institution Logo',
426: domlogo => 'Domain Logo');
427: my $itemcount = 1;
428: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.3 raeburn 429: my $datatable =
1.6 raeburn 430: '<tr'.$css_class.'><td colspan="2">'.$choices{'coursecatalog'}.
431: '</td><td>'.
1.8 raeburn 432: '<span class="LC_nobreak"><label><input type="radio" name="coursecatalog"'.
433: $catalogon.' value="1" />'.&mt('Yes').'</label> '.
434: '<label><input type="radio" name="coursecatalog"'.
435: $catalogoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.6 raeburn 436: '</tr>';
437: $itemcount ++;
438: $css_class = $itemcount%2?' class="LC_odd_row"':'';
439: $datatable .= '<tr'.$css_class.'>'.
440: '<td colspan="2">'.$choices{'adminmail'}.'</td>'.
1.8 raeburn 441: '<td><span class="LC_nobreak">'.
442: '<label><input type="radio" name="adminmail"'.
443: $adminmailon.' value="1" />'.&mt('Yes').'</label> '.
444: '<label><input type="radio" name="adminmail"'.
445: $adminmailoff.'value="0" />'.&mt('No').'</label></span></td></tr>';
1.6 raeburn 446: $itemcount ++;
1.9 raeburn 447: $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text);
1.6 raeburn 448: $datatable .= '</tr></table></td></tr>';
449: return $datatable;
450: }
451:
452: sub login_choices {
453: my %choices =
454: &Apache::lonlocal::texthash (
455: coursecatalog => 'Display Course Catalog link?',
456: adminmail => "Display Administrator's E-mail Address?",
457: img => "Header",
458: logo => "Main Logo",
459: domlogo => "Domain Logo",
460: bgs => "Background colors",
461: links => "Link colors",
462: font => "Font color",
463: pgbg => "Page",
464: mainbg => "Main panel",
465: sidebg => "Side panel",
466: link => "Link",
467: alink => "Active link",
468: vlink => "Visited link",
469: );
470: return %choices;
471: }
472:
473: sub print_rolecolors {
1.9 raeburn 474: my ($phase,$role,$dom,$confname,$settings) = @_;
1.6 raeburn 475: my %choices = &color_font_choices();
476: my @bgs = ('pgbg','tabbg','sidebg');
477: my @links = ('link','alink','vlink');
478: my @images = ('img');
479: my %alt_text = &Apache::lonlocal::texthash(img => "Banner for $role role");
1.7 albertel 480: my %designhash = &Apache::loncommon::get_domainconf($dom);
1.6 raeburn 481: my %defaultdesign = %Apache::loncommon::defaultdesign;
482: my (%is_custom,%designs);
483: my %defaults = (
484: img => $defaultdesign{$role.'.img'},
485: font => $defaultdesign{$role.'.font'},
486: );
487: foreach my $item (@bgs) {
488: $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
489: }
490: foreach my $item (@links) {
491: $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
492: }
493: if (ref($settings) eq 'HASH') {
494: if (ref($settings->{$role}) eq 'HASH') {
495: if ($settings->{$role}->{'img'} ne '') {
496: $designs{'img'} = $settings->{$role}->{'img'};
497: $is_custom{'img'} = 1;
498: }
499: if ($settings->{$role}->{'font'} ne '') {
500: $designs{'font'} = $settings->{$role}->{'font'};
501: $is_custom{'font'} = 1;
502: }
503: foreach my $item (@bgs) {
504: if ($settings->{$role}->{$item} ne '') {
505: $designs{'bgs'}{$item} = $settings->{$role}->{$item};
506: $is_custom{$item} = 1;
507: }
508: }
509: foreach my $item (@links) {
510: if ($settings->{$role}->{$item} ne '') {
511: $designs{'links'}{$item} = $settings->{$role}->{$item};
512: $is_custom{$item} = 1;
513: }
514: }
515: }
516: } else {
517: if ($designhash{$dom.'.'.$role.'.img'} ne '') {
518: $designs{img} = $designhash{$dom.'.'.$role.'.img'};
519: $is_custom{'img'} = 1;
520: }
521: if ($designhash{$dom.'.'.$role.'.font'} ne '') {
522: $designs{font} = $designhash{$dom.'.'.$role.'.font'};
523: $is_custom{'font'} = 1;
524: }
525: foreach my $item (@bgs) {
526: if ($designhash{$dom.'.'.$role.'.'.$item} ne '') {
527: $designs{'bgs'}{$item} = $designhash{$dom.'.'.$role.'.'.$item};
528: $is_custom{$item} = 1;
529:
530: }
531: }
532: foreach my $item (@links) {
533: if ($designhash{$dom.'.'.$role.'.'.$item} ne '') {
534: $designs{'links'}{$item} = $designhash{$dom.'.'.$role.'.'.$item};
535: $is_custom{$item} = 1;
536: }
537: }
538: }
539: my $itemcount = 1;
1.9 raeburn 540: my $datatable = &display_color_options($dom,$confname,$phase,$role,$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text);
1.6 raeburn 541: $datatable .= '</tr></table></td></tr>';
542: return $datatable;
543: }
544:
545: sub display_color_options {
1.9 raeburn 546: my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
1.6 raeburn 547: $images,$bgs,$links,$alt_text) = @_;
548: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
549: my $datatable = '<tr'.$css_class.'>'.
550: '<td>'.$choices->{'font'}.'</td>';
551: if (!$is_custom->{'font'}) {
552: $datatable .= '<td>'.&mt('Default in use:').' '.$defaults->{'font'}.'</td>';
553: } else {
554: $datatable .= '<td> </td>';
555: }
556: my $fontlink = &color_pick($phase,$role,'font',$choices->{'font'},$designs->{'font'});
1.8 raeburn 557: $datatable .= '<td><span class="LC_nobreak">'.
1.6 raeburn 558: '<input type="text" size="10" name="'.$role.'_font"'.
1.8 raeburn 559: ' value="'.$designs->{'font'}.'" /> '.$fontlink.
560: '</span></td></tr>';
1.9 raeburn 561: my $switchserver = &check_switchserver($dom,$confname);
1.6 raeburn 562: foreach my $img (@{$images}) {
1.18 albertel 563: $itemcount ++;
1.6 raeburn 564: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.8 raeburn 565: $datatable .= '<tr'.$css_class.'>'.
1.6 raeburn 566: '<td>'.$choices->{$img}.'</td>';
1.18 albertel 567: my ($imgfile, $img_import);
1.6 raeburn 568: if ($designs->{$img} ne '') {
569: $imgfile = $designs->{$img};
1.18 albertel 570: $img_import = ($imgfile =~ m{^/adm/});
1.6 raeburn 571: } else {
572: $imgfile = $defaults->{$img};
573: }
574: if ($imgfile) {
1.9 raeburn 575: my ($showfile,$fullsize);
576: if ($imgfile =~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
1.6 raeburn 577: my $urldir = $1;
578: my $filename = $2;
579: my @info = &Apache::lonnet::stat_file($designs->{$img});
580: if (@info) {
581: my $thumbfile = 'tn-'.$filename;
582: my @thumb=&Apache::lonnet::stat_file($urldir.'/'.$thumbfile);
583: if (@thumb) {
584: $showfile = $urldir.'/'.$thumbfile;
585: } else {
586: $showfile = $imgfile;
587: }
588: } else {
589: $showfile = '';
590: }
591: } elsif ($imgfile =~ m-^/(adm/[^/]+)/([^/]+)$-) {
1.16 raeburn 592: $showfile = $imgfile;
1.6 raeburn 593: my $imgdir = $1;
594: my $filename = $2;
595: if (-e "/home/httpd/html/$imgdir/tn-".$filename) {
596: $showfile = "/$imgdir/tn-".$filename;
597: } else {
598: my $input = "/home/httpd/html".$imgfile;
599: my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename;
600: if (!-e $output) {
1.9 raeburn 601: my ($width,$height) = &thumb_dimensions();
1.16 raeburn 602: my ($fullwidth,$fullheight) = &check_dimensions($input);
603: if ($fullwidth ne '' && $fullheight ne '') {
604: if ($fullwidth > $width && $fullheight > $height) {
605: my $size = $width.'x'.$height;
606: system("convert -sample $size $input $output");
607: $showfile = '/'.$imgdir.'/tn-'.$filename;
608: }
609: }
1.6 raeburn 610: }
611: }
1.16 raeburn 612: }
1.6 raeburn 613: if ($showfile) {
1.9 raeburn 614: $showfile = &Apache::loncommon::lonhttpdurl($showfile);
615: $fullsize = &Apache::loncommon::lonhttpdurl($imgfile);
1.6 raeburn 616: $datatable.= '<td>';
617: if (!$is_custom->{$img}) {
618: $datatable .= &mt('Default in use:').'<br />';
619: }
1.18 albertel 620: if ($img_import) {
621: $datatable.= '<input type="hidden" name="'.$role.'_import_'.$img.'" value="'.$imgfile.'" />';
622: }
1.9 raeburn 623: $datatable.= '<a href="'.$fullsize.'" target="_blank"><img src="'.
624: $showfile.'" alt="'.$alt_text->{$img}.
625: '" border="0" /></a></td>';
1.6 raeburn 626: if ($is_custom->{$img}) {
1.8 raeburn 627: $datatable.='<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
628: $role.'_del_'.$img.'" value="1" />'.&mt('Delete?').
629: '</label> '.&mt('Replace:').'</span><br />';
1.6 raeburn 630: } else {
631: $datatable.='<td valign="bottom">'.&mt('Upload:').'<br />';
632: }
633: } else {
634: $datatable .= '<td colspan="2" class="LC_right_item"><br />'.
635: &mt('Upload:');
636: }
637: } else {
638: $datatable .= '<td colspan="2" class="LC_right_item"><br />'.
639: &mt('Upload:');
640: }
1.9 raeburn 641: if ($switchserver) {
642: $datatable .= &mt('Upload to library server: [_1]',$switchserver);
643: } else {
644: $datatable .=' <input type="file" name="'.$role.'_'.$img.'" />';
645: }
646: $datatable .= '</td></tr>';
1.6 raeburn 647: }
648: $itemcount ++;
649: $css_class = $itemcount%2?' class="LC_odd_row"':'';
650: $datatable .= '<tr'.$css_class.'>'.
651: '<td>'.$choices->{'bgs'}.'</td>';
652: my $bgs_def;
653: foreach my $item (@{$bgs}) {
654: if (!$is_custom->{$item}) {
655: $bgs_def .= '<td>'.$choices->{$item}.'<br />'.$defaults->{'bgs'}{$item}.'</td>';
656: }
657: }
658: if ($bgs_def) {
1.8 raeburn 659: $datatable .= '<td>'.&mt('Default(s) in use:').'<br /><table border="0"><tr>'.$bgs_def.'</tr></table></td>';
1.6 raeburn 660: } else {
661: $datatable .= '<td> </td>';
662: }
663: $datatable .= '<td class="LC_right_item">'.
664: '<table border="0"><tr>';
665: foreach my $item (@{$bgs}) {
666: my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'bgs'}{$item});
667: $datatable .= '<td align="center">'.$link;
668: if ($designs->{'bgs'}{$item}) {
669: $datatable .= '<span style="background-color:'.$designs->{'bgs'}{$item}.'width: 10px"> </span>';
670: }
671: $datatable .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.$designs->{'bgs'}{$item}.
672: '" /></td>';
673: }
674: $datatable .= '</tr></table></td></tr>';
675: $itemcount ++;
676: $css_class = $itemcount%2?' class="LC_odd_row"':'';
677: $datatable .= '<tr'.$css_class.'>'.
678: '<td>'.$choices->{'links'}.'</td>';
679: my $links_def;
680: foreach my $item (@{$links}) {
681: if (!$is_custom->{$item}) {
682: $links_def .= '<td>'.$choices->{$item}.'<br />'.$defaults->{'links'}{$item}.'</td>';
683: }
684: }
685: if ($links_def) {
1.8 raeburn 686: $datatable .= '<td>'.&mt('Default(s) in use:').'<br /><table border="0"><tr>'.$links_def.'</tr></table></td>';
1.6 raeburn 687: } else {
688: $datatable .= '<td> </td>';
689: }
690: $datatable .= '<td class="LC_right_item">'.
691: '<table border="0"><tr>';
692: foreach my $item (@{$links}) {
693: $datatable .= '<td align="center">';
694: my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'links'}{$item});
695: if ($designs->{'links'}{$item}) {
696: $datatable.='<span style="color: '.$designs->{'links'}{$item}.';">'.
697: $link.'</span>';
698: } else {
699: $datatable .= $link;
700: }
701: $datatable .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.$designs->{'links'}{$item}.
702: '" /></td>';
703: }
1.3 raeburn 704: return $datatable;
705: }
706:
1.6 raeburn 707: sub color_pick {
708: my ($phase,$role,$item,$desc,$curcol) = @_;
709: my $link = '<a href="javascript:pjump('."'color_custom','".$desc.
710: "','".$curcol."','".$role.'_'.$item."','parmform.pres','psub'".
711: ');">'.$desc.'</a>';
712: return $link;
713: }
714:
715: sub color_pick_js {
716: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
717: my $output = <<"ENDCOL";
718: function pclose() {
719: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms","height=350,width=350,scrollbars=no,menubar=no");
720: parmwin.close();
721: }
722:
723: $pjump_def
724:
725: function psub() {
726: pclose();
727: if (document.parmform.pres_marker.value!='') {
728: if (document.parmform.pres_type.value!='') {
729: eval('document.display.'+
730: document.parmform.pres_marker.value+
731: '.value=document.parmform.pres_value.value;');
732: }
733: } else {
734: document.parmform.pres_value.value='';
735: document.parmform.pres_marker.value='';
736: }
737: }
738: ENDCOL
739: return $output;
740: }
741:
1.3 raeburn 742: sub print_quotas {
743: my ($dom,$settings) = @_;
744: my $datatable;
1.23 raeburn 745: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.3 raeburn 746: my $typecount = 0;
747: my $css_class;
1.26 ! raeburn 748: if (ref($types) eq 'ARRAY') {
1.23 raeburn 749: foreach my $type (@{$types}) {
1.3 raeburn 750: if (defined($usertypes->{$type})) {
751: $typecount ++;
752: $css_class = $typecount%2?' class="LC_odd_row"':'';
753: $datatable .= '<tr'.$css_class.'>'.
754: '<td>'.$usertypes->{$type}.'</td>'.
1.8 raeburn 755: '<td class="LC_right_item"><span class="LC_nobreak">'.
1.3 raeburn 756: '<input type="text" name="quota_'.$type.
757: '" value="'.$settings->{$type}.
1.8 raeburn 758: '" size="5" /> Mb</span></td></tr>';
1.3 raeburn 759: }
760: }
761: }
762: my $defaultquota = '20';
763: if (ref($settings) eq 'HASH') {
764: if (defined($settings->{'default'})) {
765: $defaultquota = $settings->{'default'};
766: }
767: }
768: $typecount ++;
769: $css_class = $typecount%2?' class="LC_odd_row"':'';
770: $datatable .= '<tr'.$css_class.'>'.
1.26 ! raeburn 771: '<td>'.$othertitle.'</td>'.
1.8 raeburn 772: '<td class="LC_right_item"><span class="LC_nobreak">'.
1.15 raeburn 773: '<input type="text" name="defaultquota" value="'.
1.8 raeburn 774: $defaultquota.'" size="5" /> Mb</span></td></tr>';
1.3 raeburn 775: return $datatable;
776: }
777:
778: sub print_autoenroll {
779: my ($dom,$settings) = @_;
780: my $autorun = &Apache::lonnet::auto_run(undef,$dom),
1.17 raeburn 781: my ($defdom,$runon,$runoff);
1.3 raeburn 782: if (ref($settings) eq 'HASH') {
783: if (exists($settings->{'run'})) {
784: if ($settings->{'run'} eq '0') {
785: $runoff = ' checked="checked" ';
786: $runon = ' ';
787: } else {
788: $runon = ' checked="checked" ';
789: $runoff = ' ';
790: }
791: } else {
792: if ($autorun) {
793: $runon = ' checked="checked" ';
794: $runoff = ' ';
795: } else {
796: $runoff = ' checked="checked" ';
797: $runon = ' ';
798: }
799: }
800: if (exists($settings->{'sender_domain'})) {
801: $defdom = $settings->{'sender_domain'};
802: }
1.14 raeburn 803: } else {
804: if ($autorun) {
805: $runon = ' checked="checked" ';
806: $runoff = ' ';
807: } else {
808: $runoff = ' checked="checked" ';
809: $runon = ' ';
810: }
1.3 raeburn 811: }
812: my $domform = &Apache::loncommon::select_dom_form($defdom,'sender_domain',1);
813: my $datatable='<tr class="LC_odd_row">'.
814: '<td>'.&mt('Auto-enrollment active?').'</td>'.
1.8 raeburn 815: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1.3 raeburn 816: '<input type="radio" name="autoenroll_run"'.
1.8 raeburn 817: $runon.' value="1" />'.&mt('Yes').'</label> '.
818: '<label><input type="radio" name="autoenroll_run"'.
1.14 raeburn 819: $runoff.' value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 820: '</tr><tr>'.
821: '<td>'.&mt('Notification messages - sender').
1.8 raeburn 822: '</td><td class="LC_right_item"><span class="LC_nobreak">'.
1.3 raeburn 823: &mt('username').': '.
824: '<input type="text" name="sender_uname" value="'.
825: $settings->{'sender_uname'}.
826: '" size="10" /> '.&mt('domain').
1.8 raeburn 827: ': '.$domform.'</span></td></tr>';
1.3 raeburn 828: return $datatable;
829: }
830:
831: sub print_autoupdate {
832: my ($position,$dom,$settings) = @_;
833: my $datatable;
834: if ($position eq 'top') {
835: my $updateon = ' ';
836: my $updateoff = ' checked="checked" ';
837: my $classlistson = ' ';
838: my $classlistsoff = ' checked="checked" ';
839: if (ref($settings) eq 'HASH') {
840: if ($settings->{'run'} eq '1') {
841: $updateon = $updateoff;
842: $updateoff = ' ';
843: }
844: if ($settings->{'classlists'} eq '1') {
845: $classlistson = $classlistsoff;
846: $classlistsoff = ' ';
847: }
848: }
849: my %title = (
850: run => 'Auto-update active?',
851: classlists => 'Update information in classlists?',
852: );
853: $datatable = '<tr class="LC_odd_row">'.
854: '<td>'.&mt($title{'run'}).'</td>'.
1.8 raeburn 855: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1.3 raeburn 856: '<input type="radio" name="autoupdate_run"'.
1.8 raeburn 857: $updateon.' value="1" />'.&mt('Yes').'</label> '.
858: '<label><input type="radio" name="autoupdate_run"'.
859: $updateoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 860: '</tr><tr>'.
861: '<td>'.&mt($title{'classlists'}).'</td>'.
1.8 raeburn 862: '<td class="LC_right_item"><span class="LC_nobreak">'.
863: '<label><input type="radio" name="classlists"'.
864: $classlistson.' value="1" />'.&mt('Yes').'</label> '.
865: '<label><input type="radio" name="classlists"'.
866: $classlistsoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 867: '</tr>';
868: } else {
1.23 raeburn 869: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.20 raeburn 870: my @fields = ('lastname','firstname','middlename','gen',
871: 'permanentemail','id');
1.3 raeburn 872: my %fieldtitles = &Apache::lonlocal::texthash (
873: id => 'Student/Employee ID',
1.20 raeburn 874: permanentemail => 'E-mail address',
1.3 raeburn 875: lastname => 'Last Name',
876: firstname => 'First Name',
877: middlename => 'Middle Name',
878: gen => 'Generation',
879: );
880: my $numrows = 0;
1.26 ! raeburn 881: if (ref($types) eq 'ARRAY') {
! 882: if (@{$types} > 0) {
! 883: $datatable =
! 884: &usertype_update_row($settings,$usertypes,\%fieldtitles,
! 885: \@fields,$types,\$numrows);
! 886: }
1.3 raeburn 887: }
888: $datatable .=
889: &usertype_update_row($settings,{'default' => $othertitle},
890: \%fieldtitles,\@fields,['default'],
891: \$numrows);
892: }
893: return $datatable;
894: }
895:
1.23 raeburn 896: sub print_directorysrch {
897: my ($dom,$settings) = @_;
898: my $srchon = ' ';
899: my $srchoff = ' checked="checked" ';
1.25 raeburn 900: my ($exacton,$containson,$beginson);
1.24 raeburn 901: my $localon = ' ';
902: my $localoff = ' checked="checked" ';
1.23 raeburn 903: if (ref($settings) eq 'HASH') {
904: if ($settings->{'available'} eq '1') {
905: $srchon = $srchoff;
906: $srchoff = ' ';
907: }
1.24 raeburn 908: if ($settings->{'localonly'} eq '1') {
909: $localon = $localoff;
910: $localoff = ' ';
911: }
1.25 raeburn 912: if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
913: foreach my $type (@{$settings->{'searchtypes'}}) {
914: if ($type eq 'exact') {
915: $exacton = ' checked="checked" ';
916: } elsif ($type eq 'contains') {
917: $containson = ' checked="checked" ';
918: } elsif ($type eq 'begins') {
919: $beginson = ' checked="checked" ';
920: }
921: }
922: } else {
923: if ($settings->{'searchtypes'} eq 'exact') {
924: $exacton = ' checked="checked" ';
925: } elsif ($settings->{'searchtypes'} eq 'contains') {
926: $containson = ' checked="checked" ';
927: } elsif ($settings->{'searchtypes'} eq 'specify') {
928: $exacton = ' checked="checked" ';
929: $containson = ' checked="checked" ';
930: }
1.23 raeburn 931: }
932: }
933: my ($searchtitles,$titleorder) = &sorted_searchtitles();
934: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
935:
936: my $numinrow = 4;
1.26 ! raeburn 937: my $cansrchrow = 0;
1.23 raeburn 938: my $datatable='<tr class="LC_odd_row">'.
1.24 raeburn 939: '<td colspan="2">'.&mt('Directory search available?').'</td>'.
1.23 raeburn 940: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
941: '<input type="radio" name="dirsrch_available"'.
942: $srchon.' value="1" />'.&mt('Yes').'</label> '.
943: '<label><input type="radio" name="dirsrch_available"'.
944: $srchoff.' value="0" />'.&mt('No').'</label></span></td>'.
945: '</tr><tr>'.
1.25 raeburn 946: '<td colspan="2">'.&mt('Other domains can search?').'</td>'.
1.24 raeburn 947: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
948: '<input type="radio" name="dirsrch_localonly"'.
949: $localoff.' value="0" />'.&mt('Yes').'</label> '.
950: '<label><input type="radio" name="dirsrch_localonly"'.
951: $localon.' value="1" />'.&mt('No').'</label></span></td>'.
1.25 raeburn 952: '</tr>';
1.26 ! raeburn 953: if (ref($usertypes) eq 'HASH') {
! 954: if (keys(%{$usertypes}) > 0) {
! 955: $datatable .= &users_cansearch_row($settings,$types,$usertypes,$dom,
! 956: $numinrow,$othertitle);
! 957: $cansrchrow = 1;
! 958: }
! 959: }
! 960: if ($cansrchrow) {
! 961: $datatable .= '<tr>';
! 962: } else {
! 963: $datatable .= '<tr class="LC_odd_row">';
! 964: }
! 965: $datatable .= '<td>'.&mt('Supported search methods').
1.25 raeburn 966: '</td><td class="LC_left_item" colspan="2"><table><tr>';
967: foreach my $title (@{$titleorder}) {
968: if (defined($searchtitles->{$title})) {
969: my $check = ' ';
970: if (ref($settings->{'searchby'}) eq 'ARRAY') {
971: if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
972: $check = ' checked="checked" ';
973: }
974: }
975: $datatable .= '<td class="LC_left_item">'.
976: '<span class="LC_nobreak"><label>'.
977: '<input type="checkbox" name="searchby" '.
978: 'value="'.$title.'"'.$check.'/>'.
979: $searchtitles->{$title}.'</label></span></td>';
980: }
981: }
1.26 ! raeburn 982: $datatable .= '</tr></table></td></tr>';
! 983: if ($cansrchrow) {
! 984: $datatable .= '<tr class="LC_odd_row">';
! 985: } else {
! 986: $datatable .= '<tr>';
! 987: }
! 988: $datatable .= '<td>'.&mt('Search latitude').'</td>'.
! 989: '<td class="LC_left_item" colspan="2">'.
1.25 raeburn 990: '<span class="LC_nobreak"><label>'.
991: '<input type="checkbox" name="searchtypes" '.
992: $exacton.' value="exact" />'.&mt('Exact match').
993: '</label> '.
994: '<label><input type="checkbox" name="searchtypes" '.
995: $beginson.' value="begins" />'.&mt('Begins with').
996: '</label> '.
997: '<label><input type="checkbox" name="searchtypes" '.
998: $containson.' value="contains" />'.&mt('Contains').
999: '</label></span></td></tr>';
1000: return $datatable;
1001: }
1002:
1003: sub users_cansearch_row {
1004: my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle) = @_;
1005: my $output = '<tr class="LC_odd_row">'.
1.24 raeburn 1006: '<td>'.&mt('Users allowed to search').' ('.$dom.')'.
1007: '</td><td class="LC_left_item" colspan="2"><table>';
1.26 ! raeburn 1008: my $rem;
! 1009: if (ref($types) eq 'ARRAY') {
! 1010: for (my $i=0; $i<@{$types}; $i++) {
! 1011: if (defined($usertypes->{$types->[$i]})) {
! 1012: my $rem = $i%($numinrow);
! 1013: if ($rem == 0) {
! 1014: if ($i > 0) {
! 1015: $output .= '</tr>';
! 1016: }
! 1017: $output .= '<tr>';
1.23 raeburn 1018: }
1.26 ! raeburn 1019: my $check = ' ';
! 1020: if (ref($settings->{'cansearch'}) eq 'ARRAY') {
! 1021: if (grep(/^\Q$types->[$i]\E$/,@{$settings->{'cansearch'}})) {
! 1022: $check = ' checked="checked" ';
! 1023: }
1.23 raeburn 1024: }
1.26 ! raeburn 1025: $output .= '<td class="LC_left_item">'.
! 1026: '<span class="LC_nobreak"><label>'.
! 1027: '<input type="checkbox" name="cansearch" '.
! 1028: 'value="'.$types->[$i].'"'.$check.'/>'.
! 1029: $usertypes->{$types->[$i]}.'</label></span></td>';
1.23 raeburn 1030: }
1031: }
1.26 ! raeburn 1032:
! 1033: $rem = @{$types}%($numinrow);
1.23 raeburn 1034: }
1035: my $colsleft = $numinrow - $rem;
1036: if ($colsleft > 1) {
1.25 raeburn 1037: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">';
1.23 raeburn 1038: } else {
1.25 raeburn 1039: $output .= '<td class="LC_left_item">';
1.23 raeburn 1040: }
1041: my $defcheck = ' ';
1042: if (ref($settings->{'cansearch'}) eq 'ARRAY') {
1.26 ! raeburn 1043: if (grep(/^default$/,@{$settings->{'cansearch'}})) {
! 1044: $defcheck = ' checked="checked" ';
! 1045: }
1.23 raeburn 1046: }
1.25 raeburn 1047: $output .= '<span class="LC_nobreak"><label>'.
1048: '<input type="checkbox" name="cansearch" '.
1049: 'value="default"'.$defcheck.'/>'.
1050: $othertitle.'</label></span></td>'.
1051: '</tr></table></td></tr>';
1052: return $output;
1.23 raeburn 1053: }
1054:
1055: sub sorted_inst_types {
1056: my ($dom) = @_;
1057: my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
1.26 ! raeburn 1058: my $othertitle = &mt('All users');
1.23 raeburn 1059: my @types;
1060: if (ref($order) eq 'ARRAY') {
1061: @types = @{$order};
1062: }
1063: if (@types == 0) {
1064: if (ref($usertypes) eq 'HASH') {
1065: @types = sort(keys(%{$usertypes}));
1066: }
1067: }
1068: if (keys(%{$usertypes}) > 0) {
1069: $othertitle = &mt('Other users');
1070: }
1071: return ($othertitle,$usertypes,\@types);
1072: }
1073:
1074: sub sorted_searchtitles {
1075: my %searchtitles = &Apache::lonlocal::texthash(
1076: 'uname' => 'username',
1077: 'lastname' => 'last name',
1078: 'lastfirst' => 'last name, first name',
1079: );
1080: my @titleorder = ('uname','lastname','lastfirst');
1081: return (\%searchtitles,\@titleorder);
1082: }
1083:
1.25 raeburn 1084: sub sorted_searchtypes {
1085: my %srchtypes_desc = (
1086: exact => 'is exact match',
1087: contains => 'contains ..',
1088: begins => 'begins with ..',
1089: );
1090: my @srchtypeorder = ('exact','begins','contains');
1091: return (\%srchtypes_desc,\@srchtypeorder);
1092: }
1093:
1.3 raeburn 1094: sub usertype_update_row {
1095: my ($settings,$usertypes,$fieldtitles,$fields,$types,$rownums) = @_;
1096: my $datatable;
1097: my $numinrow = 4;
1098: foreach my $type (@{$types}) {
1099: if (defined($usertypes->{$type})) {
1100: $$rownums ++;
1101: my $css_class = $$rownums%2?' class="LC_odd_row"':'';
1102: $datatable .= '<tr'.$css_class.'><td>'.$usertypes->{$type}.
1103: '</td><td class="LC_left_item"><table>';
1104: for (my $i=0; $i<@{$fields}; $i++) {
1105: my $rem = $i%($numinrow);
1106: if ($rem == 0) {
1107: if ($i > 0) {
1108: $datatable .= '</tr>';
1109: }
1110: $datatable .= '<tr>';
1111: }
1112: my $check = ' ';
1113: if (ref($settings->{'fields'}) eq 'HASH') {
1114: if (ref($settings->{'fields'}{$type}) eq 'ARRAY') {
1115: if (grep(/^\Q$fields->[$i]\E$/,@{$settings->{'fields'}{$type}})) {
1116: $check = ' checked="checked" ';
1117: }
1118: }
1119: }
1120:
1121: if ($i == @{$fields}-1) {
1122: my $colsleft = $numinrow - $rem;
1123: if ($colsleft > 1) {
1124: $datatable .= '<td colspan="'.$colsleft.'">';
1125: } else {
1126: $datatable .= '<td>';
1127: }
1128: } else {
1129: $datatable .= '<td>';
1130: }
1.8 raeburn 1131: $datatable .= '<span class="LC_nobreak"><label>'.
1132: '<input type="checkbox" name="updateable_'.$type.
1133: '_'.$fields->[$i].'" value="1"'.$check.'/>'.
1134: $fieldtitles->{$fields->[$i]}.'</label></span></td>';
1.3 raeburn 1135: }
1136: $datatable .= '</tr></table></td></tr>';
1137: }
1138: }
1139: return $datatable;
1.1 raeburn 1140: }
1141:
1142: sub modify_login {
1.9 raeburn 1143: my ($r,$dom,$confname,%domconfig) = @_;
1.6 raeburn 1144: my ($resulttext,$errors,$colchgtext,%changes,%colchanges);
1.1 raeburn 1145: my %title = ( coursecatalog => 'Display course catalog',
1146: adminmail => 'Display administrator E-mail address');
1.3 raeburn 1147: my @offon = ('off','on');
1.6 raeburn 1148: my %loginhash;
1.9 raeburn 1149: ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
1150: \%domconfig,\%loginhash);
1.6 raeburn 1151: $loginhash{login}{coursecatalog} = $env{'form.coursecatalog'};
1152: $loginhash{login}{adminmail} = $env{'form.adminmail'};
1153: if (ref($colchanges{'login'}) eq 'HASH') {
1154: $colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
1155: \%loginhash);
1156: }
1.1 raeburn 1157: my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
1158: $dom);
1159: if ($putresult eq 'ok') {
1.3 raeburn 1160: if (($domconfig{'login'}{'coursecatalog'} eq '0') &&
1.1 raeburn 1161: ($env{'form.coursecatalog'} eq '1')) {
1162: $changes{'coursecatalog'} = 1;
1.3 raeburn 1163: } elsif (($domconfig{'login'}{'coursecatalog'} eq '' ||
1164: $domconfig{'login'}{'coursecatalog'} eq '1') &&
1.1 raeburn 1165: ($env{'form.coursecatalog'} eq '0')) {
1166: $changes{'coursecatalog'} = 1;
1167: }
1.3 raeburn 1168: if (($domconfig{'login'}{'adminmail'} eq '1') &&
1.1 raeburn 1169: ($env{'form.adminmail'} eq '0')) {
1170: $changes{'adminmail'} = 1;
1171: } elsif (($domconfig{'login'}{'adminmail'} eq '' ||
1172: $domconfig{'login'}{'adminmail'} eq '0') &&
1173: ($env{'form.adminmail'} eq '1')) {
1174: $changes{'adminmail'} = 1;
1175: }
1.6 raeburn 1176: if (keys(%changes) > 0 || $colchgtext) {
1.1 raeburn 1177: $resulttext = &mt('Changes made:').'<ul>';
1178: foreach my $item (sort(keys(%changes))) {
1179: $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
1180: }
1.6 raeburn 1181: $resulttext .= $colchgtext.'</ul>';
1.1 raeburn 1182: } else {
1183: $resulttext = &mt('No changes made to log-in page settings');
1184: }
1185: } else {
1.11 albertel 1186: $resulttext = '<span class="LC_error">'.
1187: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 1188: }
1.6 raeburn 1189: if ($errors) {
1.9 raeburn 1190: $resulttext .= '<br />'.&mt('The following errors occurred: ').'<ul>'.
1.6 raeburn 1191: $errors.'</ul>';
1192: }
1193: return $resulttext;
1194: }
1195:
1196: sub color_font_choices {
1197: my %choices =
1198: &Apache::lonlocal::texthash (
1199: img => "Header",
1200: bgs => "Background colors",
1201: links => "Link colors",
1202: font => "Font color",
1203: pgbg => "Page",
1204: tabbg => "Header",
1205: sidebg => "Border",
1206: link => "Link",
1207: alink => "Active link",
1208: vlink => "Visited link",
1209: );
1210: return %choices;
1211: }
1212:
1213: sub modify_rolecolors {
1.9 raeburn 1214: my ($r,$dom,$confname,$roles,%domconfig) = @_;
1.6 raeburn 1215: my ($resulttext,%rolehash);
1216: $rolehash{'rolecolors'} = {};
1.9 raeburn 1217: my ($errors,%changes) = &modify_colors($r,$dom,$confname,$roles,
1.6 raeburn 1218: $domconfig{'rolecolors'},$rolehash{'rolecolors'});
1219: my $putresult = &Apache::lonnet::put_dom('configuration',\%rolehash,
1220: $dom);
1221: if ($putresult eq 'ok') {
1222: if (keys(%changes) > 0) {
1223: $resulttext = &display_colorchgs($dom,\%changes,$roles,
1224: $rolehash{'rolecolors'});
1225: } else {
1226: $resulttext = &mt('No changes made to default color schemes');
1227: }
1228: } else {
1.11 albertel 1229: $resulttext = '<span class="LC_error">'.
1230: &mt('An error occurred: [_1]',$putresult).'</span>';
1.6 raeburn 1231: }
1232: if ($errors) {
1233: $resulttext .= &mt('The following errors occurred: ').'<ul>'.
1234: $errors.'</ul>';
1235: }
1236: return $resulttext;
1237: }
1238:
1239: sub modify_colors {
1.9 raeburn 1240: my ($r,$dom,$confname,$roles,$domconfig,$confhash) = @_;
1.12 raeburn 1241: my (%changes,%choices);
1.6 raeburn 1242: my @bgs = ('pgbg','mainbg','sidebg');
1243: my @links = ('link','alink','vlink');
1244: my @images;
1245: my $servadm = $r->dir_config('lonAdmEMail');
1246: my $errors;
1247: foreach my $role (@{$roles}) {
1248: if ($role eq 'login') {
1.12 raeburn 1249: %choices = &login_choices();
1250: } else {
1251: %choices = &color_font_choices();
1252: }
1253: if ($role eq 'login') {
1.6 raeburn 1254: @images = ('img','logo','domlogo');
1255: } else {
1256: @images = ('img');
1257: }
1258: $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
1259: foreach my $item (@bgs,@links) {
1260: $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
1261: }
1.9 raeburn 1262: my ($configuserok,$author_ok,$switchserver,%currroles);
1263: my $uhome = &Apache::lonnet::homeserver($confname,$dom,1);
1264: ($configuserok,%currroles) = &check_configuser($uhome,$dom,
1265: $confname,$servadm);
1266: if ($configuserok eq 'ok') {
1267: $switchserver = &check_switchserver($dom,$confname);
1268: if ($switchserver eq '') {
1269: $author_ok = &check_authorstatus($dom,$confname,%currroles);
1270: }
1271: }
1272: my ($width,$height) = &thumb_dimensions();
1.8 raeburn 1273: foreach my $img (@images) {
1.18 albertel 1274: if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
1275: && !defined($domconfig->{$role}{$img})
1276: && !$env{'form.'.$role.'_del_'.$img}
1277: && $env{'form.'.$role.'_import_'.$img}) {
1278: # import the old configured image from the .tab setting
1279: # if they haven't provided a new one
1280: $domconfig->{$role}{$img} =
1281: $env{'form.'.$role.'_import_'.$img};
1282: }
1.6 raeburn 1283: if ($env{'form.'.$role.'_'.$img.'.filename'} ne '') {
1.9 raeburn 1284: my $error;
1.6 raeburn 1285: if ($configuserok eq 'ok') {
1.9 raeburn 1286: if ($switchserver) {
1.12 raeburn 1287: $error = &mt("Upload of [_1] image for $role page(s) is not permitted to this server: [_2]",$choices{$img},$switchserver);
1.9 raeburn 1288: } else {
1289: if ($author_ok eq 'ok') {
1290: my ($result,$logourl) =
1291: &publishlogo($r,'upload',$role.'_'.$img,
1292: $dom,$confname,$img,$width,$height);
1293: if ($result eq 'ok') {
1294: $confhash->{$role}{$img} = $logourl;
1.12 raeburn 1295: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 1296: } else {
1.12 raeburn 1297: $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 1298: }
1299: } else {
1.12 raeburn 1300: $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 1301: }
1302: }
1303: } else {
1.12 raeburn 1304: $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 1305: }
1306: if ($error) {
1.8 raeburn 1307: &Apache::lonnet::logthis($error);
1.11 albertel 1308: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
1.8 raeburn 1309: }
1310: } elsif ($domconfig->{$role}{$img} ne '') {
1.9 raeburn 1311: if ($domconfig->{$role}{$img} !~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
1312: my $error;
1313: if ($configuserok eq 'ok') {
1314: # is confname an author?
1315: if ($switchserver eq '') {
1316: if ($author_ok eq 'ok') {
1317: my ($result,$logourl) =
1318: &publishlogo($r,'copy',$domconfig->{$role}{$img},
1319: $dom,$confname,$img,$width,$height);
1320: if ($result eq 'ok') {
1321: $confhash->{$role}{$img} = $logourl;
1.18 albertel 1322: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 1323: }
1324: }
1325: }
1326: }
1.6 raeburn 1327: }
1328: }
1329: }
1330: if (ref($domconfig) eq 'HASH') {
1331: if (ref($domconfig->{$role}) eq 'HASH') {
1332: foreach my $img (@images) {
1333: if ($domconfig->{$role}{$img} ne '') {
1334: if ($env{'form.'.$role.'_del_'.$img}) {
1335: $confhash->{$role}{$img} = '';
1.12 raeburn 1336: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 1337: } else {
1.9 raeburn 1338: if ($confhash->{$role}{$img} eq '') {
1339: $confhash->{$role}{$img} = $domconfig->{$role}{$img};
1340: }
1.6 raeburn 1341: }
1342: } else {
1343: if ($env{'form.'.$role.'_del_'.$img}) {
1344: $confhash->{$role}{$img} = '';
1.12 raeburn 1345: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 1346: }
1347: }
1348: }
1349: if ($domconfig->{$role}{'font'} ne '') {
1350: if ($confhash->{$role}{'font'} ne $domconfig->{$role}{'font'}) {
1351: $changes{$role}{'font'} = 1;
1352: }
1353: } else {
1354: if ($confhash->{$role}{'font'}) {
1355: $changes{$role}{'font'} = 1;
1356: }
1357: }
1358: foreach my $item (@bgs) {
1359: if ($domconfig->{$role}{$item} ne '') {
1360: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
1361: $changes{$role}{'bgs'}{$item} = 1;
1362: }
1363: } else {
1364: if ($confhash->{$role}{$item}) {
1365: $changes{$role}{'bgs'}{$item} = 1;
1366: }
1367: }
1368: }
1369: foreach my $item (@links) {
1370: if ($domconfig->{$role}{$item} ne '') {
1371: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
1372: $changes{$role}{'links'}{$item} = 1;
1373: }
1374: } else {
1375: if ($confhash->{$role}{$item}) {
1376: $changes{$role}{'links'}{$item} = 1;
1377: }
1378: }
1379: }
1380: } else {
1381: &default_change_checker($role,\@images,\@links,\@bgs,
1382: $confhash,\%changes);
1383: }
1384: } else {
1385: &default_change_checker($role,\@images,\@links,\@bgs,
1386: $confhash,\%changes);
1387: }
1388: }
1389: return ($errors,%changes);
1390: }
1391:
1392: sub default_change_checker {
1393: my ($role,$images,$links,$bgs,$confhash,$changes) = @_;
1394: foreach my $item (@{$links}) {
1395: if ($confhash->{$role}{$item}) {
1396: $changes->{$role}{'links'}{$item} = 1;
1397: }
1398: }
1399: foreach my $item (@{$bgs}) {
1400: if ($confhash->{$role}{$item}) {
1401: $changes->{$role}{'bgs'}{$item} = 1;
1402: }
1403: }
1404: foreach my $img (@{$images}) {
1405: if ($env{'form.'.$role.'_del_'.$img}) {
1406: $confhash->{$role}{$img} = '';
1.12 raeburn 1407: $changes->{$role}{'images'}{$img} = 1;
1.6 raeburn 1408: }
1409: }
1410: if ($confhash->{$role}{'font'}) {
1411: $changes->{$role}{'font'} = 1;
1412: }
1413: }
1414:
1415: sub display_colorchgs {
1416: my ($dom,$changes,$roles,$confhash) = @_;
1417: my (%choices,$resulttext);
1.7 albertel 1418: &Apache::loncommon::devalidate_domconfig_cache($dom);
1.6 raeburn 1419: if (!grep(/^login$/,@{$roles})) {
1420: $resulttext = &mt('Changes made:').'<br />';
1421: }
1422: foreach my $role (@{$roles}) {
1423: if ($role eq 'login') {
1424: %choices = &login_choices();
1425: } else {
1426: %choices = &color_font_choices();
1427: }
1428: if (ref($changes->{$role}) eq 'HASH') {
1429: if ($role ne 'login') {
1430: $resulttext .= '<h4>'.&mt($role).'</h4>';
1431: }
1432: foreach my $key (sort(keys(%{$changes->{$role}}))) {
1433: if ($role ne 'login') {
1434: $resulttext .= '<ul>';
1435: }
1436: if (ref($changes->{$role}{$key}) eq 'HASH') {
1437: if ($role ne 'login') {
1438: $resulttext .= '<li>'.&mt($choices{$key}).':<ul>';
1439: }
1440: foreach my $item (sort(keys(%{$changes->{$role}{$key}}))) {
1441: if ($confhash->{$role}{$item} eq '') {
1442: $resulttext .= '<li>'.&mt("$choices{$item} set to default").'</li>';
1443: } else {
1.12 raeburn 1444: my $newitem = $confhash->{$role}{$item};
1445: if ($key eq 'images') {
1446: $newitem = '<img src="'.$confhash->{$role}{$item}.'" alt="'.$choices{$item}.'" valign="bottom" />';
1447: }
1448: $resulttext .= '<li>'.&mt("$choices{$item} set to [_1]",$newitem).'</li>';
1.6 raeburn 1449: }
1450: }
1451: if ($role ne 'login') {
1452: $resulttext .= '</ul></li>';
1453: }
1454: } else {
1455: if ($confhash->{$role}{$key} eq '') {
1456: $resulttext .= '<li>'.&mt("$choices{$key} set to default").'</li>';
1457: } else {
1458: $resulttext .= '<li>'.&mt("$choices{$key} set to [_1]",$confhash->{$role}{$key}).'</li>';
1459: }
1460: }
1461: if ($role ne 'login') {
1462: $resulttext .= '</ul>';
1463: }
1464: }
1465: }
1466: }
1.3 raeburn 1467: return $resulttext;
1.1 raeburn 1468: }
1469:
1.9 raeburn 1470: sub thumb_dimensions {
1471: return ('200','50');
1472: }
1473:
1.16 raeburn 1474: sub check_dimensions {
1475: my ($inputfile) = @_;
1476: my ($fullwidth,$fullheight);
1477: if ($inputfile =~ m|^[/\w.\-]+$|) {
1478: if (open(PIPE,"identify $inputfile 2>&1 |")) {
1479: my $imageinfo = <PIPE>;
1480: if (!close(PIPE)) {
1481: &Apache::lonnet::logthis("Failed to close PIPE opened to retrieve image information for $inputfile");
1482: }
1483: chomp($imageinfo);
1484: my ($fullsize) =
1.21 raeburn 1485: ($imageinfo =~ /^\Q$inputfile\E\s+\w+\s+(\d+x\d+)/);
1.16 raeburn 1486: if ($fullsize) {
1487: ($fullwidth,$fullheight) = split(/x/,$fullsize);
1488: }
1489: }
1490: }
1491: return ($fullwidth,$fullheight);
1492: }
1493:
1.9 raeburn 1494: sub check_configuser {
1495: my ($uhome,$dom,$confname,$servadm) = @_;
1496: my ($configuserok,%currroles);
1497: if ($uhome eq 'no_host') {
1498: srand( time() ^ ($$ + ($$ << 15)) ); # Seed rand.
1499: my $configpass = &LONCAPA::Enrollment::create_password();
1500: $configuserok =
1501: &Apache::lonnet::modifyuser($dom,$confname,'','internal',
1502: $configpass,'','','','','',undef,$servadm);
1503: } else {
1504: $configuserok = 'ok';
1505: %currroles =
1506: &Apache::lonnet::get_my_roles($confname,$dom,'userroles');
1507: }
1508: return ($configuserok,%currroles);
1509: }
1510:
1511: sub check_authorstatus {
1512: my ($dom,$confname,%currroles) = @_;
1513: my $author_ok;
1514: if (!$currroles{':'.$dom.':au'}) {
1515: my $start = time;
1516: my $end = 0;
1517: $author_ok =
1518: &Apache::lonnet::assignrole($dom,$confname,'/'.$dom.'/',
1519: 'au',$end,$start);
1520: } else {
1521: $author_ok = 'ok';
1522: }
1523: return $author_ok;
1524: }
1525:
1526: sub publishlogo {
1527: my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight) = @_;
1528: my ($output,$fname,$logourl);
1529: if ($action eq 'upload') {
1530: $fname=$env{'form.'.$formname.'.filename'};
1531: chop($env{'form.'.$formname});
1532: } else {
1533: ($fname) = ($formname =~ /([^\/]+)$/);
1534: }
1535: $fname=&Apache::lonnet::clean_filename($fname);
1536: # See if there is anything left
1537: unless ($fname) { return ('error: no uploaded file'); }
1538: $fname="$subdir/$fname";
1539: my $filepath='/home/'.$confname.'/public_html';
1540: my ($fnamepath,$file,$fetchthumb);
1541: $file=$fname;
1542: if ($fname=~m|/|) {
1543: ($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
1544: }
1545: my @parts=split(/\//,$filepath.'/'.$fnamepath);
1546: my $count;
1547: for ($count=4;$count<=$#parts;$count++) {
1548: $filepath.="/$parts[$count]";
1549: if ((-e $filepath)!=1) {
1550: mkdir($filepath,02770);
1551: }
1552: }
1553: # Check for bad extension and disallow upload
1554: if ($file=~/\.(\w+)$/ &&
1555: (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
1556: $output =
1557: &mt('Invalid file extension ([_1]) - reserved for LONCAPA use.',$1);
1558: } elsif ($file=~/\.(\w+)$/ &&
1559: !defined(&Apache::loncommon::fileembstyle($1))) {
1560: $output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1);
1561: } elsif ($file=~/\.(\d+)\.(\w+)$/) {
1562: $output = &mt('File name not allowed a rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
1563: } elsif (-d "$filepath/$file") {
1564: $output = &mt('File name is a directory name - rename the file and re-upload');
1565: } else {
1566: my $source = $filepath.'/'.$file;
1567: my $logfile;
1568: if (!open($logfile,">>$source".'.log')) {
1569: return (&mt('No write permission to Construction Space'));
1570: }
1571: print $logfile
1572: "\n================= Publish ".localtime()." ================\n".
1573: $env{'user.name'}.':'.$env{'user.domain'}."\n";
1574: # Save the file
1575: if (!open(FH,'>'.$source)) {
1576: &Apache::lonnet::logthis('Failed to create '.$source);
1577: return (&mt('Failed to create file'));
1578: }
1579: if ($action eq 'upload') {
1580: if (!print FH ($env{'form.'.$formname})) {
1581: &Apache::lonnet::logthis('Failed to write to '.$source);
1582: return (&mt('Failed to write file'));
1583: }
1584: } else {
1585: my $original = &Apache::lonnet::filelocation('',$formname);
1586: if(!copy($original,$source)) {
1587: &Apache::lonnet::logthis('Failed to copy '.$original.' to '.$source);
1588: return (&mt('Failed to write file'));
1589: }
1590: }
1591: close(FH);
1592: chmod(0660, $source); # Permissions to rw-rw---.
1593:
1594: my $docroot=$r->dir_config('lonDocRoot');
1595: my $targetdir=$docroot.'/res/'.$dom.'/'.$confname .'/'.$fnamepath;
1596: my $copyfile=$targetdir.'/'.$file;
1597:
1598: my @parts=split(/\//,$targetdir);
1599: my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]";
1600: for (my $count=5;$count<=$#parts;$count++) {
1601: $path.="/$parts[$count]";
1602: if (!-e $path) {
1603: print $logfile "\nCreating directory ".$path;
1604: mkdir($path,02770);
1605: }
1606: }
1607: my $versionresult;
1608: if (-e $copyfile) {
1609: $versionresult = &logo_versioning($targetdir,$file,$logfile);
1610: } else {
1611: $versionresult = 'ok';
1612: }
1613: if ($versionresult eq 'ok') {
1614: if (copy($source,$copyfile)) {
1615: print $logfile "\nCopied original source to ".$copyfile."\n";
1616: $output = 'ok';
1617: &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
1618: $logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;
1619: } else {
1620: print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
1621: $output = &mt('Failed to copy file to RES space').", $!";
1622: }
1623: if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) {
1624: my $inputfile = $filepath.'/'.$file;
1625: my $outfile = $filepath.'/'.'tn-'.$file;
1.16 raeburn 1626: my ($fullwidth,$fullheight) = &check_dimensions($inputfile);
1627: if ($fullwidth ne '' && $fullheight ne '') {
1628: if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) {
1629: my $thumbsize = $thumbwidth.'x'.$thumbheight;
1630: system("convert -sample $thumbsize $inputfile $outfile");
1631: chmod(0660, $filepath.'/tn-'.$file);
1632: if (-e $outfile) {
1633: my $copyfile=$targetdir.'/tn-'.$file;
1634: if (copy($outfile,$copyfile)) {
1635: print $logfile "\nCopied source to ".$copyfile."\n";
1636: &write_metadata($dom,$confname,$formname,
1637: $targetdir,'tn-'.$file,$logfile);
1638: } else {
1639: print $logfile "\nUnable to write ".$copyfile.
1640: ':'.$!."\n";
1641: }
1642: }
1.9 raeburn 1643: }
1644: }
1645: }
1646: } else {
1647: $output = $versionresult;
1648: }
1649: }
1650: return ($output,$logourl);
1651: }
1652:
1653: sub logo_versioning {
1654: my ($targetdir,$file,$logfile) = @_;
1655: my $target = $targetdir.'/'.$file;
1656: my ($maxversion,$fn,$extn,$output);
1657: $maxversion = 0;
1658: if ($file =~ /^(.+)\.(\w+)$/) {
1659: $fn=$1;
1660: $extn=$2;
1661: }
1662: opendir(DIR,$targetdir);
1663: while (my $filename=readdir(DIR)) {
1664: if ($filename=~/\Q$fn\E\.(\d+)\.\Q$extn\E$/) {
1665: $maxversion=($1>$maxversion)?$1:$maxversion;
1666: }
1667: }
1668: $maxversion++;
1669: print $logfile "\nCreating old version ".$maxversion."\n";
1670: my $copyfile=$targetdir.'/'.$fn.'.'.$maxversion.'.'.$extn;
1671: if (copy($target,$copyfile)) {
1672: print $logfile "Copied old target to ".$copyfile."\n";
1673: $copyfile=$copyfile.'.meta';
1674: if (copy($target.'.meta',$copyfile)) {
1675: print $logfile "Copied old target metadata to ".$copyfile."\n";
1676: $output = 'ok';
1677: } else {
1678: print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";
1679: $output = &mt('Failed to copy old meta').", $!, ";
1680: }
1681: } else {
1682: print $logfile "Unable to write ".$copyfile.':'.$!."\n";
1683: $output = &mt('Failed to copy old target').", $!, ";
1684: }
1685: return $output;
1686: }
1687:
1688: sub write_metadata {
1689: my ($dom,$confname,$formname,$targetdir,$file,$logfile) = @_;
1690: my (%metadatafields,%metadatakeys,$output);
1691: $metadatafields{'title'}=$formname;
1692: $metadatafields{'creationdate'}=time;
1693: $metadatafields{'lastrevisiondate'}=time;
1694: $metadatafields{'copyright'}='public';
1695: $metadatafields{'modifyinguser'}=$env{'user.name'}.':'.
1696: $env{'user.domain'};
1697: $metadatafields{'authorspace'}=$confname.':'.$dom;
1698: $metadatafields{'domain'}=$dom;
1699: {
1700: print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
1701: my $mfh;
1702: unless (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
1703: $output = &mt('Could not write metadata');
1704: }
1705: foreach (sort keys %metadatafields) {
1706: unless ($_=~/\./) {
1707: my $unikey=$_;
1708: $unikey=~/^([A-Za-z]+)/;
1709: my $tag=$1;
1710: $tag=~tr/A-Z/a-z/;
1711: print $mfh "\n\<$tag";
1712: foreach (split(/\,/,$metadatakeys{$unikey})) {
1713: my $value=$metadatafields{$unikey.'.'.$_};
1714: $value=~s/\"/\'\'/g;
1715: print $mfh ' '.$_.'="'.$value.'"';
1716: }
1717: print $mfh '>'.
1718: &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
1719: .'</'.$tag.'>';
1720: }
1721: }
1722: $output = 'ok';
1723: print $logfile "\nWrote metadata";
1724: close($mfh);
1725: }
1726: }
1727:
1728: sub check_switchserver {
1729: my ($dom,$confname) = @_;
1730: my ($allowed,$switchserver);
1731: my $home = &Apache::lonnet::homeserver($confname,$dom);
1732: if ($home eq 'no_host') {
1733: $home = &Apache::lonnet::domain($dom,'primary');
1734: }
1735: my @ids=&Apache::lonnet::current_machine_ids();
1.10 albertel 1736: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1737: if (!$allowed) {
1738: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role=dc./'.$dom.'/">'.&mt('Switch Server').'</a>';
1.9 raeburn 1739: }
1740: return $switchserver;
1741: }
1742:
1.1 raeburn 1743: sub modify_quotas {
1.3 raeburn 1744: my ($dom,%domconfig) = @_;
1.1 raeburn 1745: my ($resulttext,%changes);
1.26 ! raeburn 1746: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.1 raeburn 1747: my %formhash;
1748: foreach my $key (keys(%env)) {
1749: if ($key =~ /^form\.quota_(.+)$/) {
1750: $formhash{$1} = $env{$key};
1751: }
1752: }
1.15 raeburn 1753: $formhash{'default'} = $env{'form.defaultquota'};
1.1 raeburn 1754: if (ref($domconfig{'quotas'}) eq 'HASH') {
1755: foreach my $key (keys(%{$domconfig{'quotas'}})) {
1756: if (exists($formhash{$key})) {
1757: if ($formhash{$key} ne $domconfig{'quotas'}{$key}) {
1758: $changes{$key} = 1;
1759: }
1760: } else {
1761: $formhash{$key} = $domconfig{'quotas'}{$key};
1762: }
1763: }
1764: }
1765: foreach my $key (keys(%formhash)) {
1766: if ($formhash{$key} ne '') {
1.3 raeburn 1767: if (!exists($domconfig{'quotas'}{$key})) {
1.1 raeburn 1768: $changes{$key} = 1;
1769: }
1770: }
1771: }
1772: my %quotahash = (
1.3 raeburn 1773: quotas => {%formhash},
1.1 raeburn 1774: );
1775: my $putresult = &Apache::lonnet::put_dom('configuration',\%quotahash,
1776: $dom);
1777: if ($putresult eq 'ok') {
1778: if (keys(%changes) > 0) {
1779: $resulttext = &mt('Changes made:').'<ul>';
1.26 ! raeburn 1780: foreach my $type (@{$types},'default') {
! 1781: if (defined($changes{$type})) {
! 1782: my $typetitle = $usertypes->{$type};
! 1783: if ($type eq 'default') {
! 1784: $typetitle = $othertitle;
! 1785: }
! 1786: $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$formhash{$type}).'</li>';
! 1787: }
1.1 raeburn 1788: }
1789: $resulttext .= '</ul>';
1790: } else {
1791: $resulttext = &mt('No changes made to default quotas');
1792: }
1793: } else {
1.11 albertel 1794: $resulttext = '<span class="LC_error">'.
1795: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 1796: }
1.3 raeburn 1797: return $resulttext;
1.1 raeburn 1798: }
1799:
1.3 raeburn 1800: sub modify_autoenroll {
1801: my ($dom,%domconfig) = @_;
1.1 raeburn 1802: my ($resulttext,%changes);
1803: my %currautoenroll;
1804: if (ref($domconfig{'autoenroll'}) eq 'HASH') {
1805: foreach my $key (keys(%{$domconfig{'autoenroll'}})) {
1806: $currautoenroll{$key} = $domconfig{'autoenroll'}{$key};
1807: }
1808: }
1809: my $autorun = &Apache::lonnet::auto_run(undef,$dom),
1810: my %title = ( run => 'Auto-enrollment active',
1811: sender => 'Sender for notification messages');
1812: my @offon = ('off','on');
1.17 raeburn 1813: my $sender_uname = $env{'form.sender_uname'};
1814: my $sender_domain = $env{'form.sender_domain'};
1815: if ($sender_domain eq '') {
1816: $sender_uname = '';
1817: } elsif ($sender_uname eq '') {
1818: $sender_domain = '';
1819: }
1.1 raeburn 1820: my %autoenrollhash = (
1821: autoenroll => { run => $env{'form.autoenroll_run'},
1.17 raeburn 1822: sender_uname => $sender_uname,
1823: sender_domain => $sender_domain,
1.1 raeburn 1824:
1825: }
1826: );
1.4 raeburn 1827: my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
1828: $dom);
1.1 raeburn 1829: if ($putresult eq 'ok') {
1830: if (exists($currautoenroll{'run'})) {
1831: if ($currautoenroll{'run'} ne $env{'form.autoenroll_run'}) {
1832: $changes{'run'} = 1;
1833: }
1834: } elsif ($autorun) {
1835: if ($env{'form.autoenroll_run'} ne '1') {
1.23 raeburn 1836: $changes{'run'} = 1;
1.1 raeburn 1837: }
1838: }
1.17 raeburn 1839: if ($currautoenroll{'sender_uname'} ne $sender_uname) {
1.1 raeburn 1840: $changes{'sender'} = 1;
1841: }
1.17 raeburn 1842: if ($currautoenroll{'sender_domain'} ne $sender_domain) {
1.1 raeburn 1843: $changes{'sender'} = 1;
1844: }
1845: if (keys(%changes) > 0) {
1846: $resulttext = &mt('Changes made:').'<ul>';
1.3 raeburn 1847: if ($changes{'run'}) {
1.1 raeburn 1848: $resulttext .= '<li>'.&mt("$title{'run'} set to $offon[$env{'form.autoenroll_run'}]").'</li>';
1849: }
1850: if ($changes{'sender'}) {
1.17 raeburn 1851: if ($sender_uname eq '' || $sender_domain eq '') {
1852: $resulttext .= '<li>'.&mt("$title{'sender'} set to default (course owner).").'</li>';
1853: } else {
1854: $resulttext .= '<li>'.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'</li>';
1855: }
1.1 raeburn 1856: }
1857: $resulttext .= '</ul>';
1858: } else {
1859: $resulttext = &mt('No changes made to auto-enrollment settings');
1860: }
1861: } else {
1.11 albertel 1862: $resulttext = '<span class="LC_error">'.
1863: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 1864: }
1.3 raeburn 1865: return $resulttext;
1.1 raeburn 1866: }
1867:
1868: sub modify_autoupdate {
1.3 raeburn 1869: my ($dom,%domconfig) = @_;
1.1 raeburn 1870: my ($resulttext,%currautoupdate,%fields,%changes);
1871: if (ref($domconfig{'autoupdate'}) eq 'HASH') {
1872: foreach my $key (keys(%{$domconfig{'autoupdate'}})) {
1873: $currautoupdate{$key} = $domconfig{'autoupdate'}{$key};
1874: }
1875: }
1876: my @offon = ('off','on');
1877: my %title = &Apache::lonlocal::texthash (
1878: run => 'Auto-update:',
1879: classlists => 'Updates to user information in classlists?'
1880: );
1.26 ! raeburn 1881: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
1.1 raeburn 1882: my %fieldtitles = &Apache::lonlocal::texthash (
1883: id => 'Student/Employee ID',
1.20 raeburn 1884: permanentemail => 'E-mail address',
1.1 raeburn 1885: lastname => 'Last Name',
1886: firstname => 'First Name',
1887: middlename => 'Middle Name',
1888: gen => 'Generation',
1889: );
1890: my $othertitle = &mt('All users');
1891: if (keys(%{$usertypes}) > 0) {
1.26 ! raeburn 1892: $othertitle = &mt('Other users');
1.1 raeburn 1893: }
1894: foreach my $key (keys(%env)) {
1895: if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {
1896: push(@{$fields{$1}},$2);
1897: }
1898: }
1899: my %updatehash = (
1900: autoupdate => { run => $env{'form.autoupdate_run'},
1901: classlists => $env{'form.classlists'},
1902: fields => {%fields},
1903: }
1904: );
1905: foreach my $key (keys(%currautoupdate)) {
1906: if (($key eq 'run') || ($key eq 'classlists')) {
1907: if (exists($updatehash{autoupdate}{$key})) {
1908: if ($currautoupdate{$key} ne $updatehash{autoupdate}{$key}) {
1909: $changes{$key} = 1;
1910: }
1911: }
1912: } elsif ($key eq 'fields') {
1913: if (ref($currautoupdate{$key}) eq 'HASH') {
1.26 ! raeburn 1914: foreach my $item (@{$types},'default') {
1.1 raeburn 1915: if (ref($currautoupdate{$key}{$item}) eq 'ARRAY') {
1916: my $change = 0;
1917: foreach my $type (@{$currautoupdate{$key}{$item}}) {
1918: if (!exists($fields{$item})) {
1919: $change = 1;
1920: } elsif (ref($fields{$item}) eq 'ARRAY') {
1.26 ! raeburn 1921: if (!grep(/^\Q$type\E$/,@{$fields{$item}})) {
1.1 raeburn 1922: $change = 1;
1923: }
1924: }
1925: }
1926: if ($change) {
1927: push(@{$changes{$key}},$item);
1928: }
1.26 ! raeburn 1929: }
1.1 raeburn 1930: }
1931: }
1932: }
1933: }
1.26 ! raeburn 1934: foreach my $item (@{$types},'default') {
! 1935: if (defined($fields{$item})) {
! 1936: if (ref($currautoupdate{'fields'}) eq 'HASH') {
! 1937: if (!exists($currautoupdate{'fields'}{$item})) {
! 1938: push(@{$changes{'fields'}},$item);
! 1939: }
! 1940: } else {
! 1941: push(@{$changes{'fields'}},$item);
1.1 raeburn 1942: }
1943: }
1944: }
1945: my $putresult = &Apache::lonnet::put_dom('configuration',\%updatehash,
1946: $dom);
1947: if ($putresult eq 'ok') {
1948: if (keys(%changes) > 0) {
1949: $resulttext = &mt('Changes made:').'<ul>';
1950: foreach my $key (sort(keys(%changes))) {
1951: if (ref($changes{$key}) eq 'ARRAY') {
1952: foreach my $item (@{$changes{$key}}) {
1953: my @newvalues;
1954: foreach my $type (@{$fields{$item}}) {
1955: push(@newvalues,$fieldtitles{$type});
1956: }
1.3 raeburn 1957: my $newvaluestr;
1958: if (@newvalues > 0) {
1959: $newvaluestr = join(', ',@newvalues);
1960: } else {
1961: $newvaluestr = &mt('none');
1.6 raeburn 1962: }
1.1 raeburn 1963: if ($item eq 'default') {
1.26 ! raeburn 1964: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$othertitle,$newvaluestr).'</li>';
1.1 raeburn 1965: } else {
1.26 ! raeburn 1966: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$usertypes->{$item},$newvaluestr).'</li>';
1.1 raeburn 1967: }
1968: }
1969: } else {
1970: my $newvalue;
1971: if ($key eq 'run') {
1972: $newvalue = $offon[$env{'form.autoupdate_run'}];
1973: } else {
1974: $newvalue = $offon[$env{'form.'.$key}];
1.3 raeburn 1975: }
1.1 raeburn 1976: $resulttext .= '<li>'.&mt("[_1] set to $newvalue",$title{$key}).'</li>';
1977: }
1978: }
1979: $resulttext .= '</ul>';
1980: } else {
1.3 raeburn 1981: $resulttext = &mt('No changes made to autoupdates');
1.1 raeburn 1982: }
1983: } else {
1.11 albertel 1984: $resulttext = '<span class="LC_error">'.
1985: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 1986: }
1.3 raeburn 1987: return $resulttext;
1.1 raeburn 1988: }
1989:
1.23 raeburn 1990: sub modify_directorysrch {
1991: my ($dom,%domconfig) = @_;
1992: my ($resulttext,%changes);
1993: my %currdirsrch;
1994: if (ref($domconfig{'directorysrch'}) eq 'HASH') {
1995: foreach my $key (keys(%{$domconfig{'directorysrch'}})) {
1996: $currdirsrch{$key} = $domconfig{'directorysrch'}{$key};
1997: }
1998: }
1999: my %title = ( available => 'Directory search available',
1.24 raeburn 2000: localonly => 'Other domains can search',
1.23 raeburn 2001: searchby => 'Search types',
2002: searchtypes => 'Search latitude');
2003: my @offon = ('off','on');
1.24 raeburn 2004: my @otherdoms = ('Yes','No');
1.23 raeburn 2005:
1.25 raeburn 2006: my @searchtypes = &Apache::loncommon::get_env_multiple('form.searchtypes');
1.23 raeburn 2007: my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch');
2008: my @searchby = &Apache::loncommon::get_env_multiple('form.searchby');
2009:
1.26 ! raeburn 2010: my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
! 2011: if (keys(%{$usertypes}) == 0) {
! 2012: @cansearch = ('default');
! 2013: } else {
! 2014: if (ref($currdirsrch{'cansearch'}) eq 'ARRAY') {
! 2015: foreach my $type (@{$currdirsrch{'cansearch'}}) {
! 2016: if (!grep(/^\Q$type\E$/,@cansearch)) {
! 2017: push(@{$changes{'cansearch'}},$type);
! 2018: }
1.23 raeburn 2019: }
1.26 ! raeburn 2020: foreach my $type (@cansearch) {
! 2021: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'cansearch'}})) {
! 2022: push(@{$changes{'cansearch'}},$type);
! 2023: }
1.23 raeburn 2024: }
1.26 ! raeburn 2025: } else {
! 2026: push(@{$changes{'cansearch'}},@cansearch);
1.23 raeburn 2027: }
2028: }
2029:
2030: if (ref($currdirsrch{'searchby'}) eq 'ARRAY') {
2031: foreach my $by (@{$currdirsrch{'searchby'}}) {
2032: if (!grep(/^\Q$by\E$/,@searchby)) {
2033: push(@{$changes{'searchby'}},$by);
2034: }
2035: }
2036: foreach my $by (@searchby) {
2037: if (!grep(/^\Q$by\E$/,@{$currdirsrch{'searchby'}})) {
2038: push(@{$changes{'searchby'}},$by);
2039: }
2040: }
2041: } else {
2042: push(@{$changes{'searchby'}},@searchby);
2043: }
1.25 raeburn 2044:
2045: if (ref($currdirsrch{'searchtypes'}) eq 'ARRAY') {
2046: foreach my $type (@{$currdirsrch{'searchtypes'}}) {
2047: if (!grep(/^\Q$type\E$/,@searchtypes)) {
2048: push(@{$changes{'searchtypes'}},$type);
2049: }
2050: }
2051: foreach my $type (@searchtypes) {
2052: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'searchtypes'}})) {
2053: push(@{$changes{'searchtypes'}},$type);
2054: }
2055: }
2056: } else {
2057: if (exists($currdirsrch{'searchtypes'})) {
2058: foreach my $type (@searchtypes) {
2059: if ($type ne $currdirsrch{'searchtypes'}) {
2060: push(@{$changes{'searchtypes'}},$type);
2061: }
2062: }
2063: if (!grep(/^\Q$currdirsrch{'searchtypes'}\E/,@searchtypes)) {
2064: push(@{$changes{'searchtypes'}},$currdirsrch{'searchtypes'});
2065: }
2066: } else {
2067: push(@{$changes{'searchtypes'}},@searchtypes);
2068: }
2069: }
2070:
1.23 raeburn 2071: my %dirsrch_hash = (
2072: directorysrch => { available => $env{'form.dirsrch_available'},
2073: cansearch => \@cansearch,
1.24 raeburn 2074: localonly => $env{'form.dirsrch_localonly'},
1.23 raeburn 2075: searchby => \@searchby,
1.25 raeburn 2076: searchtypes => \@searchtypes,
1.23 raeburn 2077: }
2078: );
2079: my $putresult = &Apache::lonnet::put_dom('configuration',\%dirsrch_hash,
2080: $dom);
2081: if ($putresult eq 'ok') {
2082: if (exists($currdirsrch{'available'})) {
2083: if ($currdirsrch{'available'} ne $env{'form.dirsrch_available'}) {
2084: $changes{'available'} = 1;
2085: }
2086: } else {
2087: if ($env{'form.dirsrch_available'} eq '1') {
2088: $changes{'available'} = 1;
2089: }
2090: }
1.24 raeburn 2091: if (exists($currdirsrch{'localonly'})) {
2092: if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_localonly'}) {
2093: $changes{'localonly'} = 1;
2094: }
2095: } else {
2096: if ($env{'form.dirsrch_localonly'} eq '1') {
2097: $changes{'localonly'} = 1;
2098: }
2099: }
1.23 raeburn 2100: if (keys(%changes) > 0) {
2101: $resulttext = &mt('Changes made:').'<ul>';
2102: if ($changes{'available'}) {
2103: $resulttext .= '<li>'.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").'</li>';
2104: }
1.24 raeburn 2105: if ($changes{'localonly'}) {
2106: $resulttext .= '<li>'.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_localonly'}]").'</li>';
2107: }
2108:
1.23 raeburn 2109: if (ref($changes{'cansearch'}) eq 'ARRAY') {
2110: my $chgtext;
1.26 ! raeburn 2111: if (ref($usertypes) eq 'HASH') {
! 2112: if (keys(%{$usertypes}) > 0) {
! 2113: foreach my $type (@{$types}) {
! 2114: if (grep(/^\Q$type\E$/,@cansearch)) {
! 2115: $chgtext .= $usertypes->{$type}.'; ';
! 2116: }
! 2117: }
! 2118: if (grep(/^default$/,@cansearch)) {
! 2119: $chgtext .= $othertitle;
! 2120: } else {
! 2121: $chgtext =~ s/\; $//;
! 2122: }
! 2123: $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 2124: }
2125: }
2126: }
2127: if (ref($changes{'searchby'}) eq 'ARRAY') {
2128: my ($searchtitles,$titleorder) = &sorted_searchtitles();
2129: my $chgtext;
2130: foreach my $type (@{$titleorder}) {
2131: if (grep(/^\Q$type\E$/,@searchby)) {
2132: if (defined($searchtitles->{$type})) {
2133: $chgtext .= $searchtitles->{$type}.'; ';
2134: }
2135: }
2136: }
2137: $chgtext =~ s/\; $//;
2138: $resulttext .= '<li>'.&mt("$title{'searchby'} set to: [_1]",$chgtext).'</li>';
2139: }
1.25 raeburn 2140: if (ref($changes{'searchtypes'}) eq 'ARRAY') {
2141: my ($srchtypes_desc,$srchtypeorder) = &sorted_searchtypes();
2142: my $chgtext;
2143: foreach my $type (@{$srchtypeorder}) {
2144: if (grep(/^\Q$type\E$/,@searchtypes)) {
2145: if (defined($srchtypes_desc->{$type})) {
2146: $chgtext .= $srchtypes_desc->{$type}.'; ';
2147: }
2148: }
2149: }
2150: $chgtext =~ s/\; $//;
2151: $resulttext .= '<li>'.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).'</li>';
1.23 raeburn 2152: }
2153: $resulttext .= '</ul>';
2154: } else {
2155: $resulttext = &mt('No changes made to institution directory search settings');
2156: }
2157: } else {
2158: $resulttext = '<span class="LC_error">'.
2159: &mt('An error occurred: [_1]',$putresult).'</span>';
2160: }
2161: return $resulttext;
2162: }
2163:
1.3 raeburn 2164: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>