Annotation of loncom/interface/domainprefs.pm, revision 1.111
1.1 raeburn 1: # The LearningOnline Network with CAPA
2: # Handler to set domain-wide configuration settings
3: #
1.111 ! jms 4: # $Id: domainprefs.pm,v 1.110 2009/10/06 18:10:25 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:
1.101 raeburn 31: =pod
32:
33: =head1 NAME
34:
35: Apache::domainprefs.pm
36:
37: =head1 SYNOPSIS
38:
39: Handles configuration of a LON-CAPA domain.
40:
41: This is part of the LearningOnline Network with CAPA project
42: described at http://www.lon-capa.org.
43:
44:
45: =head1 OVERVIEW
46:
47: Each institution using LON-CAPA will typically have a single domain designated
48: for use by individuals affliated with the institution. Accordingly, each domain
49: may define a default set of logos and a color scheme which can be used to "brand"
50: the LON-CAPA instance. In addition, an institution will typically have a language
51: and timezone which are used for the majority of courses.
52:
53: LON-CAPA provides a mechanism to display and modify these defaults, as well as a
54: host of other domain-wide settings which determine the types of functionality
55: available to users and courses in the domain.
56:
57: There is also a mechanism to configure cataloging of courses in the domain, and
58: controls on the operation of automated processes which govern such things as
59: roster updates, user directory updates and processing of course requests.
60:
61: The domain coordination manual which is built dynamically on install/update of
62: LON-CAPA from the relevant help items provides more information about domain
63: configuration.
64:
65: Most of the domain settings are stored in the configuration.db GDBM file which is
66: housed on the primary library server for the domain in /home/httpd/lonUsers/$dom,
67: where $dom is the domain. The configuration.db stores settings in a number of
68: frozen hashes of hashes. In a few cases, domain information must be uploaded to
69: the domain as files (e.g., image files for logos etc., or plain text files for
70: bubblesheet formats). In this case the domainprefs.pm must be running in a user
71: session hosted on the primary library server in the domain, as these files are
72: stored in author space belonging to a special $dom-domainconfig user.
73:
74: domainprefs.pm in combination with lonconfigsettings.pm will retrieve and display
75: the current settings, and provides an interface to make modifications.
76:
77: =head1 SUBROUTINES
78:
79: =over
80:
81: =item print_quotas()
82:
83: Inputs: 4
84:
85: $dom,$settings,$rowtotal,$action.
86:
87: $dom is the domain, $settings is a reference to a hash of current settings for
88: the current context, $rowtotal is a reference to the scalar used to record the
89: number of rows displayed on the page, and $action is the context (either quotas
90: or requestcourses).
91:
92: The print_quotas routine was orginally created to display/store information
93: about default quota sizes for portfolio spaces for the different types of
94: institutional affiliation in the domain (e.g., Faculty, Staff, Student etc.),
95: but is now also used to manage availability of user tools:
96: i.e., blogs, aboutme page, and portfolios, and the course request tool,
97: used by course owners to request creation of a course.
98:
99: Outputs: 1
100:
101: $datatable - HTML containing form elements which allow settings to be changed.
102:
103: In the case of course requests, radio buttons are displayed for each institutional
104: affiliate type (and also default, and _LC_adv) for each of the course types
105: (official, unofficial and community). In each case the radio buttons allow the
106: selection of one of four values:
107:
1.104 raeburn 108: 0, approval, validate, autolimit=N (where N is blank, or a positive integer).
1.101 raeburn 109: which have the following effects:
110:
111: 0
112:
113: =over
114:
115: - course requests are not allowed for this course types/affiliation
116:
117: =back
118:
1.104 raeburn 119: approval
1.101 raeburn 120:
121: =over
122:
123: - course requests must be approved by a Doman Coordinator in the
124: course's domain
125:
126: =back
127:
128: validate
129:
130: =over
131:
132: - an institutional validation (e.g., check requestor is instructor
133: of record) needs to be passed before the course will be created. The required
134: validation is in localenroll.pm on the primary library server for the course
135: domain.
136:
137: =back
138:
139: autolimit
140:
141: =over
142:
143: - course requests will be processed autoatically up to a limit of
144: N requests for the course type for the particular requestor.
145: If N is undefined, there is no limit to the number of course requests
146: which a course owner may submit and have processed automatically.
147:
148: =back
149:
150: =item modify_quotas()
151:
152: =back
153:
154: =cut
155:
1.1 raeburn 156: package Apache::domainprefs;
157:
158: use strict;
159: use Apache::Constants qw(:common :http);
160: use Apache::lonnet;
161: use Apache::loncommon();
162: use Apache::lonhtmlcommon();
163: use Apache::lonlocal;
1.43 raeburn 164: use Apache::lonmsg();
1.91 raeburn 165: use Apache::lonconfigsettings;
1.69 raeburn 166: use LONCAPA qw(:DEFAULT :match);
1.6 raeburn 167: use LONCAPA::Enrollment;
1.81 raeburn 168: use LONCAPA::lonauthcgi();
1.9 raeburn 169: use File::Copy;
1.43 raeburn 170: use Locale::Language;
1.62 raeburn 171: use DateTime::TimeZone;
1.68 raeburn 172: use DateTime::Locale;
1.1 raeburn 173:
174: sub handler {
175: my $r=shift;
176: if ($r->header_only) {
177: &Apache::loncommon::content_type($r,'text/html');
178: $r->send_http_header;
179: return OK;
180: }
181:
1.91 raeburn 182: my $context = 'domain';
1.1 raeburn 183: my $dom = $env{'request.role.domain'};
1.5 albertel 184: my $domdesc = &Apache::lonnet::domain($dom,'description');
1.1 raeburn 185: if (&Apache::lonnet::allowed('mau',$dom)) {
186: &Apache::loncommon::content_type($r,'text/html');
187: $r->send_http_header;
188: } else {
189: $env{'user.error.msg'}=
190: "/adm/domainprefs:mau:0:0:Cannot modify domain settings";
191: return HTTP_NOT_ACCEPTABLE;
192: }
193: &Apache::lonhtmlcommon::clear_breadcrumbs();
194: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.58 raeburn 195: ['phase','actions']);
1.30 raeburn 196: my $phase = 'pickactions';
1.3 raeburn 197: if ( exists($env{'form.phase'}) ) {
198: $phase = $env{'form.phase'};
199: }
200: my %domconfig =
1.6 raeburn 201: &Apache::lonnet::get_dom('configuration',['login','rolecolors',
1.27 raeburn 202: 'quotas','autoenroll','autoupdate','directorysrch',
1.48 raeburn 203: 'usercreation','usermodification','contacts','defaults',
1.86 raeburn 204: 'scantron','coursecategories','serverstatuses',
205: 'requestcourses'],$dom);
1.43 raeburn 206: my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
1.30 raeburn 207: 'autoupdate','directorysrch','contacts',
1.48 raeburn 208: 'usercreation','usermodification','scantron',
1.86 raeburn 209: 'requestcourses','coursecategories','serverstatuses');
1.30 raeburn 210: my %prefs = (
211: 'rolecolors' =>
212: { text => 'Default color schemes',
1.67 raeburn 213: help => 'Domain_Configuration_Color_Schemes',
1.30 raeburn 214: header => [{col1 => 'Student Settings',
215: col2 => '',},
216: {col1 => 'Coordinator Settings',
217: col2 => '',},
218: {col1 => 'Author Settings',
219: col2 => '',},
220: {col1 => 'Administrator Settings',
221: col2 => '',}],
222: },
1.110 raeburn 223: 'login' =>
1.30 raeburn 224: { text => 'Log-in page options',
1.67 raeburn 225: help => 'Domain_Configuration_Login_Page',
1.30 raeburn 226: header => [{col1 => 'Item',
227: col2 => '',}],
228: },
1.110 raeburn 229:
1.43 raeburn 230: 'defaults' =>
1.54 raeburn 231: { text => 'Default authentication/language/timezone',
1.67 raeburn 232: help => 'Domain_Configuration_LangTZAuth',
1.43 raeburn 233: header => [{col1 => 'Setting',
234: col2 => 'Value'}],
235: },
1.30 raeburn 236: 'quotas' =>
1.90 weissno 237: { text => 'User blogs, personal information pages and portfolios',
1.67 raeburn 238: help => 'Domain_Configuration_Quotas',
1.77 raeburn 239: header => [{col1 => 'User affiliation',
1.72 raeburn 240: col2 => 'Available tools',
241: col3 => 'Portfolio quota',}],
1.30 raeburn 242: },
243: 'autoenroll' =>
244: { text => 'Auto-enrollment settings',
1.67 raeburn 245: help => 'Domain_Configuration_Auto_Enrollment',
1.30 raeburn 246: header => [{col1 => 'Configuration setting',
247: col2 => 'Value(s)'}],
248: },
249: 'autoupdate' =>
250: { text => 'Auto-update settings',
1.67 raeburn 251: help => 'Domain_Configuration_Auto_Updates',
1.30 raeburn 252: header => [{col1 => 'Setting',
253: col2 => 'Value',},
1.43 raeburn 254: {col1 => 'User population',
1.30 raeburn 255: col2 => 'Updataeable user data'}],
256: },
257: 'directorysrch' =>
258: { text => 'Institutional directory searches',
1.67 raeburn 259: help => 'Domain_Configuration_InstDirectory_Search',
1.30 raeburn 260: header => [{col1 => 'Setting',
261: col2 => 'Value',}],
262: },
263: 'contacts' =>
264: { text => 'Contact Information',
1.67 raeburn 265: help => 'Domain_Configuration_Contact_Info',
1.30 raeburn 266: header => [{col1 => 'Setting',
267: col2 => 'Value',}],
268: },
269:
270: 'usercreation' =>
271: { text => 'User creation',
1.67 raeburn 272: help => 'Domain_Configuration_User_Creation',
1.43 raeburn 273: header => [{col1 => 'Format rule type',
274: col2 => 'Format rules in force'},
1.34 raeburn 275: {col1 => 'User account creation',
276: col2 => 'Usernames which may be created',},
1.30 raeburn 277: {col1 => 'Context',
1.43 raeburn 278: col2 => 'Assignable authentication types'}],
1.30 raeburn 279: },
1.69 raeburn 280: 'usermodification' =>
1.33 raeburn 281: { text => 'User modification',
1.67 raeburn 282: help => 'Domain_Configuration_User_Modification',
1.33 raeburn 283: header => [{col1 => 'Target user has role',
284: col2 => 'User information updateable in author context'},
285: {col1 => 'Target user has role',
1.63 raeburn 286: col2 => 'User information updateable in course context'},
287: {col1 => "Status of user",
288: col2 => 'Information settable when self-creating account (if directory data blank)'}],
1.33 raeburn 289: },
1.69 raeburn 290: 'scantron' =>
1.95 www 291: { text => 'Bubblesheet format file',
1.67 raeburn 292: help => 'Domain_Configuration_Scantron_Format',
1.46 raeburn 293: header => [ {col1 => 'Item',
294: col2 => '',
295: }],
296: },
1.86 raeburn 297: 'requestcourses' =>
298: {text => 'Request creation of courses',
299: help => 'Domain_Configuration_Request_Courses',
300: header => [{col1 => 'User affiliation',
1.102 raeburn 301: col2 => 'Availability/Processing of requests',},
302: {col1 => 'Setting',
303: col2 => 'Value'}],
1.86 raeburn 304: },
1.69 raeburn 305: 'coursecategories' =>
1.48 raeburn 306: { text => 'Cataloging of courses',
1.67 raeburn 307: help => 'Domain_Configuration_Cataloging_Courses',
1.69 raeburn 308: header => [{col1 => 'Category settings',
1.57 raeburn 309: col2 => '',},
310: {col1 => 'Categories',
311: col2 => '',
312: }],
1.69 raeburn 313: },
314: 'serverstatuses' =>
1.77 raeburn 315: {text => 'Access to server status pages',
1.69 raeburn 316: help => 'Domain_Configuration_Server_Status',
317: header => [{col1 => 'Status Page',
318: col2 => 'Other named users',
319: col3 => 'Specific IPs',
320: }],
321: },
1.3 raeburn 322: );
1.110 raeburn 323: my %servers = &Apache::lonnet::get_servers($dom);
324: if (keys(%servers) > 1) {
325: $prefs{'login'} = { text => 'Log-in page options',
326: help => 'Domain_Configuration_Login_Page',
327: header => [{col1 => 'Log-in Service',
328: col2 => 'Server Setting',},
329: {col1 => 'Log-in Page Items',
330: col2 => ''}],
331: };
332: }
1.6 raeburn 333: my @roles = ('student','coordinator','author','admin');
1.30 raeburn 334: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
1.3 raeburn 335: &Apache::lonhtmlcommon::add_breadcrumb
1.30 raeburn 336: ({href=>"javascript:changePage(document.$phase,'pickactions')",
337: text=>"Pick functionality"});
1.9 raeburn 338: my $confname = $dom.'-domainconfig';
1.3 raeburn 339: if ($phase eq 'process') {
1.91 raeburn 340: &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);
1.30 raeburn 341: } elsif ($phase eq 'display') {
1.91 raeburn 342: &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname);
1.1 raeburn 343: } else {
1.21 raeburn 344: if (keys(%domconfig) == 0) {
345: my $primarylibserv = &Apache::lonnet::domain($dom,'primary');
1.29 raeburn 346: my @ids=&Apache::lonnet::current_machine_ids();
347: if (!grep(/^\Q$primarylibserv\E$/,@ids)) {
1.21 raeburn 348: my %designhash = &Apache::loncommon::get_domainconf($dom);
1.41 raeburn 349: my @loginimages = ('img','logo','domlogo','login');
1.21 raeburn 350: my $custom_img_count = 0;
351: foreach my $img (@loginimages) {
352: if ($designhash{$dom.'.login.'.$img} ne '') {
353: $custom_img_count ++;
354: }
355: }
356: foreach my $role (@roles) {
357: if ($designhash{$dom.'.'.$role.'.img'} ne '') {
358: $custom_img_count ++;
359: }
360: }
361: if ($custom_img_count > 0) {
1.94 raeburn 362: &Apache::lonconfigsettings::print_header($r,$phase,$context);
1.21 raeburn 363: my $switch_server = &check_switchserver($dom,$confname);
1.29 raeburn 364: $r->print(
365: &mt('Domain configuration settings have yet to be saved for this domain via the web-based domain preferences interface.').'<br />'.
366: &mt("While this remains so, you must switch to the domain's primary library server in order to update settings.").'<br /><br />'.
367: &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 />'.
368: &mt("However, you will still need to switch to the domain's primary library server to upload new images or logos.").'<br /><br />');
369: if ($switch_server) {
1.30 raeburn 370: $r->print($switch_server.' '.&mt('to primary library server for domain: [_1]',$dom));
1.29 raeburn 371: }
1.91 raeburn 372: $r->print(&Apache::loncommon::end_page());
1.21 raeburn 373: return OK;
374: }
375: }
376: }
1.91 raeburn 377: &Apache::lonconfigsettings::display_choices($r,$phase,$context,\@prefs_order,\%prefs);
1.3 raeburn 378: }
379: return OK;
380: }
381:
382: sub process_changes {
1.92 raeburn 383: my ($r,$dom,$confname,$action,$roles,$values) = @_;
384: my %domconfig;
385: if (ref($values) eq 'HASH') {
386: %domconfig = %{$values};
387: }
1.3 raeburn 388: my $output;
389: if ($action eq 'login') {
1.9 raeburn 390: $output = &modify_login($r,$dom,$confname,%domconfig);
1.6 raeburn 391: } elsif ($action eq 'rolecolors') {
1.9 raeburn 392: $output = &modify_rolecolors($r,$dom,$confname,$roles,
393: %domconfig);
1.3 raeburn 394: } elsif ($action eq 'quotas') {
1.86 raeburn 395: $output = &modify_quotas($dom,$action,%domconfig);
1.3 raeburn 396: } elsif ($action eq 'autoenroll') {
397: $output = &modify_autoenroll($dom,%domconfig);
398: } elsif ($action eq 'autoupdate') {
399: $output = &modify_autoupdate($dom,%domconfig);
1.23 raeburn 400: } elsif ($action eq 'directorysrch') {
401: $output = &modify_directorysrch($dom,%domconfig);
1.27 raeburn 402: } elsif ($action eq 'usercreation') {
1.28 raeburn 403: $output = &modify_usercreation($dom,%domconfig);
1.33 raeburn 404: } elsif ($action eq 'usermodification') {
405: $output = &modify_usermodification($dom,%domconfig);
1.28 raeburn 406: } elsif ($action eq 'contacts') {
407: $output = &modify_contacts($dom,%domconfig);
1.43 raeburn 408: } elsif ($action eq 'defaults') {
409: $output = &modify_defaults($dom,$r);
1.46 raeburn 410: } elsif ($action eq 'scantron') {
1.48 raeburn 411: $output = &modify_scantron($r,$dom,$confname,%domconfig);
412: } elsif ($action eq 'coursecategories') {
413: $output = &modify_coursecategories($dom,%domconfig);
1.69 raeburn 414: } elsif ($action eq 'serverstatuses') {
415: $output = &modify_serverstatuses($dom,%domconfig);
1.86 raeburn 416: } elsif ($action eq 'requestcourses') {
417: $output = &modify_quotas($dom,$action,%domconfig);
1.3 raeburn 418: }
419: return $output;
420: }
421:
422: sub print_config_box {
1.9 raeburn 423: my ($r,$dom,$confname,$phase,$action,$item,$settings) = @_;
1.30 raeburn 424: my $rowtotal = 0;
1.49 raeburn 425: my $output;
426: if ($action eq 'coursecategories') {
427: $output = &coursecategories_javascript($settings);
1.91 raeburn 428: }
1.49 raeburn 429: $output .=
1.30 raeburn 430: '<table class="LC_nested_outer">
1.3 raeburn 431: <tr>
1.66 raeburn 432: <th align="left" valign="middle"><span class="LC_nobreak">'.
433: &mt($item->{text}).' '.
434: &Apache::loncommon::help_open_topic($item->{'help'}).'</span></th>'."\n".
435: '</tr>';
1.30 raeburn 436: $rowtotal ++;
1.110 raeburn 437: my $numheaders = 1;
438: if (ref($item->{'header'}) eq 'ARRAY') {
439: $numheaders = scalar(@{$item->{'header'}});
440: }
441: if ($numheaders > 1) {
1.64 raeburn 442: my $colspan = '';
443: if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {
444: $colspan = ' colspan="2"';
445: }
1.30 raeburn 446: $output .= '
1.3 raeburn 447: <tr>
448: <td>
449: <table class="LC_nested">
450: <tr class="LC_info_row">
1.59 bisitz 451: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[0]->{'col1'}).'</td>
452: <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
1.30 raeburn 453: </tr>';
1.69 raeburn 454: $rowtotal ++;
1.6 raeburn 455: if ($action eq 'autoupdate') {
1.30 raeburn 456: $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal);
1.28 raeburn 457: } elsif ($action eq 'usercreation') {
1.33 raeburn 458: $output .= &print_usercreation('top',$dom,$settings,\$rowtotal);
459: } elsif ($action eq 'usermodification') {
460: $output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
1.57 raeburn 461: } elsif ($action eq 'coursecategories') {
462: $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
1.110 raeburn 463: } elsif ($action eq 'login') {
464: $output .= &print_login('top',$dom,$confname,$phase,$settings,\$rowtotal);
465: $colspan = ' colspan="2"';
1.102 raeburn 466: } elsif ($action eq 'requestcourses') {
467: $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
1.6 raeburn 468: } else {
1.30 raeburn 469: $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
1.6 raeburn 470: }
1.30 raeburn 471: $output .= '
1.6 raeburn 472: </table>
473: </td>
474: </tr>
475: <tr>
476: <td>
477: <table class="LC_nested">
478: <tr class="LC_info_row">
1.59 bisitz 479: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
1.57 raeburn 480: $output .= '
1.59 bisitz 481: <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[1]->{'col2'}).'</td>
1.30 raeburn 482: </tr>';
483: $rowtotal ++;
1.6 raeburn 484: if ($action eq 'autoupdate') {
1.30 raeburn 485: $output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
1.28 raeburn 486: } elsif ($action eq 'usercreation') {
1.34 raeburn 487: $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'
488: </table>
489: </td>
490: </tr>
491: <tr>
492: <td>
493: <table class="LC_nested">
494: <tr class="LC_info_row">
1.59 bisitz 495: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
496: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> </tr>'.
1.34 raeburn 497: &print_usercreation('bottom',$dom,$settings,\$rowtotal);
498: $rowtotal ++;
1.33 raeburn 499: } elsif ($action eq 'usermodification') {
1.63 raeburn 500: $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal).'
501: </table>
502: </td>
503: </tr>
504: <tr>
505: <td>
506: <table class="LC_nested">
507: <tr class="LC_info_row">
508: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
509: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> </tr>'.
510:
511: &print_usermodification('bottom',$dom,$settings,\$rowtotal);
512: $rowtotal ++;
1.57 raeburn 513: } elsif ($action eq 'coursecategories') {
514: $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
1.110 raeburn 515: } elsif ($action eq 'login') {
516: $output .= &print_login('bottom',$dom,$confname,$phase,$settings,\$rowtotal);
1.102 raeburn 517: } elsif ($action eq 'requestcourses') {
518: $output .= &print_courserequestmail($dom,$settings,\$rowtotal);
1.6 raeburn 519: } else {
1.30 raeburn 520: $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
1.6 raeburn 521: </table>
522: </td>
523: </tr>
524: <tr>
525: <td>
526: <table class="LC_nested">
527: <tr class="LC_info_row">
1.69 raeburn 528: <td class="LC_left_item"'.$colspan.' valign="top">'.
529: &mt($item->{'header'}->[2]->{'col1'}).'</td>
530: <td class="LC_right_item" valign="top">'.
531: &mt($item->{'header'}->[2]->{'col2'}).'</td>
1.3 raeburn 532: </tr>'.
1.30 raeburn 533: &print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'
1.3 raeburn 534: </table>
535: </td>
536: </tr>
537: <tr>
538: <td>
539: <table class="LC_nested">
540: <tr class="LC_info_row">
1.59 bisitz 541: <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col1'}).'</td>
542: <td class="LC_right_item">'.&mt($item->{'header'}->[3]->{'col2'}).'</td>
1.3 raeburn 543: </tr>'.
1.30 raeburn 544: &print_rolecolors($phase,'admin',$dom,$confname,$settings,\$rowtotal);
545: $rowtotal += 2;
1.6 raeburn 546: }
1.3 raeburn 547: } else {
1.30 raeburn 548: $output .= '
1.3 raeburn 549: <tr>
550: <td>
551: <table class="LC_nested">
1.30 raeburn 552: <tr class="LC_info_row">';
1.24 raeburn 553: if (($action eq 'login') || ($action eq 'directorysrch')) {
1.30 raeburn 554: $output .= '
1.59 bisitz 555: <td class="LC_left_item" colspan="2">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
1.69 raeburn 556: } elsif ($action eq 'serverstatuses') {
557: $output .= '
558: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).
559: '<br />('.&mt('Automatic access for Dom. Coords.').')</td>';
560:
1.6 raeburn 561: } else {
1.30 raeburn 562: $output .= '
1.69 raeburn 563: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
564: }
1.72 raeburn 565: if (defined($item->{'header'}->[0]->{'col3'})) {
566: $output .= '<td class="LC_left_item" valign="top">'.
567: &mt($item->{'header'}->[0]->{'col2'});
568: if ($action eq 'serverstatuses') {
569: $output .= '<br />(<tt>'.&mt('user1:domain1,user2:domain2 etc.').'</tt>)';
570: }
1.69 raeburn 571: } else {
572: $output .= '<td class="LC_right_item" valign="top">'.
573: &mt($item->{'header'}->[0]->{'col2'});
574: }
575: $output .= '</td>';
576: if ($item->{'header'}->[0]->{'col3'}) {
577: $output .= '<td class="LC_right_item" valign="top">'.
578: &mt($item->{'header'}->[0]->{'col3'});
579: if ($action eq 'serverstatuses') {
580: $output .= '<br />(<tt>'.&mt('IP1,IP2 etc.').'</tt>)';
581: }
582: $output .= '</td>';
1.6 raeburn 583: }
1.69 raeburn 584: $output .= '</tr>';
1.48 raeburn 585: $rowtotal ++;
1.3 raeburn 586: if ($action eq 'login') {
1.110 raeburn 587: $output .= &print_login('bottom',$dom,$confname,$phase,$settings,
588: \$rowtotal);
1.3 raeburn 589: } elsif ($action eq 'quotas') {
1.86 raeburn 590: $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
1.3 raeburn 591: } elsif ($action eq 'autoenroll') {
1.30 raeburn 592: $output .= &print_autoenroll($dom,$settings,\$rowtotal);
1.23 raeburn 593: } elsif ($action eq 'directorysrch') {
1.30 raeburn 594: $output .= &print_directorysrch($dom,$settings,\$rowtotal);
1.28 raeburn 595: } elsif ($action eq 'contacts') {
1.30 raeburn 596: $output .= &print_contacts($dom,$settings,\$rowtotal);
1.43 raeburn 597: } elsif ($action eq 'defaults') {
598: $output .= &print_defaults($dom,\$rowtotal);
1.46 raeburn 599: } elsif ($action eq 'scantron') {
600: $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
1.69 raeburn 601: } elsif ($action eq 'serverstatuses') {
602: $output .= &print_serverstatuses($dom,$settings,\$rowtotal);
1.27 raeburn 603: }
1.3 raeburn 604: }
1.30 raeburn 605: $output .= '
1.3 raeburn 606: </table>
607: </td>
608: </tr>
1.30 raeburn 609: </table><br />';
610: return ($output,$rowtotal);
1.1 raeburn 611: }
612:
1.3 raeburn 613: sub print_login {
1.110 raeburn 614: my ($position,$dom,$confname,$phase,$settings,$rowtotal) = @_;
615: my ($css_class,$datatable);
1.6 raeburn 616: my %choices = &login_choices();
1.110 raeburn 617: my $itemcount = 1;
618:
619: if ($position eq 'top') {
620: my %servers = &Apache::lonnet::get_servers($dom);
621: my $choice = $choices{'disallowlogin'};
622: $css_class = ' class="LC_odd_row"';
623: $datatable .= '<tr'.$css_class.'><td>'.$choices{'disallowlogin'}.'</td>'.
624: '<td align="right"><table><tr><th>'.$choices{'hostid'}.'</th>'.
625: '<th>'.$choices{'serverurl'}.'</th></tr>'."\n";
626: my %disallowed;
627: if (ref($settings) eq 'HASH') {
628: if (ref($settings->{'loginvia'}) eq 'HASH') {
629: %disallowed = %{$settings->{'loginvia'}};
630: }
631: }
632: foreach my $lonhost (sort(keys(%servers))) {
633: my $direct = 'selected="selected"';
634: if ($disallowed{$lonhost} eq '') {
635: $direct = '';
636: }
637: $datatable .= '<tr><td>'.$lonhost.'</td>'.
638: '<td><select name="'.$lonhost.'_serverurl">'.
639: '<option value=""'.$direct.'>'.$choices{'directlogin'}.
640: '</option>';
641: foreach my $hostid (keys(%servers)) {
642: next if ($hostid eq $lonhost);
643: my $selected = '';
644: if ($hostid eq $disallowed{$lonhost}) {
645: $selected = 'selected="selected"';
646: }
647: $datatable .= '<option value="'.$hostid.'"'.$selected.'>'.
648: $servers{$hostid}.'</option>';
649: }
650: $datatable .= '</select></td></tr>';
651: }
652: $datatable .= '</table></td></tr>';
653: return $datatable;
654: }
655:
1.42 raeburn 656: my %defaultchecked = (
1.43 raeburn 657: 'coursecatalog' => 'on',
658: 'adminmail' => 'off',
659: 'newuser' => 'off',
660: );
661: my @toggles = ('coursecatalog','adminmail','newuser');
1.42 raeburn 662: my (%checkedon,%checkedoff);
663: foreach my $item (@toggles) {
664: if ($defaultchecked{$item} eq 'on') {
665: $checkedon{$item} = ' checked="checked" ';
666: $checkedoff{$item} = ' ';
667: } elsif ($defaultchecked{$item} eq 'off') {
668: $checkedoff{$item} = ' checked="checked" ';
669: $checkedon{$item} = ' ';
670: }
671: }
672: my $loginheader = 'image';
1.41 raeburn 673: my @images = ('img','logo','domlogo','login');
674: my @logintext = ('textcol','bgcol');
1.6 raeburn 675: my @bgs = ('pgbg','mainbg','sidebg');
676: my @links = ('link','alink','vlink');
1.7 albertel 677: my %designhash = &Apache::loncommon::get_domainconf($dom);
1.6 raeburn 678: my %defaultdesign = %Apache::loncommon::defaultdesign;
679: my (%is_custom,%designs);
680: my %defaults = (
681: font => $defaultdesign{'login.font'},
682: );
683: foreach my $item (@images) {
684: $defaults{$item} = $defaultdesign{'login.'.$item};
1.70 raeburn 685: $defaults{'showlogo'}{$item} = 1;
1.6 raeburn 686: }
687: foreach my $item (@bgs) {
688: $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
689: }
1.41 raeburn 690: foreach my $item (@logintext) {
691: $defaults{'logintext'}{$item} = $defaultdesign{'login.'.$item};
692: }
1.6 raeburn 693: foreach my $item (@links) {
694: $defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
695: }
1.3 raeburn 696: if (ref($settings) eq 'HASH') {
1.42 raeburn 697: foreach my $item (@toggles) {
698: if ($settings->{$item} eq '1') {
699: $checkedon{$item} = ' checked="checked" ';
700: $checkedoff{$item} = ' ';
701: } elsif ($settings->{$item} eq '0') {
702: $checkedoff{$item} = ' checked="checked" ';
703: $checkedon{$item} = ' ';
704: }
1.1 raeburn 705: }
1.6 raeburn 706: foreach my $item (@images) {
1.70 raeburn 707: if (defined($settings->{$item})) {
1.6 raeburn 708: $designs{$item} = $settings->{$item};
709: $is_custom{$item} = 1;
710: }
1.70 raeburn 711: if (defined($settings->{'showlogo'}{$item})) {
712: $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
713: }
1.6 raeburn 714: }
1.41 raeburn 715: foreach my $item (@logintext) {
716: if ($settings->{$item} ne '') {
717: $designs{'logintext'}{$item} = $settings->{$item};
718: $is_custom{$item} = 1;
719: }
720: }
721: if ($settings->{'loginheader'} ne '') {
722: $loginheader = $settings->{'loginheader'};
723: }
1.6 raeburn 724: if ($settings->{'font'} ne '') {
725: $designs{'font'} = $settings->{'font'};
726: $is_custom{'font'} = 1;
727: }
728: foreach my $item (@bgs) {
729: if ($settings->{$item} ne '') {
730: $designs{'bgs'}{$item} = $settings->{$item};
731: $is_custom{$item} = 1;
732: }
733: }
734: foreach my $item (@links) {
735: if ($settings->{$item} ne '') {
736: $designs{'links'}{$item} = $settings->{$item};
737: $is_custom{$item} = 1;
738: }
739: }
740: } else {
741: if ($designhash{$dom.'.login.font'} ne '') {
742: $designs{'font'} = $designhash{$dom.'.login.font'};
743: $is_custom{'font'} = 1;
744: }
1.8 raeburn 745: foreach my $item (@images) {
746: if ($designhash{$dom.'.login.'.$item} ne '') {
747: $designs{$item} = $designhash{$dom.'.login.'.$item};
748: $is_custom{$item} = 1;
749: }
750: }
1.6 raeburn 751: foreach my $item (@bgs) {
752: if ($designhash{$dom.'.login.'.$item} ne '') {
753: $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item};
754: $is_custom{$item} = 1;
755: }
756: }
757: foreach my $item (@links) {
758: if ($designhash{$dom.'.login.'.$item} ne '') {
759: $designs{'links'}{$item} = $designhash{$dom.'.login.'.$item};
760: $is_custom{$item} = 1;
761: }
762: }
1.1 raeburn 763: }
1.6 raeburn 764: my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
765: logo => 'Institution Logo',
1.41 raeburn 766: domlogo => 'Domain Logo',
767: login => 'Login box');
1.6 raeburn 768: my $itemcount = 1;
1.42 raeburn 769: my ($css_class,$datatable);
770: foreach my $item (@toggles) {
771: $css_class = $itemcount%2?' class="LC_odd_row"':'';
772: $datatable .=
773: '<tr'.$css_class.'><td colspan="2">'.$choices{$item}.
774: '</td><td>'.
775: '<span class="LC_nobreak"><label><input type="radio" name="'.
776: $item.'"'.$checkedon{$item}.' value="1" />'.&mt('Yes').
777: '</label> <label><input type="radio" name="'.$item.'"'.
778: $checkedoff{$item}.' value="0" />'.&mt('No').'</label></span></td>'.
779: '</tr>';
780: $itemcount ++;
781: }
1.41 raeburn 782: $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext,$loginheader);
1.6 raeburn 783: $datatable .= '</tr></table></td></tr>';
784: return $datatable;
785: }
786:
787: sub login_choices {
788: my %choices =
789: &Apache::lonlocal::texthash (
790: coursecatalog => 'Display Course Catalog link?',
1.110 raeburn 791: adminmail => "Display Administrator's E-mail Address?",
792: disallowlogin => "Login page requests redirected",
793: hostid => "Server",
794: serverurl => "Redirect to log-in via:",
795: directlogin => "No redirect",
796: newuser => "Link to create a user account",
797: img => "Header",
798: logo => "Main Logo",
799: domlogo => "Domain Logo",
800: login => "Log-in Header",
801: textcol => "Text color",
802: bgcol => "Box color",
803: bgs => "Background colors",
804: links => "Link colors",
805: font => "Font color",
806: pgbg => "Header",
807: mainbg => "Page",
808: sidebg => "Login box",
809: link => "Link",
810: alink => "Active link",
811: vlink => "Visited link",
1.6 raeburn 812: );
813: return %choices;
814: }
815:
816: sub print_rolecolors {
1.30 raeburn 817: my ($phase,$role,$dom,$confname,$settings,$rowtotal) = @_;
1.6 raeburn 818: my %choices = &color_font_choices();
819: my @bgs = ('pgbg','tabbg','sidebg');
820: my @links = ('link','alink','vlink');
821: my @images = ('img');
822: my %alt_text = &Apache::lonlocal::texthash(img => "Banner for $role role");
1.7 albertel 823: my %designhash = &Apache::loncommon::get_domainconf($dom);
1.6 raeburn 824: my %defaultdesign = %Apache::loncommon::defaultdesign;
825: my (%is_custom,%designs);
826: my %defaults = (
827: img => $defaultdesign{$role.'.img'},
828: font => $defaultdesign{$role.'.font'},
1.97 tempelho 829: fontmenu => $defaultdesign{$role.'.fontmenu'},
1.6 raeburn 830: );
831: foreach my $item (@bgs) {
832: $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
833: }
834: foreach my $item (@links) {
835: $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
836: }
837: if (ref($settings) eq 'HASH') {
838: if (ref($settings->{$role}) eq 'HASH') {
839: if ($settings->{$role}->{'img'} ne '') {
840: $designs{'img'} = $settings->{$role}->{'img'};
841: $is_custom{'img'} = 1;
842: }
843: if ($settings->{$role}->{'font'} ne '') {
844: $designs{'font'} = $settings->{$role}->{'font'};
845: $is_custom{'font'} = 1;
846: }
1.97 tempelho 847: if ($settings->{$role}->{'fontmenu'} ne '') {
848: $designs{'fontmenu'} = $settings->{$role}->{'fontmenu'};
849: $is_custom{'fontmenu'} = 1;
850: }
1.6 raeburn 851: foreach my $item (@bgs) {
852: if ($settings->{$role}->{$item} ne '') {
853: $designs{'bgs'}{$item} = $settings->{$role}->{$item};
854: $is_custom{$item} = 1;
855: }
856: }
857: foreach my $item (@links) {
858: if ($settings->{$role}->{$item} ne '') {
859: $designs{'links'}{$item} = $settings->{$role}->{$item};
860: $is_custom{$item} = 1;
861: }
862: }
863: }
864: } else {
865: if ($designhash{$dom.'.'.$role.'.img'} ne '') {
866: $designs{img} = $designhash{$dom.'.'.$role.'.img'};
867: $is_custom{'img'} = 1;
868: }
1.97 tempelho 869: if ($designhash{$dom.'.'.$role.'.fontmenu'} ne '') {
870: $designs{fontmenu} = $designhash{$dom.'.'.$role.'.fontmenu'};
871: $is_custom{'fontmenu'} = 1;
872: }
1.6 raeburn 873: if ($designhash{$dom.'.'.$role.'.font'} ne '') {
874: $designs{font} = $designhash{$dom.'.'.$role.'.font'};
875: $is_custom{'font'} = 1;
876: }
877: foreach my $item (@bgs) {
878: if ($designhash{$dom.'.'.$role.'.'.$item} ne '') {
879: $designs{'bgs'}{$item} = $designhash{$dom.'.'.$role.'.'.$item};
880: $is_custom{$item} = 1;
881:
882: }
883: }
884: foreach my $item (@links) {
885: if ($designhash{$dom.'.'.$role.'.'.$item} ne '') {
886: $designs{'links'}{$item} = $designhash{$dom.'.'.$role.'.'.$item};
887: $is_custom{$item} = 1;
888: }
889: }
890: }
891: my $itemcount = 1;
1.30 raeburn 892: my $datatable = &display_color_options($dom,$confname,$phase,$role,$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal);
1.6 raeburn 893: $datatable .= '</tr></table></td></tr>';
894: return $datatable;
895: }
896:
897: sub display_color_options {
1.9 raeburn 898: my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
1.41 raeburn 899: $images,$bgs,$links,$alt_text,$rowtotal,$logintext,$loginheader) = @_;
1.6 raeburn 900: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.97 tempelho 901: my $datatable = '<tr>'.
1.6 raeburn 902: '<td>'.$choices->{'font'}.'</td>';
903: if (!$is_custom->{'font'}) {
1.30 raeburn 904: $datatable .= '<td>'.&mt('Default in use:').' <span id="css_default_'.$role.'_font" style="color: '.$defaults->{'font'}.';">'.$defaults->{'font'}.'</span></td>';
1.6 raeburn 905: } else {
906: $datatable .= '<td> </td>';
907: }
908: my $fontlink = &color_pick($phase,$role,'font',$choices->{'font'},$designs->{'font'});
1.8 raeburn 909: $datatable .= '<td><span class="LC_nobreak">'.
1.6 raeburn 910: '<input type="text" size="10" name="'.$role.'_font"'.
1.8 raeburn 911: ' value="'.$designs->{'font'}.'" /> '.$fontlink.
1.30 raeburn 912: ' <span id="css_'.$role.'_font" style="background-color: '.
913: $designs->{'font'}.';"> </span>'.
1.8 raeburn 914: '</span></td></tr>';
1.107 raeburn 915: unless ($role eq 'login') {
916: $datatable .= '<tr'.$css_class.'>'.
917: '<td>'.$choices->{'fontmenu'}.'</td>';
918: if (!$is_custom->{'fontmenu'}) {
919: $datatable .= '<td>'.&mt('Default in use:').' <span id="css_default_'.$role.'_font" style="color: '.$defaults->{'fontmenu'}.';">'.$defaults->{'fontmenu'}.'</span></td>';
920: } else {
921: $datatable .= '<td> </td>';
922: }
923: $fontlink = &color_pick($phase,$role,'fontmenu',$choices->{'fontmenu'},$designs->{'fontmenu'});
924: $datatable .= '<td><span class="LC_nobreak">'.
925: '<input type="text" size="10" name="'.$role.'_fontmenu"'.
926: ' value="'.$designs->{'fontmenu'}.'" /> '.$fontlink.
927: ' <span id="css_'.$role.'_fontmenu" style="background-color: '.
928: $designs->{'fontmenu'}.';"> </span>'.
929: '</span></td></tr>';
1.97 tempelho 930: }
1.9 raeburn 931: my $switchserver = &check_switchserver($dom,$confname);
1.6 raeburn 932: foreach my $img (@{$images}) {
1.18 albertel 933: $itemcount ++;
1.6 raeburn 934: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.8 raeburn 935: $datatable .= '<tr'.$css_class.'>'.
1.70 raeburn 936: '<td>'.$choices->{$img};
1.41 raeburn 937: my ($imgfile,$img_import,$login_hdr_pick,$logincolors);
1.70 raeburn 938: if ($role eq 'login') {
939: if ($img eq 'login') {
940: $login_hdr_pick =
941: &login_header_options($img,$role,$defaults,$is_custom,$choices,
942: $loginheader);
943: $logincolors =
944: &login_text_colors($img,$role,$logintext,$phase,$choices,
945: $designs);
946: } elsif ($img ne 'domlogo') {
947: $datatable.= &logo_display_options($img,$defaults,$designs);
948: }
949: }
950: $datatable .= '</td>';
1.6 raeburn 951: if ($designs->{$img} ne '') {
952: $imgfile = $designs->{$img};
1.18 albertel 953: $img_import = ($imgfile =~ m{^/adm/});
1.6 raeburn 954: } else {
955: $imgfile = $defaults->{$img};
956: }
957: if ($imgfile) {
1.9 raeburn 958: my ($showfile,$fullsize);
959: if ($imgfile =~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
1.6 raeburn 960: my $urldir = $1;
961: my $filename = $2;
962: my @info = &Apache::lonnet::stat_file($designs->{$img});
963: if (@info) {
964: my $thumbfile = 'tn-'.$filename;
965: my @thumb=&Apache::lonnet::stat_file($urldir.'/'.$thumbfile);
966: if (@thumb) {
967: $showfile = $urldir.'/'.$thumbfile;
968: } else {
969: $showfile = $imgfile;
970: }
971: } else {
972: $showfile = '';
973: }
974: } elsif ($imgfile =~ m-^/(adm/[^/]+)/([^/]+)$-) {
1.16 raeburn 975: $showfile = $imgfile;
1.6 raeburn 976: my $imgdir = $1;
977: my $filename = $2;
978: if (-e "/home/httpd/html/$imgdir/tn-".$filename) {
979: $showfile = "/$imgdir/tn-".$filename;
980: } else {
981: my $input = "/home/httpd/html".$imgfile;
982: my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename;
983: if (!-e $output) {
1.9 raeburn 984: my ($width,$height) = &thumb_dimensions();
1.16 raeburn 985: my ($fullwidth,$fullheight) = &check_dimensions($input);
986: if ($fullwidth ne '' && $fullheight ne '') {
987: if ($fullwidth > $width && $fullheight > $height) {
988: my $size = $width.'x'.$height;
989: system("convert -sample $size $input $output");
990: $showfile = '/'.$imgdir.'/tn-'.$filename;
991: }
992: }
1.6 raeburn 993: }
994: }
1.16 raeburn 995: }
1.6 raeburn 996: if ($showfile) {
1.40 raeburn 997: if ($showfile =~ m{^/(adm|res)/}) {
998: if ($showfile =~ m{^/res/}) {
999: my $local_showfile =
1000: &Apache::lonnet::filelocation('',$showfile);
1001: &Apache::lonnet::repcopy($local_showfile);
1002: }
1003: $showfile = &Apache::loncommon::lonhttpdurl($showfile);
1004: }
1005: if ($imgfile) {
1006: if ($imgfile =~ m{^/(adm|res)/}) {
1007: if ($imgfile =~ m{^/res/}) {
1008: my $local_imgfile =
1009: &Apache::lonnet::filelocation('',$imgfile);
1010: &Apache::lonnet::repcopy($local_imgfile);
1011: }
1012: $fullsize = &Apache::loncommon::lonhttpdurl($imgfile);
1013: } else {
1014: $fullsize = $imgfile;
1015: }
1016: }
1.41 raeburn 1017: $datatable .= '<td>';
1018: if ($img eq 'login') {
1019: $datatable .= $login_hdr_pick;
1.6 raeburn 1020: }
1.41 raeburn 1021: $datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import,
1022: $showfile,$fullsize,$role,$img,$imgfile,$logincolors);
1.6 raeburn 1023: } else {
1024: $datatable .= '<td colspan="2" class="LC_right_item"><br />'.
1025: &mt('Upload:');
1026: }
1027: } else {
1028: $datatable .= '<td colspan="2" class="LC_right_item"><br />'.
1029: &mt('Upload:');
1030: }
1.9 raeburn 1031: if ($switchserver) {
1032: $datatable .= &mt('Upload to library server: [_1]',$switchserver);
1033: } else {
1034: $datatable .=' <input type="file" name="'.$role.'_'.$img.'" />';
1035: }
1036: $datatable .= '</td></tr>';
1.6 raeburn 1037: }
1038: $itemcount ++;
1039: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1040: $datatable .= '<tr'.$css_class.'>'.
1041: '<td>'.$choices->{'bgs'}.'</td>';
1042: my $bgs_def;
1043: foreach my $item (@{$bgs}) {
1044: if (!$is_custom->{$item}) {
1.70 raeburn 1045: $bgs_def .= '<td><span class="LC_nobreak">'.$choices->{$item}.'</span> <span id="css_default_'.$role.'_'.$item.'" style="background-color: '.$defaults->{'bgs'}{$item}.';"> </span><br />'.$defaults->{'bgs'}{$item}.'</td>';
1.6 raeburn 1046: }
1047: }
1048: if ($bgs_def) {
1.8 raeburn 1049: $datatable .= '<td>'.&mt('Default(s) in use:').'<br /><table border="0"><tr>'.$bgs_def.'</tr></table></td>';
1.6 raeburn 1050: } else {
1051: $datatable .= '<td> </td>';
1052: }
1053: $datatable .= '<td class="LC_right_item">'.
1054: '<table border="0"><tr>';
1055: foreach my $item (@{$bgs}) {
1056: my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'bgs'}{$item});
1057: $datatable .= '<td align="center">'.$link;
1058: if ($designs->{'bgs'}{$item}) {
1.30 raeburn 1059: $datatable .= ' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'bgs'}{$item}.';"> </span>';
1.6 raeburn 1060: }
1061: $datatable .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.$designs->{'bgs'}{$item}.
1.41 raeburn 1062: '" onblur = "javascript:colchg_span('."'css_".$role.'_'.$item."'".',this);" /></td>';
1.6 raeburn 1063: }
1064: $datatable .= '</tr></table></td></tr>';
1065: $itemcount ++;
1066: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1067: $datatable .= '<tr'.$css_class.'>'.
1068: '<td>'.$choices->{'links'}.'</td>';
1069: my $links_def;
1070: foreach my $item (@{$links}) {
1071: if (!$is_custom->{$item}) {
1.30 raeburn 1072: $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 1073: }
1074: }
1075: if ($links_def) {
1.8 raeburn 1076: $datatable .= '<td>'.&mt('Default(s) in use:').'<br /><table border="0"><tr>'.$links_def.'</tr></table></td>';
1.6 raeburn 1077: } else {
1078: $datatable .= '<td> </td>';
1079: }
1080: $datatable .= '<td class="LC_right_item">'.
1081: '<table border="0"><tr>';
1082: foreach my $item (@{$links}) {
1.30 raeburn 1083: $datatable .= '<td align="center">'."\n".
1084: &color_pick($phase,$role,$item,$choices->{$item},
1085: $designs->{'links'}{$item});
1.6 raeburn 1086: if ($designs->{'links'}{$item}) {
1.30 raeburn 1087: $datatable.=' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'links'}{$item}.';"> </span>';
1.6 raeburn 1088: }
1089: $datatable .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.$designs->{'links'}{$item}.
1090: '" /></td>';
1091: }
1.30 raeburn 1092: $$rowtotal += $itemcount;
1.3 raeburn 1093: return $datatable;
1094: }
1095:
1.70 raeburn 1096: sub logo_display_options {
1097: my ($img,$defaults,$designs) = @_;
1098: my $checkedon;
1099: if (ref($defaults) eq 'HASH') {
1100: if (ref($defaults->{'showlogo'}) eq 'HASH') {
1101: if ($defaults->{'showlogo'}{$img}) {
1102: $checkedon = 'checked="checked" ';
1103: }
1104: }
1105: }
1106: if (ref($designs) eq 'HASH') {
1107: if (ref($designs->{'showlogo'}) eq 'HASH') {
1108: if (defined($designs->{'showlogo'}{$img})) {
1109: if ($designs->{'showlogo'}{$img} == 0) {
1110: $checkedon = '';
1111: } elsif ($designs->{'showlogo'}{$img} == 1) {
1112: $checkedon = 'checked="checked" ';
1113: }
1114: }
1115: }
1116: }
1117: return '<br /><label> <input type="checkbox" name="'.
1118: 'login_showlogo_'.$img.'" value="1" '.$checkedon.'/>'.
1119: &mt('show').'</label>'."\n";
1120: }
1121:
1.41 raeburn 1122: sub login_header_options {
1123: my ($img,$role,$defaults,$is_custom,$choices,$loginheader) = @_;
1124: my $image_checked = ' checked="checked" ';
1125: my $text_checked = ' ';
1126: if ($loginheader eq 'text') {
1127: $image_checked = ' ';
1128: $text_checked = ' checked="checked" ';
1129: }
1130: my $output = '<span class="LC_nobreak"><label><input type="radio" name="'.
1131: 'loginheader" value="image" '.$image_checked.'/>'.
1132: &mt('use image').'</label> '.
1133: '<label><input type="radio" name="loginheader" value="text"'.
1134: $text_checked.'/>'.&mt('use text').'</label><br />'."\n";
1135: if ((!$is_custom->{'textcol'}) || (!$is_custom->{'bgcol'})) {
1136: $output .= &mt('Text default(s)').':<br />';
1137: if (!$is_custom->{'textcol'}) {
1138: $output .= $choices->{'textcol'}.': '.$defaults->{'logintext'}{'textcol'}.
1139: ' ';
1140: }
1141: if (!$is_custom->{'bgcol'}) {
1142: $output .= $choices->{'bgcol'}.': '.
1143: '<span id="css_'.$role.'_font" style="background-color: '.
1144: $defaults->{'logintext'}{'bgcol'}.';"> </span>';
1145: }
1146: $output .= '<br />';
1147: }
1148: $output .='<br />';
1149: return $output;
1150: }
1151:
1152: sub login_text_colors {
1153: my ($img,$role,$logintext,$phase,$choices,$designs) = @_;
1154: my $color_menu = '<table border="0"><tr>';
1155: foreach my $item (@{$logintext}) {
1156: my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'logintext'}{$item});
1157: $color_menu .= '<td align="center">'.$link;
1158: if ($designs->{'logintext'}{$item}) {
1159: $color_menu .= ' <span id="css_'.$role.'_'.$item.'" style="background-color: '.$designs->{'logintext'}{$item}.';"> </span>';
1160: }
1161: $color_menu .= '<br /><input type="text" size="8" name="'.$role.'_'.$item.'" value="'.
1162: $designs->{'logintext'}{$item}.'" onblur = "javascript:colchg_span('."'css_".$role.'_'.$item."'".',this);" /></td>'.
1163: '<td> </td>';
1164: }
1165: $color_menu .= '</tr></table><br />';
1166: return $color_menu;
1167: }
1168:
1169: sub image_changes {
1170: my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;
1171: my $output;
1172: if (!$is_custom) {
1.70 raeburn 1173: if ($img ne 'domlogo') {
1.41 raeburn 1174: $output .= &mt('Default image:').'<br />';
1175: } else {
1176: $output .= &mt('Default in use:').'<br />';
1177: }
1178: }
1179: if ($img_import) {
1180: $output .= '<input type="hidden" name="'.$role.'_import_'.$img.'" value="'.$imgfile.'" />';
1181: }
1182: $output .= '<a href="'.$fullsize.'" target="_blank"><img src="'.
1183: $showfile.'" alt="'.$alt_text.'" border="0" /></a></td>';
1184: if ($is_custom) {
1185: $output .= '<td>'.$logincolors.'<span class="LC_nobreak"><label>'.
1186: '<input type="checkbox" name="'.
1187: $role.'_del_'.$img.'" value="1" />'.&mt('Delete?').
1188: '</label> '.&mt('Replace:').'</span><br />';
1189: } else {
1190: $output .= '<td valign="bottom">'.$logincolors.&mt('Upload:').'<br />';
1191: }
1192: return $output;
1193: }
1194:
1.6 raeburn 1195: sub color_pick {
1196: my ($phase,$role,$item,$desc,$curcol) = @_;
1197: my $link = '<a href="javascript:pjump('."'color_custom','".$desc.
1198: "','".$curcol."','".$role.'_'.$item."','parmform.pres','psub'".
1199: ');">'.$desc.'</a>';
1200: return $link;
1201: }
1202:
1.3 raeburn 1203: sub print_quotas {
1.86 raeburn 1204: my ($dom,$settings,$rowtotal,$action) = @_;
1205: my $context;
1206: if ($action eq 'quotas') {
1207: $context = 'tools';
1208: } else {
1209: $context = $action;
1210: }
1.101 raeburn 1211: my ($datatable,$defaultquota,@usertools,@options,%validations);
1.44 raeburn 1212: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.3 raeburn 1213: my $typecount = 0;
1.101 raeburn 1214: my ($css_class,%titles);
1.86 raeburn 1215: if ($context eq 'requestcourses') {
1.98 raeburn 1216: @usertools = ('official','unofficial','community');
1.106 raeburn 1217: @options =('norequest','approval','validate','autolimit');
1.101 raeburn 1218: %validations = &Apache::lonnet::auto_courserequest_checks($dom);
1219: %titles = &courserequest_titles();
1.86 raeburn 1220: } else {
1221: @usertools = ('aboutme','blog','portfolio');
1.101 raeburn 1222: %titles = &tool_titles();
1.86 raeburn 1223: }
1.26 raeburn 1224: if (ref($types) eq 'ARRAY') {
1.23 raeburn 1225: foreach my $type (@{$types}) {
1.72 raeburn 1226: my $currdefquota;
1.86 raeburn 1227: unless ($context eq 'requestcourses') {
1228: if (ref($settings) eq 'HASH') {
1229: if (ref($settings->{defaultquota}) eq 'HASH') {
1230: $currdefquota = $settings->{defaultquota}->{$type};
1231: } else {
1232: $currdefquota = $settings->{$type};
1233: }
1.78 raeburn 1234: }
1.72 raeburn 1235: }
1.3 raeburn 1236: if (defined($usertypes->{$type})) {
1237: $typecount ++;
1238: $css_class = $typecount%2?' class="LC_odd_row"':'';
1.72 raeburn 1239: $datatable .= '<tr'.$css_class.'>'.
1.3 raeburn 1240: '<td>'.$usertypes->{$type}.'</td>'.
1.72 raeburn 1241: '<td class="LC_left_item">';
1.101 raeburn 1242: if ($context eq 'requestcourses') {
1243: $datatable .= '<table><tr>';
1244: }
1245: my %cell;
1.72 raeburn 1246: foreach my $item (@usertools) {
1.101 raeburn 1247: if ($context eq 'requestcourses') {
1248: my ($curroption,$currlimit);
1249: if (ref($settings) eq 'HASH') {
1250: if (ref($settings->{$item}) eq 'HASH') {
1251: $curroption = $settings->{$item}->{$type};
1252: if ($curroption =~ /^autolimit=(\d*)$/) {
1253: $currlimit = $1;
1254: }
1255: }
1256: }
1257: if (!$curroption) {
1258: $curroption = 'norequest';
1259: }
1260: $datatable .= '<th>'.$titles{$item}.'</th>';
1261: foreach my $option (@options) {
1262: my $val = $option;
1263: if ($option eq 'norequest') {
1264: $val = 0;
1265: }
1266: if ($option eq 'validate') {
1267: my $canvalidate = 0;
1268: if (ref($validations{$item}) eq 'HASH') {
1269: if ($validations{$item}{$type}) {
1270: $canvalidate = 1;
1271: }
1272: }
1273: next if (!$canvalidate);
1274: }
1275: my $checked = '';
1276: if ($option eq $curroption) {
1277: $checked = ' checked="checked"';
1278: } elsif ($option eq 'autolimit') {
1279: if ($curroption =~ /^autolimit/) {
1280: $checked = ' checked="checked"';
1281: }
1282: }
1283: $cell{$item} .= '<span class="LC_nobreak"><label>'.
1284: '<input type="radio" name="crsreq_'.$item.
1285: '_'.$type.'" value="'.$val.'"'.$checked.' />'.
1286: $titles{$option}.'</label> ';
1287: if ($option eq 'autolimit') {
1288: $cell{$item} .= '<input type="text" name="crsreq_'.
1289: $item.'_limit_'.$type.'" size="1" '.
1.103 raeburn 1290: 'value="'.$currlimit.'" />';
1.101 raeburn 1291: }
1292: $cell{$item} .= '</span> ';
1.103 raeburn 1293: if ($option eq 'autolimit') {
1294: $cell{$item} .= $titles{'unlimited'}
1295: }
1.101 raeburn 1296: }
1297: } else {
1298: my $checked = 'checked="checked" ';
1299: if (ref($settings) eq 'HASH') {
1300: if (ref($settings->{$item}) eq 'HASH') {
1301: if ($settings->{$item}->{$type} == 0) {
1302: $checked = '';
1303: } elsif ($settings->{$item}->{$type} == 1) {
1304: $checked = 'checked="checked" ';
1305: }
1.78 raeburn 1306: }
1.72 raeburn 1307: }
1.101 raeburn 1308: $datatable .= '<span class="LC_nobreak"><label>'.
1309: '<input type="checkbox" name="'.$context.'_'.$item.
1310: '" value="'.$type.'" '.$checked.'/>'.$titles{$item}.
1311: '</label></span> ';
1.72 raeburn 1312: }
1.101 raeburn 1313: }
1314: if ($context eq 'requestcourses') {
1315: $datatable .= '</tr><tr>';
1316: foreach my $item (@usertools) {
1.106 raeburn 1317: $datatable .= '<td style="vertical-align: top">'.$cell{$item}.'</td>';
1.101 raeburn 1318: }
1319: $datatable .= '</tr></table>';
1.72 raeburn 1320: }
1.86 raeburn 1321: $datatable .= '</td>';
1322: unless ($context eq 'requestcourses') {
1323: $datatable .=
1324: '<td class="LC_right_item"><span class="LC_nobreak">'.
1.3 raeburn 1325: '<input type="text" name="quota_'.$type.
1.72 raeburn 1326: '" value="'.$currdefquota.
1.86 raeburn 1327: '" size="5" /> Mb</span></td>';
1328: }
1329: $datatable .= '</tr>';
1.3 raeburn 1330: }
1331: }
1332: }
1.86 raeburn 1333: unless ($context eq 'requestcourses') {
1334: $defaultquota = '20';
1335: if (ref($settings) eq 'HASH') {
1336: if (ref($settings->{'defaultquota'}) eq 'HASH') {
1337: $defaultquota = $settings->{'defaultquota'}->{'default'};
1338: } elsif (defined($settings->{'default'})) {
1339: $defaultquota = $settings->{'default'};
1340: }
1.3 raeburn 1341: }
1342: }
1343: $typecount ++;
1344: $css_class = $typecount%2?' class="LC_odd_row"':'';
1345: $datatable .= '<tr'.$css_class.'>'.
1.26 raeburn 1346: '<td>'.$othertitle.'</td>'.
1.72 raeburn 1347: '<td class="LC_left_item">';
1.101 raeburn 1348: if ($context eq 'requestcourses') {
1349: $datatable .= '<table><tr>';
1350: }
1351: my %defcell;
1.72 raeburn 1352: foreach my $item (@usertools) {
1.101 raeburn 1353: if ($context eq 'requestcourses') {
1354: my ($curroption,$currlimit);
1355: if (ref($settings) eq 'HASH') {
1356: if (ref($settings->{$item}) eq 'HASH') {
1357: $curroption = $settings->{$item}->{'default'};
1358: if ($curroption =~ /^autolimit=(\d*)$/) {
1359: $currlimit = $1;
1360: }
1361: }
1362: }
1363: if (!$curroption) {
1364: $curroption = 'norequest';
1365: }
1366: $datatable .= '<th>'.$titles{$item}.'</th>';
1367: foreach my $option (@options) {
1368: my $val = $option;
1369: if ($option eq 'norequest') {
1370: $val = 0;
1371: }
1372: if ($option eq 'validate') {
1373: my $canvalidate = 0;
1374: if (ref($validations{$item}) eq 'HASH') {
1375: if ($validations{$item}{'default'}) {
1376: $canvalidate = 1;
1377: }
1378: }
1379: next if (!$canvalidate);
1380: }
1381: my $checked = '';
1382: if ($option eq $curroption) {
1383: $checked = ' checked="checked"';
1384: } elsif ($option eq 'autolimit') {
1385: if ($curroption =~ /^autolimit/) {
1386: $checked = ' checked="checked"';
1387: }
1388: }
1389: $defcell{$item} .= '<span class="LC_nobreak"><label>'.
1390: '<input type="radio" name="crsreq_'.$item.
1391: '_default" value="'.$val.'"'.$checked.' />'.
1392: $titles{$option}.'</label>';
1393: if ($option eq 'autolimit') {
1394: $defcell{$item} .= '<input type="text" name="crsreq_'.
1395: $item.'_limit_default" size="1" '.
1396: 'value="'.$currlimit.'" />';
1397: }
1398: $defcell{$item} .= '</span> ';
1.104 raeburn 1399: if ($option eq 'autolimit') {
1400: $defcell{$item} .= $titles{'unlimited'}
1401: }
1.101 raeburn 1402: }
1403: } else {
1404: my $checked = 'checked="checked" ';
1405: if (ref($settings) eq 'HASH') {
1406: if (ref($settings->{$item}) eq 'HASH') {
1407: if ($settings->{$item}->{'default'} == 0) {
1408: $checked = '';
1409: } elsif ($settings->{$item}->{'default'} == 1) {
1410: $checked = 'checked="checked" ';
1411: }
1.78 raeburn 1412: }
1.72 raeburn 1413: }
1.101 raeburn 1414: $datatable .= '<span class="LC_nobreak"><label>'.
1415: '<input type="checkbox" name="'.$context.'_'.$item.
1416: '" value="default" '.$checked.'/>'.$titles{$item}.
1417: '</label></span> ';
1418: }
1419: }
1420: if ($context eq 'requestcourses') {
1421: $datatable .= '</tr><tr>';
1422: foreach my $item (@usertools) {
1.106 raeburn 1423: $datatable .= '<td style="vertical-align: top">'.$defcell{$item}.'</td>';
1.72 raeburn 1424: }
1.101 raeburn 1425: $datatable .= '</tr></table>';
1.72 raeburn 1426: }
1.86 raeburn 1427: $datatable .= '</td>';
1428: unless ($context eq 'requestcourses') {
1429: $datatable .= '<td class="LC_right_item"><span class="LC_nobreak">'.
1430: '<input type="text" name="defaultquota" value="'.
1431: $defaultquota.'" size="5" /> Mb</span></td>';
1432: }
1433: $datatable .= '</tr>';
1.72 raeburn 1434: $typecount ++;
1435: $css_class = $typecount%2?' class="LC_odd_row"':'';
1436: $datatable .= '<tr'.$css_class.'>'.
1.104 raeburn 1437: '<td>'.&mt('LON-CAPA Advanced Users').' ';
1438: if ($context eq 'requestcourses') {
1.109 raeburn 1439: $datatable .= &mt('(overrides affiliation, if set)').
1440: '</td>'.
1441: '<td class="LC_left_item">'.
1442: '<table><tr>';
1.101 raeburn 1443: } else {
1.109 raeburn 1444: $datatable .= &mt('(overrides affiliation, if checked)').
1445: '</td>'.
1446: '<td class="LC_left_item" colspan="2">'.
1447: '<br />';
1.101 raeburn 1448: }
1449: my %advcell;
1.72 raeburn 1450: foreach my $item (@usertools) {
1.101 raeburn 1451: if ($context eq 'requestcourses') {
1452: my ($curroption,$currlimit);
1453: if (ref($settings) eq 'HASH') {
1454: if (ref($settings->{$item}) eq 'HASH') {
1455: $curroption = $settings->{$item}->{'_LC_adv'};
1456: if ($curroption =~ /^autolimit=(\d*)$/) {
1457: $currlimit = $1;
1458: }
1459: }
1460: }
1461: $datatable .= '<th>'.$titles{$item}.'</th>';
1.104 raeburn 1462: my $checked = '';
1463: if ($curroption eq '') {
1464: $checked = ' checked="checked"';
1465: }
1466: $advcell{$item} .= '<span class="LC_nobreak"><label>'.
1467: '<input type="radio" name="crsreq_'.$item.
1468: '__LC_adv" value=""'.$checked.' />'.
1469: &mt('No override set').'</label></span> ';
1.101 raeburn 1470: foreach my $option (@options) {
1471: my $val = $option;
1472: if ($option eq 'norequest') {
1473: $val = 0;
1474: }
1475: if ($option eq 'validate') {
1476: my $canvalidate = 0;
1477: if (ref($validations{$item}) eq 'HASH') {
1478: if ($validations{$item}{'_LC_adv'}) {
1479: $canvalidate = 1;
1480: }
1481: }
1482: next if (!$canvalidate);
1483: }
1484: my $checked = '';
1.104 raeburn 1485: if ($val eq $curroption) {
1.101 raeburn 1486: $checked = ' checked="checked"';
1487: } elsif ($option eq 'autolimit') {
1488: if ($curroption =~ /^autolimit/) {
1489: $checked = ' checked="checked"';
1490: }
1491: }
1492: $advcell{$item} .= '<span class="LC_nobreak"><label>'.
1493: '<input type="radio" name="crsreq_'.$item.
1494: '__LC_adv" value="'.$val.'"'.$checked.' />'.
1495: $titles{$option}.'</label>';
1496: if ($option eq 'autolimit') {
1497: $advcell{$item} .= '<input type="text" name="crsreq_'.
1498: $item.'_limit__LC_adv" size="1" '.
1499: 'value="'.$currlimit.'" />';
1500: }
1501: $advcell{$item} .= '</span> ';
1.104 raeburn 1502: if ($option eq 'autolimit') {
1503: $advcell{$item} .= $titles{'unlimited'}
1504: }
1.101 raeburn 1505: }
1506: } else {
1507: my $checked = 'checked="checked" ';
1508: if (ref($settings) eq 'HASH') {
1509: if (ref($settings->{$item}) eq 'HASH') {
1510: if ($settings->{$item}->{'_LC_adv'} == 0) {
1511: $checked = '';
1512: } elsif ($settings->{$item}->{'_LC_adv'} == 1) {
1513: $checked = 'checked="checked" ';
1514: }
1.79 raeburn 1515: }
1.72 raeburn 1516: }
1.101 raeburn 1517: $datatable .= '<span class="LC_nobreak"><label>'.
1518: '<input type="checkbox" name="'.$context.'_'.$item.
1519: '" value="_LC_adv" '.$checked.'/>'.$titles{$item}.
1520: '</label></span> ';
1521: }
1522: }
1523: if ($context eq 'requestcourses') {
1524: $datatable .= '</tr><tr>';
1525: foreach my $item (@usertools) {
1.106 raeburn 1526: $datatable .= '<td style="vertical-align: top">'.$advcell{$item}.'</td>';
1.72 raeburn 1527: }
1.101 raeburn 1528: $datatable .= '</tr></table>';
1.72 raeburn 1529: }
1.98 raeburn 1530: $datatable .= '</td></tr>';
1.30 raeburn 1531: $$rowtotal += $typecount;
1.3 raeburn 1532: return $datatable;
1533: }
1534:
1.102 raeburn 1535: sub print_courserequestmail {
1536: my ($dom,$settings,$rowtotal) = @_;
1.104 raeburn 1537: my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows);
1.102 raeburn 1538: $now = time;
1539: $rows = 0;
1540: %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);
1541: foreach my $server (keys(%dompersonnel)) {
1542: foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
1543: my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);
1544: if (!grep(/^$uname:$udom$/,@domcoord)) {
1545: push(@domcoord,$uname.':'.$udom);
1546: }
1547: }
1548: }
1549: if (ref($settings) eq 'HASH') {
1550: if (ref($settings->{'notify'}) eq 'HASH') {
1551: if ($settings->{'notify'}{'approval'} ne '') {
1.104 raeburn 1552: @currapproval = split(',',$settings->{'notify'}{'approval'});
1.102 raeburn 1553: }
1554: }
1555: }
1.104 raeburn 1556: if (@currapproval) {
1557: foreach my $dc (@currapproval) {
1.102 raeburn 1558: unless (grep(/^\Q$dc\E$/,@domcoord)) {
1559: push(@domcoord,$dc);
1560: }
1561: }
1562: }
1563: @domcoord = sort(@domcoord);
1564: my $numinrow = 4;
1565: my $numdc = @domcoord;
1566: my $css_class = 'class="LC_odd_row"';
1567: $datatable = '<tr'.$css_class.'>'.
1568: ' <td>'.&mt('Receive notification of course requests requiring approval.').
1569: ' </td>'.
1570: ' <td class="LC_left_item">';
1571: if (@domcoord > 0) {
1572: $datatable .= '<table>';
1573: for (my $i=0; $i<$numdc; $i++) {
1574: my $rem = $i%($numinrow);
1575: if ($rem == 0) {
1576: if ($i > 0) {
1577: $datatable .= '</tr>';
1578: }
1579: $datatable .= '<tr>';
1580: $rows ++;
1581: }
1582: my $check = ' ';
1.104 raeburn 1583: if (grep(/^\Q$domcoord[$i]\E$/,@currapproval)) {
1.102 raeburn 1584: $check = ' checked="checked" ';
1585: }
1586: my ($uname,$udom) = split(':',$domcoord[$i]);
1587: my $fullname = &Apache::loncommon::plainname($uname,$udom);
1588: if ($i == $numdc-1) {
1589: my $colsleft = $numinrow-$rem;
1590: if ($colsleft > 1) {
1591: $datatable .= '<td colspan="'.$colsleft.'" class="LC_left_item">';
1592: } else {
1593: $datatable .= '<td class="LC_left_item">';
1594: }
1595: } else {
1596: $datatable .= '<td class="LC_left_item">';
1597: }
1598: $datatable .= '<span class="LC_nobreak"><label>'.
1599: '<input type="checkbox" name="reqapprovalnotify" '.
1600: 'value="'.$domcoord[$i].'"'.$check.'/>'.
1601: $fullname.'</label></span></td>';
1602: }
1603: $datatable .= '</tr></table>';
1604: } else {
1605: $datatable .= &mt('There are no active Domain Coordinators');
1606: $rows ++;
1607: }
1608: $datatable .='</td></tr>';
1609: $$rowtotal += $rows;
1610: return $datatable;
1611: }
1612:
1.3 raeburn 1613: sub print_autoenroll {
1.30 raeburn 1614: my ($dom,$settings,$rowtotal) = @_;
1.3 raeburn 1615: my $autorun = &Apache::lonnet::auto_run(undef,$dom),
1.17 raeburn 1616: my ($defdom,$runon,$runoff);
1.3 raeburn 1617: if (ref($settings) eq 'HASH') {
1618: if (exists($settings->{'run'})) {
1619: if ($settings->{'run'} eq '0') {
1620: $runoff = ' checked="checked" ';
1621: $runon = ' ';
1622: } else {
1623: $runon = ' checked="checked" ';
1624: $runoff = ' ';
1625: }
1626: } else {
1627: if ($autorun) {
1628: $runon = ' checked="checked" ';
1629: $runoff = ' ';
1630: } else {
1631: $runoff = ' checked="checked" ';
1632: $runon = ' ';
1633: }
1634: }
1635: if (exists($settings->{'sender_domain'})) {
1636: $defdom = $settings->{'sender_domain'};
1637: }
1.14 raeburn 1638: } else {
1639: if ($autorun) {
1640: $runon = ' checked="checked" ';
1641: $runoff = ' ';
1642: } else {
1643: $runoff = ' checked="checked" ';
1644: $runon = ' ';
1645: }
1.3 raeburn 1646: }
1647: my $domform = &Apache::loncommon::select_dom_form($defdom,'sender_domain',1);
1.39 raeburn 1648: my $notif_sender;
1649: if (ref($settings) eq 'HASH') {
1650: $notif_sender = $settings->{'sender_uname'};
1651: }
1.3 raeburn 1652: my $datatable='<tr class="LC_odd_row">'.
1653: '<td>'.&mt('Auto-enrollment active?').'</td>'.
1.8 raeburn 1654: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1.3 raeburn 1655: '<input type="radio" name="autoenroll_run"'.
1.8 raeburn 1656: $runon.' value="1" />'.&mt('Yes').'</label> '.
1657: '<label><input type="radio" name="autoenroll_run"'.
1.14 raeburn 1658: $runoff.' value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1659: '</tr><tr>'.
1660: '<td>'.&mt('Notification messages - sender').
1.8 raeburn 1661: '</td><td class="LC_right_item"><span class="LC_nobreak">'.
1.3 raeburn 1662: &mt('username').': '.
1663: '<input type="text" name="sender_uname" value="'.
1.39 raeburn 1664: $notif_sender.'" size="10" /> '.&mt('domain').
1.8 raeburn 1665: ': '.$domform.'</span></td></tr>';
1.30 raeburn 1666: $$rowtotal += 2;
1.3 raeburn 1667: return $datatable;
1668: }
1669:
1670: sub print_autoupdate {
1.30 raeburn 1671: my ($position,$dom,$settings,$rowtotal) = @_;
1.3 raeburn 1672: my $datatable;
1673: if ($position eq 'top') {
1674: my $updateon = ' ';
1675: my $updateoff = ' checked="checked" ';
1676: my $classlistson = ' ';
1677: my $classlistsoff = ' checked="checked" ';
1678: if (ref($settings) eq 'HASH') {
1679: if ($settings->{'run'} eq '1') {
1680: $updateon = $updateoff;
1681: $updateoff = ' ';
1682: }
1683: if ($settings->{'classlists'} eq '1') {
1684: $classlistson = $classlistsoff;
1685: $classlistsoff = ' ';
1686: }
1687: }
1688: my %title = (
1689: run => 'Auto-update active?',
1690: classlists => 'Update information in classlists?',
1691: );
1692: $datatable = '<tr class="LC_odd_row">'.
1693: '<td>'.&mt($title{'run'}).'</td>'.
1.8 raeburn 1694: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1.3 raeburn 1695: '<input type="radio" name="autoupdate_run"'.
1.8 raeburn 1696: $updateon.' value="1" />'.&mt('Yes').'</label> '.
1697: '<label><input type="radio" name="autoupdate_run"'.
1698: $updateoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1699: '</tr><tr>'.
1700: '<td>'.&mt($title{'classlists'}).'</td>'.
1.8 raeburn 1701: '<td class="LC_right_item"><span class="LC_nobreak">'.
1702: '<label><input type="radio" name="classlists"'.
1703: $classlistson.' value="1" />'.&mt('Yes').'</label> '.
1704: '<label><input type="radio" name="classlists"'.
1705: $classlistsoff.'value="0" />'.&mt('No').'</label></span></td>'.
1.3 raeburn 1706: '</tr>';
1.30 raeburn 1707: $$rowtotal += 2;
1.3 raeburn 1708: } else {
1.44 raeburn 1709: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.20 raeburn 1710: my @fields = ('lastname','firstname','middlename','gen',
1711: 'permanentemail','id');
1.33 raeburn 1712: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
1.3 raeburn 1713: my $numrows = 0;
1.26 raeburn 1714: if (ref($types) eq 'ARRAY') {
1715: if (@{$types} > 0) {
1716: $datatable =
1717: &usertype_update_row($settings,$usertypes,\%fieldtitles,
1718: \@fields,$types,\$numrows);
1.30 raeburn 1719: $$rowtotal += @{$types};
1.26 raeburn 1720: }
1.3 raeburn 1721: }
1722: $datatable .=
1723: &usertype_update_row($settings,{'default' => $othertitle},
1724: \%fieldtitles,\@fields,['default'],
1725: \$numrows);
1.30 raeburn 1726: $$rowtotal ++;
1.3 raeburn 1727: }
1728: return $datatable;
1729: }
1730:
1.23 raeburn 1731: sub print_directorysrch {
1.30 raeburn 1732: my ($dom,$settings,$rowtotal) = @_;
1.23 raeburn 1733: my $srchon = ' ';
1734: my $srchoff = ' checked="checked" ';
1.25 raeburn 1735: my ($exacton,$containson,$beginson);
1.24 raeburn 1736: my $localon = ' ';
1737: my $localoff = ' checked="checked" ';
1.23 raeburn 1738: if (ref($settings) eq 'HASH') {
1739: if ($settings->{'available'} eq '1') {
1740: $srchon = $srchoff;
1741: $srchoff = ' ';
1742: }
1.24 raeburn 1743: if ($settings->{'localonly'} eq '1') {
1744: $localon = $localoff;
1745: $localoff = ' ';
1746: }
1.25 raeburn 1747: if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
1748: foreach my $type (@{$settings->{'searchtypes'}}) {
1749: if ($type eq 'exact') {
1750: $exacton = ' checked="checked" ';
1751: } elsif ($type eq 'contains') {
1752: $containson = ' checked="checked" ';
1753: } elsif ($type eq 'begins') {
1754: $beginson = ' checked="checked" ';
1755: }
1756: }
1757: } else {
1758: if ($settings->{'searchtypes'} eq 'exact') {
1759: $exacton = ' checked="checked" ';
1760: } elsif ($settings->{'searchtypes'} eq 'contains') {
1761: $containson = ' checked="checked" ';
1762: } elsif ($settings->{'searchtypes'} eq 'specify') {
1763: $exacton = ' checked="checked" ';
1764: $containson = ' checked="checked" ';
1765: }
1.23 raeburn 1766: }
1767: }
1768: my ($searchtitles,$titleorder) = &sorted_searchtitles();
1.45 raeburn 1769: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.23 raeburn 1770:
1771: my $numinrow = 4;
1.26 raeburn 1772: my $cansrchrow = 0;
1.23 raeburn 1773: my $datatable='<tr class="LC_odd_row">'.
1.30 raeburn 1774: '<td colspan="2"><span class ="LC_nobreak">'.&mt('Directory search available?').'</span></td>'.
1.23 raeburn 1775: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1776: '<input type="radio" name="dirsrch_available"'.
1777: $srchon.' value="1" />'.&mt('Yes').'</label> '.
1778: '<label><input type="radio" name="dirsrch_available"'.
1779: $srchoff.' value="0" />'.&mt('No').'</label></span></td>'.
1780: '</tr><tr>'.
1.30 raeburn 1781: '<td colspan="2"><span class ="LC_nobreak">'.&mt('Other domains can search?').'</span></td>'.
1.24 raeburn 1782: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
1783: '<input type="radio" name="dirsrch_localonly"'.
1784: $localoff.' value="0" />'.&mt('Yes').'</label> '.
1785: '<label><input type="radio" name="dirsrch_localonly"'.
1786: $localon.' value="1" />'.&mt('No').'</label></span></td>'.
1.25 raeburn 1787: '</tr>';
1.30 raeburn 1788: $$rowtotal += 2;
1.26 raeburn 1789: if (ref($usertypes) eq 'HASH') {
1790: if (keys(%{$usertypes}) > 0) {
1.93 raeburn 1791: $datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
1792: $numinrow,$othertitle,'cansearch');
1.26 raeburn 1793: $cansrchrow = 1;
1794: }
1795: }
1796: if ($cansrchrow) {
1.30 raeburn 1797: $$rowtotal ++;
1.26 raeburn 1798: $datatable .= '<tr>';
1799: } else {
1800: $datatable .= '<tr class="LC_odd_row">';
1801: }
1.30 raeburn 1802: $datatable .= '<td><span class ="LC_nobreak">'.&mt('Supported search methods').
1803: '</span></td><td class="LC_left_item" colspan="2"><table><tr>';
1.25 raeburn 1804: foreach my $title (@{$titleorder}) {
1805: if (defined($searchtitles->{$title})) {
1806: my $check = ' ';
1.93 raeburn 1807: if (ref($settings) eq 'HASH') {
1.39 raeburn 1808: if (ref($settings->{'searchby'}) eq 'ARRAY') {
1809: if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
1810: $check = ' checked="checked" ';
1811: }
1.25 raeburn 1812: }
1813: }
1814: $datatable .= '<td class="LC_left_item">'.
1815: '<span class="LC_nobreak"><label>'.
1816: '<input type="checkbox" name="searchby" '.
1817: 'value="'.$title.'"'.$check.'/>'.
1818: $searchtitles->{$title}.'</label></span></td>';
1819: }
1820: }
1.26 raeburn 1821: $datatable .= '</tr></table></td></tr>';
1.30 raeburn 1822: $$rowtotal ++;
1.26 raeburn 1823: if ($cansrchrow) {
1824: $datatable .= '<tr class="LC_odd_row">';
1825: } else {
1826: $datatable .= '<tr>';
1827: }
1.30 raeburn 1828: $datatable .= '<td><span class ="LC_nobreak">'.&mt('Search latitude').'</span></td>'.
1.26 raeburn 1829: '<td class="LC_left_item" colspan="2">'.
1.25 raeburn 1830: '<span class="LC_nobreak"><label>'.
1831: '<input type="checkbox" name="searchtypes" '.
1832: $exacton.' value="exact" />'.&mt('Exact match').
1833: '</label> '.
1834: '<label><input type="checkbox" name="searchtypes" '.
1835: $beginson.' value="begins" />'.&mt('Begins with').
1836: '</label> '.
1837: '<label><input type="checkbox" name="searchtypes" '.
1838: $containson.' value="contains" />'.&mt('Contains').
1839: '</label></span></td></tr>';
1.30 raeburn 1840: $$rowtotal ++;
1.25 raeburn 1841: return $datatable;
1842: }
1843:
1.28 raeburn 1844: sub print_contacts {
1.30 raeburn 1845: my ($dom,$settings,$rowtotal) = @_;
1.28 raeburn 1846: my $datatable;
1847: my @contacts = ('adminemail','supportemail');
1848: my (%checked,%to,%otheremails);
1.102 raeburn 1849: my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail',
1850: 'requestsmail');
1.28 raeburn 1851: foreach my $type (@mailings) {
1852: $otheremails{$type} = '';
1853: }
1854: if (ref($settings) eq 'HASH') {
1855: foreach my $item (@contacts) {
1856: if (exists($settings->{$item})) {
1857: $to{$item} = $settings->{$item};
1858: }
1859: }
1860: foreach my $type (@mailings) {
1861: if (exists($settings->{$type})) {
1862: if (ref($settings->{$type}) eq 'HASH') {
1863: foreach my $item (@contacts) {
1864: if ($settings->{$type}{$item}) {
1865: $checked{$type}{$item} = ' checked="checked" ';
1866: }
1867: }
1868: $otheremails{$type} = $settings->{$type}{'others'};
1869: }
1.89 raeburn 1870: } elsif ($type eq 'lonstatusmail') {
1871: $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
1.28 raeburn 1872: }
1873: }
1874: } else {
1875: $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
1876: $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
1877: $checked{'errormail'}{'adminemail'} = ' checked="checked" ';
1878: $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
1.89 raeburn 1879: $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
1880: $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
1.102 raeburn 1881: $checked{'requestsmail'}{'adminemail'} = ' checked="checked" ';
1.28 raeburn 1882: }
1883: my ($titles,$short_titles) = &contact_titles();
1884: my $rownum = 0;
1885: my $css_class;
1886: foreach my $item (@contacts) {
1.69 raeburn 1887: $rownum ++;
1888: $css_class = $rownum%2?' class="LC_odd_row"':'';
1.30 raeburn 1889: $datatable .= '<tr'.$css_class.'>'.
1890: '<td><span class="LC_nobreak">'.$titles->{$item}.
1891: '</span></td><td class="LC_right_item">'.
1.28 raeburn 1892: '<input type="text" name="'.$item.'" value="'.
1893: $to{$item}.'" /></td></tr>';
1894: }
1895: foreach my $type (@mailings) {
1.69 raeburn 1896: $rownum ++;
1897: $css_class = $rownum%2?' class="LC_odd_row"':'';
1.28 raeburn 1898: $datatable .= '<tr'.$css_class.'>'.
1.30 raeburn 1899: '<td><span class="LC_nobreak">'.
1900: $titles->{$type}.': </span></td>'.
1.28 raeburn 1901: '<td class="LC_left_item">'.
1902: '<span class="LC_nobreak">';
1903: foreach my $item (@contacts) {
1904: $datatable .= '<label>'.
1905: '<input type="checkbox" name="'.$type.'"'.
1906: $checked{$type}{$item}.
1907: ' value="'.$item.'" />'.$short_titles->{$item}.
1908: '</label> ';
1909: }
1910: $datatable .= '</span><br />'.&mt('Others').': '.
1911: '<input type="text" name="'.$type.'_others" '.
1912: 'value="'.$otheremails{$type}.'" />'.
1913: '</td></tr>'."\n";
1914: }
1.30 raeburn 1915: $$rowtotal += $rownum;
1.28 raeburn 1916: return $datatable;
1917: }
1918:
1919: sub contact_titles {
1920: my %titles = &Apache::lonlocal::texthash (
1921: 'supportemail' => 'Support E-mail address',
1.69 raeburn 1922: 'adminemail' => 'Default Server Admin E-mail address',
1.28 raeburn 1923: 'errormail' => 'Error reports to be e-mailed to',
1924: 'packagesmail' => 'Package update alerts to be e-mailed to',
1.89 raeburn 1925: 'helpdeskmail' => 'Helpdesk requests to be e-mailed to',
1926: 'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)',
1.102 raeburn 1927: 'requestsmail' => 'E-mail from course requests requiring approval',
1.28 raeburn 1928: );
1929: my %short_titles = &Apache::lonlocal::texthash (
1930: adminemail => 'Admin E-mail address',
1931: supportemail => 'Support E-mail',
1932: );
1933: return (\%titles,\%short_titles);
1934: }
1935:
1.72 raeburn 1936: sub tool_titles {
1937: my %titles = &Apache::lonlocal::texthash (
1.90 weissno 1938: aboutme => 'Personal Information Page',
1.86 raeburn 1939: blog => 'Blog',
1940: portfolio => 'Portfolio',
1.88 bisitz 1941: official => 'Official courses (with institutional codes)',
1942: unofficial => 'Unofficial courses',
1.98 raeburn 1943: community => 'Communities',
1.86 raeburn 1944: );
1.72 raeburn 1945: return %titles;
1946: }
1947:
1.101 raeburn 1948: sub courserequest_titles {
1949: my %titles = &Apache::lonlocal::texthash (
1950: official => 'Official',
1951: unofficial => 'Unofficial',
1952: community => 'Communities',
1953: norequest => 'Not allowed',
1.104 raeburn 1954: approval => 'Approval by Dom. Coord.',
1.101 raeburn 1955: validate => 'With validation',
1956: autolimit => 'Numerical limit',
1.103 raeburn 1957: unlimited => '(blank for unlimited)',
1.101 raeburn 1958: );
1959: return %titles;
1960: }
1961:
1962: sub courserequest_conditions {
1963: my %conditions = &Apache::lonlocal::texthash (
1.104 raeburn 1964: approval => '(Processing of request subject to approval by Domain Coordinator).',
1.101 raeburn 1965: validate => '(Processing of request subject to instittutional validation).',
1966: );
1967: return %conditions;
1968: }
1969:
1970:
1.27 raeburn 1971: sub print_usercreation {
1.30 raeburn 1972: my ($position,$dom,$settings,$rowtotal) = @_;
1.27 raeburn 1973: my $numinrow = 4;
1.28 raeburn 1974: my $datatable;
1975: if ($position eq 'top') {
1.30 raeburn 1976: $$rowtotal ++;
1.34 raeburn 1977: my $rowcount = 0;
1.32 raeburn 1978: my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username');
1.28 raeburn 1979: if (ref($rules) eq 'HASH') {
1980: if (keys(%{$rules}) > 0) {
1.32 raeburn 1981: $datatable .= &user_formats_row('username',$settings,$rules,
1982: $ruleorder,$numinrow,$rowcount);
1.30 raeburn 1983: $$rowtotal ++;
1.32 raeburn 1984: $rowcount ++;
1985: }
1986: }
1987: my ($idrules,$idruleorder) = &Apache::lonnet::inst_userrules($dom,'id');
1988: if (ref($idrules) eq 'HASH') {
1989: if (keys(%{$idrules}) > 0) {
1990: $datatable .= &user_formats_row('id',$settings,$idrules,
1991: $idruleorder,$numinrow,$rowcount);
1992: $$rowtotal ++;
1993: $rowcount ++;
1.28 raeburn 1994: }
1995: }
1.43 raeburn 1996: my ($emailrules,$emailruleorder) =
1997: &Apache::lonnet::inst_userrules($dom,'email');
1998: if (ref($emailrules) eq 'HASH') {
1999: if (keys(%{$emailrules}) > 0) {
2000: $datatable .= &user_formats_row('email',$settings,$emailrules,
2001: $emailruleorder,$numinrow,$rowcount);
2002: $$rowtotal ++;
2003: $rowcount ++;
2004: }
2005: }
1.39 raeburn 2006: if ($rowcount == 0) {
2007: $datatable .= '<tr><td colspan="2">'.&mt('No format rules have been defined for usernames or IDs in this domain.').'</td></tr>';
2008: $$rowtotal ++;
2009: $rowcount ++;
2010: }
1.34 raeburn 2011: } elsif ($position eq 'middle') {
1.100 raeburn 2012: my @creators = ('author','course','requestcrs','selfcreate');
1.37 raeburn 2013: my ($rules,$ruleorder) =
2014: &Apache::lonnet::inst_userrules($dom,'username');
1.34 raeburn 2015: my %lt = &usercreation_types();
2016: my %checked;
1.50 raeburn 2017: my @selfcreate;
1.34 raeburn 2018: if (ref($settings) eq 'HASH') {
2019: if (ref($settings->{'cancreate'}) eq 'HASH') {
2020: foreach my $item (@creators) {
2021: $checked{$item} = $settings->{'cancreate'}{$item};
2022: }
1.50 raeburn 2023: if (ref($settings->{'cancreate'}{'selfcreate'}) eq 'ARRAY') {
2024: @selfcreate = @{$settings->{'cancreate'}{'selfcreate'}};
2025: } elsif ($settings->{'cancreate'}{'selfcreate'} ne '') {
2026: if ($settings->{'cancreate'}{'selfcreate'} eq 'any') {
2027: @selfcreate = ('email','login','sso');
2028: } elsif ($settings->{'cancreate'}{'selfcreate'} ne 'none') {
2029: @selfcreate = ($settings->{'cancreate'}{'selfcreate'});
2030: }
2031: }
1.34 raeburn 2032: } elsif (ref($settings->{'cancreate'}) eq 'ARRAY') {
2033: foreach my $item (@creators) {
2034: if (grep(/^\Q$item\E$/,@{$settings->{'cancreate'}})) {
2035: $checked{$item} = 'none';
2036: }
2037: }
2038: }
2039: }
2040: my $rownum = 0;
2041: foreach my $item (@creators) {
2042: $rownum ++;
1.50 raeburn 2043: if ($item ne 'selfcreate') {
2044: if ($checked{$item} eq '') {
1.43 raeburn 2045: $checked{$item} = 'any';
2046: }
1.34 raeburn 2047: }
2048: my $css_class;
2049: if ($rownum%2) {
2050: $css_class = '';
2051: } else {
2052: $css_class = ' class="LC_odd_row" ';
2053: }
2054: $datatable .= '<tr'.$css_class.'>'.
2055: '<td><span class="LC_nobreak">'.$lt{$item}.
2056: '</span></td><td align="right">';
1.50 raeburn 2057: my @options;
1.45 raeburn 2058: if ($item eq 'selfcreate') {
1.43 raeburn 2059: push(@options,('email','login','sso'));
2060: } else {
1.50 raeburn 2061: @options = ('any');
1.43 raeburn 2062: if (ref($rules) eq 'HASH') {
2063: if (keys(%{$rules}) > 0) {
2064: push(@options,('official','unofficial'));
2065: }
1.37 raeburn 2066: }
1.50 raeburn 2067: push(@options,'none');
1.37 raeburn 2068: }
2069: foreach my $option (@options) {
1.50 raeburn 2070: my $type = 'radio';
1.34 raeburn 2071: my $check = ' ';
1.50 raeburn 2072: if ($item eq 'selfcreate') {
2073: $type = 'checkbox';
2074: if (grep(/^\Q$option\E$/,@selfcreate)) {
2075: $check = ' checked="checked" ';
2076: }
2077: } else {
2078: if ($checked{$item} eq $option) {
2079: $check = ' checked="checked" ';
2080: }
1.34 raeburn 2081: }
2082: $datatable .= '<span class="LC_nobreak"><label>'.
1.50 raeburn 2083: '<input type="'.$type.'" name="can_createuser_'.
1.34 raeburn 2084: $item.'" value="'.$option.'"'.$check.'/> '.
2085: $lt{$option}.'</label> </span>';
2086: }
2087: $datatable .= '</td></tr>';
2088: }
1.93 raeburn 2089: my ($othertitle,$usertypes,$types) =
2090: &Apache::loncommon::sorted_inst_types($dom);
2091: if (ref($usertypes) eq 'HASH') {
2092: if (keys(%{$usertypes}) > 0) {
1.99 raeburn 2093: my $createsettings;
2094: if (ref($settings) eq 'HASH') {
2095: $createsettings = $settings->{cancreate};
2096: }
2097: $datatable .= &insttypes_row($createsettings,$types,$usertypes,
1.93 raeburn 2098: $dom,$numinrow,$othertitle,
2099: 'statustocreate');
2100: $$rowtotal ++;
2101: }
2102: }
1.28 raeburn 2103: } else {
2104: my @contexts = ('author','course','domain');
2105: my @authtypes = ('int','krb4','krb5','loc');
2106: my %checked;
2107: if (ref($settings) eq 'HASH') {
2108: if (ref($settings->{'authtypes'}) eq 'HASH') {
2109: foreach my $item (@contexts) {
2110: if (ref($settings->{'authtypes'}{$item}) eq 'HASH') {
2111: foreach my $auth (@authtypes) {
2112: if ($settings->{'authtypes'}{$item}{$auth}) {
2113: $checked{$item}{$auth} = ' checked="checked" ';
2114: }
2115: }
2116: }
2117: }
1.27 raeburn 2118: }
1.35 raeburn 2119: } else {
2120: foreach my $item (@contexts) {
1.36 raeburn 2121: foreach my $auth (@authtypes) {
1.35 raeburn 2122: $checked{$item}{$auth} = ' checked="checked" ';
2123: }
2124: }
1.27 raeburn 2125: }
1.28 raeburn 2126: my %title = &context_names();
2127: my %authname = &authtype_names();
2128: my $rownum = 0;
2129: my $css_class;
2130: foreach my $item (@contexts) {
2131: if ($rownum%2) {
2132: $css_class = '';
2133: } else {
2134: $css_class = ' class="LC_odd_row" ';
2135: }
1.30 raeburn 2136: $datatable .= '<tr'.$css_class.'>'.
1.28 raeburn 2137: '<td>'.$title{$item}.
2138: '</td><td class="LC_left_item">'.
2139: '<span class="LC_nobreak">';
2140: foreach my $auth (@authtypes) {
2141: $datatable .= '<label>'.
2142: '<input type="checkbox" name="'.$item.'_auth" '.
2143: $checked{$item}{$auth}.' value="'.$auth.'" />'.
2144: $authname{$auth}.'</label> ';
2145: }
2146: $datatable .= '</span></td></tr>';
2147: $rownum ++;
1.27 raeburn 2148: }
1.30 raeburn 2149: $$rowtotal += $rownum;
1.27 raeburn 2150: }
2151: return $datatable;
2152: }
2153:
1.32 raeburn 2154: sub user_formats_row {
2155: my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_;
2156: my $output;
2157: my %text = (
2158: 'username' => 'new usernames',
2159: 'id' => 'IDs',
1.45 raeburn 2160: 'email' => 'self-created accounts (e-mail)',
1.32 raeburn 2161: );
2162: my $css_class = $rowcount%2?' class="LC_odd_row"':'';
2163: $output = '<tr '.$css_class.'>'.
1.63 raeburn 2164: '<td><span class="LC_nobreak">';
2165: if ($type eq 'email') {
2166: $output .= &mt("Formats disallowed for $text{$type}: ");
2167: } else {
2168: $output .= &mt("Format rules to check for $text{$type}: ");
2169: }
2170: $output .= '</span></td>'.
2171: '<td class="LC_left_item" colspan="2"><table>';
1.27 raeburn 2172: my $rem;
2173: if (ref($ruleorder) eq 'ARRAY') {
2174: for (my $i=0; $i<@{$ruleorder}; $i++) {
2175: if (ref($rules->{$ruleorder->[$i]}) eq 'HASH') {
2176: my $rem = $i%($numinrow);
2177: if ($rem == 0) {
2178: if ($i > 0) {
2179: $output .= '</tr>';
2180: }
2181: $output .= '<tr>';
2182: }
2183: my $check = ' ';
1.39 raeburn 2184: if (ref($settings) eq 'HASH') {
2185: if (ref($settings->{$type.'_rule'}) eq 'ARRAY') {
2186: if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) {
2187: $check = ' checked="checked" ';
2188: }
1.27 raeburn 2189: }
2190: }
2191: $output .= '<td class="LC_left_item">'.
2192: '<span class="LC_nobreak"><label>'.
1.32 raeburn 2193: '<input type="checkbox" name="'.$type.'_rule" '.
1.27 raeburn 2194: 'value="'.$ruleorder->[$i].'"'.$check.'/>'.
2195: $rules->{$ruleorder->[$i]}{'name'}.'</label></span></td>';
2196: }
2197: }
2198: $rem = @{$ruleorder}%($numinrow);
2199: }
2200: my $colsleft = $numinrow - $rem;
2201: if ($colsleft > 1 ) {
2202: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
2203: ' </td>';
2204: } elsif ($colsleft == 1) {
2205: $output .= '<td class="LC_left_item"> </td>';
2206: }
2207: $output .= '</tr></table></td></tr>';
2208: return $output;
2209: }
2210:
1.34 raeburn 2211: sub usercreation_types {
2212: my %lt = &Apache::lonlocal::texthash (
2213: author => 'When adding a co-author',
2214: course => 'When adding a user to a course',
1.100 raeburn 2215: requestcrs => 'When requesting a course',
1.45 raeburn 2216: selfcreate => 'User creates own account',
1.34 raeburn 2217: any => 'Any',
2218: official => 'Institutional only ',
2219: unofficial => 'Non-institutional only',
1.85 schafran 2220: email => 'E-mail address',
1.43 raeburn 2221: login => 'Institutional Login',
2222: sso => 'SSO',
1.34 raeburn 2223: none => 'None',
2224: );
2225: return %lt;
1.48 raeburn 2226: }
1.34 raeburn 2227:
1.28 raeburn 2228: sub authtype_names {
2229: my %lt = &Apache::lonlocal::texthash(
2230: int => 'Internal',
2231: krb4 => 'Kerberos 4',
2232: krb5 => 'Kerberos 5',
2233: loc => 'Local',
2234: );
2235: return %lt;
2236: }
2237:
2238: sub context_names {
2239: my %context_title = &Apache::lonlocal::texthash(
2240: author => 'Creating users when an Author',
2241: course => 'Creating users when in a course',
2242: domain => 'Creating users when a Domain Coordinator',
2243: );
2244: return %context_title;
2245: }
2246:
1.33 raeburn 2247: sub print_usermodification {
2248: my ($position,$dom,$settings,$rowtotal) = @_;
2249: my $numinrow = 4;
2250: my ($context,$datatable,$rowcount);
2251: if ($position eq 'top') {
2252: $rowcount = 0;
2253: $context = 'author';
2254: foreach my $role ('ca','aa') {
2255: $datatable .= &modifiable_userdata_row($context,$role,$settings,
2256: $numinrow,$rowcount);
2257: $$rowtotal ++;
2258: $rowcount ++;
2259: }
1.63 raeburn 2260: } elsif ($position eq 'middle') {
1.33 raeburn 2261: $context = 'course';
2262: $rowcount = 0;
2263: foreach my $role ('st','ep','ta','in','cr') {
2264: $datatable .= &modifiable_userdata_row($context,$role,$settings,
2265: $numinrow,$rowcount);
2266: $$rowtotal ++;
2267: $rowcount ++;
2268: }
1.63 raeburn 2269: } elsif ($position eq 'bottom') {
2270: $context = 'selfcreate';
2271: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
2272: $usertypes->{'default'} = $othertitle;
2273: if (ref($types) eq 'ARRAY') {
2274: push(@{$types},'default');
2275: $usertypes->{'default'} = $othertitle;
2276: foreach my $status (@{$types}) {
2277: $datatable .= &modifiable_userdata_row($context,$status,$settings,
2278: $numinrow,$rowcount,$usertypes);
2279: $$rowtotal ++;
2280: $rowcount ++;
2281: }
2282: }
1.33 raeburn 2283: }
2284: return $datatable;
2285: }
2286:
1.43 raeburn 2287: sub print_defaults {
2288: my ($dom,$rowtotal) = @_;
1.68 raeburn 2289: my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
2290: 'datelocale_def');
1.43 raeburn 2291: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
2292: my $titles = &defaults_titles();
2293: my $rownum = 0;
2294: my ($datatable,$css_class);
2295: foreach my $item (@items) {
2296: if ($rownum%2) {
2297: $css_class = '';
2298: } else {
2299: $css_class = ' class="LC_odd_row" ';
2300: }
2301: $datatable .= '<tr'.$css_class.'>'.
2302: '<td><span class="LC_nobreak">'.$titles->{$item}.
2303: '</span></td><td class="LC_right_item">';
2304: if ($item eq 'auth_def') {
2305: my @authtypes = ('internal','krb4','krb5','localauth');
2306: my %shortauth = (
2307: internal => 'int',
2308: krb4 => 'krb4',
2309: krb5 => 'krb5',
2310: localauth => 'loc'
2311: );
2312: my %authnames = &authtype_names();
2313: foreach my $auth (@authtypes) {
2314: my $checked = ' ';
2315: if ($domdefaults{$item} eq $auth) {
2316: $checked = ' checked="checked" ';
2317: }
2318: $datatable .= '<label><input type="radio" name="'.$item.
2319: '" value="'.$auth.'"'.$checked.'/>'.
2320: $authnames{$shortauth{$auth}}.'</label> ';
2321: }
1.54 raeburn 2322: } elsif ($item eq 'timezone_def') {
2323: my $includeempty = 1;
2324: $datatable .= &Apache::loncommon::select_timezone($item,$domdefaults{$item},undef,$includeempty);
1.68 raeburn 2325: } elsif ($item eq 'datelocale_def') {
2326: my $includeempty = 1;
2327: $datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
1.43 raeburn 2328: } else {
2329: $datatable .= '<input type="text" name="'.$item.'" value="'.
2330: $domdefaults{$item}.'" />';
2331: }
2332: $datatable .= '</td></tr>';
2333: $rownum ++;
2334: }
2335: $$rowtotal += $rownum;
2336: return $datatable;
2337: }
2338:
2339: sub defaults_titles {
2340: my %titles = &Apache::lonlocal::texthash (
2341: 'auth_def' => 'Default authentication type',
2342: 'auth_arg_def' => 'Default authentication argument',
2343: 'lang_def' => 'Default language',
1.54 raeburn 2344: 'timezone_def' => 'Default timezone',
1.68 raeburn 2345: 'datelocale_def' => 'Default locale for dates',
1.43 raeburn 2346: );
2347: return (\%titles);
2348: }
2349:
1.46 raeburn 2350: sub print_scantronformat {
2351: my ($r,$dom,$confname,$settings,$rowtotal) = @_;
2352: my $itemcount = 1;
1.60 raeburn 2353: my ($datatable,$css_class,$scantronurl,$is_custom,%error,%scantronurls,
2354: %confhash);
1.46 raeburn 2355: my $switchserver = &check_switchserver($dom,$confname);
2356: my %lt = &Apache::lonlocal::texthash (
1.95 www 2357: default => 'Default bubblesheet format file error',
2358: custom => 'Custom bubblesheet format file error',
1.46 raeburn 2359: );
2360: my %scantronfiles = (
2361: default => 'default.tab',
2362: custom => 'custom.tab',
2363: );
2364: foreach my $key (keys(%scantronfiles)) {
2365: $scantronurls{$key} = '/res/'.$dom.'/'.$confname.'/scantron/'
2366: .$scantronfiles{$key};
2367: }
2368: my @defaultinfo = &Apache::lonnet::stat_file($scantronurls{'default'});
2369: if ((!@defaultinfo) || ($defaultinfo[0] eq 'no_such_dir')) {
2370: if (!$switchserver) {
2371: my $servadm = $r->dir_config('lonAdmEMail');
2372: my ($configuserok,$author_ok) = &config_check($dom,$confname,$servadm);
2373: if ($configuserok eq 'ok') {
2374: if ($author_ok eq 'ok') {
2375: my %legacyfile = (
2376: default => $Apache::lonnet::perlvar{'lonTabDir'}.'/default_scantronformat.tab',
2377: custom => $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab',
2378: );
2379: my %md5chk;
2380: foreach my $type (keys(%legacyfile)) {
1.60 raeburn 2381: ($md5chk{$type}) = split(/ /,`md5sum $legacyfile{$type}`);
2382: chomp($md5chk{$type});
1.46 raeburn 2383: }
2384: if ($md5chk{'default'} ne $md5chk{'custom'}) {
2385: foreach my $type (keys(%legacyfile)) {
1.60 raeburn 2386: ($scantronurls{$type},my $error) =
1.46 raeburn 2387: &legacy_scantronformat($r,$dom,$confname,
2388: $type,$legacyfile{$type},
2389: $scantronurls{$type},
2390: $scantronfiles{$type});
1.60 raeburn 2391: if ($error ne '') {
2392: $error{$type} = $error;
2393: }
2394: }
2395: if (keys(%error) == 0) {
2396: $is_custom = 1;
2397: $confhash{'scantron'}{'scantronformat'} =
2398: $scantronurls{'custom'};
2399: my $putresult =
2400: &Apache::lonnet::put_dom('configuration',
2401: \%confhash,$dom);
2402: if ($putresult ne 'ok') {
2403: $error{'custom'} =
2404: '<span class="LC_error">'.
2405: &mt('An error occurred updating the domain configuration: [_1]',$putresult).'</span>';
2406: }
1.46 raeburn 2407: }
2408: } else {
1.60 raeburn 2409: ($scantronurls{'default'},my $error) =
1.46 raeburn 2410: &legacy_scantronformat($r,$dom,$confname,
2411: 'default',$legacyfile{'default'},
2412: $scantronurls{'default'},
2413: $scantronfiles{'default'});
1.60 raeburn 2414: if ($error eq '') {
2415: $confhash{'scantron'}{'scantronformat'} = '';
2416: my $putresult =
2417: &Apache::lonnet::put_dom('configuration',
2418: \%confhash,$dom);
2419: if ($putresult ne 'ok') {
2420: $error{'default'} =
2421: '<span class="LC_error">'.
2422: &mt('An error occurred updating the domain configuration: [_1]',$putresult).'</span>';
2423: }
2424: } else {
2425: $error{'default'} = $error;
2426: }
1.46 raeburn 2427: }
2428: }
2429: }
2430: } else {
1.95 www 2431: $error{'default'} = &mt("Unable to copy default bubblesheet formatfile to domain's RES space: [_1]",$switchserver);
1.46 raeburn 2432: }
2433: }
2434: if (ref($settings) eq 'HASH') {
2435: if ($settings->{'scantronformat'} eq "/res/$dom/$confname/scantron/custom.tab") {
2436: my @info = &Apache::lonnet::stat_file($settings->{'scantronformat'});
2437: if ((!@info) || ($info[0] eq 'no_such_dir')) {
2438: $scantronurl = '';
2439: } else {
2440: $scantronurl = $settings->{'scantronformat'};
2441: }
2442: $is_custom = 1;
2443: } else {
2444: $scantronurl = $scantronurls{'default'};
2445: }
2446: } else {
1.60 raeburn 2447: if ($is_custom) {
2448: $scantronurl = $scantronurls{'custom'};
2449: } else {
2450: $scantronurl = $scantronurls{'default'};
2451: }
1.46 raeburn 2452: }
2453: $css_class = $itemcount%2?' class="LC_odd_row"':'';
2454: $datatable .= '<tr'.$css_class.'>';
2455: if (!$is_custom) {
1.65 raeburn 2456: $datatable .= '<td>'.&mt('Default in use:').'<br />'.
2457: '<span class="LC_nobreak">';
1.46 raeburn 2458: if ($scantronurl) {
2459: $datatable .= '<a href="'.$scantronurl.'" target="_blank">'.
2460: &mt('Default scantron format file').'</a>';
2461: } else {
2462: $datatable = &mt('File unavailable for display');
2463: }
1.65 raeburn 2464: $datatable .= '</span></td>';
1.60 raeburn 2465: if (keys(%error) == 0) {
2466: $datatable .= '<td valign="bottom">';
2467: if (!$switchserver) {
2468: $datatable .= &mt('Upload:').'<br />';
2469: }
2470: } else {
2471: my $errorstr;
2472: foreach my $key (sort(keys(%error))) {
2473: $errorstr .= $lt{$key}.': '.$error{$key}.'<br />';
2474: }
2475: $datatable .= '<td>'.$errorstr;
2476: }
1.46 raeburn 2477: } else {
2478: if (keys(%error) > 0) {
2479: my $errorstr;
2480: foreach my $key (sort(keys(%error))) {
2481: $errorstr .= $lt{$key}.': '.$error{$key}.'<br />';
2482: }
1.60 raeburn 2483: $datatable .= '<td>'.$errorstr.'</td><td> ';
1.46 raeburn 2484: } elsif ($scantronurl) {
1.65 raeburn 2485: $datatable .= '<td><span class="LC_nobreak">'.
2486: '<a href="'.$scantronurl.'" target="_blank">'.
2487: &mt('Custom scantron format file').'</a><label>'.
2488: '<input type="checkbox" name="scantronformat_del"'.
2489: '" value="1" />'.&mt('Delete?').'</label></span></td>'.
2490: '<td><span class="LC_nobreak"> '.
2491: &mt('Replace:').'</span><br />';
1.46 raeburn 2492: }
2493: }
2494: if (keys(%error) == 0) {
2495: if ($switchserver) {
2496: $datatable .= &mt('Upload to library server: [_1]',$switchserver);
2497: } else {
1.65 raeburn 2498: $datatable .='<span class="LC_nobreak"> '.
2499: '<input type="file" name="scantronformat" /></span>';
1.46 raeburn 2500: }
2501: }
2502: $datatable .= '</td></tr>';
2503: $$rowtotal ++;
2504: return $datatable;
2505: }
2506:
2507: sub legacy_scantronformat {
2508: my ($r,$dom,$confname,$file,$legacyfile,$newurl,$newfile) = @_;
2509: my ($url,$error);
2510: my @statinfo = &Apache::lonnet::stat_file($newurl);
2511: if ((!@statinfo) || ($statinfo[0] eq 'no_such_dir')) {
2512: (my $result,$url) =
2513: &publishlogo($r,'copy',$legacyfile,$dom,$confname,'scantron',
2514: '','',$newfile);
2515: if ($result ne 'ok') {
2516: $error = &mt("An error occurred publishing the [_1] scantron format file in RES space. Error was: [_2].",$newfile,$result);
2517: }
2518: }
2519: return ($url,$error);
2520: }
1.43 raeburn 2521:
1.49 raeburn 2522: sub print_coursecategories {
1.57 raeburn 2523: my ($position,$dom,$hdritem,$settings,$rowtotal) = @_;
2524: my $datatable;
2525: if ($position eq 'top') {
2526: my $toggle_cats_crs = ' ';
2527: my $toggle_cats_dom = ' checked="checked" ';
2528: my $can_cat_crs = ' ';
2529: my $can_cat_dom = ' checked="checked" ';
2530: if (ref($settings) eq 'HASH') {
2531: if ($settings->{'togglecats'} eq 'crs') {
2532: $toggle_cats_crs = $toggle_cats_dom;
2533: $toggle_cats_dom = ' ';
2534: }
2535: if ($settings->{'categorize'} eq 'crs') {
2536: $can_cat_crs = $can_cat_dom;
2537: $can_cat_dom = ' ';
2538: }
2539: }
2540: my %title = &Apache::lonlocal::texthash (
2541: togglecats => 'Show/Hide a course in the catalog',
2542: categorize => 'Assign a category to a course',
2543: );
2544: my %level = &Apache::lonlocal::texthash (
2545: dom => 'Set in "Modify Course" (Domain)',
1.60 raeburn 2546: crs => 'Set in "Modify Parameters" (Course)',
1.57 raeburn 2547: );
2548: $datatable = '<tr class="LC_odd_row">'.
2549: '<td>'.$title{'togglecats'}.'</td>'.
2550: '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
2551: '<input type="radio" name="togglecats"'.
2552: $toggle_cats_dom.' value="dom" />'.$level{'dom'}.'</label> '.
2553: '<label><input type="radio" name="togglecats"'.
2554: $toggle_cats_crs.' value="crs" />'.$level{'crs'}.'</label></span></td>'.
2555: '</tr><tr>'.
2556: '<td>'.$title{'categorize'}.'</td>'.
2557: '<td class="LC_right_item"><span class="LC_nobreak">'.
2558: '<label><input type="radio" name="categorize"'.
2559: $can_cat_dom.' value="dom" />'.$level{'dom'}.'</label> '.
2560: '<label><input type="radio" name="categorize"'.
2561: $can_cat_crs.'value="crs" />'.$level{'crs'}.'</label></span></td>'.
2562: '</tr>';
2563: $$rowtotal += 2;
2564: } else {
2565: my $css_class;
2566: my $itemcount = 1;
2567: my $cathash;
2568: if (ref($settings) eq 'HASH') {
2569: $cathash = $settings->{'cats'};
2570: }
2571: if (ref($cathash) eq 'HASH') {
2572: my (@cats,@trails,%allitems,%idx,@jsarray);
2573: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
2574: \%allitems,\%idx,\@jsarray);
2575: my $maxdepth = scalar(@cats);
2576: my $colattrib = '';
2577: if ($maxdepth > 2) {
2578: $colattrib = ' colspan="2" ';
2579: }
2580: my @path;
2581: if (@cats > 0) {
2582: if (ref($cats[0]) eq 'ARRAY') {
2583: my $numtop = @{$cats[0]};
2584: my $maxnum = $numtop;
2585: if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
2586: $maxnum ++;
2587: }
2588: my $lastidx;
2589: for (my $i=0; $i<$numtop; $i++) {
2590: my $parent = $cats[0][$i];
2591: $css_class = $itemcount%2?' class="LC_odd_row"':'';
2592: my $item = &escape($parent).'::0';
2593: my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$item','$idx{$item}'".');"';
2594: $lastidx = $idx{$item};
2595: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
2596: .'<select name="'.$item.'"'.$chgstr.'>';
2597: for (my $k=0; $k<=$maxnum; $k++) {
2598: my $vpos = $k+1;
2599: my $selstr;
2600: if ($k == $i) {
2601: $selstr = ' selected="selected" ';
2602: }
2603: $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
2604: }
2605: $datatable .= '</select></td><td>';
2606: if ($parent eq 'instcode') {
2607: $datatable .= '<span class="LC_nobreak">'.&mt('Official courses')
2608: .'</span><br /><span class="LC_nobreak">('
2609: .&mt('with institutional codes').')</span></td>'
2610: .'<td'.$colattrib.'><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" checked="checked" />'
2611: .&mt('Display').'</label> '
2612: .'<label><input type="radio" name="instcode" value="0" />'
2613: .&mt('Do not display').'</label></span></td>';
2614: } else {
2615: $datatable .= $parent
2616: .' <label><input type="checkbox" name="deletecategory" '
2617: .'value="'.$item.'" />'.&mt('Delete').'</label></span></td>';
2618: }
2619: my $depth = 1;
2620: push(@path,$parent);
2621: $datatable .= &build_category_rows($itemcount,\@cats,$depth,$parent,\@path,\%idx);
2622: pop(@path);
2623: $datatable .= '</tr><tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr>';
2624: $itemcount ++;
2625: }
1.48 raeburn 2626: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.57 raeburn 2627: my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','$lastidx'".');"';
2628: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak"><select name="addcategory_pos"'.$chgstr.'>';
1.48 raeburn 2629: for (my $k=0; $k<=$maxnum; $k++) {
2630: my $vpos = $k+1;
2631: my $selstr;
1.57 raeburn 2632: if ($k == $numtop) {
1.48 raeburn 2633: $selstr = ' selected="selected" ';
2634: }
2635: $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
2636: }
1.59 bisitz 2637: $datatable .= '</select></span></td><td colspan="2">'.&mt('Add category:').' '
1.57 raeburn 2638: .'<input type="text" size="20" name="addcategory_name" value="" /></td>'
2639: .'</tr>'."\n";
1.48 raeburn 2640: $itemcount ++;
1.57 raeburn 2641: if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
2642: $css_class = $itemcount%2?' class="LC_odd_row"':'';
2643: my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','$lastidx'".');"';
2644: $datatable .= '<tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr><tr '.$css_class.'><td>'.
2645: '<span class="LC_nobreak"><select name="instcode_pos"'.$chgstr.'>';
2646: for (my $k=0; $k<=$maxnum; $k++) {
2647: my $vpos = $k+1;
2648: my $selstr;
2649: if ($k == $maxnum) {
2650: $selstr = ' selected="selected" ';
2651: }
2652: $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
1.48 raeburn 2653: }
1.57 raeburn 2654: $datatable .= '</select></span></td><td><span class="LC_nobreak">'
2655: .&mt('Official courses').'</span>'.'<br /><span class="LC_nobreak">('
2656: .&mt('with institutional codes').')</span></td>'
2657: .'<td><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" />'
2658: .&mt('Display').'</label> '
2659: .'<label><input type="radio" name="instcode" value="0" checked="checked"/>'
2660: .&mt('Do not display').'</label></span></td></tr>';
1.48 raeburn 2661: }
2662: }
1.57 raeburn 2663: } else {
2664: $datatable .= &initialize_categories($itemcount);
1.48 raeburn 2665: }
2666: } else {
1.57 raeburn 2667: $datatable .= '<td class="LC_right_item">'.$hdritem->{'header'}->[0]->{'col2'}.'</td>'
2668: .&initialize_categories($itemcount);
1.48 raeburn 2669: }
1.57 raeburn 2670: $$rowtotal += $itemcount;
1.48 raeburn 2671: }
2672: return $datatable;
2673: }
2674:
1.69 raeburn 2675: sub print_serverstatuses {
2676: my ($dom,$settings,$rowtotal) = @_;
2677: my $datatable;
2678: my @pages = &serverstatus_pages();
2679: my (%namedaccess,%machineaccess);
2680: foreach my $type (@pages) {
2681: $namedaccess{$type} = '';
2682: $machineaccess{$type}= '';
2683: }
2684: if (ref($settings) eq 'HASH') {
2685: foreach my $type (@pages) {
2686: if (exists($settings->{$type})) {
2687: if (ref($settings->{$type}) eq 'HASH') {
2688: foreach my $key (keys(%{$settings->{$type}})) {
2689: if ($key eq 'namedusers') {
2690: $namedaccess{$type} = $settings->{$type}->{$key};
2691: } elsif ($key eq 'machines') {
2692: $machineaccess{$type} = $settings->{$type}->{$key};
2693: }
2694: }
2695: }
2696: }
2697: }
2698: }
1.81 raeburn 2699: my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
1.69 raeburn 2700: my $rownum = 0;
2701: my $css_class;
2702: foreach my $type (@pages) {
2703: $rownum ++;
2704: $css_class = $rownum%2?' class="LC_odd_row"':'';
2705: $datatable .= '<tr'.$css_class.'>'.
2706: '<td><span class="LC_nobreak">'.
2707: $titles->{$type}.'</span></td>'.
2708: '<td class="LC_left_item">'.
2709: '<input type="text" name="'.$type.'_namedusers" '.
2710: 'value="'.$namedaccess{$type}.'" size="30" /></td>'.
2711: '<td class="LC_right_item">'.
2712: '<span class="LC_nobreak">'.
2713: '<input type="text" name="'.$type.'_machines" '.
2714: 'value="'.$machineaccess{$type}.'" size="10" />'.
2715: '</td></tr>'."\n";
2716: }
2717: $$rowtotal += $rownum;
2718: return $datatable;
2719: }
2720:
2721: sub serverstatus_pages {
2722: return ('userstatus','lonstatus','loncron','server-status','codeversions',
2723: 'clusterstatus','metadata_keywords','metadata_harvest',
2724: 'takeoffline','takeonline','showenv');
2725: }
2726:
1.49 raeburn 2727: sub coursecategories_javascript {
2728: my ($settings) = @_;
1.57 raeburn 2729: my ($output,$jstext,$cathash);
1.49 raeburn 2730: if (ref($settings) eq 'HASH') {
1.57 raeburn 2731: $cathash = $settings->{'cats'};
2732: }
2733: if (ref($cathash) eq 'HASH') {
1.49 raeburn 2734: my (@cats,@jsarray,%idx);
1.57 raeburn 2735: &Apache::loncommon::gather_categories($cathash,\@cats,\%idx,\@jsarray);
1.49 raeburn 2736: if (@jsarray > 0) {
2737: $jstext = ' var categories = Array('.scalar(@jsarray).');'."\n";
2738: for (my $i=0; $i<@jsarray; $i++) {
2739: if (ref($jsarray[$i]) eq 'ARRAY') {
2740: my $catstr = join('","',@{$jsarray[$i]});
2741: $jstext .= ' categories['.$i.'] = Array("'.$catstr.'");'."\n";
2742: }
2743: }
2744: }
2745: } else {
2746: $jstext = ' var categories = Array(1);'."\n".
2747: ' categories[0] = Array("instcode_pos");'."\n";
2748: }
2749: $output = <<"ENDSCRIPT";
2750: <script type="text/javascript">
1.109 raeburn 2751: // <![CDATA[
1.49 raeburn 2752: function reorderCats(form,parent,item,idx) {
2753: var changedVal;
2754: $jstext
2755: var newpos = 'addcategory_pos';
2756: var current = new Array;
2757: if (parent == '') {
2758: var has_instcode = 0;
2759: var maxtop = categories[idx].length;
2760: for (var j=0; j<maxtop; j++) {
2761: if (categories[idx][j] == 'instcode::0') {
2762: has_instcode == 1;
2763: }
2764: }
2765: if (has_instcode == 0) {
2766: categories[idx][maxtop] = 'instcode_pos';
2767: }
2768: } else {
2769: newpos += '_'+parent;
2770: }
2771: var maxh = 1 + categories[idx].length;
2772: var current = new Array;
2773: var newitemVal = form.elements[newpos].options[form.elements[newpos].selectedIndex].value;
2774: if (item == newpos) {
2775: changedVal = newitemVal;
2776: } else {
2777: changedVal = form.elements[item].options[form.elements[item].selectedIndex].value;
2778: current[newitemVal] = newpos;
2779: }
2780: for (var i=0; i<categories[idx].length; i++) {
2781: var elementName = categories[idx][i];
2782: if (elementName != item) {
2783: if (form.elements[elementName]) {
2784: var currVal = form.elements[elementName].options[form.elements[elementName].selectedIndex].value;
2785: current[currVal] = elementName;
2786: }
2787: }
2788: }
2789: var oldVal;
2790: for (var j=0; j<maxh; j++) {
2791: if (current[j] == undefined) {
2792: oldVal = j;
2793: }
2794: }
2795: if (oldVal < changedVal) {
2796: for (var k=oldVal+1; k<=changedVal ; k++) {
2797: var elementName = current[k];
2798: form.elements[elementName].selectedIndex = form.elements[elementName].selectedIndex - 1;
2799: }
2800: } else {
2801: for (var k=changedVal; k<oldVal; k++) {
2802: var elementName = current[k];
2803: form.elements[elementName].selectedIndex = form.elements[elementName].selectedIndex + 1;
2804: }
2805: }
2806: return;
2807: }
1.109 raeburn 2808: // ]]>
1.49 raeburn 2809: </script>
2810:
2811: ENDSCRIPT
2812: return $output;
2813: }
2814:
1.48 raeburn 2815: sub initialize_categories {
2816: my ($itemcount) = @_;
2817: my $datatable;
2818: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.49 raeburn 2819: my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','0'".');"';
2820:
1.48 raeburn 2821: $datatable = '<tr '.$css_class.'><td><span class="LC_nobreak">'
2822: .'<select name="instcode_pos"><option value="0" selected="selected">1</option>'
2823: .'<option value="1">2</option></select> '
2824: .&mt('Official courses (with institutional codes)')
2825: .'</span></td><td><span class="LC_nobreak">'
2826: .'<label><input type="radio" name="instcode" value="1" checked="checked" />'
2827: .&mt('Display').'</label> <label>'
2828: .'<input type="radio" name="instcode" value="0" />'.&mt('Do not display')
2829: .'</label></span></td></tr>';
2830: $itemcount ++;
2831: $css_class = $itemcount%2?' class="LC_odd_row"':'';
1.49 raeburn 2832: $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','0'".');"';
1.48 raeburn 2833: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
1.53 raeburn 2834: .'<select name="addcategory_pos"'.$chgstr.'><option value="0">1</option>'
1.48 raeburn 2835: .'<option value="1" selected="selected">2</option></select> '
2836: .&mt('Add category').'</td><td>'.&mt('Name:')
2837: .' <input type="text" size="20" name="addcategory_name" value="" /></td></tr>';
2838: return $datatable;
2839: }
2840:
2841: sub build_category_rows {
1.49 raeburn 2842: my ($itemcount,$cats,$depth,$parent,$path,$idx) = @_;
2843: my ($text,$name,$item,$chgstr);
1.48 raeburn 2844: if (ref($cats) eq 'ARRAY') {
2845: my $maxdepth = scalar(@{$cats});
2846: if (ref($cats->[$depth]) eq 'HASH') {
2847: if (ref($cats->[$depth]{$parent}) eq 'ARRAY') {
2848: my $numchildren = @{$cats->[$depth]{$parent}};
2849: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
2850: $text .= '<td><table class="LC_datatable">';
1.49 raeburn 2851: my ($idxnum,$parent_name,$parent_item);
2852: my $higher = $depth - 1;
2853: if ($higher == 0) {
2854: $parent_name = &escape($parent).'::'.$higher;
2855: } else {
2856: if (ref($path) eq 'ARRAY') {
2857: $parent_name = &escape($parent).':'.&escape($path->[-2]).':'.$higher;
2858: }
2859: }
2860: $parent_item = 'addcategory_pos_'.$parent_name;
1.48 raeburn 2861: for (my $j=0; $j<=$numchildren; $j++) {
1.49 raeburn 2862: if ($j < $numchildren) {
1.48 raeburn 2863: $name = $cats->[$depth]{$parent}[$j];
2864: $item = &escape($name).':'.&escape($parent).':'.$depth;
1.49 raeburn 2865: $idxnum = $idx->{$item};
2866: } else {
2867: $name = $parent_name;
2868: $item = $parent_item;
1.48 raeburn 2869: }
1.49 raeburn 2870: $chgstr = ' onchange="javascript:reorderCats(this.form,'."'$parent_name','$item','$idxnum'".');"';
2871: $text .= '<tr '.$css_class.'><td><span class="LC_nobreak"><select name="'.$item.'"'.$chgstr.'>';
1.48 raeburn 2872: for (my $i=0; $i<=$numchildren; $i++) {
2873: my $vpos = $i+1;
2874: my $selstr;
2875: if ($j == $i) {
2876: $selstr = ' selected="selected" ';
2877: }
2878: $text .= '<option value="'.$i.'"'.$selstr.'>'.$vpos.'</option>';
2879: }
2880: $text .= '</select> ';
2881: if ($j < $numchildren) {
2882: my $deeper = $depth+1;
2883: $text .= $name.' '
2884: .'<label><input type="checkbox" name="deletecategory" value="'
2885: .$item.'" />'.&mt('Delete').'</label></span></td><td>';
2886: if(ref($path) eq 'ARRAY') {
2887: push(@{$path},$name);
1.49 raeburn 2888: $text .= &build_category_rows($itemcount,$cats,$deeper,$name,$path,$idx);
1.48 raeburn 2889: pop(@{$path});
2890: }
2891: } else {
1.59 bisitz 2892: $text .= &mt('Add subcategory:').' </span><input type="textbox" size="20" name="addcategory_name_';
1.48 raeburn 2893: if ($j == $numchildren) {
2894: $text .= $name;
2895: } else {
2896: $text .= $item;
2897: }
2898: $text .= '" value="" />';
2899: }
2900: $text .= '</td></tr>';
2901: }
2902: $text .= '</table></td>';
2903: } else {
2904: my $higher = $depth-1;
2905: if ($higher == 0) {
2906: $name = &escape($parent).'::'.$higher;
2907: } else {
2908: if (ref($path) eq 'ARRAY') {
2909: $name = &escape($parent).':'.&escape($path->[-2]).':'.$higher;
2910: }
2911: }
2912: my $colspan;
2913: if ($parent ne 'instcode') {
2914: $colspan = $maxdepth - $depth - 1;
2915: $text .= '<td colspan="'.$colspan.'">'.&mt('Add subcategory:').'<input type="textbox" size="20" name="subcat_'.$name.'" value="" /></td>';
2916: }
2917: }
2918: }
2919: }
2920: return $text;
2921: }
2922:
1.33 raeburn 2923: sub modifiable_userdata_row {
1.63 raeburn 2924: my ($context,$role,$settings,$numinrow,$rowcount,$usertypes) = @_;
1.33 raeburn 2925: my $rolename;
1.63 raeburn 2926: if ($context eq 'selfcreate') {
2927: if (ref($usertypes) eq 'HASH') {
2928: $rolename = $usertypes->{$role};
2929: } else {
2930: $rolename = $role;
2931: }
1.33 raeburn 2932: } else {
1.63 raeburn 2933: if ($role eq 'cr') {
2934: $rolename = &mt('Custom role');
2935: } else {
2936: $rolename = &Apache::lonnet::plaintext($role);
2937: }
1.33 raeburn 2938: }
2939: my @fields = ('lastname','firstname','middlename','generation',
2940: 'permanentemail','id');
2941: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
2942: my $output;
2943: my $css_class = $rowcount%2?' class="LC_odd_row"':'';
2944: $output = '<tr '.$css_class.'>'.
2945: '<td><span class="LC_nobreak">'.$rolename.'</span></td>'.
2946: '<td class="LC_left_item" colspan="2"><table>';
2947: my $rem;
2948: my %checks;
2949: if (ref($settings) eq 'HASH') {
2950: if (ref($settings->{$context}) eq 'HASH') {
2951: if (ref($settings->{$context}->{$role}) eq 'HASH') {
2952: foreach my $field (@fields) {
2953: if ($settings->{$context}->{$role}->{$field}) {
2954: $checks{$field} = ' checked="checked" ';
2955: }
2956: }
2957: }
2958: }
2959: }
2960: for (my $i=0; $i<@fields; $i++) {
2961: my $rem = $i%($numinrow);
2962: if ($rem == 0) {
2963: if ($i > 0) {
2964: $output .= '</tr>';
2965: }
2966: $output .= '<tr>';
2967: }
2968: my $check = ' ';
2969: if (exists($checks{$fields[$i]})) {
2970: $check = $checks{$fields[$i]}
2971: } else {
2972: if ($role eq 'st') {
2973: if (ref($settings) ne 'HASH') {
2974: $check = ' checked="checked" ';
2975: }
2976: }
2977: }
2978: $output .= '<td class="LC_left_item">'.
2979: '<span class="LC_nobreak"><label>'.
2980: '<input type="checkbox" name="canmodify_'.$role.'" '.
2981: 'value="'.$fields[$i].'"'.$check.'/>'.$fieldtitles{$fields[$i]}.
2982: '</label></span></td>';
2983: $rem = @fields%($numinrow);
2984: }
2985: my $colsleft = $numinrow - $rem;
2986: if ($colsleft > 1 ) {
2987: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
2988: ' </td>';
2989: } elsif ($colsleft == 1) {
2990: $output .= '<td class="LC_left_item"> </td>';
2991: }
2992: $output .= '</tr></table></td></tr>';
2993: return $output;
2994: }
1.28 raeburn 2995:
1.93 raeburn 2996: sub insttypes_row {
2997: my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context) = @_;
2998: my %lt = &Apache::lonlocal::texthash (
2999: cansearch => 'Users allowed to search',
3000: statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)',
3001: );
3002: my $showdom;
3003: if ($context eq 'cansearch') {
3004: $showdom = ' ('.$dom.')';
3005: }
1.25 raeburn 3006: my $output = '<tr class="LC_odd_row">'.
1.93 raeburn 3007: '<td>'.$lt{$context}.$showdom.
1.24 raeburn 3008: '</td><td class="LC_left_item" colspan="2"><table>';
1.26 raeburn 3009: my $rem;
3010: if (ref($types) eq 'ARRAY') {
3011: for (my $i=0; $i<@{$types}; $i++) {
3012: if (defined($usertypes->{$types->[$i]})) {
3013: my $rem = $i%($numinrow);
3014: if ($rem == 0) {
3015: if ($i > 0) {
3016: $output .= '</tr>';
3017: }
3018: $output .= '<tr>';
1.23 raeburn 3019: }
1.26 raeburn 3020: my $check = ' ';
1.99 raeburn 3021: if (ref($settings) eq 'HASH') {
3022: if (ref($settings->{$context}) eq 'ARRAY') {
3023: if (grep(/^\Q$types->[$i]\E$/,@{$settings->{$context}})) {
3024: $check = ' checked="checked" ';
3025: }
3026: } elsif ($context eq 'statustocreate') {
1.26 raeburn 3027: $check = ' checked="checked" ';
3028: }
1.23 raeburn 3029: }
1.26 raeburn 3030: $output .= '<td class="LC_left_item">'.
3031: '<span class="LC_nobreak"><label>'.
1.93 raeburn 3032: '<input type="checkbox" name="'.$context.'" '.
1.26 raeburn 3033: 'value="'.$types->[$i].'"'.$check.'/>'.
3034: $usertypes->{$types->[$i]}.'</label></span></td>';
1.23 raeburn 3035: }
3036: }
1.26 raeburn 3037:
3038: $rem = @{$types}%($numinrow);
1.23 raeburn 3039: }
3040: my $colsleft = $numinrow - $rem;
3041: if ($colsleft > 1) {
1.25 raeburn 3042: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">';
1.23 raeburn 3043: } else {
1.25 raeburn 3044: $output .= '<td class="LC_left_item">';
1.23 raeburn 3045: }
3046: my $defcheck = ' ';
1.99 raeburn 3047: if (ref($settings) eq 'HASH') {
3048: if (ref($settings->{$context}) eq 'ARRAY') {
3049: if (grep(/^default$/,@{$settings->{$context}})) {
3050: $defcheck = ' checked="checked" ';
3051: }
3052: } elsif ($context eq 'statustocreate') {
1.26 raeburn 3053: $defcheck = ' checked="checked" ';
3054: }
1.23 raeburn 3055: }
1.25 raeburn 3056: $output .= '<span class="LC_nobreak"><label>'.
1.93 raeburn 3057: '<input type="checkbox" name="'.$context.'" '.
1.25 raeburn 3058: 'value="default"'.$defcheck.'/>'.
3059: $othertitle.'</label></span></td>'.
3060: '</tr></table></td></tr>';
3061: return $output;
1.23 raeburn 3062: }
3063:
3064: sub sorted_searchtitles {
3065: my %searchtitles = &Apache::lonlocal::texthash(
3066: 'uname' => 'username',
3067: 'lastname' => 'last name',
3068: 'lastfirst' => 'last name, first name',
3069: );
3070: my @titleorder = ('uname','lastname','lastfirst');
3071: return (\%searchtitles,\@titleorder);
3072: }
3073:
1.25 raeburn 3074: sub sorted_searchtypes {
3075: my %srchtypes_desc = (
3076: exact => 'is exact match',
3077: contains => 'contains ..',
3078: begins => 'begins with ..',
3079: );
3080: my @srchtypeorder = ('exact','begins','contains');
3081: return (\%srchtypes_desc,\@srchtypeorder);
3082: }
3083:
1.3 raeburn 3084: sub usertype_update_row {
3085: my ($settings,$usertypes,$fieldtitles,$fields,$types,$rownums) = @_;
3086: my $datatable;
3087: my $numinrow = 4;
3088: foreach my $type (@{$types}) {
3089: if (defined($usertypes->{$type})) {
3090: $$rownums ++;
3091: my $css_class = $$rownums%2?' class="LC_odd_row"':'';
3092: $datatable .= '<tr'.$css_class.'><td>'.$usertypes->{$type}.
3093: '</td><td class="LC_left_item"><table>';
3094: for (my $i=0; $i<@{$fields}; $i++) {
3095: my $rem = $i%($numinrow);
3096: if ($rem == 0) {
3097: if ($i > 0) {
3098: $datatable .= '</tr>';
3099: }
3100: $datatable .= '<tr>';
3101: }
3102: my $check = ' ';
1.39 raeburn 3103: if (ref($settings) eq 'HASH') {
3104: if (ref($settings->{'fields'}) eq 'HASH') {
3105: if (ref($settings->{'fields'}{$type}) eq 'ARRAY') {
3106: if (grep(/^\Q$fields->[$i]\E$/,@{$settings->{'fields'}{$type}})) {
3107: $check = ' checked="checked" ';
3108: }
1.3 raeburn 3109: }
3110: }
3111: }
3112:
3113: if ($i == @{$fields}-1) {
3114: my $colsleft = $numinrow - $rem;
3115: if ($colsleft > 1) {
3116: $datatable .= '<td colspan="'.$colsleft.'">';
3117: } else {
3118: $datatable .= '<td>';
3119: }
3120: } else {
3121: $datatable .= '<td>';
3122: }
1.8 raeburn 3123: $datatable .= '<span class="LC_nobreak"><label>'.
3124: '<input type="checkbox" name="updateable_'.$type.
3125: '_'.$fields->[$i].'" value="1"'.$check.'/>'.
3126: $fieldtitles->{$fields->[$i]}.'</label></span></td>';
1.3 raeburn 3127: }
3128: $datatable .= '</tr></table></td></tr>';
3129: }
3130: }
3131: return $datatable;
1.1 raeburn 3132: }
3133:
3134: sub modify_login {
1.9 raeburn 3135: my ($r,$dom,$confname,%domconfig) = @_;
1.6 raeburn 3136: my ($resulttext,$errors,$colchgtext,%changes,%colchanges);
1.1 raeburn 3137: my %title = ( coursecatalog => 'Display course catalog',
1.41 raeburn 3138: adminmail => 'Display administrator E-mail address',
1.43 raeburn 3139: newuser => 'Link for visitors to create a user account',
1.41 raeburn 3140: loginheader => 'Log-in box header');
1.3 raeburn 3141: my @offon = ('off','on');
1.6 raeburn 3142: my %loginhash;
1.9 raeburn 3143: ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
3144: \%domconfig,\%loginhash);
1.43 raeburn 3145: my @toggles = ('coursecatalog','adminmail','newuser');
1.42 raeburn 3146: foreach my $item (@toggles) {
3147: $loginhash{login}{$item} = $env{'form.'.$item};
3148: }
1.41 raeburn 3149: $loginhash{login}{loginheader} = $env{'form.loginheader'};
1.6 raeburn 3150: if (ref($colchanges{'login'}) eq 'HASH') {
3151: $colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
3152: \%loginhash);
3153: }
1.110 raeburn 3154:
3155: my %servers = &Apache::lonnet::get_servers($dom);
3156: if (keys(%servers) > 1) {
3157: foreach my $lonhost (keys(%servers)) {
3158: if ($env{'form.'.$lonhost.'_serverurl'} ne '') {
3159: if (defined($servers{$env{'form.'.$lonhost.'_serverurl'}})) {
3160: $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};
1.111 ! jms 3161: $changes{$item} = 1;
1.110 raeburn 3162: }
3163: }
3164: }
3165: }
3166:
1.1 raeburn 3167: my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
3168: $dom);
3169: if ($putresult eq 'ok') {
1.43 raeburn 3170: my @toggles = ('coursecatalog','adminmail','newuser');
1.42 raeburn 3171: my %defaultchecked = (
3172: 'coursecatalog' => 'on',
3173: 'adminmail' => 'off',
1.43 raeburn 3174: 'newuser' => 'off',
1.42 raeburn 3175: );
1.55 raeburn 3176: if (ref($domconfig{'login'}) eq 'HASH') {
3177: foreach my $item (@toggles) {
3178: if ($defaultchecked{$item} eq 'on') {
3179: if (($domconfig{'login'}{$item} eq '0') &&
3180: ($env{'form.'.$item} eq '1')) {
3181: $changes{$item} = 1;
3182: } elsif (($domconfig{'login'}{$item} eq '' ||
3183: $domconfig{'login'}{$item} eq '1') &&
3184: ($env{'form.'.$item} eq '0')) {
3185: $changes{$item} = 1;
3186: }
3187: } elsif ($defaultchecked{$item} eq 'off') {
3188: if (($domconfig{'login'}{$item} eq '1') &&
3189: ($env{'form.'.$item} eq '0')) {
3190: $changes{$item} = 1;
3191: } elsif (($domconfig{'login'}{$item} eq '' ||
3192: $domconfig{'login'}{$item} eq '0') &&
3193: ($env{'form.'.$item} eq '1')) {
3194: $changes{$item} = 1;
3195: }
1.42 raeburn 3196: }
3197: }
1.55 raeburn 3198: if (($domconfig{'login'}{'loginheader'} eq 'text') &&
3199: ($env{'form.loginheader'} eq 'image')) {
3200: $changes{'loginheader'} = 1;
3201: } elsif (($domconfig{'login'}{'loginheader'} eq '' ||
3202: $domconfig{'login'}{'loginheader'} eq 'image') &&
3203: ($env{'form.loginheader'} eq 'text')) {
3204: $changes{'loginheader'} = 1;
3205: }
1.41 raeburn 3206: }
1.6 raeburn 3207: if (keys(%changes) > 0 || $colchgtext) {
1.41 raeburn 3208: &Apache::loncommon::devalidate_domconfig_cache($dom);
1.1 raeburn 3209: $resulttext = &mt('Changes made:').'<ul>';
3210: foreach my $item (sort(keys(%changes))) {
1.41 raeburn 3211: if ($item eq 'loginheader') {
3212: $resulttext .= '<li>'.&mt("$title{$item} set to $env{'form.loginheader'}").'</li>';
3213: } else {
3214: $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
3215: }
1.1 raeburn 3216: }
1.6 raeburn 3217: $resulttext .= $colchgtext.'</ul>';
1.1 raeburn 3218: } else {
3219: $resulttext = &mt('No changes made to log-in page settings');
3220: }
3221: } else {
1.11 albertel 3222: $resulttext = '<span class="LC_error">'.
3223: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 3224: }
1.6 raeburn 3225: if ($errors) {
1.9 raeburn 3226: $resulttext .= '<br />'.&mt('The following errors occurred: ').'<ul>'.
1.6 raeburn 3227: $errors.'</ul>';
3228: }
3229: return $resulttext;
3230: }
3231:
3232: sub color_font_choices {
3233: my %choices =
3234: &Apache::lonlocal::texthash (
3235: img => "Header",
3236: bgs => "Background colors",
3237: links => "Link colors",
1.55 raeburn 3238: images => "Images",
1.6 raeburn 3239: font => "Font color",
1.97 tempelho 3240: fontmenu => "Font Menu",
1.76 raeburn 3241: pgbg => "Page",
1.6 raeburn 3242: tabbg => "Header",
3243: sidebg => "Border",
3244: link => "Link",
3245: alink => "Active link",
3246: vlink => "Visited link",
3247: );
3248: return %choices;
3249: }
3250:
3251: sub modify_rolecolors {
1.9 raeburn 3252: my ($r,$dom,$confname,$roles,%domconfig) = @_;
1.6 raeburn 3253: my ($resulttext,%rolehash);
3254: $rolehash{'rolecolors'} = {};
1.55 raeburn 3255: if (ref($domconfig{'rolecolors'}) ne 'HASH') {
3256: if ($domconfig{'rolecolors'} eq '') {
3257: $domconfig{'rolecolors'} = {};
3258: }
3259: }
1.9 raeburn 3260: my ($errors,%changes) = &modify_colors($r,$dom,$confname,$roles,
1.6 raeburn 3261: $domconfig{'rolecolors'},$rolehash{'rolecolors'});
3262: my $putresult = &Apache::lonnet::put_dom('configuration',\%rolehash,
3263: $dom);
3264: if ($putresult eq 'ok') {
3265: if (keys(%changes) > 0) {
1.41 raeburn 3266: &Apache::loncommon::devalidate_domconfig_cache($dom);
1.6 raeburn 3267: $resulttext = &display_colorchgs($dom,\%changes,$roles,
3268: $rolehash{'rolecolors'});
3269: } else {
3270: $resulttext = &mt('No changes made to default color schemes');
3271: }
3272: } else {
1.11 albertel 3273: $resulttext = '<span class="LC_error">'.
3274: &mt('An error occurred: [_1]',$putresult).'</span>';
1.6 raeburn 3275: }
3276: if ($errors) {
3277: $resulttext .= &mt('The following errors occurred: ').'<ul>'.
3278: $errors.'</ul>';
3279: }
3280: return $resulttext;
3281: }
3282:
3283: sub modify_colors {
1.9 raeburn 3284: my ($r,$dom,$confname,$roles,$domconfig,$confhash) = @_;
1.12 raeburn 3285: my (%changes,%choices);
1.51 raeburn 3286: my @bgs;
1.6 raeburn 3287: my @links = ('link','alink','vlink');
1.41 raeburn 3288: my @logintext;
1.6 raeburn 3289: my @images;
3290: my $servadm = $r->dir_config('lonAdmEMail');
3291: my $errors;
3292: foreach my $role (@{$roles}) {
3293: if ($role eq 'login') {
1.12 raeburn 3294: %choices = &login_choices();
1.41 raeburn 3295: @logintext = ('textcol','bgcol');
1.12 raeburn 3296: } else {
3297: %choices = &color_font_choices();
1.107 raeburn 3298: $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
1.12 raeburn 3299: }
3300: if ($role eq 'login') {
1.41 raeburn 3301: @images = ('img','logo','domlogo','login');
1.51 raeburn 3302: @bgs = ('pgbg','mainbg','sidebg');
1.6 raeburn 3303: } else {
3304: @images = ('img');
1.51 raeburn 3305: @bgs = ('pgbg','tabbg','sidebg');
1.6 raeburn 3306: }
3307: $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
1.41 raeburn 3308: foreach my $item (@bgs,@links,@logintext) {
1.6 raeburn 3309: $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
3310: }
1.46 raeburn 3311: my ($configuserok,$author_ok,$switchserver) =
3312: &config_check($dom,$confname,$servadm);
1.9 raeburn 3313: my ($width,$height) = &thumb_dimensions();
1.40 raeburn 3314: if (ref($domconfig->{$role}) ne 'HASH') {
3315: $domconfig->{$role} = {};
3316: }
1.8 raeburn 3317: foreach my $img (@images) {
1.70 raeburn 3318: if (($role eq 'login') && (($img eq 'img') || ($img eq 'logo'))) {
3319: if (defined($env{'form.login_showlogo_'.$img})) {
3320: $confhash->{$role}{'showlogo'}{$img} = 1;
3321: } else {
3322: $confhash->{$role}{'showlogo'}{$img} = 0;
3323: }
3324: }
1.18 albertel 3325: if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
3326: && !defined($domconfig->{$role}{$img})
3327: && !$env{'form.'.$role.'_del_'.$img}
3328: && $env{'form.'.$role.'_import_'.$img}) {
3329: # import the old configured image from the .tab setting
3330: # if they haven't provided a new one
3331: $domconfig->{$role}{$img} =
3332: $env{'form.'.$role.'_import_'.$img};
3333: }
1.6 raeburn 3334: if ($env{'form.'.$role.'_'.$img.'.filename'} ne '') {
1.9 raeburn 3335: my $error;
1.6 raeburn 3336: if ($configuserok eq 'ok') {
1.9 raeburn 3337: if ($switchserver) {
1.12 raeburn 3338: $error = &mt("Upload of [_1] image for $role page(s) is not permitted to this server: [_2]",$choices{$img},$switchserver);
1.9 raeburn 3339: } else {
3340: if ($author_ok eq 'ok') {
3341: my ($result,$logourl) =
3342: &publishlogo($r,'upload',$role.'_'.$img,
3343: $dom,$confname,$img,$width,$height);
3344: if ($result eq 'ok') {
3345: $confhash->{$role}{$img} = $logourl;
1.12 raeburn 3346: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 3347: } else {
1.12 raeburn 3348: $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 3349: }
3350: } else {
1.46 raeburn 3351: $error = &mt("Upload of [_1] image for $role page(s) failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$choices{$img},$confname,$dom,$author_ok);
1.6 raeburn 3352: }
3353: }
3354: } else {
1.46 raeburn 3355: $error = &mt("Upload of [_1] image for $role page(s) failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$choices{$img},$confname,$dom,$configuserok);
1.9 raeburn 3356: }
3357: if ($error) {
1.8 raeburn 3358: &Apache::lonnet::logthis($error);
1.11 albertel 3359: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
1.8 raeburn 3360: }
3361: } elsif ($domconfig->{$role}{$img} ne '') {
1.9 raeburn 3362: if ($domconfig->{$role}{$img} !~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
3363: my $error;
3364: if ($configuserok eq 'ok') {
3365: # is confname an author?
3366: if ($switchserver eq '') {
3367: if ($author_ok eq 'ok') {
3368: my ($result,$logourl) =
3369: &publishlogo($r,'copy',$domconfig->{$role}{$img},
3370: $dom,$confname,$img,$width,$height);
3371: if ($result eq 'ok') {
3372: $confhash->{$role}{$img} = $logourl;
1.18 albertel 3373: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 3374: }
3375: }
3376: }
3377: }
1.6 raeburn 3378: }
3379: }
3380: }
3381: if (ref($domconfig) eq 'HASH') {
3382: if (ref($domconfig->{$role}) eq 'HASH') {
3383: foreach my $img (@images) {
3384: if ($domconfig->{$role}{$img} ne '') {
3385: if ($env{'form.'.$role.'_del_'.$img}) {
3386: $confhash->{$role}{$img} = '';
1.12 raeburn 3387: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 3388: } else {
1.9 raeburn 3389: if ($confhash->{$role}{$img} eq '') {
3390: $confhash->{$role}{$img} = $domconfig->{$role}{$img};
3391: }
1.6 raeburn 3392: }
3393: } else {
3394: if ($env{'form.'.$role.'_del_'.$img}) {
3395: $confhash->{$role}{$img} = '';
1.12 raeburn 3396: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 3397: }
3398: }
1.70 raeburn 3399: if (($role eq 'login') && (($img eq 'logo') || ($img eq 'img'))) {
3400: if (ref($domconfig->{'login'}{'showlogo'}) eq 'HASH') {
3401: if ($confhash->{$role}{'showlogo'}{$img} ne
3402: $domconfig->{$role}{'showlogo'}{$img}) {
3403: $changes{$role}{'showlogo'}{$img} = 1;
3404: }
3405: } else {
3406: if ($confhash->{$role}{'showlogo'}{$img} == 0) {
3407: $changes{$role}{'showlogo'}{$img} = 1;
3408: }
3409: }
3410: }
3411: }
1.6 raeburn 3412: if ($domconfig->{$role}{'font'} ne '') {
3413: if ($confhash->{$role}{'font'} ne $domconfig->{$role}{'font'}) {
3414: $changes{$role}{'font'} = 1;
3415: }
3416: } else {
3417: if ($confhash->{$role}{'font'}) {
3418: $changes{$role}{'font'} = 1;
3419: }
3420: }
1.107 raeburn 3421: if ($role ne 'login') {
3422: if ($domconfig->{$role}{'fontmenu'} ne '') {
3423: if ($confhash->{$role}{'fontmenu'} ne $domconfig->{$role}{'fontmenu'}) {
3424: $changes{$role}{'fontmenu'} = 1;
3425: }
3426: } else {
3427: if ($confhash->{$role}{'fontmenu'}) {
3428: $changes{$role}{'fontmenu'} = 1;
3429: }
1.97 tempelho 3430: }
3431: }
1.6 raeburn 3432: foreach my $item (@bgs) {
3433: if ($domconfig->{$role}{$item} ne '') {
3434: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
3435: $changes{$role}{'bgs'}{$item} = 1;
3436: }
3437: } else {
3438: if ($confhash->{$role}{$item}) {
3439: $changes{$role}{'bgs'}{$item} = 1;
3440: }
3441: }
3442: }
3443: foreach my $item (@links) {
3444: if ($domconfig->{$role}{$item} ne '') {
3445: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
3446: $changes{$role}{'links'}{$item} = 1;
3447: }
3448: } else {
3449: if ($confhash->{$role}{$item}) {
3450: $changes{$role}{'links'}{$item} = 1;
3451: }
3452: }
3453: }
1.41 raeburn 3454: foreach my $item (@logintext) {
3455: if ($domconfig->{$role}{$item} ne '') {
3456: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
3457: $changes{$role}{'logintext'}{$item} = 1;
3458: }
3459: } else {
3460: if ($confhash->{$role}{$item}) {
3461: $changes{$role}{'logintext'}{$item} = 1;
3462: }
3463: }
3464: }
1.6 raeburn 3465: } else {
3466: &default_change_checker($role,\@images,\@links,\@bgs,
1.41 raeburn 3467: \@logintext,$confhash,\%changes);
1.6 raeburn 3468: }
3469: } else {
3470: &default_change_checker($role,\@images,\@links,\@bgs,
1.41 raeburn 3471: \@logintext,$confhash,\%changes);
1.6 raeburn 3472: }
3473: }
3474: return ($errors,%changes);
3475: }
3476:
1.46 raeburn 3477: sub config_check {
3478: my ($dom,$confname,$servadm) = @_;
3479: my ($configuserok,$author_ok,$switchserver,%currroles);
3480: my $uhome = &Apache::lonnet::homeserver($confname,$dom,1);
3481: ($configuserok,%currroles) = &check_configuser($uhome,$dom,
3482: $confname,$servadm);
3483: if ($configuserok eq 'ok') {
3484: $switchserver = &check_switchserver($dom,$confname);
3485: if ($switchserver eq '') {
3486: $author_ok = &check_authorstatus($dom,$confname,%currroles);
3487: }
3488: }
3489: return ($configuserok,$author_ok,$switchserver);
3490: }
3491:
1.6 raeburn 3492: sub default_change_checker {
1.41 raeburn 3493: my ($role,$images,$links,$bgs,$logintext,$confhash,$changes) = @_;
1.6 raeburn 3494: foreach my $item (@{$links}) {
3495: if ($confhash->{$role}{$item}) {
3496: $changes->{$role}{'links'}{$item} = 1;
3497: }
3498: }
3499: foreach my $item (@{$bgs}) {
3500: if ($confhash->{$role}{$item}) {
3501: $changes->{$role}{'bgs'}{$item} = 1;
3502: }
3503: }
1.41 raeburn 3504: foreach my $item (@{$logintext}) {
3505: if ($confhash->{$role}{$item}) {
3506: $changes->{$role}{'logintext'}{$item} = 1;
3507: }
3508: }
1.6 raeburn 3509: foreach my $img (@{$images}) {
3510: if ($env{'form.'.$role.'_del_'.$img}) {
3511: $confhash->{$role}{$img} = '';
1.12 raeburn 3512: $changes->{$role}{'images'}{$img} = 1;
1.6 raeburn 3513: }
1.70 raeburn 3514: if ($role eq 'login') {
3515: if ($confhash->{$role}{'showlogo'}{$img} == 0) {
3516: $changes->{$role}{'showlogo'}{$img} = 1;
3517: }
3518: }
1.6 raeburn 3519: }
3520: if ($confhash->{$role}{'font'}) {
3521: $changes->{$role}{'font'} = 1;
3522: }
1.48 raeburn 3523: }
1.6 raeburn 3524:
3525: sub display_colorchgs {
3526: my ($dom,$changes,$roles,$confhash) = @_;
3527: my (%choices,$resulttext);
3528: if (!grep(/^login$/,@{$roles})) {
3529: $resulttext = &mt('Changes made:').'<br />';
3530: }
3531: foreach my $role (@{$roles}) {
3532: if ($role eq 'login') {
3533: %choices = &login_choices();
3534: } else {
3535: %choices = &color_font_choices();
3536: }
3537: if (ref($changes->{$role}) eq 'HASH') {
3538: if ($role ne 'login') {
3539: $resulttext .= '<h4>'.&mt($role).'</h4>';
3540: }
3541: foreach my $key (sort(keys(%{$changes->{$role}}))) {
3542: if ($role ne 'login') {
3543: $resulttext .= '<ul>';
3544: }
3545: if (ref($changes->{$role}{$key}) eq 'HASH') {
3546: if ($role ne 'login') {
3547: $resulttext .= '<li>'.&mt($choices{$key}).':<ul>';
3548: }
3549: foreach my $item (sort(keys(%{$changes->{$role}{$key}}))) {
1.70 raeburn 3550: if (($role eq 'login') && ($key eq 'showlogo')) {
3551: if ($confhash->{$role}{$key}{$item}) {
3552: $resulttext .= '<li>'.&mt("$choices{$item} set to be displayed").'</li>';
3553: } else {
3554: $resulttext .= '<li>'.&mt("$choices{$item} set to not be displayed").'</li>';
3555: }
3556: } elsif ($confhash->{$role}{$item} eq '') {
1.6 raeburn 3557: $resulttext .= '<li>'.&mt("$choices{$item} set to default").'</li>';
3558: } else {
1.12 raeburn 3559: my $newitem = $confhash->{$role}{$item};
3560: if ($key eq 'images') {
3561: $newitem = '<img src="'.$confhash->{$role}{$item}.'" alt="'.$choices{$item}.'" valign="bottom" />';
3562: }
3563: $resulttext .= '<li>'.&mt("$choices{$item} set to [_1]",$newitem).'</li>';
1.6 raeburn 3564: }
3565: }
3566: if ($role ne 'login') {
3567: $resulttext .= '</ul></li>';
3568: }
3569: } else {
3570: if ($confhash->{$role}{$key} eq '') {
3571: $resulttext .= '<li>'.&mt("$choices{$key} set to default").'</li>';
3572: } else {
3573: $resulttext .= '<li>'.&mt("$choices{$key} set to [_1]",$confhash->{$role}{$key}).'</li>';
3574: }
3575: }
3576: if ($role ne 'login') {
3577: $resulttext .= '</ul>';
3578: }
3579: }
3580: }
3581: }
1.3 raeburn 3582: return $resulttext;
1.1 raeburn 3583: }
3584:
1.9 raeburn 3585: sub thumb_dimensions {
3586: return ('200','50');
3587: }
3588:
1.16 raeburn 3589: sub check_dimensions {
3590: my ($inputfile) = @_;
3591: my ($fullwidth,$fullheight);
3592: if ($inputfile =~ m|^[/\w.\-]+$|) {
3593: if (open(PIPE,"identify $inputfile 2>&1 |")) {
3594: my $imageinfo = <PIPE>;
3595: if (!close(PIPE)) {
3596: &Apache::lonnet::logthis("Failed to close PIPE opened to retrieve image information for $inputfile");
3597: }
3598: chomp($imageinfo);
3599: my ($fullsize) =
1.21 raeburn 3600: ($imageinfo =~ /^\Q$inputfile\E\s+\w+\s+(\d+x\d+)/);
1.16 raeburn 3601: if ($fullsize) {
3602: ($fullwidth,$fullheight) = split(/x/,$fullsize);
3603: }
3604: }
3605: }
3606: return ($fullwidth,$fullheight);
3607: }
3608:
1.9 raeburn 3609: sub check_configuser {
3610: my ($uhome,$dom,$confname,$servadm) = @_;
3611: my ($configuserok,%currroles);
3612: if ($uhome eq 'no_host') {
3613: srand( time() ^ ($$ + ($$ << 15)) ); # Seed rand.
3614: my $configpass = &LONCAPA::Enrollment::create_password();
3615: $configuserok =
3616: &Apache::lonnet::modifyuser($dom,$confname,'','internal',
3617: $configpass,'','','','','',undef,$servadm);
3618: } else {
3619: $configuserok = 'ok';
3620: %currroles =
3621: &Apache::lonnet::get_my_roles($confname,$dom,'userroles');
3622: }
3623: return ($configuserok,%currroles);
3624: }
3625:
3626: sub check_authorstatus {
3627: my ($dom,$confname,%currroles) = @_;
3628: my $author_ok;
1.40 raeburn 3629: if (!$currroles{':'.$dom.':au'}) {
1.9 raeburn 3630: my $start = time;
3631: my $end = 0;
3632: $author_ok =
3633: &Apache::lonnet::assignrole($dom,$confname,'/'.$dom.'/',
1.47 raeburn 3634: 'au',$end,$start,'','','domconfig');
1.9 raeburn 3635: } else {
3636: $author_ok = 'ok';
3637: }
3638: return $author_ok;
3639: }
3640:
3641: sub publishlogo {
1.46 raeburn 3642: my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight,$savefileas) = @_;
1.9 raeburn 3643: my ($output,$fname,$logourl);
3644: if ($action eq 'upload') {
3645: $fname=$env{'form.'.$formname.'.filename'};
3646: chop($env{'form.'.$formname});
3647: } else {
3648: ($fname) = ($formname =~ /([^\/]+)$/);
3649: }
1.46 raeburn 3650: if ($savefileas ne '') {
3651: $fname = $savefileas;
3652: }
1.9 raeburn 3653: $fname=&Apache::lonnet::clean_filename($fname);
3654: # See if there is anything left
3655: unless ($fname) { return ('error: no uploaded file'); }
3656: $fname="$subdir/$fname";
3657: my $filepath='/home/'.$confname.'/public_html';
3658: my ($fnamepath,$file,$fetchthumb);
3659: $file=$fname;
3660: if ($fname=~m|/|) {
3661: ($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
3662: }
3663: my @parts=split(/\//,$filepath.'/'.$fnamepath);
3664: my $count;
3665: for ($count=4;$count<=$#parts;$count++) {
3666: $filepath.="/$parts[$count]";
3667: if ((-e $filepath)!=1) {
3668: mkdir($filepath,02770);
3669: }
3670: }
3671: # Check for bad extension and disallow upload
3672: if ($file=~/\.(\w+)$/ &&
3673: (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
3674: $output =
3675: &mt('Invalid file extension ([_1]) - reserved for LONCAPA use.',$1);
3676: } elsif ($file=~/\.(\w+)$/ &&
3677: !defined(&Apache::loncommon::fileembstyle($1))) {
3678: $output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1);
3679: } elsif ($file=~/\.(\d+)\.(\w+)$/) {
1.46 raeburn 3680: $output = &mt('File name not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
1.9 raeburn 3681: } elsif (-d "$filepath/$file") {
3682: $output = &mt('File name is a directory name - rename the file and re-upload');
3683: } else {
3684: my $source = $filepath.'/'.$file;
3685: my $logfile;
3686: if (!open($logfile,">>$source".'.log')) {
3687: return (&mt('No write permission to Construction Space'));
3688: }
3689: print $logfile
3690: "\n================= Publish ".localtime()." ================\n".
3691: $env{'user.name'}.':'.$env{'user.domain'}."\n";
3692: # Save the file
3693: if (!open(FH,'>'.$source)) {
3694: &Apache::lonnet::logthis('Failed to create '.$source);
3695: return (&mt('Failed to create file'));
3696: }
3697: if ($action eq 'upload') {
3698: if (!print FH ($env{'form.'.$formname})) {
3699: &Apache::lonnet::logthis('Failed to write to '.$source);
3700: return (&mt('Failed to write file'));
3701: }
3702: } else {
3703: my $original = &Apache::lonnet::filelocation('',$formname);
3704: if(!copy($original,$source)) {
3705: &Apache::lonnet::logthis('Failed to copy '.$original.' to '.$source);
3706: return (&mt('Failed to write file'));
3707: }
3708: }
3709: close(FH);
3710: chmod(0660, $source); # Permissions to rw-rw---.
3711:
3712: my $docroot=$r->dir_config('lonDocRoot');
3713: my $targetdir=$docroot.'/res/'.$dom.'/'.$confname .'/'.$fnamepath;
3714: my $copyfile=$targetdir.'/'.$file;
3715:
3716: my @parts=split(/\//,$targetdir);
3717: my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]";
3718: for (my $count=5;$count<=$#parts;$count++) {
3719: $path.="/$parts[$count]";
3720: if (!-e $path) {
3721: print $logfile "\nCreating directory ".$path;
3722: mkdir($path,02770);
3723: }
3724: }
3725: my $versionresult;
3726: if (-e $copyfile) {
3727: $versionresult = &logo_versioning($targetdir,$file,$logfile);
3728: } else {
3729: $versionresult = 'ok';
3730: }
3731: if ($versionresult eq 'ok') {
3732: if (copy($source,$copyfile)) {
3733: print $logfile "\nCopied original source to ".$copyfile."\n";
3734: $output = 'ok';
3735: &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
3736: $logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;
3737: } else {
3738: print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
3739: $output = &mt('Failed to copy file to RES space').", $!";
3740: }
3741: if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) {
3742: my $inputfile = $filepath.'/'.$file;
3743: my $outfile = $filepath.'/'.'tn-'.$file;
1.16 raeburn 3744: my ($fullwidth,$fullheight) = &check_dimensions($inputfile);
3745: if ($fullwidth ne '' && $fullheight ne '') {
3746: if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) {
3747: my $thumbsize = $thumbwidth.'x'.$thumbheight;
3748: system("convert -sample $thumbsize $inputfile $outfile");
3749: chmod(0660, $filepath.'/tn-'.$file);
3750: if (-e $outfile) {
3751: my $copyfile=$targetdir.'/tn-'.$file;
3752: if (copy($outfile,$copyfile)) {
3753: print $logfile "\nCopied source to ".$copyfile."\n";
3754: &write_metadata($dom,$confname,$formname,
3755: $targetdir,'tn-'.$file,$logfile);
3756: } else {
3757: print $logfile "\nUnable to write ".$copyfile.
3758: ':'.$!."\n";
3759: }
3760: }
1.9 raeburn 3761: }
3762: }
3763: }
3764: } else {
3765: $output = $versionresult;
3766: }
3767: }
3768: return ($output,$logourl);
3769: }
3770:
3771: sub logo_versioning {
3772: my ($targetdir,$file,$logfile) = @_;
3773: my $target = $targetdir.'/'.$file;
3774: my ($maxversion,$fn,$extn,$output);
3775: $maxversion = 0;
3776: if ($file =~ /^(.+)\.(\w+)$/) {
3777: $fn=$1;
3778: $extn=$2;
3779: }
3780: opendir(DIR,$targetdir);
3781: while (my $filename=readdir(DIR)) {
3782: if ($filename=~/\Q$fn\E\.(\d+)\.\Q$extn\E$/) {
3783: $maxversion=($1>$maxversion)?$1:$maxversion;
3784: }
3785: }
3786: $maxversion++;
3787: print $logfile "\nCreating old version ".$maxversion."\n";
3788: my $copyfile=$targetdir.'/'.$fn.'.'.$maxversion.'.'.$extn;
3789: if (copy($target,$copyfile)) {
3790: print $logfile "Copied old target to ".$copyfile."\n";
3791: $copyfile=$copyfile.'.meta';
3792: if (copy($target.'.meta',$copyfile)) {
3793: print $logfile "Copied old target metadata to ".$copyfile."\n";
3794: $output = 'ok';
3795: } else {
3796: print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";
3797: $output = &mt('Failed to copy old meta').", $!, ";
3798: }
3799: } else {
3800: print $logfile "Unable to write ".$copyfile.':'.$!."\n";
3801: $output = &mt('Failed to copy old target').", $!, ";
3802: }
3803: return $output;
3804: }
3805:
3806: sub write_metadata {
3807: my ($dom,$confname,$formname,$targetdir,$file,$logfile) = @_;
3808: my (%metadatafields,%metadatakeys,$output);
3809: $metadatafields{'title'}=$formname;
3810: $metadatafields{'creationdate'}=time;
3811: $metadatafields{'lastrevisiondate'}=time;
3812: $metadatafields{'copyright'}='public';
3813: $metadatafields{'modifyinguser'}=$env{'user.name'}.':'.
3814: $env{'user.domain'};
3815: $metadatafields{'authorspace'}=$confname.':'.$dom;
3816: $metadatafields{'domain'}=$dom;
3817: {
3818: print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
3819: my $mfh;
3820: unless (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
3821: $output = &mt('Could not write metadata');
3822: }
3823: foreach (sort keys %metadatafields) {
3824: unless ($_=~/\./) {
3825: my $unikey=$_;
3826: $unikey=~/^([A-Za-z]+)/;
3827: my $tag=$1;
3828: $tag=~tr/A-Z/a-z/;
3829: print $mfh "\n\<$tag";
3830: foreach (split(/\,/,$metadatakeys{$unikey})) {
3831: my $value=$metadatafields{$unikey.'.'.$_};
3832: $value=~s/\"/\'\'/g;
3833: print $mfh ' '.$_.'="'.$value.'"';
3834: }
3835: print $mfh '>'.
3836: &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
3837: .'</'.$tag.'>';
3838: }
3839: }
3840: $output = 'ok';
3841: print $logfile "\nWrote metadata";
3842: close($mfh);
3843: }
3844: }
3845:
3846: sub check_switchserver {
3847: my ($dom,$confname) = @_;
3848: my ($allowed,$switchserver);
3849: my $home = &Apache::lonnet::homeserver($confname,$dom);
3850: if ($home eq 'no_host') {
3851: $home = &Apache::lonnet::domain($dom,'primary');
3852: }
3853: my @ids=&Apache::lonnet::current_machine_ids();
1.10 albertel 3854: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
3855: if (!$allowed) {
3856: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role=dc./'.$dom.'/">'.&mt('Switch Server').'</a>';
1.9 raeburn 3857: }
3858: return $switchserver;
3859: }
3860:
1.1 raeburn 3861: sub modify_quotas {
1.86 raeburn 3862: my ($dom,$action,%domconfig) = @_;
1.101 raeburn 3863: my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,
3864: %limithash,$toolregexp,%conditions,$resulttext,%changes);
1.86 raeburn 3865: if ($action eq 'quotas') {
3866: $context = 'tools';
3867: } else {
3868: $context = $action;
3869: }
3870: if ($context eq 'requestcourses') {
1.98 raeburn 3871: @usertools = ('official','unofficial','community');
1.106 raeburn 3872: @options =('norequest','approval','validate','autolimit');
1.101 raeburn 3873: %validations = &Apache::lonnet::auto_courserequest_checks($dom);
3874: %titles = &courserequest_titles();
3875: $toolregexp = join('|',@usertools);
3876: %conditions = &courserequest_conditions();
1.86 raeburn 3877: } else {
3878: @usertools = ('aboutme','blog','portfolio');
1.101 raeburn 3879: %titles = &tool_titles();
1.86 raeburn 3880: }
1.72 raeburn 3881: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.44 raeburn 3882: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.1 raeburn 3883: foreach my $key (keys(%env)) {
1.101 raeburn 3884: if ($context eq 'requestcourses') {
3885: if ($key =~ /^form\.crsreq_($toolregexp)_(.+)$/) {
3886: my $item = $1;
3887: my $type = $2;
3888: if ($type =~ /^limit_(.+)/) {
3889: $limithash{$item}{$1} = $env{$key};
3890: } else {
3891: $confhash{$item}{$type} = $env{$key};
3892: }
3893: }
3894: } else {
1.86 raeburn 3895: if ($key =~ /^form\.quota_(.+)$/) {
3896: $confhash{'defaultquota'}{$1} = $env{$key};
3897: }
1.101 raeburn 3898: if ($key =~ /^form\.\Q$context\E_(.+)$/) {
3899: @{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
3900: }
1.72 raeburn 3901: }
3902: }
1.102 raeburn 3903: if ($context eq 'requestcourses') {
3904: my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify');
3905: @approvalnotify = sort(@approvalnotify);
3906: $confhash{'notify'}{'approval'} = join(',',@approvalnotify);
3907: if (ref($domconfig{$action}) eq 'HASH') {
3908: if (ref($domconfig{$action}{'notify'}) eq 'HASH') {
3909: if ($domconfig{$action}{'notify'}{'approval'} ne $confhash{'notify'}{'approval'}) {
3910: $changes{'notify'}{'approval'} = 1;
3911: }
3912: } else {
3913: if ($domconfig{$action}{'notify'}{'approval'}) {
3914: $changes{'notify'}{'approval'} = 1;
3915: }
3916: }
3917: } else {
3918: if ($domconfig{$action}{'notify'}{'approval'}) {
3919: $changes{'notify'}{'approval'} = 1;
3920: }
3921: }
3922: } else {
1.86 raeburn 3923: $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
3924: }
1.72 raeburn 3925: foreach my $item (@usertools) {
3926: foreach my $type (@{$types},'default','_LC_adv') {
1.104 raeburn 3927: my $unset;
1.101 raeburn 3928: if ($context eq 'requestcourses') {
1.104 raeburn 3929: $unset = '0';
3930: if ($type eq '_LC_adv') {
3931: $unset = '';
3932: }
1.101 raeburn 3933: if ($confhash{$item}{$type} eq 'autolimit') {
3934: $confhash{$item}{$type} .= '=';
3935: unless ($limithash{$item}{$type} =~ /\D/) {
3936: $confhash{$item}{$type} .= $limithash{$item}{$type};
3937: }
3938: }
1.72 raeburn 3939: } else {
1.101 raeburn 3940: if (grep(/^\Q$type\E$/,@{$toolshash{$item}})) {
3941: $confhash{$item}{$type} = 1;
3942: } else {
3943: $confhash{$item}{$type} = 0;
3944: }
1.72 raeburn 3945: }
1.86 raeburn 3946: if (ref($domconfig{$action}) eq 'HASH') {
3947: if (ref($domconfig{$action}{$item}) eq 'HASH') {
3948: if ($domconfig{$action}{$item}{$type} ne $confhash{$item}{$type}) {
3949: $changes{$item}{$type} = 1;
3950: }
3951: } else {
3952: if ($context eq 'requestcourses') {
1.104 raeburn 3953: if ($confhash{$item}{$type} ne $unset) {
1.86 raeburn 3954: $changes{$item}{$type} = 1;
3955: }
3956: } else {
3957: if (!$confhash{$item}{$type}) {
3958: $changes{$item}{$type} = 1;
3959: }
3960: }
3961: }
3962: } else {
3963: if ($context eq 'requestcourses') {
1.104 raeburn 3964: if ($confhash{$item}{$type} ne $unset) {
1.72 raeburn 3965: $changes{$item}{$type} = 1;
3966: }
3967: } else {
3968: if (!$confhash{$item}{$type}) {
3969: $changes{$item}{$type} = 1;
3970: }
3971: }
3972: }
1.1 raeburn 3973: }
3974: }
1.86 raeburn 3975: unless ($context eq 'requestcourses') {
3976: if (ref($domconfig{'quotas'}) eq 'HASH') {
3977: if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
3978: foreach my $key (keys(%{$domconfig{'quotas'}{'defaultquota'}})) {
3979: if (exists($confhash{'defaultquota'}{$key})) {
3980: if ($confhash{'defaultquota'}{$key} ne $domconfig{'quotas'}{'defaultquota'}{$key}) {
3981: $changes{'defaultquota'}{$key} = 1;
3982: }
3983: } else {
3984: $confhash{'defaultquota'}{$key} = $domconfig{'quotas'}{'defaultquota'}{$key};
1.72 raeburn 3985: }
3986: }
1.86 raeburn 3987: } else {
3988: foreach my $key (keys(%{$domconfig{'quotas'}})) {
3989: if (exists($confhash{'defaultquota'}{$key})) {
3990: if ($confhash{'defaultquota'}{$key} ne $domconfig{'quotas'}{$key}) {
3991: $changes{'defaultquota'}{$key} = 1;
3992: }
3993: } else {
3994: $confhash{'defaultquota'}{$key} = $domconfig{'quotas'}{$key};
1.72 raeburn 3995: }
1.1 raeburn 3996: }
3997: }
3998: }
1.86 raeburn 3999: if (ref($confhash{'defaultquota'}) eq 'HASH') {
4000: foreach my $key (keys(%{$confhash{'defaultquota'}})) {
4001: if (ref($domconfig{'quotas'}) eq 'HASH') {
4002: if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
4003: if (!exists($domconfig{'quotas'}{'defaultquota'}{$key})) {
4004: $changes{'defaultquota'}{$key} = 1;
4005: }
4006: } else {
4007: if (!exists($domconfig{'quotas'}{$key})) {
4008: $changes{'defaultquota'}{$key} = 1;
4009: }
1.72 raeburn 4010: }
4011: } else {
1.86 raeburn 4012: $changes{'defaultquota'}{$key} = 1;
1.55 raeburn 4013: }
1.1 raeburn 4014: }
4015: }
4016: }
1.72 raeburn 4017:
4018: foreach my $key (keys(%confhash)) {
4019: $domdefaults{$key} = $confhash{$key};
4020: }
4021:
1.1 raeburn 4022: my %quotahash = (
1.86 raeburn 4023: $action => { %confhash }
1.1 raeburn 4024: );
4025: my $putresult = &Apache::lonnet::put_dom('configuration',\%quotahash,
4026: $dom);
4027: if ($putresult eq 'ok') {
4028: if (keys(%changes) > 0) {
1.72 raeburn 4029: my $cachetime = 24*60*60;
4030: &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
4031:
1.1 raeburn 4032: $resulttext = &mt('Changes made:').'<ul>';
1.86 raeburn 4033: unless ($context eq 'requestcourses') {
4034: if (ref($changes{'defaultquota'}) eq 'HASH') {
4035: $resulttext .= '<li>'.&mt('Portfolio default quotas').'<ul>';
4036: foreach my $type (@{$types},'default') {
4037: if (defined($changes{'defaultquota'}{$type})) {
4038: my $typetitle = $usertypes->{$type};
4039: if ($type eq 'default') {
4040: $typetitle = $othertitle;
4041: }
4042: $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'defaultquota'}{$type}).'</li>';
1.72 raeburn 4043: }
4044: }
1.86 raeburn 4045: $resulttext .= '</ul></li>';
1.72 raeburn 4046: }
4047: }
1.80 raeburn 4048: my %newenv;
1.72 raeburn 4049: foreach my $item (@usertools) {
4050: if (ref($changes{$item}) eq 'HASH') {
1.80 raeburn 4051: my $newacc =
4052: &Apache::lonnet::usertools_access($env{'user.name'},
4053: $env{'user.domain'},
1.86 raeburn 4054: $item,'reload',$context);
4055: if ($context eq 'requestcourses') {
1.108 raeburn 4056: if ($env{'environment.canrequest.'.$item} ne $newacc) {
4057: $newenv{'environment.canrequest.'.$item} = $newacc;
1.86 raeburn 4058: }
4059: } else {
4060: if ($env{'environment.availabletools.'.$item} ne $newacc) {
4061: $newenv{'environment.availabletools.'.$item} = $newacc;
4062: }
1.80 raeburn 4063: }
1.72 raeburn 4064: $resulttext .= '<li>'.$titles{$item}.'<ul>';
4065: foreach my $type (@{$types},'default','_LC_adv') {
4066: if ($changes{$item}{$type}) {
4067: my $typetitle = $usertypes->{$type};
4068: if ($type eq 'default') {
4069: $typetitle = $othertitle;
4070: } elsif ($type eq '_LC_adv') {
4071: $typetitle = 'LON-CAPA Advanced Users';
4072: }
4073: if ($confhash{$item}{$type}) {
1.101 raeburn 4074: if ($context eq 'requestcourses') {
4075: my $cond;
4076: if ($confhash{$item}{$type} =~ /^autolimit=(\d*)$/) {
4077: if ($1 eq '') {
4078: $cond = &mt('(Automatic processing of any request).');
4079: } else {
4080: $cond = &mt('(Automatic processing of requests up to limit of [quant,_1,request] per user).',$1);
4081: }
4082: } else {
4083: $cond = $conditions{$confhash{$item}{$type}};
4084: }
4085: $resulttext .= '<li>'.&mt('Set to be available to [_1].',$typetitle).' '.$cond.'</li>';
4086: } else {
4087: $resulttext .= '<li>'.&mt('Set to be available to [_1]',$typetitle).'</li>';
4088: }
1.72 raeburn 4089: } else {
1.104 raeburn 4090: if ($type eq '_LC_adv') {
4091: if ($confhash{$item}{$type} eq '0') {
4092: $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
4093: } else {
4094: $resulttext .= '<li>'.&mt('No override set for [_1]',$typetitle).'</li>';
4095: }
4096: } else {
4097: $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
4098: }
1.72 raeburn 4099: }
4100: }
1.26 raeburn 4101: }
1.72 raeburn 4102: $resulttext .= '</ul></li>';
1.26 raeburn 4103: }
1.1 raeburn 4104: }
1.102 raeburn 4105: if ($action eq 'requestcourses') {
4106: if (ref($changes{'notify'}) eq 'HASH') {
4107: if ($changes{'notify'}{'approval'}) {
4108: if (ref($confhash{'notify'}) eq 'HASH') {
4109: if ($confhash{'notify'}{'approval'}) {
4110: $resulttext .= '<li>'.&mt('Notification of requests requiring approval will be sent to: ').$confhash{'notify'}{'approval'}.'</li>';
4111: } else {
4112: $resulttext .= '<li>'.&mt('No Domain Coordinators will receive notification of course requests requiring approval.').'</li>';
4113: }
4114: }
4115: }
4116: }
4117: }
1.1 raeburn 4118: $resulttext .= '</ul>';
1.80 raeburn 4119: if (keys(%newenv)) {
4120: &Apache::lonnet::appenv(\%newenv);
4121: }
1.1 raeburn 4122: } else {
1.86 raeburn 4123: if ($context eq 'requestcourses') {
4124: $resulttext = &mt('No changes made to rights to request creation of courses.');
4125: } else {
1.90 weissno 4126: $resulttext = &mt('No changes made to availability of personal information pages, blogs, portfolios or default quotas');
1.86 raeburn 4127: }
1.1 raeburn 4128: }
4129: } else {
1.11 albertel 4130: $resulttext = '<span class="LC_error">'.
4131: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 4132: }
1.3 raeburn 4133: return $resulttext;
1.1 raeburn 4134: }
4135:
1.3 raeburn 4136: sub modify_autoenroll {
4137: my ($dom,%domconfig) = @_;
1.1 raeburn 4138: my ($resulttext,%changes);
4139: my %currautoenroll;
4140: if (ref($domconfig{'autoenroll'}) eq 'HASH') {
4141: foreach my $key (keys(%{$domconfig{'autoenroll'}})) {
4142: $currautoenroll{$key} = $domconfig{'autoenroll'}{$key};
4143: }
4144: }
4145: my $autorun = &Apache::lonnet::auto_run(undef,$dom),
4146: my %title = ( run => 'Auto-enrollment active',
4147: sender => 'Sender for notification messages');
4148: my @offon = ('off','on');
1.17 raeburn 4149: my $sender_uname = $env{'form.sender_uname'};
4150: my $sender_domain = $env{'form.sender_domain'};
4151: if ($sender_domain eq '') {
4152: $sender_uname = '';
4153: } elsif ($sender_uname eq '') {
4154: $sender_domain = '';
4155: }
1.1 raeburn 4156: my %autoenrollhash = (
4157: autoenroll => { run => $env{'form.autoenroll_run'},
1.17 raeburn 4158: sender_uname => $sender_uname,
4159: sender_domain => $sender_domain,
1.1 raeburn 4160:
4161: }
4162: );
1.4 raeburn 4163: my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
4164: $dom);
1.1 raeburn 4165: if ($putresult eq 'ok') {
4166: if (exists($currautoenroll{'run'})) {
4167: if ($currautoenroll{'run'} ne $env{'form.autoenroll_run'}) {
4168: $changes{'run'} = 1;
4169: }
4170: } elsif ($autorun) {
4171: if ($env{'form.autoenroll_run'} ne '1') {
1.23 raeburn 4172: $changes{'run'} = 1;
1.1 raeburn 4173: }
4174: }
1.17 raeburn 4175: if ($currautoenroll{'sender_uname'} ne $sender_uname) {
1.1 raeburn 4176: $changes{'sender'} = 1;
4177: }
1.17 raeburn 4178: if ($currautoenroll{'sender_domain'} ne $sender_domain) {
1.1 raeburn 4179: $changes{'sender'} = 1;
4180: }
4181: if (keys(%changes) > 0) {
4182: $resulttext = &mt('Changes made:').'<ul>';
1.3 raeburn 4183: if ($changes{'run'}) {
1.1 raeburn 4184: $resulttext .= '<li>'.&mt("$title{'run'} set to $offon[$env{'form.autoenroll_run'}]").'</li>';
4185: }
4186: if ($changes{'sender'}) {
1.17 raeburn 4187: if ($sender_uname eq '' || $sender_domain eq '') {
4188: $resulttext .= '<li>'.&mt("$title{'sender'} set to default (course owner).").'</li>';
4189: } else {
4190: $resulttext .= '<li>'.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'</li>';
4191: }
1.1 raeburn 4192: }
4193: $resulttext .= '</ul>';
4194: } else {
4195: $resulttext = &mt('No changes made to auto-enrollment settings');
4196: }
4197: } else {
1.11 albertel 4198: $resulttext = '<span class="LC_error">'.
4199: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 4200: }
1.3 raeburn 4201: return $resulttext;
1.1 raeburn 4202: }
4203:
4204: sub modify_autoupdate {
1.3 raeburn 4205: my ($dom,%domconfig) = @_;
1.1 raeburn 4206: my ($resulttext,%currautoupdate,%fields,%changes);
4207: if (ref($domconfig{'autoupdate'}) eq 'HASH') {
4208: foreach my $key (keys(%{$domconfig{'autoupdate'}})) {
4209: $currautoupdate{$key} = $domconfig{'autoupdate'}{$key};
4210: }
4211: }
4212: my @offon = ('off','on');
4213: my %title = &Apache::lonlocal::texthash (
4214: run => 'Auto-update:',
4215: classlists => 'Updates to user information in classlists?'
4216: );
1.44 raeburn 4217: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.1 raeburn 4218: my %fieldtitles = &Apache::lonlocal::texthash (
4219: id => 'Student/Employee ID',
1.20 raeburn 4220: permanentemail => 'E-mail address',
1.1 raeburn 4221: lastname => 'Last Name',
4222: firstname => 'First Name',
4223: middlename => 'Middle Name',
4224: gen => 'Generation',
4225: );
4226: my $othertitle = &mt('All users');
4227: if (keys(%{$usertypes}) > 0) {
1.26 raeburn 4228: $othertitle = &mt('Other users');
1.1 raeburn 4229: }
4230: foreach my $key (keys(%env)) {
4231: if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {
4232: push(@{$fields{$1}},$2);
4233: }
4234: }
4235: my %updatehash = (
4236: autoupdate => { run => $env{'form.autoupdate_run'},
4237: classlists => $env{'form.classlists'},
4238: fields => {%fields},
4239: }
4240: );
4241: foreach my $key (keys(%currautoupdate)) {
4242: if (($key eq 'run') || ($key eq 'classlists')) {
4243: if (exists($updatehash{autoupdate}{$key})) {
4244: if ($currautoupdate{$key} ne $updatehash{autoupdate}{$key}) {
4245: $changes{$key} = 1;
4246: }
4247: }
4248: } elsif ($key eq 'fields') {
4249: if (ref($currautoupdate{$key}) eq 'HASH') {
1.26 raeburn 4250: foreach my $item (@{$types},'default') {
1.1 raeburn 4251: if (ref($currautoupdate{$key}{$item}) eq 'ARRAY') {
4252: my $change = 0;
4253: foreach my $type (@{$currautoupdate{$key}{$item}}) {
4254: if (!exists($fields{$item})) {
4255: $change = 1;
4256: } elsif (ref($fields{$item}) eq 'ARRAY') {
1.26 raeburn 4257: if (!grep(/^\Q$type\E$/,@{$fields{$item}})) {
1.1 raeburn 4258: $change = 1;
4259: }
4260: }
4261: }
4262: if ($change) {
4263: push(@{$changes{$key}},$item);
4264: }
1.26 raeburn 4265: }
1.1 raeburn 4266: }
4267: }
4268: }
4269: }
1.26 raeburn 4270: foreach my $item (@{$types},'default') {
4271: if (defined($fields{$item})) {
4272: if (ref($currautoupdate{'fields'}) eq 'HASH') {
4273: if (!exists($currautoupdate{'fields'}{$item})) {
4274: push(@{$changes{'fields'}},$item);
4275: }
4276: } else {
4277: push(@{$changes{'fields'}},$item);
1.1 raeburn 4278: }
4279: }
4280: }
4281: my $putresult = &Apache::lonnet::put_dom('configuration',\%updatehash,
4282: $dom);
4283: if ($putresult eq 'ok') {
4284: if (keys(%changes) > 0) {
4285: $resulttext = &mt('Changes made:').'<ul>';
4286: foreach my $key (sort(keys(%changes))) {
4287: if (ref($changes{$key}) eq 'ARRAY') {
4288: foreach my $item (@{$changes{$key}}) {
4289: my @newvalues;
4290: foreach my $type (@{$fields{$item}}) {
4291: push(@newvalues,$fieldtitles{$type});
4292: }
1.3 raeburn 4293: my $newvaluestr;
4294: if (@newvalues > 0) {
4295: $newvaluestr = join(', ',@newvalues);
4296: } else {
4297: $newvaluestr = &mt('none');
1.6 raeburn 4298: }
1.1 raeburn 4299: if ($item eq 'default') {
1.26 raeburn 4300: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$othertitle,$newvaluestr).'</li>';
1.1 raeburn 4301: } else {
1.26 raeburn 4302: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$usertypes->{$item},$newvaluestr).'</li>';
1.1 raeburn 4303: }
4304: }
4305: } else {
4306: my $newvalue;
4307: if ($key eq 'run') {
4308: $newvalue = $offon[$env{'form.autoupdate_run'}];
4309: } else {
4310: $newvalue = $offon[$env{'form.'.$key}];
1.3 raeburn 4311: }
1.1 raeburn 4312: $resulttext .= '<li>'.&mt("[_1] set to $newvalue",$title{$key}).'</li>';
4313: }
4314: }
4315: $resulttext .= '</ul>';
4316: } else {
1.3 raeburn 4317: $resulttext = &mt('No changes made to autoupdates');
1.1 raeburn 4318: }
4319: } else {
1.11 albertel 4320: $resulttext = '<span class="LC_error">'.
4321: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 4322: }
1.3 raeburn 4323: return $resulttext;
1.1 raeburn 4324: }
4325:
1.23 raeburn 4326: sub modify_directorysrch {
4327: my ($dom,%domconfig) = @_;
4328: my ($resulttext,%changes);
4329: my %currdirsrch;
4330: if (ref($domconfig{'directorysrch'}) eq 'HASH') {
4331: foreach my $key (keys(%{$domconfig{'directorysrch'}})) {
4332: $currdirsrch{$key} = $domconfig{'directorysrch'}{$key};
4333: }
4334: }
4335: my %title = ( available => 'Directory search available',
1.24 raeburn 4336: localonly => 'Other domains can search',
1.23 raeburn 4337: searchby => 'Search types',
4338: searchtypes => 'Search latitude');
4339: my @offon = ('off','on');
1.24 raeburn 4340: my @otherdoms = ('Yes','No');
1.23 raeburn 4341:
1.25 raeburn 4342: my @searchtypes = &Apache::loncommon::get_env_multiple('form.searchtypes');
1.23 raeburn 4343: my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch');
4344: my @searchby = &Apache::loncommon::get_env_multiple('form.searchby');
4345:
1.44 raeburn 4346: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.26 raeburn 4347: if (keys(%{$usertypes}) == 0) {
4348: @cansearch = ('default');
4349: } else {
4350: if (ref($currdirsrch{'cansearch'}) eq 'ARRAY') {
4351: foreach my $type (@{$currdirsrch{'cansearch'}}) {
4352: if (!grep(/^\Q$type\E$/,@cansearch)) {
4353: push(@{$changes{'cansearch'}},$type);
4354: }
1.23 raeburn 4355: }
1.26 raeburn 4356: foreach my $type (@cansearch) {
4357: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'cansearch'}})) {
4358: push(@{$changes{'cansearch'}},$type);
4359: }
1.23 raeburn 4360: }
1.26 raeburn 4361: } else {
4362: push(@{$changes{'cansearch'}},@cansearch);
1.23 raeburn 4363: }
4364: }
4365:
4366: if (ref($currdirsrch{'searchby'}) eq 'ARRAY') {
4367: foreach my $by (@{$currdirsrch{'searchby'}}) {
4368: if (!grep(/^\Q$by\E$/,@searchby)) {
4369: push(@{$changes{'searchby'}},$by);
4370: }
4371: }
4372: foreach my $by (@searchby) {
4373: if (!grep(/^\Q$by\E$/,@{$currdirsrch{'searchby'}})) {
4374: push(@{$changes{'searchby'}},$by);
4375: }
4376: }
4377: } else {
4378: push(@{$changes{'searchby'}},@searchby);
4379: }
1.25 raeburn 4380:
4381: if (ref($currdirsrch{'searchtypes'}) eq 'ARRAY') {
4382: foreach my $type (@{$currdirsrch{'searchtypes'}}) {
4383: if (!grep(/^\Q$type\E$/,@searchtypes)) {
4384: push(@{$changes{'searchtypes'}},$type);
4385: }
4386: }
4387: foreach my $type (@searchtypes) {
4388: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'searchtypes'}})) {
4389: push(@{$changes{'searchtypes'}},$type);
4390: }
4391: }
4392: } else {
4393: if (exists($currdirsrch{'searchtypes'})) {
4394: foreach my $type (@searchtypes) {
4395: if ($type ne $currdirsrch{'searchtypes'}) {
4396: push(@{$changes{'searchtypes'}},$type);
4397: }
4398: }
4399: if (!grep(/^\Q$currdirsrch{'searchtypes'}\E/,@searchtypes)) {
4400: push(@{$changes{'searchtypes'}},$currdirsrch{'searchtypes'});
4401: }
4402: } else {
4403: push(@{$changes{'searchtypes'}},@searchtypes);
4404: }
4405: }
4406:
1.23 raeburn 4407: my %dirsrch_hash = (
4408: directorysrch => { available => $env{'form.dirsrch_available'},
4409: cansearch => \@cansearch,
1.24 raeburn 4410: localonly => $env{'form.dirsrch_localonly'},
1.23 raeburn 4411: searchby => \@searchby,
1.25 raeburn 4412: searchtypes => \@searchtypes,
1.23 raeburn 4413: }
4414: );
4415: my $putresult = &Apache::lonnet::put_dom('configuration',\%dirsrch_hash,
4416: $dom);
4417: if ($putresult eq 'ok') {
4418: if (exists($currdirsrch{'available'})) {
4419: if ($currdirsrch{'available'} ne $env{'form.dirsrch_available'}) {
4420: $changes{'available'} = 1;
4421: }
4422: } else {
4423: if ($env{'form.dirsrch_available'} eq '1') {
4424: $changes{'available'} = 1;
4425: }
4426: }
1.24 raeburn 4427: if (exists($currdirsrch{'localonly'})) {
4428: if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_localonly'}) {
4429: $changes{'localonly'} = 1;
4430: }
4431: } else {
4432: if ($env{'form.dirsrch_localonly'} eq '1') {
4433: $changes{'localonly'} = 1;
4434: }
4435: }
1.23 raeburn 4436: if (keys(%changes) > 0) {
4437: $resulttext = &mt('Changes made:').'<ul>';
4438: if ($changes{'available'}) {
4439: $resulttext .= '<li>'.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").'</li>';
4440: }
1.24 raeburn 4441: if ($changes{'localonly'}) {
4442: $resulttext .= '<li>'.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_localonly'}]").'</li>';
4443: }
4444:
1.23 raeburn 4445: if (ref($changes{'cansearch'}) eq 'ARRAY') {
4446: my $chgtext;
1.26 raeburn 4447: if (ref($usertypes) eq 'HASH') {
4448: if (keys(%{$usertypes}) > 0) {
4449: foreach my $type (@{$types}) {
4450: if (grep(/^\Q$type\E$/,@cansearch)) {
4451: $chgtext .= $usertypes->{$type}.'; ';
4452: }
4453: }
4454: if (grep(/^default$/,@cansearch)) {
4455: $chgtext .= $othertitle;
4456: } else {
4457: $chgtext =~ s/\; $//;
4458: }
4459: $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 4460: }
4461: }
4462: }
4463: if (ref($changes{'searchby'}) eq 'ARRAY') {
4464: my ($searchtitles,$titleorder) = &sorted_searchtitles();
4465: my $chgtext;
4466: foreach my $type (@{$titleorder}) {
4467: if (grep(/^\Q$type\E$/,@searchby)) {
4468: if (defined($searchtitles->{$type})) {
4469: $chgtext .= $searchtitles->{$type}.'; ';
4470: }
4471: }
4472: }
4473: $chgtext =~ s/\; $//;
4474: $resulttext .= '<li>'.&mt("$title{'searchby'} set to: [_1]",$chgtext).'</li>';
4475: }
1.25 raeburn 4476: if (ref($changes{'searchtypes'}) eq 'ARRAY') {
4477: my ($srchtypes_desc,$srchtypeorder) = &sorted_searchtypes();
4478: my $chgtext;
4479: foreach my $type (@{$srchtypeorder}) {
4480: if (grep(/^\Q$type\E$/,@searchtypes)) {
4481: if (defined($srchtypes_desc->{$type})) {
4482: $chgtext .= $srchtypes_desc->{$type}.'; ';
4483: }
4484: }
4485: }
4486: $chgtext =~ s/\; $//;
4487: $resulttext .= '<li>'.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).'</li>';
1.23 raeburn 4488: }
4489: $resulttext .= '</ul>';
4490: } else {
4491: $resulttext = &mt('No changes made to institution directory search settings');
4492: }
4493: } else {
4494: $resulttext = '<span class="LC_error">'.
1.27 raeburn 4495: &mt('An error occurred: [_1]',$putresult).'</span>';
4496: }
4497: return $resulttext;
4498: }
4499:
1.28 raeburn 4500: sub modify_contacts {
4501: my ($dom,%domconfig) = @_;
4502: my ($resulttext,%currsetting,%newsetting,%changes,%contacts_hash);
4503: if (ref($domconfig{'contacts'}) eq 'HASH') {
4504: foreach my $key (keys(%{$domconfig{'contacts'}})) {
4505: $currsetting{$key} = $domconfig{'contacts'}{$key};
4506: }
4507: }
4508: my (%others,%to);
4509: my @contacts = ('supportemail','adminemail');
1.102 raeburn 4510: my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail',
4511: 'requestsmail');
1.28 raeburn 4512: foreach my $type (@mailings) {
4513: @{$newsetting{$type}} =
4514: &Apache::loncommon::get_env_multiple('form.'.$type);
4515: foreach my $item (@contacts) {
4516: if (grep(/^\Q$item\E$/,@{$newsetting{$type}})) {
4517: $contacts_hash{contacts}{$type}{$item} = 1;
4518: } else {
4519: $contacts_hash{contacts}{$type}{$item} = 0;
4520: }
4521: }
4522: $others{$type} = $env{'form.'.$type.'_others'};
4523: $contacts_hash{contacts}{$type}{'others'} = $others{$type};
4524: }
4525: foreach my $item (@contacts) {
4526: $to{$item} = $env{'form.'.$item};
4527: $contacts_hash{'contacts'}{$item} = $to{$item};
4528: }
4529: if (keys(%currsetting) > 0) {
4530: foreach my $item (@contacts) {
4531: if ($to{$item} ne $currsetting{$item}) {
4532: $changes{$item} = 1;
4533: }
4534: }
4535: foreach my $type (@mailings) {
4536: foreach my $item (@contacts) {
4537: if (ref($currsetting{$type}) eq 'HASH') {
4538: if ($currsetting{$type}{$item} ne $contacts_hash{contacts}{$type}{$item}) {
4539: push(@{$changes{$type}},$item);
4540: }
4541: } else {
4542: push(@{$changes{$type}},@{$newsetting{$type}});
4543: }
4544: }
4545: if ($others{$type} ne $currsetting{$type}{'others'}) {
4546: push(@{$changes{$type}},'others');
4547: }
4548: }
4549: } else {
4550: my %default;
4551: $default{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
4552: $default{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
4553: $default{'errormail'} = 'adminemail';
4554: $default{'packagesmail'} = 'adminemail';
4555: $default{'helpdeskmail'} = 'supportemail';
1.89 raeburn 4556: $default{'lonstatusmail'} = 'adminemail';
1.102 raeburn 4557: $default{'requestsmail'} = 'adminemail';
1.28 raeburn 4558: foreach my $item (@contacts) {
4559: if ($to{$item} ne $default{$item}) {
4560: $changes{$item} = 1;
4561: }
4562: }
4563: foreach my $type (@mailings) {
4564: if ((@{$newsetting{$type}} != 1) || ($newsetting{$type}[0] ne $default{$type})) {
4565:
4566: push(@{$changes{$type}},@{$newsetting{$type}});
4567: }
4568: if ($others{$type} ne '') {
4569: push(@{$changes{$type}},'others');
4570: }
4571: }
4572: }
4573: my $putresult = &Apache::lonnet::put_dom('configuration',\%contacts_hash,
4574: $dom);
4575: if ($putresult eq 'ok') {
4576: if (keys(%changes) > 0) {
4577: my ($titles,$short_titles) = &contact_titles();
4578: $resulttext = &mt('Changes made:').'<ul>';
4579: foreach my $item (@contacts) {
4580: if ($changes{$item}) {
4581: $resulttext .= '<li>'.$titles->{$item}.
4582: &mt(' set to: ').
4583: '<span class="LC_cusr_emph">'.
4584: $to{$item}.'</span></li>';
4585: }
4586: }
4587: foreach my $type (@mailings) {
4588: if (ref($changes{$type}) eq 'ARRAY') {
4589: $resulttext .= '<li>'.$titles->{$type}.': ';
4590: my @text;
4591: foreach my $item (@{$newsetting{$type}}) {
4592: push(@text,$short_titles->{$item});
4593: }
4594: if ($others{$type} ne '') {
4595: push(@text,$others{$type});
4596: }
4597: $resulttext .= '<span class="LC_cusr_emph">'.
4598: join(', ',@text).'</span></li>';
4599: }
4600: }
4601: $resulttext .= '</ul>';
4602: } else {
1.34 raeburn 4603: $resulttext = &mt('No changes made to contact information');
1.28 raeburn 4604: }
4605: } else {
4606: $resulttext = '<span class="LC_error">'.
4607: &mt('An error occurred: [_1].',$putresult).'</span>';
4608: }
4609: return $resulttext;
4610: }
4611:
4612: sub modify_usercreation {
1.27 raeburn 4613: my ($dom,%domconfig) = @_;
1.34 raeburn 4614: my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate);
1.43 raeburn 4615: my $warningmsg;
1.27 raeburn 4616: if (ref($domconfig{'usercreation'}) eq 'HASH') {
4617: foreach my $key (keys(%{$domconfig{'usercreation'}})) {
4618: $curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
4619: }
4620: }
4621: my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
1.32 raeburn 4622: my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
1.43 raeburn 4623: my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
1.100 raeburn 4624: my @contexts = ('author','course','requestcrs','selfcreate');
1.34 raeburn 4625: foreach my $item(@contexts) {
1.45 raeburn 4626: if ($item eq 'selfcreate') {
1.50 raeburn 4627: @{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item);
1.43 raeburn 4628: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
4629: if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) {
1.50 raeburn 4630: if (ref($cancreate{$item}) eq 'ARRAY') {
4631: if (grep(/^login$/,@{$cancreate{$item}})) {
4632: $warningmsg = &mt('Although account creation has been set to be available for institutional logins, currently default authentication in this domain has not been set to support this.').' '.&mt('You need to set the default authentication type to Kerberos 4 or 5 (with a Kerberos domain specified), or to Local authentication, if the localauth module has been customized in your domain to authenticate institutional logins.');
4633: }
1.43 raeburn 4634: }
4635: }
1.50 raeburn 4636: } else {
4637: $cancreate{$item} = $env{'form.can_createuser_'.$item};
1.43 raeburn 4638: }
1.34 raeburn 4639: }
1.93 raeburn 4640: my ($othertitle,$usertypes,$types) =
4641: &Apache::loncommon::sorted_inst_types($dom);
4642: if (ref($types) eq 'ARRAY') {
4643: if (@{$types} > 0) {
4644: @{$cancreate{'statustocreate'}} =
4645: &Apache::loncommon::get_env_multiple('form.statustocreate');
1.103 raeburn 4646: } else {
4647: @{$cancreate{'statustocreate'}} = ();
1.93 raeburn 4648: }
4649: push(@contexts,'statustocreate');
4650: }
1.34 raeburn 4651: if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
4652: foreach my $item (@contexts) {
1.93 raeburn 4653: if (($item eq 'selfcreate') || ($item eq 'statustocreate')) {
4654: if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
1.50 raeburn 4655: foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) {
1.103 raeburn 4656: if (ref($cancreate{$item}) eq 'ARRAY') {
4657: if (!grep(/^$curr$/,@{$cancreate{$item}})) {
4658: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4659: push(@{$changes{'cancreate'}},$item);
4660: }
1.50 raeburn 4661: }
4662: }
4663: }
4664: } else {
4665: if ($curr_usercreation{'cancreate'}{$item} eq '') {
4666: if (@{$cancreate{$item}} > 0) {
4667: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4668: push(@{$changes{'cancreate'}},$item);
4669: }
4670: }
4671: } else {
4672: if ($curr_usercreation{'cancreate'}{$item} eq 'any') {
4673: if (@{$cancreate{$item}} < 3) {
4674: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4675: push(@{$changes{'cancreate'}},$item);
4676: }
4677: }
4678: } elsif ($curr_usercreation{'cancreate'}{$item} eq 'none') {
4679: if (@{$cancreate{$item}} > 0) {
4680: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4681: push(@{$changes{'cancreate'}},$item);
4682: }
4683: }
4684: } elsif (!grep(/^$curr_usercreation{'cancreate'}{$item}$/,@{$cancreate{$item}})) {
4685: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4686: push(@{$changes{'cancreate'}},$item);
4687: }
4688: }
4689: }
4690: }
4691: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4692: foreach my $type (@{$cancreate{$item}}) {
4693: if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
4694: if (!grep(/^$type$/,@{$curr_usercreation{'cancreate'}{$item}})) {
4695: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4696: push(@{$changes{'cancreate'}},$item);
4697: }
4698: }
4699: } elsif (($curr_usercreation{'cancreate'}{$item} ne 'any') &&
4700: ($curr_usercreation{'cancreate'}{$item} ne 'none')) {
4701: if ($curr_usercreation{'cancreate'}{$item} ne $type) {
4702: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4703: push(@{$changes{'cancreate'}},$item);
4704: }
4705: }
4706: }
4707: }
4708: }
4709: } else {
4710: if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) {
4711: push(@{$changes{'cancreate'}},$item);
4712: }
4713: }
1.27 raeburn 4714: }
1.34 raeburn 4715: } elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
4716: foreach my $item (@contexts) {
1.43 raeburn 4717: if (!grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) {
1.34 raeburn 4718: if ($cancreate{$item} ne 'any') {
4719: push(@{$changes{'cancreate'}},$item);
4720: }
4721: } else {
4722: if ($cancreate{$item} ne 'none') {
4723: push(@{$changes{'cancreate'}},$item);
4724: }
1.27 raeburn 4725: }
4726: }
4727: } else {
1.43 raeburn 4728: foreach my $item (@contexts) {
1.34 raeburn 4729: push(@{$changes{'cancreate'}},$item);
4730: }
1.27 raeburn 4731: }
1.34 raeburn 4732:
1.27 raeburn 4733: if (ref($curr_usercreation{'username_rule'}) eq 'ARRAY') {
4734: foreach my $type (@{$curr_usercreation{'username_rule'}}) {
4735: if (!grep(/^\Q$type\E$/,@username_rule)) {
4736: push(@{$changes{'username_rule'}},$type);
4737: }
4738: }
4739: foreach my $type (@username_rule) {
4740: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'username_rule'}})) {
4741: push(@{$changes{'username_rule'}},$type);
4742: }
4743: }
4744: } else {
4745: push(@{$changes{'username_rule'}},@username_rule);
4746: }
4747:
1.32 raeburn 4748: if (ref($curr_usercreation{'id_rule'}) eq 'ARRAY') {
4749: foreach my $type (@{$curr_usercreation{'id_rule'}}) {
4750: if (!grep(/^\Q$type\E$/,@id_rule)) {
4751: push(@{$changes{'id_rule'}},$type);
4752: }
4753: }
4754: foreach my $type (@id_rule) {
4755: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'id_rule'}})) {
4756: push(@{$changes{'id_rule'}},$type);
4757: }
4758: }
4759: } else {
4760: push(@{$changes{'id_rule'}},@id_rule);
4761: }
4762:
1.43 raeburn 4763: if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') {
4764: foreach my $type (@{$curr_usercreation{'email_rule'}}) {
4765: if (!grep(/^\Q$type\E$/,@email_rule)) {
4766: push(@{$changes{'email_rule'}},$type);
4767: }
4768: }
4769: foreach my $type (@email_rule) {
4770: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'email_rule'}})) {
4771: push(@{$changes{'email_rule'}},$type);
4772: }
4773: }
4774: } else {
4775: push(@{$changes{'email_rule'}},@email_rule);
4776: }
4777:
4778: my @authen_contexts = ('author','course','domain');
1.28 raeburn 4779: my @authtypes = ('int','krb4','krb5','loc');
4780: my %authhash;
1.43 raeburn 4781: foreach my $item (@authen_contexts) {
1.28 raeburn 4782: my @authallowed = &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');
4783: foreach my $auth (@authtypes) {
4784: if (grep(/^\Q$auth\E$/,@authallowed)) {
4785: $authhash{$item}{$auth} = 1;
4786: } else {
4787: $authhash{$item}{$auth} = 0;
4788: }
4789: }
4790: }
4791: if (ref($curr_usercreation{'authtypes'}) eq 'HASH') {
1.43 raeburn 4792: foreach my $item (@authen_contexts) {
1.28 raeburn 4793: if (ref($curr_usercreation{'authtypes'}{$item}) eq 'HASH') {
4794: foreach my $auth (@authtypes) {
4795: if ($authhash{$item}{$auth} ne $curr_usercreation{'authtypes'}{$item}{$auth}) {
4796: push(@{$changes{'authtypes'}},$item);
4797: last;
4798: }
4799: }
4800: }
4801: }
4802: } else {
1.43 raeburn 4803: foreach my $item (@authen_contexts) {
1.28 raeburn 4804: push(@{$changes{'authtypes'}},$item);
4805: }
4806: }
4807:
1.27 raeburn 4808: my %usercreation_hash = (
1.28 raeburn 4809: usercreation => {
1.34 raeburn 4810: cancreate => \%cancreate,
1.27 raeburn 4811: username_rule => \@username_rule,
1.32 raeburn 4812: id_rule => \@id_rule,
1.43 raeburn 4813: email_rule => \@email_rule,
1.32 raeburn 4814: authtypes => \%authhash,
1.27 raeburn 4815: }
4816: );
4817:
4818: my $putresult = &Apache::lonnet::put_dom('configuration',\%usercreation_hash,
4819: $dom);
1.50 raeburn 4820:
4821: my %selfcreatetypes = (
4822: sso => 'users authenticated by institutional single sign on',
4823: login => 'users authenticated by institutional log-in',
4824: email => 'users who provide a valid e-mail address for use as the username',
4825: );
1.27 raeburn 4826: if ($putresult eq 'ok') {
4827: if (keys(%changes) > 0) {
4828: $resulttext = &mt('Changes made:').'<ul>';
4829: if (ref($changes{'cancreate'}) eq 'ARRAY') {
1.34 raeburn 4830: my %lt = &usercreation_types();
4831: foreach my $type (@{$changes{'cancreate'}}) {
1.100 raeburn 4832: my $chgtext;
4833: unless ($type eq 'statustocreate') {
4834: $chgtext = $lt{$type}.', ';
4835: }
1.45 raeburn 4836: if ($type eq 'selfcreate') {
1.50 raeburn 4837: if (@{$cancreate{$type}} == 0) {
1.43 raeburn 4838: $chgtext .= &mt('creation of a new user account is not permitted.');
1.50 raeburn 4839: } else {
1.100 raeburn 4840: $chgtext .= &mt('creation of a new account is permitted for:').'<ul>';
1.50 raeburn 4841: foreach my $case (@{$cancreate{$type}}) {
4842: $chgtext .= '<li>'.$selfcreatetypes{$case}.'</li>';
4843: }
4844: $chgtext .= '</ul>';
1.100 raeburn 4845: if (ref($cancreate{$type}) eq 'ARRAY') {
4846: if (grep(/^(login|sso)$/,@{$cancreate{$type}})) {
4847: if (ref($cancreate{'statustocreate'}) eq 'ARRAY') {
4848: if (@{$cancreate{'statustocreate'}} == 0) {
4849: $chgtext .= '<br /><span class="LC_warning">'.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'</span>';
4850: }
4851: }
4852: }
4853: }
1.43 raeburn 4854: }
1.93 raeburn 4855: } elsif ($type eq 'statustocreate') {
1.96 raeburn 4856: if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') &&
4857: (ref($cancreate{'statustocreate'}) eq 'ARRAY')) {
4858: if (@{$cancreate{'selfcreate'}} > 0) {
4859: if (@{$cancreate{'statustocreate'}} == 0) {
1.100 raeburn 4860:
4861: $chgtext .= &mt("Institutional affiliations permitted to create accounts set to 'None'.");
1.96 raeburn 4862: if (!grep(/^email$/,@{$cancreate{'selfcreate'}})) {
1.100 raeburn 4863: $chgtext .= '<br /><span class="LC_warning">'.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'</span>';
4864: }
1.96 raeburn 4865: } elsif (ref($usertypes) eq 'HASH') {
4866: if (grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
1.100 raeburn 4867: $chgtext .= &mt('Creation of a new account for an institutional user is restricted to the following institutional affiliation(s):');
4868: } else {
4869: $chgtext .= &mt('Institutional affiliations permitted to create accounts with institutional authentication were set as follows:');
4870: }
4871: $chgtext .= '<ul>';
4872: foreach my $case (@{$cancreate{$type}}) {
4873: if ($case eq 'default') {
4874: $chgtext .= '<li>'.$othertitle.'</li>';
4875: } else {
4876: $chgtext .= '<li>'.$usertypes->{$case}.'</li>';
1.93 raeburn 4877: }
4878: }
1.100 raeburn 4879: $chgtext .= '</ul>';
4880: if (!grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
4881: $chgtext .= '<br /><span class="LC_warning">'.&mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').'</span>';
4882: }
4883: }
4884: } else {
4885: if (@{$cancreate{$type}} == 0) {
4886: $chgtext .= &mt("Institutional affiliations permitted to create accounts were set to 'none'.");
4887: } else {
4888: $chgtext .= &mt('Although institutional affiliations permitted to create accounts were changed, self creation of accounts is not currently permitted for any authentication types.');
1.93 raeburn 4889: }
4890: }
4891: }
1.43 raeburn 4892: } else {
4893: if ($cancreate{$type} eq 'none') {
4894: $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.');
4895: } elsif ($cancreate{$type} eq 'any') {
4896: $chgtext .= &mt('creation of new users is permitted for both institutional and non-institutional usernames.');
4897: } elsif ($cancreate{$type} eq 'official') {
4898: $chgtext .= &mt('creation of new users is only permitted for institutional usernames.');
4899: } elsif ($cancreate{$type} eq 'unofficial') {
4900: $chgtext .= &mt('creation of new users is only permitted for non-institutional usernames.');
4901: }
1.34 raeburn 4902: }
4903: $resulttext .= '<li>'.$chgtext.'</li>';
1.27 raeburn 4904: }
4905: }
4906: if (ref($changes{'username_rule'}) eq 'ARRAY') {
1.32 raeburn 4907: my ($rules,$ruleorder) =
4908: &Apache::lonnet::inst_userrules($dom,'username');
1.27 raeburn 4909: my $chgtext = '<ul>';
4910: foreach my $type (@username_rule) {
4911: if (ref($rules->{$type}) eq 'HASH') {
4912: $chgtext .= '<li>'.$rules->{$type}{'name'}.'</li>';
4913: }
4914: }
4915: $chgtext .= '</ul>';
4916: if (@username_rule > 0) {
4917: $resulttext .= '<li>'.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
4918: } else {
1.28 raeburn 4919: $resulttext .= '<li>'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'</li>';
1.27 raeburn 4920: }
4921: }
1.32 raeburn 4922: if (ref($changes{'id_rule'}) eq 'ARRAY') {
4923: my ($idrules,$idruleorder) =
4924: &Apache::lonnet::inst_userrules($dom,'id');
4925: my $chgtext = '<ul>';
4926: foreach my $type (@id_rule) {
4927: if (ref($idrules->{$type}) eq 'HASH') {
4928: $chgtext .= '<li>'.$idrules->{$type}{'name'}.'</li>';
4929: }
4930: }
4931: $chgtext .= '</ul>';
4932: if (@id_rule > 0) {
4933: $resulttext .= '<li>'.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
4934: } else {
4935: $resulttext .= '<li>'.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'</li>';
4936: }
4937: }
1.43 raeburn 4938: if (ref($changes{'email_rule'}) eq 'ARRAY') {
4939: my ($emailrules,$emailruleorder) =
4940: &Apache::lonnet::inst_userrules($dom,'email');
4941: my $chgtext = '<ul>';
4942: foreach my $type (@email_rule) {
4943: if (ref($emailrules->{$type}) eq 'HASH') {
4944: $chgtext .= '<li>'.$emailrules->{$type}{'name'}.'</li>';
4945: }
4946: }
4947: $chgtext .= '</ul>';
4948: if (@email_rule > 0) {
4949: $resulttext .= '<li>'.&mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: ').$chgtext.'</li>';
4950: } else {
4951: $resulttext .= '<li>'.&mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.').'</li>';
4952: }
4953: }
4954:
1.28 raeburn 4955: my %authname = &authtype_names();
4956: my %context_title = &context_names();
4957: if (ref($changes{'authtypes'}) eq 'ARRAY') {
4958: my $chgtext = '<ul>';
4959: foreach my $type (@{$changes{'authtypes'}}) {
4960: my @allowed;
4961: $chgtext .= '<li><span class="LC_cusr_emph">'.$context_title{$type}.'</span> - '.&mt('assignable authentication types: ');
4962: foreach my $auth (@authtypes) {
4963: if ($authhash{$type}{$auth}) {
4964: push(@allowed,$authname{$auth});
4965: }
4966: }
1.43 raeburn 4967: if (@allowed > 0) {
4968: $chgtext .= join(', ',@allowed).'</li>';
4969: } else {
4970: $chgtext .= &mt('none').'</li>';
4971: }
1.28 raeburn 4972: }
4973: $chgtext .= '</ul>';
4974: $resulttext .= '<li>'.&mt('Authentication types available for assignment to new users').'<br />'.$chgtext;
4975: $resulttext .= '</li>';
4976: }
1.27 raeburn 4977: $resulttext .= '</ul>';
4978: } else {
1.28 raeburn 4979: $resulttext = &mt('No changes made to user creation settings');
1.27 raeburn 4980: }
4981: } else {
4982: $resulttext = '<span class="LC_error">'.
1.23 raeburn 4983: &mt('An error occurred: [_1]',$putresult).'</span>';
4984: }
1.43 raeburn 4985: if ($warningmsg ne '') {
4986: $resulttext .= '<br /><span class="LC_warning">'.$warningmsg.'</span><br />';
4987: }
1.23 raeburn 4988: return $resulttext;
4989: }
4990:
1.33 raeburn 4991: sub modify_usermodification {
4992: my ($dom,%domconfig) = @_;
4993: my ($resulttext,%curr_usermodification,%changes);
4994: if (ref($domconfig{'usermodification'}) eq 'HASH') {
4995: foreach my $key (keys(%{$domconfig{'usermodification'}})) {
4996: $curr_usermodification{$key} = $domconfig{'usermodification'}{$key};
4997: }
4998: }
1.63 raeburn 4999: my @contexts = ('author','course','selfcreate');
1.33 raeburn 5000: my %context_title = (
5001: author => 'In author context',
5002: course => 'In course context',
1.63 raeburn 5003: selfcreate => 'When self creating account',
1.33 raeburn 5004: );
5005: my @fields = ('lastname','firstname','middlename','generation',
5006: 'permanentemail','id');
5007: my %roles = (
5008: author => ['ca','aa'],
5009: course => ['st','ep','ta','in','cr'],
5010: );
1.63 raeburn 5011: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
5012: if (ref($types) eq 'ARRAY') {
5013: push(@{$types},'default');
5014: $usertypes->{'default'} = $othertitle;
5015: }
5016: $roles{'selfcreate'} = $types;
1.33 raeburn 5017: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
5018: my %modifyhash;
5019: foreach my $context (@contexts) {
5020: foreach my $role (@{$roles{$context}}) {
5021: my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role);
5022: foreach my $item (@fields) {
5023: if (grep(/^\Q$item\E$/,@modifiable)) {
5024: $modifyhash{$context}{$role}{$item} = 1;
5025: } else {
5026: $modifyhash{$context}{$role}{$item} = 0;
5027: }
5028: }
5029: }
5030: if (ref($curr_usermodification{$context}) eq 'HASH') {
5031: foreach my $role (@{$roles{$context}}) {
5032: if (ref($curr_usermodification{$context}{$role}) eq 'HASH') {
5033: foreach my $field (@fields) {
5034: if ($modifyhash{$context}{$role}{$field} ne
5035: $curr_usermodification{$context}{$role}{$field}) {
5036: push(@{$changes{$context}},$role);
5037: last;
5038: }
5039: }
5040: }
5041: }
5042: } else {
5043: foreach my $context (@contexts) {
5044: foreach my $role (@{$roles{$context}}) {
5045: push(@{$changes{$context}},$role);
5046: }
5047: }
5048: }
5049: }
5050: my %usermodification_hash = (
5051: usermodification => \%modifyhash,
5052: );
5053: my $putresult = &Apache::lonnet::put_dom('configuration',
5054: \%usermodification_hash,$dom);
5055: if ($putresult eq 'ok') {
5056: if (keys(%changes) > 0) {
5057: $resulttext = &mt('Changes made: ').'<ul>';
5058: foreach my $context (@contexts) {
5059: if (ref($changes{$context}) eq 'ARRAY') {
5060: $resulttext .= '<li>'.$context_title{$context}.':<ul>';
5061: if (ref($changes{$context}) eq 'ARRAY') {
5062: foreach my $role (@{$changes{$context}}) {
5063: my $rolename;
1.63 raeburn 5064: if ($context eq 'selfcreate') {
5065: $rolename = $role;
5066: if (ref($usertypes) eq 'HASH') {
5067: if ($usertypes->{$role} ne '') {
5068: $rolename = $usertypes->{$role};
5069: }
5070: }
1.33 raeburn 5071: } else {
1.63 raeburn 5072: if ($role eq 'cr') {
5073: $rolename = &mt('Custom');
5074: } else {
5075: $rolename = &Apache::lonnet::plaintext($role);
5076: }
1.33 raeburn 5077: }
5078: my @modifiable;
1.63 raeburn 5079: if ($context eq 'selfcreate') {
5080: $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Self-creation of account by users with status: [_1] ',$rolename).'</span> - '.&mt('modifiable fields (if institutional data blank): ');
5081: } else {
5082: $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');
5083: }
1.33 raeburn 5084: foreach my $field (@fields) {
5085: if ($modifyhash{$context}{$role}{$field}) {
5086: push(@modifiable,$fieldtitles{$field});
5087: }
5088: }
5089: if (@modifiable > 0) {
5090: $resulttext .= join(', ',@modifiable);
5091: } else {
5092: $resulttext .= &mt('none');
5093: }
5094: $resulttext .= '</li>';
5095: }
5096: $resulttext .= '</ul></li>';
5097: }
5098: }
5099: }
5100: $resulttext .= '</ul>';
5101: } else {
5102: $resulttext = &mt('No changes made to user modification settings');
5103: }
5104: } else {
5105: $resulttext = '<span class="LC_error">'.
5106: &mt('An error occurred: [_1]',$putresult).'</span>';
5107: }
5108: return $resulttext;
5109: }
5110:
1.43 raeburn 5111: sub modify_defaults {
5112: my ($dom,$r) = @_;
5113: my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
5114: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.68 raeburn 5115: my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def');
1.43 raeburn 5116: my @authtypes = ('internal','krb4','krb5','localauth');
5117: foreach my $item (@items) {
5118: $newvalues{$item} = $env{'form.'.$item};
5119: if ($item eq 'auth_def') {
5120: if ($newvalues{$item} ne '') {
5121: if (!grep(/^\Q$newvalues{$item}\E$/,@authtypes)) {
5122: push(@errors,$item);
5123: }
5124: }
5125: } elsif ($item eq 'lang_def') {
5126: if ($newvalues{$item} ne '') {
5127: if ($newvalues{$item} =~ /^(\w+)/) {
5128: my $langcode = $1;
1.103 raeburn 5129: if ($langcode ne 'x_chef') {
5130: if (code2language($langcode) eq '') {
5131: push(@errors,$item);
5132: }
1.43 raeburn 5133: }
5134: } else {
5135: push(@errors,$item);
5136: }
5137: }
1.54 raeburn 5138: } elsif ($item eq 'timezone_def') {
5139: if ($newvalues{$item} ne '') {
1.62 raeburn 5140: if (!DateTime::TimeZone->is_valid_name($newvalues{$item})) {
1.54 raeburn 5141: push(@errors,$item);
5142: }
5143: }
1.68 raeburn 5144: } elsif ($item eq 'datelocale_def') {
5145: if ($newvalues{$item} ne '') {
5146: my @datelocale_ids = DateTime::Locale->ids();
5147: if (!grep(/^\Q$newvalues{$item}\E$/,@datelocale_ids)) {
5148: push(@errors,$item);
5149: }
5150: }
1.43 raeburn 5151: }
5152: if (grep(/^\Q$item\E$/,@errors)) {
5153: $newvalues{$item} = $domdefaults{$item};
5154: } elsif ($domdefaults{$item} ne $newvalues{$item}) {
5155: $changes{$item} = 1;
5156: }
1.72 raeburn 5157: $domdefaults{$item} = $newvalues{$item};
1.43 raeburn 5158: }
5159: my %defaults_hash = (
1.72 raeburn 5160: defaults => \%newvalues,
5161: );
1.43 raeburn 5162: my $title = &defaults_titles();
5163: my $putresult = &Apache::lonnet::put_dom('configuration',\%defaults_hash,
5164: $dom);
5165: if ($putresult eq 'ok') {
5166: if (keys(%changes) > 0) {
5167: $resulttext = &mt('Changes made:').'<ul>';
5168: my $version = $r->dir_config('lonVersion');
5169: my $mailmsgtext = "Changes made to domain settings in a LON-CAPA installation - domain: $dom (running version: $version) - dns_domain.tab needs to be updated with the following changes, to support legacy 2.4, 2.5 and 2.6 versions of LON-CAPA.\n\n";
5170: foreach my $item (sort(keys(%changes))) {
5171: my $value = $env{'form.'.$item};
5172: if ($value eq '') {
5173: $value = &mt('none');
5174: } elsif ($item eq 'auth_def') {
5175: my %authnames = &authtype_names();
5176: my %shortauth = (
5177: internal => 'int',
5178: krb4 => 'krb4',
5179: krb5 => 'krb5',
5180: localauth => 'loc',
5181: );
5182: $value = $authnames{$shortauth{$value}};
5183: }
5184: $resulttext .= '<li>'.&mt('[_1] set to "[_2]"',$title->{$item},$value).'</li>';
5185: $mailmsgtext .= "$title->{$item} set to $value\n";
5186: }
5187: $resulttext .= '</ul>';
5188: $mailmsgtext .= "\n";
5189: my $cachetime = 24*60*60;
1.72 raeburn 5190: &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
1.68 raeburn 5191: if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'} || $changes{'datelocale_def'}) {
1.54 raeburn 5192: my $sysmail = $r->dir_config('lonSysEMail');
5193: &Apache::lonmsg::sendemail($sysmail,"LON-CAPA Domain Settings Change - $dom",$mailmsgtext);
5194: }
1.43 raeburn 5195: } else {
1.54 raeburn 5196: $resulttext = &mt('No changes made to default authentication/language/timezone settings');
1.43 raeburn 5197: }
5198: } else {
5199: $resulttext = '<span class="LC_error">'.
5200: &mt('An error occurred: [_1]',$putresult).'</span>';
5201: }
5202: if (@errors > 0) {
5203: $resulttext .= '<br />'.&mt('The following were left unchanged because the values entered were invalid:');
5204: foreach my $item (@errors) {
5205: $resulttext .= ' "'.$title->{$item}.'",';
5206: }
5207: $resulttext =~ s/,$//;
5208: }
5209: return $resulttext;
5210: }
5211:
1.46 raeburn 5212: sub modify_scantron {
1.48 raeburn 5213: my ($r,$dom,$confname,%domconfig) = @_;
1.46 raeburn 5214: my ($resulttext,%confhash,%changes,$errors);
5215: my $custom = 'custom.tab';
5216: my $default = 'default.tab';
5217: my $servadm = $r->dir_config('lonAdmEMail');
5218: my ($configuserok,$author_ok,$switchserver) =
5219: &config_check($dom,$confname,$servadm);
5220: if ($env{'form.scantronformat.filename'} ne '') {
5221: my $error;
5222: if ($configuserok eq 'ok') {
5223: if ($switchserver) {
5224: $error = &mt("Upload of scantron format file is not permitted to this server: [_1]",$switchserver);
5225: } else {
5226: if ($author_ok eq 'ok') {
5227: my ($result,$scantronurl) =
5228: &publishlogo($r,'upload','scantronformat',$dom,
5229: $confname,'scantron','','',$custom);
5230: if ($result eq 'ok') {
5231: $confhash{'scantron'}{'scantronformat'} = $scantronurl;
1.48 raeburn 5232: $changes{'scantronformat'} = 1;
1.46 raeburn 5233: } else {
5234: $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$custom,$result);
5235: }
5236: } else {
5237: $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$custom,$confname,$dom,$author_ok);
5238: }
5239: }
5240: } else {
5241: $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$custom,$confname,$dom,$configuserok);
5242: }
5243: if ($error) {
5244: &Apache::lonnet::logthis($error);
5245: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
5246: }
5247: }
1.48 raeburn 5248: if (ref($domconfig{'scantron'}) eq 'HASH') {
5249: if ($domconfig{'scantron'}{'scantronformat'} ne '') {
5250: if ($env{'form.scantronformat_del'}) {
5251: $confhash{'scantron'}{'scantronformat'} = '';
5252: $changes{'scantronformat'} = 1;
1.46 raeburn 5253: }
5254: }
5255: }
5256: if (keys(%confhash) > 0) {
5257: my $putresult = &Apache::lonnet::put_dom('configuration',\%confhash,
5258: $dom);
5259: if ($putresult eq 'ok') {
5260: if (keys(%changes) > 0) {
1.48 raeburn 5261: if (ref($confhash{'scantron'}) eq 'HASH') {
5262: $resulttext = &mt('Changes made:').'<ul>';
5263: if ($confhash{'scantron'}{'scantronformat'} eq '') {
5264: $resulttext .= '<li>'.&mt('[_1] scantron format file removed; [_2] file will be used for courses in this domain.',$custom,$default).'</li>';
5265: } else {
5266: $resulttext .= '<li>'.&mt('Custom scantron format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>';
1.46 raeburn 5267: }
1.48 raeburn 5268: $resulttext .= '</ul>';
5269: } else {
5270: $resulttext = &mt('Changes made to scantron format file.');
1.46 raeburn 5271: }
5272: $resulttext .= '</ul>';
5273: &Apache::loncommon::devalidate_domconfig_cache($dom);
5274: } else {
5275: $resulttext = &mt('No changes made to scantron format file');
5276: }
5277: } else {
5278: $resulttext = '<span class="LC_error">'.
5279: &mt('An error occurred: [_1]',$putresult).'</span>';
5280: }
5281: } else {
5282: $resulttext = &mt('No changes made to scantron format file');
5283: }
5284: if ($errors) {
5285: $resulttext .= &mt('The following errors occurred: ').'<ul>'.
5286: $errors.'</ul>';
5287: }
5288: return $resulttext;
5289: }
5290:
1.48 raeburn 5291: sub modify_coursecategories {
5292: my ($dom,%domconfig) = @_;
1.57 raeburn 5293: my ($resulttext,%deletions,%reorderings,%needreordering,%adds,%changes,$errors,
5294: $cathash);
1.48 raeburn 5295: my @deletecategory = &Apache::loncommon::get_env_multiple('form.deletecategory');
1.55 raeburn 5296: if (ref($domconfig{'coursecategories'}) eq 'HASH') {
1.57 raeburn 5297: $cathash = $domconfig{'coursecategories'}{'cats'};
5298: if ($domconfig{'coursecategories'}{'togglecats'} ne $env{'form.togglecats'}) {
5299: $changes{'togglecats'} = 1;
5300: $domconfig{'coursecategories'}{'togglecats'} = $env{'form.togglecats'};
5301: }
5302: if ($domconfig{'coursecategories'}{'categorize'} ne $env{'form.categorize'}) {
5303: $changes{'categorize'} = 1;
5304: $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
5305: }
5306: } else {
5307: $changes{'togglecats'} = 1;
5308: $changes{'categorize'} = 1;
1.87 raeburn 5309: $domconfig{'coursecategories'} = {
5310: togglecats => $env{'form.togglecats'},
5311: categorize => $env{'form.categorize'},
5312: };
1.57 raeburn 5313: }
5314: if (ref($cathash) eq 'HASH') {
5315: if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) {
1.55 raeburn 5316: push (@deletecategory,'instcode::0');
5317: }
1.48 raeburn 5318: }
1.57 raeburn 5319: my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail);
5320: if (ref($cathash) eq 'HASH') {
1.48 raeburn 5321: if (@deletecategory > 0) {
5322: #FIXME Need to remove category from all courses using a deleted category
1.57 raeburn 5323: &Apache::loncommon::extract_categories($cathash,\@predelcats,\@predeltrails,\%predelallitems);
1.48 raeburn 5324: foreach my $item (@deletecategory) {
1.57 raeburn 5325: if ($domconfig{'coursecategories'}{'cats'}{$item} ne '') {
5326: delete($domconfig{'coursecategories'}{'cats'}{$item});
1.48 raeburn 5327: $deletions{$item} = 1;
1.57 raeburn 5328: &recurse_cat_deletes($item,$cathash,\%deletions);
1.48 raeburn 5329: }
5330: }
5331: }
1.57 raeburn 5332: foreach my $item (keys(%{$cathash})) {
1.48 raeburn 5333: my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$item);
1.57 raeburn 5334: if ($cathash->{$item} ne $env{'form.'.$item}) {
1.48 raeburn 5335: $reorderings{$item} = 1;
1.57 raeburn 5336: $domconfig{'coursecategories'}{'cats'}{$item} = $env{'form.'.$item};
1.48 raeburn 5337: }
5338: if ($env{'form.addcategory_name_'.$item} ne '') {
5339: my $newcat = $env{'form.addcategory_name_'.$item};
5340: my $newdepth = $depth+1;
5341: my $newitem = &escape($newcat).':'.&escape($cat).':'.$newdepth;
1.57 raeburn 5342: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos_'.$item};
1.48 raeburn 5343: $adds{$newitem} = 1;
5344: }
5345: if ($env{'form.subcat_'.$item} ne '') {
5346: my $newcat = $env{'form.subcat_'.$item};
5347: my $newdepth = $depth+1;
5348: my $newitem = &escape($newcat).':'.&escape($cat).':'.$newdepth;
1.57 raeburn 5349: $domconfig{'coursecategories'}{'cats'}{$newitem} = 0;
1.48 raeburn 5350: $adds{$newitem} = 1;
5351: }
5352: }
5353: }
5354: if ($env{'form.instcode'} eq '1') {
1.57 raeburn 5355: if (ref($cathash) eq 'HASH') {
1.48 raeburn 5356: my $newitem = 'instcode::0';
1.57 raeburn 5357: if ($cathash->{$newitem} eq '') {
5358: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.instcode_pos'};
1.48 raeburn 5359: $adds{$newitem} = 1;
5360: }
5361: } else {
5362: my $newitem = 'instcode::0';
1.57 raeburn 5363: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.instcode_pos'};
1.48 raeburn 5364: $adds{$newitem} = 1;
5365: }
5366: }
5367: if ($env{'form.addcategory_name'} ne '') {
5368: my $newitem = &escape($env{'form.addcategory_name'}).'::0';
1.57 raeburn 5369: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
1.48 raeburn 5370: $adds{$newitem} = 1;
5371: }
1.57 raeburn 5372: my $putresult;
1.48 raeburn 5373: if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
5374: if (keys(%deletions) > 0) {
5375: foreach my $key (keys(%deletions)) {
5376: if ($predelallitems{$key} ne '') {
5377: $sort_by_deltrail{$predelallitems{$key}} = $predeltrails[$predelallitems{$key}];
5378: }
5379: }
5380: }
5381: my (@chkcats,@chktrails,%chkallitems);
1.57 raeburn 5382: &Apache::loncommon::extract_categories($domconfig{'coursecategories'}{'cats'},\@chkcats,\@chktrails,\%chkallitems);
1.48 raeburn 5383: if (ref($chkcats[0]) eq 'ARRAY') {
5384: my $depth = 0;
5385: my $chg = 0;
5386: for (my $i=0; $i<@{$chkcats[0]}; $i++) {
5387: my $name = $chkcats[0][$i];
5388: my $item;
5389: if ($name eq '') {
5390: $chg ++;
5391: } else {
5392: $item = &escape($name).'::0';
5393: if ($chg) {
1.57 raeburn 5394: $domconfig{'coursecategories'}{'cats'}{$item} -= $chg;
1.48 raeburn 5395: }
5396: $depth ++;
1.57 raeburn 5397: &recurse_check(\@chkcats,$domconfig{'coursecategories'}{'cats'},$depth,$name);
1.48 raeburn 5398: $depth --;
5399: }
5400: }
5401: }
1.57 raeburn 5402: }
5403: if ((keys(%changes) > 0) || (keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
5404: $putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);
1.48 raeburn 5405: if ($putresult eq 'ok') {
1.57 raeburn 5406: my %title = (
5407: togglecats => 'Show/Hide a course in the catalog',
5408: categorize => 'Category assigned to course',
5409: );
5410: my %level = (
5411: dom => 'set from "Modify Course" (Domain)',
5412: crs => 'set from "Parameters" (Course)',
5413: );
1.48 raeburn 5414: $resulttext = &mt('Changes made:').'<ul>';
1.57 raeburn 5415: if ($changes{'togglecats'}) {
5416: $resulttext .= '<li>'.&mt("$title{'togglecats'} $level{$env{'form.togglecats'}}").'</li>';
5417: }
5418: if ($changes{'categorize'}) {
5419: $resulttext .= '<li>'.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'</li>';
1.48 raeburn 5420: }
1.57 raeburn 5421: if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
5422: my $cathash;
5423: if (ref($domconfig{'coursecategories'}) eq 'HASH') {
5424: $cathash = $domconfig{'coursecategories'}{'cats'};
5425: } else {
5426: $cathash = {};
5427: }
5428: my (@cats,@trails,%allitems);
5429: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems);
5430: if (keys(%deletions) > 0) {
5431: $resulttext .= '<li>'.&mt('Deleted categories:').'<ul>';
5432: foreach my $predeltrail (sort {$a <=> $b } (keys(%sort_by_deltrail))) {
5433: $resulttext .= '<li>'.$predeltrails[$predeltrail].'</li>';
5434: }
5435: $resulttext .= '</ul></li>';
5436: }
5437: if (keys(%reorderings) > 0) {
5438: my %sort_by_trail;
5439: $resulttext .= '<li>'.&mt('Reordered categories:').'<ul>';
5440: foreach my $key (keys(%reorderings)) {
5441: if ($allitems{$key} ne '') {
5442: $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
5443: }
1.48 raeburn 5444: }
1.57 raeburn 5445: foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
5446: $resulttext .= '<li>'.$trails[$trail].'</li>';
5447: }
5448: $resulttext .= '</ul></li>';
1.48 raeburn 5449: }
1.57 raeburn 5450: if (keys(%adds) > 0) {
5451: my %sort_by_trail;
5452: $resulttext .= '<li>'.&mt('Added categories:').'<ul>';
5453: foreach my $key (keys(%adds)) {
5454: if ($allitems{$key} ne '') {
5455: $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
5456: }
5457: }
5458: foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
5459: $resulttext .= '<li>'.$trails[$trail].'</li>';
1.48 raeburn 5460: }
1.57 raeburn 5461: $resulttext .= '</ul></li>';
1.48 raeburn 5462: }
5463: }
5464: $resulttext .= '</ul>';
5465: } else {
5466: $resulttext = '<span class="LC_error">'.
1.57 raeburn 5467: &mt('An error occurred: [_1]',$putresult).'</span>';
1.48 raeburn 5468: }
5469: } else {
5470: $resulttext = &mt('No changes made to course categories');
5471: }
5472: return $resulttext;
5473: }
5474:
1.69 raeburn 5475: sub modify_serverstatuses {
5476: my ($dom,%domconfig) = @_;
5477: my ($resulttext,%changes,%currserverstatus,%newserverstatus);
5478: if (ref($domconfig{'serverstatuses'}) eq 'HASH') {
5479: %currserverstatus = %{$domconfig{'serverstatuses'}};
5480: }
5481: my @pages = &serverstatus_pages();
5482: foreach my $type (@pages) {
5483: $newserverstatus{$type}{'namedusers'} = '';
5484: $newserverstatus{$type}{'machines'} = '';
5485: if (defined($env{'form.'.$type.'_namedusers'})) {
5486: my @users = split(/,/,$env{'form.'.$type.'_namedusers'});
5487: my @okusers;
5488: foreach my $user (@users) {
5489: my ($uname,$udom) = split(/:/,$user);
5490: if (($udom =~ /^$match_domain$/) &&
5491: (&Apache::lonnet::domain($udom)) &&
5492: ($uname =~ /^$match_username$/)) {
5493: if (!grep(/^\Q$user\E/,@okusers)) {
5494: push(@okusers,$user);
5495: }
5496: }
5497: }
5498: if (@okusers > 0) {
5499: @okusers = sort(@okusers);
5500: $newserverstatus{$type}{'namedusers'} = join(',',@okusers);
5501: }
5502: }
5503: if (defined($env{'form.'.$type.'_machines'})) {
5504: my @machines = split(/,/,$env{'form.'.$type.'_machines'});
5505: my @okmachines;
5506: foreach my $ip (@machines) {
5507: my @parts = split(/\./,$ip);
5508: next if (@parts < 4);
5509: my $badip = 0;
5510: for (my $i=0; $i<4; $i++) {
5511: if (!(($parts[$i] >= 0) && ($parts[$i] <= 255))) {
5512: $badip = 1;
5513: last;
5514: }
5515: }
5516: if (!$badip) {
5517: push(@okmachines,$ip);
5518: }
5519: }
5520: @okmachines = sort(@okmachines);
5521: $newserverstatus{$type}{'machines'} = join(',',@okmachines);
5522: }
5523: }
5524: my %serverstatushash = (
5525: serverstatuses => \%newserverstatus,
5526: );
5527: my %changes;
5528: foreach my $type (@pages) {
1.83 raeburn 5529: foreach my $setting ('namedusers','machines') {
1.84 raeburn 5530: my (@current,@new);
1.83 raeburn 5531: if (ref($currserverstatus{$type}) eq 'HASH') {
1.84 raeburn 5532: if ($currserverstatus{$type}{$setting} ne '') {
5533: @current = split(/,/,$currserverstatus{$type}{$setting});
5534: }
5535: }
5536: if ($newserverstatus{$type}{$setting} ne '') {
5537: @new = split(/,/,$newserverstatus{$type}{$setting});
1.83 raeburn 5538: }
5539: if (@current > 0) {
5540: if (@new > 0) {
5541: foreach my $item (@current) {
5542: if (!grep(/^\Q$item\E$/,@new)) {
5543: $changes{$type}{$setting} = 1;
1.82 raeburn 5544: last;
5545: }
5546: }
1.84 raeburn 5547: foreach my $item (@new) {
5548: if (!grep(/^\Q$item\E$/,@current)) {
5549: $changes{$type}{$setting} = 1;
5550: last;
1.82 raeburn 5551: }
5552: }
5553: } else {
1.83 raeburn 5554: $changes{$type}{$setting} = 1;
1.69 raeburn 5555: }
1.83 raeburn 5556: } elsif (@new > 0) {
5557: $changes{$type}{$setting} = 1;
1.69 raeburn 5558: }
5559: }
5560: }
5561: if (keys(%changes) > 0) {
1.81 raeburn 5562: my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
1.69 raeburn 5563: my $putresult = &Apache::lonnet::put_dom('configuration',
5564: \%serverstatushash,$dom);
5565: if ($putresult eq 'ok') {
5566: $resulttext .= &mt('Changes made:').'<ul>';
5567: foreach my $type (@pages) {
1.84 raeburn 5568: if (ref($changes{$type}) eq 'HASH') {
1.69 raeburn 5569: $resulttext .= '<li>'.$titles->{$type}.'<ul>';
1.84 raeburn 5570: if ($changes{$type}{'namedusers'}) {
1.69 raeburn 5571: if ($newserverstatus{$type}{'namedusers'} eq '') {
5572: $resulttext .= '<li>'.&mt("Access terminated for all specific (named) users").'</li>'."\n";
5573: } else {
5574: $resulttext .= '<li>'.&mt("Access available for the following specified users: ").$newserverstatus{$type}{'namedusers'}.'</li>'."\n";
5575: }
1.84 raeburn 5576: }
5577: if ($changes{$type}{'machines'}) {
1.69 raeburn 5578: if ($newserverstatus{$type}{'machines'} eq '') {
5579: $resulttext .= '<li>'.&mt("Access terminated for all specific IP addresses").'</li>'."\n";
5580: } else {
5581: $resulttext .= '<li>'.&mt("Access available for the following specified IP addresses: ").$newserverstatus{$type}{'machines'}.'</li>'."\n";
5582: }
5583:
5584: }
5585: $resulttext .= '</ul></li>';
5586: }
5587: }
5588: $resulttext .= '</ul>';
5589: } else {
5590: $resulttext = '<span class="LC_error">'.
5591: &mt('An error occurred saving access settings for server status pages: [_1].',$putresult).'</span>';
5592:
5593: }
5594: } else {
5595: $resulttext = &mt('No changes made to access to server status pages');
5596: }
5597: return $resulttext;
5598: }
5599:
1.48 raeburn 5600: sub recurse_check {
5601: my ($chkcats,$categories,$depth,$name) = @_;
5602: if (ref($chkcats->[$depth]{$name}) eq 'ARRAY') {
5603: my $chg = 0;
5604: for (my $j=0; $j<@{$chkcats->[$depth]{$name}}; $j++) {
5605: my $category = $chkcats->[$depth]{$name}[$j];
5606: my $item;
5607: if ($category eq '') {
5608: $chg ++;
5609: } else {
5610: my $deeper = $depth + 1;
5611: $item = &escape($category).':'.&escape($name).':'.$depth;
5612: if ($chg) {
5613: $categories->{$item} -= $chg;
5614: }
5615: &recurse_check($chkcats,$categories,$deeper,$category);
5616: $deeper --;
5617: }
5618: }
5619: }
5620: return;
5621: }
5622:
5623: sub recurse_cat_deletes {
5624: my ($item,$coursecategories,$deletions) = @_;
5625: my ($deleted,$container,$depth) = map { &unescape($_); } split(/:/,$item);
5626: my $subdepth = $depth + 1;
5627: if (ref($coursecategories) eq 'HASH') {
5628: foreach my $subitem (keys(%{$coursecategories})) {
5629: my ($child,$parent,$itemdepth) = map { &unescape($_); } split(/:/,$subitem);
5630: if (($parent eq $deleted) && ($itemdepth == $subdepth)) {
5631: delete($coursecategories->{$subitem});
5632: $deletions->{$subitem} = 1;
5633: &recurse_cat_deletes($subitem,$coursecategories,$deletions);
5634: }
5635: }
5636: }
5637: return;
5638: }
5639:
1.3 raeburn 5640: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>