Annotation of loncom/interface/domainprefs.pm, revision 1.112
1.1 raeburn 1: # The LearningOnline Network with CAPA
2: # Handler to set domain-wide configuration settings
3: #
1.112 ! raeburn 4: # $Id: domainprefs.pm,v 1.111 2009/10/06 18:24:29 jms 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.112 ! raeburn 3142: my %curr_loginvia;
! 3143: if (ref($domconfig{login}) eq 'HASH') {
! 3144: if (ref($domconfig{login}{loginvia}) eq 'HASH') {
! 3145: foreach my $lonhost (keys(%{$domconfig{login}{loginvia}})) {
! 3146: $curr_loginvia{$lonhost} = $domconfig{login}{loginvia}{$lonhost};
! 3147: }
! 3148: }
! 3149: }
1.6 raeburn 3150: my %loginhash;
1.9 raeburn 3151: ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
3152: \%domconfig,\%loginhash);
1.43 raeburn 3153: my @toggles = ('coursecatalog','adminmail','newuser');
1.42 raeburn 3154: foreach my $item (@toggles) {
3155: $loginhash{login}{$item} = $env{'form.'.$item};
3156: }
1.41 raeburn 3157: $loginhash{login}{loginheader} = $env{'form.loginheader'};
1.6 raeburn 3158: if (ref($colchanges{'login'}) eq 'HASH') {
3159: $colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
3160: \%loginhash);
3161: }
1.110 raeburn 3162:
3163: my %servers = &Apache::lonnet::get_servers($dom);
3164: if (keys(%servers) > 1) {
3165: foreach my $lonhost (keys(%servers)) {
1.112 ! raeburn 3166: next if ($env{'form.'.$lonhost.'_serverurl'} eq $curr_loginvia{$lonhost});
! 3167: next if ($env{'form.'.$lonhost.'_serverurl'} eq $lonhost);
! 3168: if ($curr_loginvia{$lonhost} ne '') {
! 3169: $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};
! 3170: $changes{'loginvia'}{$lonhost} = 1;
! 3171: } else {
1.110 raeburn 3172: if (defined($servers{$env{'form.'.$lonhost.'_serverurl'}})) {
3173: $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};
1.112 ! raeburn 3174: $changes{'loginvia'}{$lonhost} = 1;
1.110 raeburn 3175: }
3176: }
3177: }
3178: }
3179:
1.1 raeburn 3180: my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
3181: $dom);
3182: if ($putresult eq 'ok') {
1.43 raeburn 3183: my @toggles = ('coursecatalog','adminmail','newuser');
1.42 raeburn 3184: my %defaultchecked = (
3185: 'coursecatalog' => 'on',
3186: 'adminmail' => 'off',
1.43 raeburn 3187: 'newuser' => 'off',
1.42 raeburn 3188: );
1.55 raeburn 3189: if (ref($domconfig{'login'}) eq 'HASH') {
3190: foreach my $item (@toggles) {
3191: if ($defaultchecked{$item} eq 'on') {
3192: if (($domconfig{'login'}{$item} eq '0') &&
3193: ($env{'form.'.$item} eq '1')) {
3194: $changes{$item} = 1;
3195: } elsif (($domconfig{'login'}{$item} eq '' ||
3196: $domconfig{'login'}{$item} eq '1') &&
3197: ($env{'form.'.$item} eq '0')) {
3198: $changes{$item} = 1;
3199: }
3200: } elsif ($defaultchecked{$item} eq 'off') {
3201: if (($domconfig{'login'}{$item} eq '1') &&
3202: ($env{'form.'.$item} eq '0')) {
3203: $changes{$item} = 1;
3204: } elsif (($domconfig{'login'}{$item} eq '' ||
3205: $domconfig{'login'}{$item} eq '0') &&
3206: ($env{'form.'.$item} eq '1')) {
3207: $changes{$item} = 1;
3208: }
1.42 raeburn 3209: }
3210: }
1.55 raeburn 3211: if (($domconfig{'login'}{'loginheader'} eq 'text') &&
3212: ($env{'form.loginheader'} eq 'image')) {
3213: $changes{'loginheader'} = 1;
3214: } elsif (($domconfig{'login'}{'loginheader'} eq '' ||
3215: $domconfig{'login'}{'loginheader'} eq 'image') &&
3216: ($env{'form.loginheader'} eq 'text')) {
3217: $changes{'loginheader'} = 1;
3218: }
1.41 raeburn 3219: }
1.6 raeburn 3220: if (keys(%changes) > 0 || $colchgtext) {
1.41 raeburn 3221: &Apache::loncommon::devalidate_domconfig_cache($dom);
1.1 raeburn 3222: $resulttext = &mt('Changes made:').'<ul>';
3223: foreach my $item (sort(keys(%changes))) {
1.41 raeburn 3224: if ($item eq 'loginheader') {
3225: $resulttext .= '<li>'.&mt("$title{$item} set to $env{'form.loginheader'}").'</li>';
1.112 ! raeburn 3226: } elsif ($item eq 'loginvia') {
! 3227: if (ref($changes{$item}) eq 'HASH') {
! 3228: $resulttext .= '<li>'.&mt('Log-in page availability:').'<ul>';
! 3229: foreach my $lonhost (sort(keys(%{$changes{$item}}))) {
! 3230: if ($servers{$env{'form.'.$lonhost.'_serverurl'}} ne '') {
! 3231: $resulttext .= '<li>'.&mt('Server: [_1] log-in page now redirects to [_2]',$lonhost,$servers{$env{'form.'.$lonhost.'_serverurl'}}).'</li>';
! 3232: } else {
! 3233: $resulttext .= '<li>'.&mt('Server: [_1] now has standard log-in page.',$lonhost).'</li>';
! 3234: }
! 3235: }
! 3236: $resulttext .= '</ul></li>';
! 3237: }
1.41 raeburn 3238: } else {
3239: $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
3240: }
1.1 raeburn 3241: }
1.6 raeburn 3242: $resulttext .= $colchgtext.'</ul>';
1.1 raeburn 3243: } else {
3244: $resulttext = &mt('No changes made to log-in page settings');
3245: }
3246: } else {
1.11 albertel 3247: $resulttext = '<span class="LC_error">'.
3248: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 3249: }
1.6 raeburn 3250: if ($errors) {
1.9 raeburn 3251: $resulttext .= '<br />'.&mt('The following errors occurred: ').'<ul>'.
1.6 raeburn 3252: $errors.'</ul>';
3253: }
3254: return $resulttext;
3255: }
3256:
3257: sub color_font_choices {
3258: my %choices =
3259: &Apache::lonlocal::texthash (
3260: img => "Header",
3261: bgs => "Background colors",
3262: links => "Link colors",
1.55 raeburn 3263: images => "Images",
1.6 raeburn 3264: font => "Font color",
1.97 tempelho 3265: fontmenu => "Font Menu",
1.76 raeburn 3266: pgbg => "Page",
1.6 raeburn 3267: tabbg => "Header",
3268: sidebg => "Border",
3269: link => "Link",
3270: alink => "Active link",
3271: vlink => "Visited link",
3272: );
3273: return %choices;
3274: }
3275:
3276: sub modify_rolecolors {
1.9 raeburn 3277: my ($r,$dom,$confname,$roles,%domconfig) = @_;
1.6 raeburn 3278: my ($resulttext,%rolehash);
3279: $rolehash{'rolecolors'} = {};
1.55 raeburn 3280: if (ref($domconfig{'rolecolors'}) ne 'HASH') {
3281: if ($domconfig{'rolecolors'} eq '') {
3282: $domconfig{'rolecolors'} = {};
3283: }
3284: }
1.9 raeburn 3285: my ($errors,%changes) = &modify_colors($r,$dom,$confname,$roles,
1.6 raeburn 3286: $domconfig{'rolecolors'},$rolehash{'rolecolors'});
3287: my $putresult = &Apache::lonnet::put_dom('configuration',\%rolehash,
3288: $dom);
3289: if ($putresult eq 'ok') {
3290: if (keys(%changes) > 0) {
1.41 raeburn 3291: &Apache::loncommon::devalidate_domconfig_cache($dom);
1.6 raeburn 3292: $resulttext = &display_colorchgs($dom,\%changes,$roles,
3293: $rolehash{'rolecolors'});
3294: } else {
3295: $resulttext = &mt('No changes made to default color schemes');
3296: }
3297: } else {
1.11 albertel 3298: $resulttext = '<span class="LC_error">'.
3299: &mt('An error occurred: [_1]',$putresult).'</span>';
1.6 raeburn 3300: }
3301: if ($errors) {
3302: $resulttext .= &mt('The following errors occurred: ').'<ul>'.
3303: $errors.'</ul>';
3304: }
3305: return $resulttext;
3306: }
3307:
3308: sub modify_colors {
1.9 raeburn 3309: my ($r,$dom,$confname,$roles,$domconfig,$confhash) = @_;
1.12 raeburn 3310: my (%changes,%choices);
1.51 raeburn 3311: my @bgs;
1.6 raeburn 3312: my @links = ('link','alink','vlink');
1.41 raeburn 3313: my @logintext;
1.6 raeburn 3314: my @images;
3315: my $servadm = $r->dir_config('lonAdmEMail');
3316: my $errors;
3317: foreach my $role (@{$roles}) {
3318: if ($role eq 'login') {
1.12 raeburn 3319: %choices = &login_choices();
1.41 raeburn 3320: @logintext = ('textcol','bgcol');
1.12 raeburn 3321: } else {
3322: %choices = &color_font_choices();
1.107 raeburn 3323: $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
1.12 raeburn 3324: }
3325: if ($role eq 'login') {
1.41 raeburn 3326: @images = ('img','logo','domlogo','login');
1.51 raeburn 3327: @bgs = ('pgbg','mainbg','sidebg');
1.6 raeburn 3328: } else {
3329: @images = ('img');
1.51 raeburn 3330: @bgs = ('pgbg','tabbg','sidebg');
1.6 raeburn 3331: }
3332: $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
1.41 raeburn 3333: foreach my $item (@bgs,@links,@logintext) {
1.6 raeburn 3334: $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
3335: }
1.46 raeburn 3336: my ($configuserok,$author_ok,$switchserver) =
3337: &config_check($dom,$confname,$servadm);
1.9 raeburn 3338: my ($width,$height) = &thumb_dimensions();
1.40 raeburn 3339: if (ref($domconfig->{$role}) ne 'HASH') {
3340: $domconfig->{$role} = {};
3341: }
1.8 raeburn 3342: foreach my $img (@images) {
1.70 raeburn 3343: if (($role eq 'login') && (($img eq 'img') || ($img eq 'logo'))) {
3344: if (defined($env{'form.login_showlogo_'.$img})) {
3345: $confhash->{$role}{'showlogo'}{$img} = 1;
3346: } else {
3347: $confhash->{$role}{'showlogo'}{$img} = 0;
3348: }
3349: }
1.18 albertel 3350: if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
3351: && !defined($domconfig->{$role}{$img})
3352: && !$env{'form.'.$role.'_del_'.$img}
3353: && $env{'form.'.$role.'_import_'.$img}) {
3354: # import the old configured image from the .tab setting
3355: # if they haven't provided a new one
3356: $domconfig->{$role}{$img} =
3357: $env{'form.'.$role.'_import_'.$img};
3358: }
1.6 raeburn 3359: if ($env{'form.'.$role.'_'.$img.'.filename'} ne '') {
1.9 raeburn 3360: my $error;
1.6 raeburn 3361: if ($configuserok eq 'ok') {
1.9 raeburn 3362: if ($switchserver) {
1.12 raeburn 3363: $error = &mt("Upload of [_1] image for $role page(s) is not permitted to this server: [_2]",$choices{$img},$switchserver);
1.9 raeburn 3364: } else {
3365: if ($author_ok eq 'ok') {
3366: my ($result,$logourl) =
3367: &publishlogo($r,'upload',$role.'_'.$img,
3368: $dom,$confname,$img,$width,$height);
3369: if ($result eq 'ok') {
3370: $confhash->{$role}{$img} = $logourl;
1.12 raeburn 3371: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 3372: } else {
1.12 raeburn 3373: $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 3374: }
3375: } else {
1.46 raeburn 3376: $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 3377: }
3378: }
3379: } else {
1.46 raeburn 3380: $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 3381: }
3382: if ($error) {
1.8 raeburn 3383: &Apache::lonnet::logthis($error);
1.11 albertel 3384: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
1.8 raeburn 3385: }
3386: } elsif ($domconfig->{$role}{$img} ne '') {
1.9 raeburn 3387: if ($domconfig->{$role}{$img} !~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
3388: my $error;
3389: if ($configuserok eq 'ok') {
3390: # is confname an author?
3391: if ($switchserver eq '') {
3392: if ($author_ok eq 'ok') {
3393: my ($result,$logourl) =
3394: &publishlogo($r,'copy',$domconfig->{$role}{$img},
3395: $dom,$confname,$img,$width,$height);
3396: if ($result eq 'ok') {
3397: $confhash->{$role}{$img} = $logourl;
1.18 albertel 3398: $changes{$role}{'images'}{$img} = 1;
1.9 raeburn 3399: }
3400: }
3401: }
3402: }
1.6 raeburn 3403: }
3404: }
3405: }
3406: if (ref($domconfig) eq 'HASH') {
3407: if (ref($domconfig->{$role}) eq 'HASH') {
3408: foreach my $img (@images) {
3409: if ($domconfig->{$role}{$img} ne '') {
3410: if ($env{'form.'.$role.'_del_'.$img}) {
3411: $confhash->{$role}{$img} = '';
1.12 raeburn 3412: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 3413: } else {
1.9 raeburn 3414: if ($confhash->{$role}{$img} eq '') {
3415: $confhash->{$role}{$img} = $domconfig->{$role}{$img};
3416: }
1.6 raeburn 3417: }
3418: } else {
3419: if ($env{'form.'.$role.'_del_'.$img}) {
3420: $confhash->{$role}{$img} = '';
1.12 raeburn 3421: $changes{$role}{'images'}{$img} = 1;
1.6 raeburn 3422: }
3423: }
1.70 raeburn 3424: if (($role eq 'login') && (($img eq 'logo') || ($img eq 'img'))) {
3425: if (ref($domconfig->{'login'}{'showlogo'}) eq 'HASH') {
3426: if ($confhash->{$role}{'showlogo'}{$img} ne
3427: $domconfig->{$role}{'showlogo'}{$img}) {
3428: $changes{$role}{'showlogo'}{$img} = 1;
3429: }
3430: } else {
3431: if ($confhash->{$role}{'showlogo'}{$img} == 0) {
3432: $changes{$role}{'showlogo'}{$img} = 1;
3433: }
3434: }
3435: }
3436: }
1.6 raeburn 3437: if ($domconfig->{$role}{'font'} ne '') {
3438: if ($confhash->{$role}{'font'} ne $domconfig->{$role}{'font'}) {
3439: $changes{$role}{'font'} = 1;
3440: }
3441: } else {
3442: if ($confhash->{$role}{'font'}) {
3443: $changes{$role}{'font'} = 1;
3444: }
3445: }
1.107 raeburn 3446: if ($role ne 'login') {
3447: if ($domconfig->{$role}{'fontmenu'} ne '') {
3448: if ($confhash->{$role}{'fontmenu'} ne $domconfig->{$role}{'fontmenu'}) {
3449: $changes{$role}{'fontmenu'} = 1;
3450: }
3451: } else {
3452: if ($confhash->{$role}{'fontmenu'}) {
3453: $changes{$role}{'fontmenu'} = 1;
3454: }
1.97 tempelho 3455: }
3456: }
1.6 raeburn 3457: foreach my $item (@bgs) {
3458: if ($domconfig->{$role}{$item} ne '') {
3459: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
3460: $changes{$role}{'bgs'}{$item} = 1;
3461: }
3462: } else {
3463: if ($confhash->{$role}{$item}) {
3464: $changes{$role}{'bgs'}{$item} = 1;
3465: }
3466: }
3467: }
3468: foreach my $item (@links) {
3469: if ($domconfig->{$role}{$item} ne '') {
3470: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
3471: $changes{$role}{'links'}{$item} = 1;
3472: }
3473: } else {
3474: if ($confhash->{$role}{$item}) {
3475: $changes{$role}{'links'}{$item} = 1;
3476: }
3477: }
3478: }
1.41 raeburn 3479: foreach my $item (@logintext) {
3480: if ($domconfig->{$role}{$item} ne '') {
3481: if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
3482: $changes{$role}{'logintext'}{$item} = 1;
3483: }
3484: } else {
3485: if ($confhash->{$role}{$item}) {
3486: $changes{$role}{'logintext'}{$item} = 1;
3487: }
3488: }
3489: }
1.6 raeburn 3490: } else {
3491: &default_change_checker($role,\@images,\@links,\@bgs,
1.41 raeburn 3492: \@logintext,$confhash,\%changes);
1.6 raeburn 3493: }
3494: } else {
3495: &default_change_checker($role,\@images,\@links,\@bgs,
1.41 raeburn 3496: \@logintext,$confhash,\%changes);
1.6 raeburn 3497: }
3498: }
3499: return ($errors,%changes);
3500: }
3501:
1.46 raeburn 3502: sub config_check {
3503: my ($dom,$confname,$servadm) = @_;
3504: my ($configuserok,$author_ok,$switchserver,%currroles);
3505: my $uhome = &Apache::lonnet::homeserver($confname,$dom,1);
3506: ($configuserok,%currroles) = &check_configuser($uhome,$dom,
3507: $confname,$servadm);
3508: if ($configuserok eq 'ok') {
3509: $switchserver = &check_switchserver($dom,$confname);
3510: if ($switchserver eq '') {
3511: $author_ok = &check_authorstatus($dom,$confname,%currroles);
3512: }
3513: }
3514: return ($configuserok,$author_ok,$switchserver);
3515: }
3516:
1.6 raeburn 3517: sub default_change_checker {
1.41 raeburn 3518: my ($role,$images,$links,$bgs,$logintext,$confhash,$changes) = @_;
1.6 raeburn 3519: foreach my $item (@{$links}) {
3520: if ($confhash->{$role}{$item}) {
3521: $changes->{$role}{'links'}{$item} = 1;
3522: }
3523: }
3524: foreach my $item (@{$bgs}) {
3525: if ($confhash->{$role}{$item}) {
3526: $changes->{$role}{'bgs'}{$item} = 1;
3527: }
3528: }
1.41 raeburn 3529: foreach my $item (@{$logintext}) {
3530: if ($confhash->{$role}{$item}) {
3531: $changes->{$role}{'logintext'}{$item} = 1;
3532: }
3533: }
1.6 raeburn 3534: foreach my $img (@{$images}) {
3535: if ($env{'form.'.$role.'_del_'.$img}) {
3536: $confhash->{$role}{$img} = '';
1.12 raeburn 3537: $changes->{$role}{'images'}{$img} = 1;
1.6 raeburn 3538: }
1.70 raeburn 3539: if ($role eq 'login') {
3540: if ($confhash->{$role}{'showlogo'}{$img} == 0) {
3541: $changes->{$role}{'showlogo'}{$img} = 1;
3542: }
3543: }
1.6 raeburn 3544: }
3545: if ($confhash->{$role}{'font'}) {
3546: $changes->{$role}{'font'} = 1;
3547: }
1.48 raeburn 3548: }
1.6 raeburn 3549:
3550: sub display_colorchgs {
3551: my ($dom,$changes,$roles,$confhash) = @_;
3552: my (%choices,$resulttext);
3553: if (!grep(/^login$/,@{$roles})) {
3554: $resulttext = &mt('Changes made:').'<br />';
3555: }
3556: foreach my $role (@{$roles}) {
3557: if ($role eq 'login') {
3558: %choices = &login_choices();
3559: } else {
3560: %choices = &color_font_choices();
3561: }
3562: if (ref($changes->{$role}) eq 'HASH') {
3563: if ($role ne 'login') {
3564: $resulttext .= '<h4>'.&mt($role).'</h4>';
3565: }
3566: foreach my $key (sort(keys(%{$changes->{$role}}))) {
3567: if ($role ne 'login') {
3568: $resulttext .= '<ul>';
3569: }
3570: if (ref($changes->{$role}{$key}) eq 'HASH') {
3571: if ($role ne 'login') {
3572: $resulttext .= '<li>'.&mt($choices{$key}).':<ul>';
3573: }
3574: foreach my $item (sort(keys(%{$changes->{$role}{$key}}))) {
1.70 raeburn 3575: if (($role eq 'login') && ($key eq 'showlogo')) {
3576: if ($confhash->{$role}{$key}{$item}) {
3577: $resulttext .= '<li>'.&mt("$choices{$item} set to be displayed").'</li>';
3578: } else {
3579: $resulttext .= '<li>'.&mt("$choices{$item} set to not be displayed").'</li>';
3580: }
3581: } elsif ($confhash->{$role}{$item} eq '') {
1.6 raeburn 3582: $resulttext .= '<li>'.&mt("$choices{$item} set to default").'</li>';
3583: } else {
1.12 raeburn 3584: my $newitem = $confhash->{$role}{$item};
3585: if ($key eq 'images') {
3586: $newitem = '<img src="'.$confhash->{$role}{$item}.'" alt="'.$choices{$item}.'" valign="bottom" />';
3587: }
3588: $resulttext .= '<li>'.&mt("$choices{$item} set to [_1]",$newitem).'</li>';
1.6 raeburn 3589: }
3590: }
3591: if ($role ne 'login') {
3592: $resulttext .= '</ul></li>';
3593: }
3594: } else {
3595: if ($confhash->{$role}{$key} eq '') {
3596: $resulttext .= '<li>'.&mt("$choices{$key} set to default").'</li>';
3597: } else {
3598: $resulttext .= '<li>'.&mt("$choices{$key} set to [_1]",$confhash->{$role}{$key}).'</li>';
3599: }
3600: }
3601: if ($role ne 'login') {
3602: $resulttext .= '</ul>';
3603: }
3604: }
3605: }
3606: }
1.3 raeburn 3607: return $resulttext;
1.1 raeburn 3608: }
3609:
1.9 raeburn 3610: sub thumb_dimensions {
3611: return ('200','50');
3612: }
3613:
1.16 raeburn 3614: sub check_dimensions {
3615: my ($inputfile) = @_;
3616: my ($fullwidth,$fullheight);
3617: if ($inputfile =~ m|^[/\w.\-]+$|) {
3618: if (open(PIPE,"identify $inputfile 2>&1 |")) {
3619: my $imageinfo = <PIPE>;
3620: if (!close(PIPE)) {
3621: &Apache::lonnet::logthis("Failed to close PIPE opened to retrieve image information for $inputfile");
3622: }
3623: chomp($imageinfo);
3624: my ($fullsize) =
1.21 raeburn 3625: ($imageinfo =~ /^\Q$inputfile\E\s+\w+\s+(\d+x\d+)/);
1.16 raeburn 3626: if ($fullsize) {
3627: ($fullwidth,$fullheight) = split(/x/,$fullsize);
3628: }
3629: }
3630: }
3631: return ($fullwidth,$fullheight);
3632: }
3633:
1.9 raeburn 3634: sub check_configuser {
3635: my ($uhome,$dom,$confname,$servadm) = @_;
3636: my ($configuserok,%currroles);
3637: if ($uhome eq 'no_host') {
3638: srand( time() ^ ($$ + ($$ << 15)) ); # Seed rand.
3639: my $configpass = &LONCAPA::Enrollment::create_password();
3640: $configuserok =
3641: &Apache::lonnet::modifyuser($dom,$confname,'','internal',
3642: $configpass,'','','','','',undef,$servadm);
3643: } else {
3644: $configuserok = 'ok';
3645: %currroles =
3646: &Apache::lonnet::get_my_roles($confname,$dom,'userroles');
3647: }
3648: return ($configuserok,%currroles);
3649: }
3650:
3651: sub check_authorstatus {
3652: my ($dom,$confname,%currroles) = @_;
3653: my $author_ok;
1.40 raeburn 3654: if (!$currroles{':'.$dom.':au'}) {
1.9 raeburn 3655: my $start = time;
3656: my $end = 0;
3657: $author_ok =
3658: &Apache::lonnet::assignrole($dom,$confname,'/'.$dom.'/',
1.47 raeburn 3659: 'au',$end,$start,'','','domconfig');
1.9 raeburn 3660: } else {
3661: $author_ok = 'ok';
3662: }
3663: return $author_ok;
3664: }
3665:
3666: sub publishlogo {
1.46 raeburn 3667: my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight,$savefileas) = @_;
1.9 raeburn 3668: my ($output,$fname,$logourl);
3669: if ($action eq 'upload') {
3670: $fname=$env{'form.'.$formname.'.filename'};
3671: chop($env{'form.'.$formname});
3672: } else {
3673: ($fname) = ($formname =~ /([^\/]+)$/);
3674: }
1.46 raeburn 3675: if ($savefileas ne '') {
3676: $fname = $savefileas;
3677: }
1.9 raeburn 3678: $fname=&Apache::lonnet::clean_filename($fname);
3679: # See if there is anything left
3680: unless ($fname) { return ('error: no uploaded file'); }
3681: $fname="$subdir/$fname";
3682: my $filepath='/home/'.$confname.'/public_html';
3683: my ($fnamepath,$file,$fetchthumb);
3684: $file=$fname;
3685: if ($fname=~m|/|) {
3686: ($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
3687: }
3688: my @parts=split(/\//,$filepath.'/'.$fnamepath);
3689: my $count;
3690: for ($count=4;$count<=$#parts;$count++) {
3691: $filepath.="/$parts[$count]";
3692: if ((-e $filepath)!=1) {
3693: mkdir($filepath,02770);
3694: }
3695: }
3696: # Check for bad extension and disallow upload
3697: if ($file=~/\.(\w+)$/ &&
3698: (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
3699: $output =
3700: &mt('Invalid file extension ([_1]) - reserved for LONCAPA use.',$1);
3701: } elsif ($file=~/\.(\w+)$/ &&
3702: !defined(&Apache::loncommon::fileembstyle($1))) {
3703: $output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1);
3704: } elsif ($file=~/\.(\d+)\.(\w+)$/) {
1.46 raeburn 3705: $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 3706: } elsif (-d "$filepath/$file") {
3707: $output = &mt('File name is a directory name - rename the file and re-upload');
3708: } else {
3709: my $source = $filepath.'/'.$file;
3710: my $logfile;
3711: if (!open($logfile,">>$source".'.log')) {
3712: return (&mt('No write permission to Construction Space'));
3713: }
3714: print $logfile
3715: "\n================= Publish ".localtime()." ================\n".
3716: $env{'user.name'}.':'.$env{'user.domain'}."\n";
3717: # Save the file
3718: if (!open(FH,'>'.$source)) {
3719: &Apache::lonnet::logthis('Failed to create '.$source);
3720: return (&mt('Failed to create file'));
3721: }
3722: if ($action eq 'upload') {
3723: if (!print FH ($env{'form.'.$formname})) {
3724: &Apache::lonnet::logthis('Failed to write to '.$source);
3725: return (&mt('Failed to write file'));
3726: }
3727: } else {
3728: my $original = &Apache::lonnet::filelocation('',$formname);
3729: if(!copy($original,$source)) {
3730: &Apache::lonnet::logthis('Failed to copy '.$original.' to '.$source);
3731: return (&mt('Failed to write file'));
3732: }
3733: }
3734: close(FH);
3735: chmod(0660, $source); # Permissions to rw-rw---.
3736:
3737: my $docroot=$r->dir_config('lonDocRoot');
3738: my $targetdir=$docroot.'/res/'.$dom.'/'.$confname .'/'.$fnamepath;
3739: my $copyfile=$targetdir.'/'.$file;
3740:
3741: my @parts=split(/\//,$targetdir);
3742: my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]";
3743: for (my $count=5;$count<=$#parts;$count++) {
3744: $path.="/$parts[$count]";
3745: if (!-e $path) {
3746: print $logfile "\nCreating directory ".$path;
3747: mkdir($path,02770);
3748: }
3749: }
3750: my $versionresult;
3751: if (-e $copyfile) {
3752: $versionresult = &logo_versioning($targetdir,$file,$logfile);
3753: } else {
3754: $versionresult = 'ok';
3755: }
3756: if ($versionresult eq 'ok') {
3757: if (copy($source,$copyfile)) {
3758: print $logfile "\nCopied original source to ".$copyfile."\n";
3759: $output = 'ok';
3760: &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
3761: $logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;
3762: } else {
3763: print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
3764: $output = &mt('Failed to copy file to RES space').", $!";
3765: }
3766: if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) {
3767: my $inputfile = $filepath.'/'.$file;
3768: my $outfile = $filepath.'/'.'tn-'.$file;
1.16 raeburn 3769: my ($fullwidth,$fullheight) = &check_dimensions($inputfile);
3770: if ($fullwidth ne '' && $fullheight ne '') {
3771: if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) {
3772: my $thumbsize = $thumbwidth.'x'.$thumbheight;
3773: system("convert -sample $thumbsize $inputfile $outfile");
3774: chmod(0660, $filepath.'/tn-'.$file);
3775: if (-e $outfile) {
3776: my $copyfile=$targetdir.'/tn-'.$file;
3777: if (copy($outfile,$copyfile)) {
3778: print $logfile "\nCopied source to ".$copyfile."\n";
3779: &write_metadata($dom,$confname,$formname,
3780: $targetdir,'tn-'.$file,$logfile);
3781: } else {
3782: print $logfile "\nUnable to write ".$copyfile.
3783: ':'.$!."\n";
3784: }
3785: }
1.9 raeburn 3786: }
3787: }
3788: }
3789: } else {
3790: $output = $versionresult;
3791: }
3792: }
3793: return ($output,$logourl);
3794: }
3795:
3796: sub logo_versioning {
3797: my ($targetdir,$file,$logfile) = @_;
3798: my $target = $targetdir.'/'.$file;
3799: my ($maxversion,$fn,$extn,$output);
3800: $maxversion = 0;
3801: if ($file =~ /^(.+)\.(\w+)$/) {
3802: $fn=$1;
3803: $extn=$2;
3804: }
3805: opendir(DIR,$targetdir);
3806: while (my $filename=readdir(DIR)) {
3807: if ($filename=~/\Q$fn\E\.(\d+)\.\Q$extn\E$/) {
3808: $maxversion=($1>$maxversion)?$1:$maxversion;
3809: }
3810: }
3811: $maxversion++;
3812: print $logfile "\nCreating old version ".$maxversion."\n";
3813: my $copyfile=$targetdir.'/'.$fn.'.'.$maxversion.'.'.$extn;
3814: if (copy($target,$copyfile)) {
3815: print $logfile "Copied old target to ".$copyfile."\n";
3816: $copyfile=$copyfile.'.meta';
3817: if (copy($target.'.meta',$copyfile)) {
3818: print $logfile "Copied old target metadata to ".$copyfile."\n";
3819: $output = 'ok';
3820: } else {
3821: print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";
3822: $output = &mt('Failed to copy old meta').", $!, ";
3823: }
3824: } else {
3825: print $logfile "Unable to write ".$copyfile.':'.$!."\n";
3826: $output = &mt('Failed to copy old target').", $!, ";
3827: }
3828: return $output;
3829: }
3830:
3831: sub write_metadata {
3832: my ($dom,$confname,$formname,$targetdir,$file,$logfile) = @_;
3833: my (%metadatafields,%metadatakeys,$output);
3834: $metadatafields{'title'}=$formname;
3835: $metadatafields{'creationdate'}=time;
3836: $metadatafields{'lastrevisiondate'}=time;
3837: $metadatafields{'copyright'}='public';
3838: $metadatafields{'modifyinguser'}=$env{'user.name'}.':'.
3839: $env{'user.domain'};
3840: $metadatafields{'authorspace'}=$confname.':'.$dom;
3841: $metadatafields{'domain'}=$dom;
3842: {
3843: print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
3844: my $mfh;
3845: unless (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
3846: $output = &mt('Could not write metadata');
3847: }
3848: foreach (sort keys %metadatafields) {
3849: unless ($_=~/\./) {
3850: my $unikey=$_;
3851: $unikey=~/^([A-Za-z]+)/;
3852: my $tag=$1;
3853: $tag=~tr/A-Z/a-z/;
3854: print $mfh "\n\<$tag";
3855: foreach (split(/\,/,$metadatakeys{$unikey})) {
3856: my $value=$metadatafields{$unikey.'.'.$_};
3857: $value=~s/\"/\'\'/g;
3858: print $mfh ' '.$_.'="'.$value.'"';
3859: }
3860: print $mfh '>'.
3861: &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
3862: .'</'.$tag.'>';
3863: }
3864: }
3865: $output = 'ok';
3866: print $logfile "\nWrote metadata";
3867: close($mfh);
3868: }
3869: }
3870:
3871: sub check_switchserver {
3872: my ($dom,$confname) = @_;
3873: my ($allowed,$switchserver);
3874: my $home = &Apache::lonnet::homeserver($confname,$dom);
3875: if ($home eq 'no_host') {
3876: $home = &Apache::lonnet::domain($dom,'primary');
3877: }
3878: my @ids=&Apache::lonnet::current_machine_ids();
1.10 albertel 3879: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
3880: if (!$allowed) {
3881: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role=dc./'.$dom.'/">'.&mt('Switch Server').'</a>';
1.9 raeburn 3882: }
3883: return $switchserver;
3884: }
3885:
1.1 raeburn 3886: sub modify_quotas {
1.86 raeburn 3887: my ($dom,$action,%domconfig) = @_;
1.101 raeburn 3888: my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,
3889: %limithash,$toolregexp,%conditions,$resulttext,%changes);
1.86 raeburn 3890: if ($action eq 'quotas') {
3891: $context = 'tools';
3892: } else {
3893: $context = $action;
3894: }
3895: if ($context eq 'requestcourses') {
1.98 raeburn 3896: @usertools = ('official','unofficial','community');
1.106 raeburn 3897: @options =('norequest','approval','validate','autolimit');
1.101 raeburn 3898: %validations = &Apache::lonnet::auto_courserequest_checks($dom);
3899: %titles = &courserequest_titles();
3900: $toolregexp = join('|',@usertools);
3901: %conditions = &courserequest_conditions();
1.86 raeburn 3902: } else {
3903: @usertools = ('aboutme','blog','portfolio');
1.101 raeburn 3904: %titles = &tool_titles();
1.86 raeburn 3905: }
1.72 raeburn 3906: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.44 raeburn 3907: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.1 raeburn 3908: foreach my $key (keys(%env)) {
1.101 raeburn 3909: if ($context eq 'requestcourses') {
3910: if ($key =~ /^form\.crsreq_($toolregexp)_(.+)$/) {
3911: my $item = $1;
3912: my $type = $2;
3913: if ($type =~ /^limit_(.+)/) {
3914: $limithash{$item}{$1} = $env{$key};
3915: } else {
3916: $confhash{$item}{$type} = $env{$key};
3917: }
3918: }
3919: } else {
1.86 raeburn 3920: if ($key =~ /^form\.quota_(.+)$/) {
3921: $confhash{'defaultquota'}{$1} = $env{$key};
3922: }
1.101 raeburn 3923: if ($key =~ /^form\.\Q$context\E_(.+)$/) {
3924: @{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
3925: }
1.72 raeburn 3926: }
3927: }
1.102 raeburn 3928: if ($context eq 'requestcourses') {
3929: my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify');
3930: @approvalnotify = sort(@approvalnotify);
3931: $confhash{'notify'}{'approval'} = join(',',@approvalnotify);
3932: if (ref($domconfig{$action}) eq 'HASH') {
3933: if (ref($domconfig{$action}{'notify'}) eq 'HASH') {
3934: if ($domconfig{$action}{'notify'}{'approval'} ne $confhash{'notify'}{'approval'}) {
3935: $changes{'notify'}{'approval'} = 1;
3936: }
3937: } else {
3938: if ($domconfig{$action}{'notify'}{'approval'}) {
3939: $changes{'notify'}{'approval'} = 1;
3940: }
3941: }
3942: } else {
3943: if ($domconfig{$action}{'notify'}{'approval'}) {
3944: $changes{'notify'}{'approval'} = 1;
3945: }
3946: }
3947: } else {
1.86 raeburn 3948: $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
3949: }
1.72 raeburn 3950: foreach my $item (@usertools) {
3951: foreach my $type (@{$types},'default','_LC_adv') {
1.104 raeburn 3952: my $unset;
1.101 raeburn 3953: if ($context eq 'requestcourses') {
1.104 raeburn 3954: $unset = '0';
3955: if ($type eq '_LC_adv') {
3956: $unset = '';
3957: }
1.101 raeburn 3958: if ($confhash{$item}{$type} eq 'autolimit') {
3959: $confhash{$item}{$type} .= '=';
3960: unless ($limithash{$item}{$type} =~ /\D/) {
3961: $confhash{$item}{$type} .= $limithash{$item}{$type};
3962: }
3963: }
1.72 raeburn 3964: } else {
1.101 raeburn 3965: if (grep(/^\Q$type\E$/,@{$toolshash{$item}})) {
3966: $confhash{$item}{$type} = 1;
3967: } else {
3968: $confhash{$item}{$type} = 0;
3969: }
1.72 raeburn 3970: }
1.86 raeburn 3971: if (ref($domconfig{$action}) eq 'HASH') {
3972: if (ref($domconfig{$action}{$item}) eq 'HASH') {
3973: if ($domconfig{$action}{$item}{$type} ne $confhash{$item}{$type}) {
3974: $changes{$item}{$type} = 1;
3975: }
3976: } else {
3977: if ($context eq 'requestcourses') {
1.104 raeburn 3978: if ($confhash{$item}{$type} ne $unset) {
1.86 raeburn 3979: $changes{$item}{$type} = 1;
3980: }
3981: } else {
3982: if (!$confhash{$item}{$type}) {
3983: $changes{$item}{$type} = 1;
3984: }
3985: }
3986: }
3987: } else {
3988: if ($context eq 'requestcourses') {
1.104 raeburn 3989: if ($confhash{$item}{$type} ne $unset) {
1.72 raeburn 3990: $changes{$item}{$type} = 1;
3991: }
3992: } else {
3993: if (!$confhash{$item}{$type}) {
3994: $changes{$item}{$type} = 1;
3995: }
3996: }
3997: }
1.1 raeburn 3998: }
3999: }
1.86 raeburn 4000: unless ($context eq 'requestcourses') {
4001: if (ref($domconfig{'quotas'}) eq 'HASH') {
4002: if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
4003: foreach my $key (keys(%{$domconfig{'quotas'}{'defaultquota'}})) {
4004: if (exists($confhash{'defaultquota'}{$key})) {
4005: if ($confhash{'defaultquota'}{$key} ne $domconfig{'quotas'}{'defaultquota'}{$key}) {
4006: $changes{'defaultquota'}{$key} = 1;
4007: }
4008: } else {
4009: $confhash{'defaultquota'}{$key} = $domconfig{'quotas'}{'defaultquota'}{$key};
1.72 raeburn 4010: }
4011: }
1.86 raeburn 4012: } else {
4013: foreach my $key (keys(%{$domconfig{'quotas'}})) {
4014: if (exists($confhash{'defaultquota'}{$key})) {
4015: if ($confhash{'defaultquota'}{$key} ne $domconfig{'quotas'}{$key}) {
4016: $changes{'defaultquota'}{$key} = 1;
4017: }
4018: } else {
4019: $confhash{'defaultquota'}{$key} = $domconfig{'quotas'}{$key};
1.72 raeburn 4020: }
1.1 raeburn 4021: }
4022: }
4023: }
1.86 raeburn 4024: if (ref($confhash{'defaultquota'}) eq 'HASH') {
4025: foreach my $key (keys(%{$confhash{'defaultquota'}})) {
4026: if (ref($domconfig{'quotas'}) eq 'HASH') {
4027: if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
4028: if (!exists($domconfig{'quotas'}{'defaultquota'}{$key})) {
4029: $changes{'defaultquota'}{$key} = 1;
4030: }
4031: } else {
4032: if (!exists($domconfig{'quotas'}{$key})) {
4033: $changes{'defaultquota'}{$key} = 1;
4034: }
1.72 raeburn 4035: }
4036: } else {
1.86 raeburn 4037: $changes{'defaultquota'}{$key} = 1;
1.55 raeburn 4038: }
1.1 raeburn 4039: }
4040: }
4041: }
1.72 raeburn 4042:
4043: foreach my $key (keys(%confhash)) {
4044: $domdefaults{$key} = $confhash{$key};
4045: }
4046:
1.1 raeburn 4047: my %quotahash = (
1.86 raeburn 4048: $action => { %confhash }
1.1 raeburn 4049: );
4050: my $putresult = &Apache::lonnet::put_dom('configuration',\%quotahash,
4051: $dom);
4052: if ($putresult eq 'ok') {
4053: if (keys(%changes) > 0) {
1.72 raeburn 4054: my $cachetime = 24*60*60;
4055: &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
4056:
1.1 raeburn 4057: $resulttext = &mt('Changes made:').'<ul>';
1.86 raeburn 4058: unless ($context eq 'requestcourses') {
4059: if (ref($changes{'defaultquota'}) eq 'HASH') {
4060: $resulttext .= '<li>'.&mt('Portfolio default quotas').'<ul>';
4061: foreach my $type (@{$types},'default') {
4062: if (defined($changes{'defaultquota'}{$type})) {
4063: my $typetitle = $usertypes->{$type};
4064: if ($type eq 'default') {
4065: $typetitle = $othertitle;
4066: }
4067: $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'defaultquota'}{$type}).'</li>';
1.72 raeburn 4068: }
4069: }
1.86 raeburn 4070: $resulttext .= '</ul></li>';
1.72 raeburn 4071: }
4072: }
1.80 raeburn 4073: my %newenv;
1.72 raeburn 4074: foreach my $item (@usertools) {
4075: if (ref($changes{$item}) eq 'HASH') {
1.80 raeburn 4076: my $newacc =
4077: &Apache::lonnet::usertools_access($env{'user.name'},
4078: $env{'user.domain'},
1.86 raeburn 4079: $item,'reload',$context);
4080: if ($context eq 'requestcourses') {
1.108 raeburn 4081: if ($env{'environment.canrequest.'.$item} ne $newacc) {
4082: $newenv{'environment.canrequest.'.$item} = $newacc;
1.86 raeburn 4083: }
4084: } else {
4085: if ($env{'environment.availabletools.'.$item} ne $newacc) {
4086: $newenv{'environment.availabletools.'.$item} = $newacc;
4087: }
1.80 raeburn 4088: }
1.72 raeburn 4089: $resulttext .= '<li>'.$titles{$item}.'<ul>';
4090: foreach my $type (@{$types},'default','_LC_adv') {
4091: if ($changes{$item}{$type}) {
4092: my $typetitle = $usertypes->{$type};
4093: if ($type eq 'default') {
4094: $typetitle = $othertitle;
4095: } elsif ($type eq '_LC_adv') {
4096: $typetitle = 'LON-CAPA Advanced Users';
4097: }
4098: if ($confhash{$item}{$type}) {
1.101 raeburn 4099: if ($context eq 'requestcourses') {
4100: my $cond;
4101: if ($confhash{$item}{$type} =~ /^autolimit=(\d*)$/) {
4102: if ($1 eq '') {
4103: $cond = &mt('(Automatic processing of any request).');
4104: } else {
4105: $cond = &mt('(Automatic processing of requests up to limit of [quant,_1,request] per user).',$1);
4106: }
4107: } else {
4108: $cond = $conditions{$confhash{$item}{$type}};
4109: }
4110: $resulttext .= '<li>'.&mt('Set to be available to [_1].',$typetitle).' '.$cond.'</li>';
4111: } else {
4112: $resulttext .= '<li>'.&mt('Set to be available to [_1]',$typetitle).'</li>';
4113: }
1.72 raeburn 4114: } else {
1.104 raeburn 4115: if ($type eq '_LC_adv') {
4116: if ($confhash{$item}{$type} eq '0') {
4117: $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
4118: } else {
4119: $resulttext .= '<li>'.&mt('No override set for [_1]',$typetitle).'</li>';
4120: }
4121: } else {
4122: $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
4123: }
1.72 raeburn 4124: }
4125: }
1.26 raeburn 4126: }
1.72 raeburn 4127: $resulttext .= '</ul></li>';
1.26 raeburn 4128: }
1.1 raeburn 4129: }
1.102 raeburn 4130: if ($action eq 'requestcourses') {
4131: if (ref($changes{'notify'}) eq 'HASH') {
4132: if ($changes{'notify'}{'approval'}) {
4133: if (ref($confhash{'notify'}) eq 'HASH') {
4134: if ($confhash{'notify'}{'approval'}) {
4135: $resulttext .= '<li>'.&mt('Notification of requests requiring approval will be sent to: ').$confhash{'notify'}{'approval'}.'</li>';
4136: } else {
4137: $resulttext .= '<li>'.&mt('No Domain Coordinators will receive notification of course requests requiring approval.').'</li>';
4138: }
4139: }
4140: }
4141: }
4142: }
1.1 raeburn 4143: $resulttext .= '</ul>';
1.80 raeburn 4144: if (keys(%newenv)) {
4145: &Apache::lonnet::appenv(\%newenv);
4146: }
1.1 raeburn 4147: } else {
1.86 raeburn 4148: if ($context eq 'requestcourses') {
4149: $resulttext = &mt('No changes made to rights to request creation of courses.');
4150: } else {
1.90 weissno 4151: $resulttext = &mt('No changes made to availability of personal information pages, blogs, portfolios or default quotas');
1.86 raeburn 4152: }
1.1 raeburn 4153: }
4154: } else {
1.11 albertel 4155: $resulttext = '<span class="LC_error">'.
4156: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 4157: }
1.3 raeburn 4158: return $resulttext;
1.1 raeburn 4159: }
4160:
1.3 raeburn 4161: sub modify_autoenroll {
4162: my ($dom,%domconfig) = @_;
1.1 raeburn 4163: my ($resulttext,%changes);
4164: my %currautoenroll;
4165: if (ref($domconfig{'autoenroll'}) eq 'HASH') {
4166: foreach my $key (keys(%{$domconfig{'autoenroll'}})) {
4167: $currautoenroll{$key} = $domconfig{'autoenroll'}{$key};
4168: }
4169: }
4170: my $autorun = &Apache::lonnet::auto_run(undef,$dom),
4171: my %title = ( run => 'Auto-enrollment active',
4172: sender => 'Sender for notification messages');
4173: my @offon = ('off','on');
1.17 raeburn 4174: my $sender_uname = $env{'form.sender_uname'};
4175: my $sender_domain = $env{'form.sender_domain'};
4176: if ($sender_domain eq '') {
4177: $sender_uname = '';
4178: } elsif ($sender_uname eq '') {
4179: $sender_domain = '';
4180: }
1.1 raeburn 4181: my %autoenrollhash = (
4182: autoenroll => { run => $env{'form.autoenroll_run'},
1.17 raeburn 4183: sender_uname => $sender_uname,
4184: sender_domain => $sender_domain,
1.1 raeburn 4185:
4186: }
4187: );
1.4 raeburn 4188: my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
4189: $dom);
1.1 raeburn 4190: if ($putresult eq 'ok') {
4191: if (exists($currautoenroll{'run'})) {
4192: if ($currautoenroll{'run'} ne $env{'form.autoenroll_run'}) {
4193: $changes{'run'} = 1;
4194: }
4195: } elsif ($autorun) {
4196: if ($env{'form.autoenroll_run'} ne '1') {
1.23 raeburn 4197: $changes{'run'} = 1;
1.1 raeburn 4198: }
4199: }
1.17 raeburn 4200: if ($currautoenroll{'sender_uname'} ne $sender_uname) {
1.1 raeburn 4201: $changes{'sender'} = 1;
4202: }
1.17 raeburn 4203: if ($currautoenroll{'sender_domain'} ne $sender_domain) {
1.1 raeburn 4204: $changes{'sender'} = 1;
4205: }
4206: if (keys(%changes) > 0) {
4207: $resulttext = &mt('Changes made:').'<ul>';
1.3 raeburn 4208: if ($changes{'run'}) {
1.1 raeburn 4209: $resulttext .= '<li>'.&mt("$title{'run'} set to $offon[$env{'form.autoenroll_run'}]").'</li>';
4210: }
4211: if ($changes{'sender'}) {
1.17 raeburn 4212: if ($sender_uname eq '' || $sender_domain eq '') {
4213: $resulttext .= '<li>'.&mt("$title{'sender'} set to default (course owner).").'</li>';
4214: } else {
4215: $resulttext .= '<li>'.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'</li>';
4216: }
1.1 raeburn 4217: }
4218: $resulttext .= '</ul>';
4219: } else {
4220: $resulttext = &mt('No changes made to auto-enrollment settings');
4221: }
4222: } else {
1.11 albertel 4223: $resulttext = '<span class="LC_error">'.
4224: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 4225: }
1.3 raeburn 4226: return $resulttext;
1.1 raeburn 4227: }
4228:
4229: sub modify_autoupdate {
1.3 raeburn 4230: my ($dom,%domconfig) = @_;
1.1 raeburn 4231: my ($resulttext,%currautoupdate,%fields,%changes);
4232: if (ref($domconfig{'autoupdate'}) eq 'HASH') {
4233: foreach my $key (keys(%{$domconfig{'autoupdate'}})) {
4234: $currautoupdate{$key} = $domconfig{'autoupdate'}{$key};
4235: }
4236: }
4237: my @offon = ('off','on');
4238: my %title = &Apache::lonlocal::texthash (
4239: run => 'Auto-update:',
4240: classlists => 'Updates to user information in classlists?'
4241: );
1.44 raeburn 4242: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.1 raeburn 4243: my %fieldtitles = &Apache::lonlocal::texthash (
4244: id => 'Student/Employee ID',
1.20 raeburn 4245: permanentemail => 'E-mail address',
1.1 raeburn 4246: lastname => 'Last Name',
4247: firstname => 'First Name',
4248: middlename => 'Middle Name',
4249: gen => 'Generation',
4250: );
4251: my $othertitle = &mt('All users');
4252: if (keys(%{$usertypes}) > 0) {
1.26 raeburn 4253: $othertitle = &mt('Other users');
1.1 raeburn 4254: }
4255: foreach my $key (keys(%env)) {
4256: if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {
4257: push(@{$fields{$1}},$2);
4258: }
4259: }
4260: my %updatehash = (
4261: autoupdate => { run => $env{'form.autoupdate_run'},
4262: classlists => $env{'form.classlists'},
4263: fields => {%fields},
4264: }
4265: );
4266: foreach my $key (keys(%currautoupdate)) {
4267: if (($key eq 'run') || ($key eq 'classlists')) {
4268: if (exists($updatehash{autoupdate}{$key})) {
4269: if ($currautoupdate{$key} ne $updatehash{autoupdate}{$key}) {
4270: $changes{$key} = 1;
4271: }
4272: }
4273: } elsif ($key eq 'fields') {
4274: if (ref($currautoupdate{$key}) eq 'HASH') {
1.26 raeburn 4275: foreach my $item (@{$types},'default') {
1.1 raeburn 4276: if (ref($currautoupdate{$key}{$item}) eq 'ARRAY') {
4277: my $change = 0;
4278: foreach my $type (@{$currautoupdate{$key}{$item}}) {
4279: if (!exists($fields{$item})) {
4280: $change = 1;
4281: } elsif (ref($fields{$item}) eq 'ARRAY') {
1.26 raeburn 4282: if (!grep(/^\Q$type\E$/,@{$fields{$item}})) {
1.1 raeburn 4283: $change = 1;
4284: }
4285: }
4286: }
4287: if ($change) {
4288: push(@{$changes{$key}},$item);
4289: }
1.26 raeburn 4290: }
1.1 raeburn 4291: }
4292: }
4293: }
4294: }
1.26 raeburn 4295: foreach my $item (@{$types},'default') {
4296: if (defined($fields{$item})) {
4297: if (ref($currautoupdate{'fields'}) eq 'HASH') {
4298: if (!exists($currautoupdate{'fields'}{$item})) {
4299: push(@{$changes{'fields'}},$item);
4300: }
4301: } else {
4302: push(@{$changes{'fields'}},$item);
1.1 raeburn 4303: }
4304: }
4305: }
4306: my $putresult = &Apache::lonnet::put_dom('configuration',\%updatehash,
4307: $dom);
4308: if ($putresult eq 'ok') {
4309: if (keys(%changes) > 0) {
4310: $resulttext = &mt('Changes made:').'<ul>';
4311: foreach my $key (sort(keys(%changes))) {
4312: if (ref($changes{$key}) eq 'ARRAY') {
4313: foreach my $item (@{$changes{$key}}) {
4314: my @newvalues;
4315: foreach my $type (@{$fields{$item}}) {
4316: push(@newvalues,$fieldtitles{$type});
4317: }
1.3 raeburn 4318: my $newvaluestr;
4319: if (@newvalues > 0) {
4320: $newvaluestr = join(', ',@newvalues);
4321: } else {
4322: $newvaluestr = &mt('none');
1.6 raeburn 4323: }
1.1 raeburn 4324: if ($item eq 'default') {
1.26 raeburn 4325: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$othertitle,$newvaluestr).'</li>';
1.1 raeburn 4326: } else {
1.26 raeburn 4327: $resulttext .= '<li>'.&mt("Updates for '[_1]' set to: '[_2]'",$usertypes->{$item},$newvaluestr).'</li>';
1.1 raeburn 4328: }
4329: }
4330: } else {
4331: my $newvalue;
4332: if ($key eq 'run') {
4333: $newvalue = $offon[$env{'form.autoupdate_run'}];
4334: } else {
4335: $newvalue = $offon[$env{'form.'.$key}];
1.3 raeburn 4336: }
1.1 raeburn 4337: $resulttext .= '<li>'.&mt("[_1] set to $newvalue",$title{$key}).'</li>';
4338: }
4339: }
4340: $resulttext .= '</ul>';
4341: } else {
1.3 raeburn 4342: $resulttext = &mt('No changes made to autoupdates');
1.1 raeburn 4343: }
4344: } else {
1.11 albertel 4345: $resulttext = '<span class="LC_error">'.
4346: &mt('An error occurred: [_1]',$putresult).'</span>';
1.1 raeburn 4347: }
1.3 raeburn 4348: return $resulttext;
1.1 raeburn 4349: }
4350:
1.23 raeburn 4351: sub modify_directorysrch {
4352: my ($dom,%domconfig) = @_;
4353: my ($resulttext,%changes);
4354: my %currdirsrch;
4355: if (ref($domconfig{'directorysrch'}) eq 'HASH') {
4356: foreach my $key (keys(%{$domconfig{'directorysrch'}})) {
4357: $currdirsrch{$key} = $domconfig{'directorysrch'}{$key};
4358: }
4359: }
4360: my %title = ( available => 'Directory search available',
1.24 raeburn 4361: localonly => 'Other domains can search',
1.23 raeburn 4362: searchby => 'Search types',
4363: searchtypes => 'Search latitude');
4364: my @offon = ('off','on');
1.24 raeburn 4365: my @otherdoms = ('Yes','No');
1.23 raeburn 4366:
1.25 raeburn 4367: my @searchtypes = &Apache::loncommon::get_env_multiple('form.searchtypes');
1.23 raeburn 4368: my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch');
4369: my @searchby = &Apache::loncommon::get_env_multiple('form.searchby');
4370:
1.44 raeburn 4371: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
1.26 raeburn 4372: if (keys(%{$usertypes}) == 0) {
4373: @cansearch = ('default');
4374: } else {
4375: if (ref($currdirsrch{'cansearch'}) eq 'ARRAY') {
4376: foreach my $type (@{$currdirsrch{'cansearch'}}) {
4377: if (!grep(/^\Q$type\E$/,@cansearch)) {
4378: push(@{$changes{'cansearch'}},$type);
4379: }
1.23 raeburn 4380: }
1.26 raeburn 4381: foreach my $type (@cansearch) {
4382: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'cansearch'}})) {
4383: push(@{$changes{'cansearch'}},$type);
4384: }
1.23 raeburn 4385: }
1.26 raeburn 4386: } else {
4387: push(@{$changes{'cansearch'}},@cansearch);
1.23 raeburn 4388: }
4389: }
4390:
4391: if (ref($currdirsrch{'searchby'}) eq 'ARRAY') {
4392: foreach my $by (@{$currdirsrch{'searchby'}}) {
4393: if (!grep(/^\Q$by\E$/,@searchby)) {
4394: push(@{$changes{'searchby'}},$by);
4395: }
4396: }
4397: foreach my $by (@searchby) {
4398: if (!grep(/^\Q$by\E$/,@{$currdirsrch{'searchby'}})) {
4399: push(@{$changes{'searchby'}},$by);
4400: }
4401: }
4402: } else {
4403: push(@{$changes{'searchby'}},@searchby);
4404: }
1.25 raeburn 4405:
4406: if (ref($currdirsrch{'searchtypes'}) eq 'ARRAY') {
4407: foreach my $type (@{$currdirsrch{'searchtypes'}}) {
4408: if (!grep(/^\Q$type\E$/,@searchtypes)) {
4409: push(@{$changes{'searchtypes'}},$type);
4410: }
4411: }
4412: foreach my $type (@searchtypes) {
4413: if (!grep(/^\Q$type\E$/,@{$currdirsrch{'searchtypes'}})) {
4414: push(@{$changes{'searchtypes'}},$type);
4415: }
4416: }
4417: } else {
4418: if (exists($currdirsrch{'searchtypes'})) {
4419: foreach my $type (@searchtypes) {
4420: if ($type ne $currdirsrch{'searchtypes'}) {
4421: push(@{$changes{'searchtypes'}},$type);
4422: }
4423: }
4424: if (!grep(/^\Q$currdirsrch{'searchtypes'}\E/,@searchtypes)) {
4425: push(@{$changes{'searchtypes'}},$currdirsrch{'searchtypes'});
4426: }
4427: } else {
4428: push(@{$changes{'searchtypes'}},@searchtypes);
4429: }
4430: }
4431:
1.23 raeburn 4432: my %dirsrch_hash = (
4433: directorysrch => { available => $env{'form.dirsrch_available'},
4434: cansearch => \@cansearch,
1.24 raeburn 4435: localonly => $env{'form.dirsrch_localonly'},
1.23 raeburn 4436: searchby => \@searchby,
1.25 raeburn 4437: searchtypes => \@searchtypes,
1.23 raeburn 4438: }
4439: );
4440: my $putresult = &Apache::lonnet::put_dom('configuration',\%dirsrch_hash,
4441: $dom);
4442: if ($putresult eq 'ok') {
4443: if (exists($currdirsrch{'available'})) {
4444: if ($currdirsrch{'available'} ne $env{'form.dirsrch_available'}) {
4445: $changes{'available'} = 1;
4446: }
4447: } else {
4448: if ($env{'form.dirsrch_available'} eq '1') {
4449: $changes{'available'} = 1;
4450: }
4451: }
1.24 raeburn 4452: if (exists($currdirsrch{'localonly'})) {
4453: if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_localonly'}) {
4454: $changes{'localonly'} = 1;
4455: }
4456: } else {
4457: if ($env{'form.dirsrch_localonly'} eq '1') {
4458: $changes{'localonly'} = 1;
4459: }
4460: }
1.23 raeburn 4461: if (keys(%changes) > 0) {
4462: $resulttext = &mt('Changes made:').'<ul>';
4463: if ($changes{'available'}) {
4464: $resulttext .= '<li>'.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").'</li>';
4465: }
1.24 raeburn 4466: if ($changes{'localonly'}) {
4467: $resulttext .= '<li>'.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_localonly'}]").'</li>';
4468: }
4469:
1.23 raeburn 4470: if (ref($changes{'cansearch'}) eq 'ARRAY') {
4471: my $chgtext;
1.26 raeburn 4472: if (ref($usertypes) eq 'HASH') {
4473: if (keys(%{$usertypes}) > 0) {
4474: foreach my $type (@{$types}) {
4475: if (grep(/^\Q$type\E$/,@cansearch)) {
4476: $chgtext .= $usertypes->{$type}.'; ';
4477: }
4478: }
4479: if (grep(/^default$/,@cansearch)) {
4480: $chgtext .= $othertitle;
4481: } else {
4482: $chgtext =~ s/\; $//;
4483: }
4484: $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 4485: }
4486: }
4487: }
4488: if (ref($changes{'searchby'}) eq 'ARRAY') {
4489: my ($searchtitles,$titleorder) = &sorted_searchtitles();
4490: my $chgtext;
4491: foreach my $type (@{$titleorder}) {
4492: if (grep(/^\Q$type\E$/,@searchby)) {
4493: if (defined($searchtitles->{$type})) {
4494: $chgtext .= $searchtitles->{$type}.'; ';
4495: }
4496: }
4497: }
4498: $chgtext =~ s/\; $//;
4499: $resulttext .= '<li>'.&mt("$title{'searchby'} set to: [_1]",$chgtext).'</li>';
4500: }
1.25 raeburn 4501: if (ref($changes{'searchtypes'}) eq 'ARRAY') {
4502: my ($srchtypes_desc,$srchtypeorder) = &sorted_searchtypes();
4503: my $chgtext;
4504: foreach my $type (@{$srchtypeorder}) {
4505: if (grep(/^\Q$type\E$/,@searchtypes)) {
4506: if (defined($srchtypes_desc->{$type})) {
4507: $chgtext .= $srchtypes_desc->{$type}.'; ';
4508: }
4509: }
4510: }
4511: $chgtext =~ s/\; $//;
4512: $resulttext .= '<li>'.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).'</li>';
1.23 raeburn 4513: }
4514: $resulttext .= '</ul>';
4515: } else {
4516: $resulttext = &mt('No changes made to institution directory search settings');
4517: }
4518: } else {
4519: $resulttext = '<span class="LC_error">'.
1.27 raeburn 4520: &mt('An error occurred: [_1]',$putresult).'</span>';
4521: }
4522: return $resulttext;
4523: }
4524:
1.28 raeburn 4525: sub modify_contacts {
4526: my ($dom,%domconfig) = @_;
4527: my ($resulttext,%currsetting,%newsetting,%changes,%contacts_hash);
4528: if (ref($domconfig{'contacts'}) eq 'HASH') {
4529: foreach my $key (keys(%{$domconfig{'contacts'}})) {
4530: $currsetting{$key} = $domconfig{'contacts'}{$key};
4531: }
4532: }
4533: my (%others,%to);
4534: my @contacts = ('supportemail','adminemail');
1.102 raeburn 4535: my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail',
4536: 'requestsmail');
1.28 raeburn 4537: foreach my $type (@mailings) {
4538: @{$newsetting{$type}} =
4539: &Apache::loncommon::get_env_multiple('form.'.$type);
4540: foreach my $item (@contacts) {
4541: if (grep(/^\Q$item\E$/,@{$newsetting{$type}})) {
4542: $contacts_hash{contacts}{$type}{$item} = 1;
4543: } else {
4544: $contacts_hash{contacts}{$type}{$item} = 0;
4545: }
4546: }
4547: $others{$type} = $env{'form.'.$type.'_others'};
4548: $contacts_hash{contacts}{$type}{'others'} = $others{$type};
4549: }
4550: foreach my $item (@contacts) {
4551: $to{$item} = $env{'form.'.$item};
4552: $contacts_hash{'contacts'}{$item} = $to{$item};
4553: }
4554: if (keys(%currsetting) > 0) {
4555: foreach my $item (@contacts) {
4556: if ($to{$item} ne $currsetting{$item}) {
4557: $changes{$item} = 1;
4558: }
4559: }
4560: foreach my $type (@mailings) {
4561: foreach my $item (@contacts) {
4562: if (ref($currsetting{$type}) eq 'HASH') {
4563: if ($currsetting{$type}{$item} ne $contacts_hash{contacts}{$type}{$item}) {
4564: push(@{$changes{$type}},$item);
4565: }
4566: } else {
4567: push(@{$changes{$type}},@{$newsetting{$type}});
4568: }
4569: }
4570: if ($others{$type} ne $currsetting{$type}{'others'}) {
4571: push(@{$changes{$type}},'others');
4572: }
4573: }
4574: } else {
4575: my %default;
4576: $default{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
4577: $default{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
4578: $default{'errormail'} = 'adminemail';
4579: $default{'packagesmail'} = 'adminemail';
4580: $default{'helpdeskmail'} = 'supportemail';
1.89 raeburn 4581: $default{'lonstatusmail'} = 'adminemail';
1.102 raeburn 4582: $default{'requestsmail'} = 'adminemail';
1.28 raeburn 4583: foreach my $item (@contacts) {
4584: if ($to{$item} ne $default{$item}) {
4585: $changes{$item} = 1;
4586: }
4587: }
4588: foreach my $type (@mailings) {
4589: if ((@{$newsetting{$type}} != 1) || ($newsetting{$type}[0] ne $default{$type})) {
4590:
4591: push(@{$changes{$type}},@{$newsetting{$type}});
4592: }
4593: if ($others{$type} ne '') {
4594: push(@{$changes{$type}},'others');
4595: }
4596: }
4597: }
4598: my $putresult = &Apache::lonnet::put_dom('configuration',\%contacts_hash,
4599: $dom);
4600: if ($putresult eq 'ok') {
4601: if (keys(%changes) > 0) {
4602: my ($titles,$short_titles) = &contact_titles();
4603: $resulttext = &mt('Changes made:').'<ul>';
4604: foreach my $item (@contacts) {
4605: if ($changes{$item}) {
4606: $resulttext .= '<li>'.$titles->{$item}.
4607: &mt(' set to: ').
4608: '<span class="LC_cusr_emph">'.
4609: $to{$item}.'</span></li>';
4610: }
4611: }
4612: foreach my $type (@mailings) {
4613: if (ref($changes{$type}) eq 'ARRAY') {
4614: $resulttext .= '<li>'.$titles->{$type}.': ';
4615: my @text;
4616: foreach my $item (@{$newsetting{$type}}) {
4617: push(@text,$short_titles->{$item});
4618: }
4619: if ($others{$type} ne '') {
4620: push(@text,$others{$type});
4621: }
4622: $resulttext .= '<span class="LC_cusr_emph">'.
4623: join(', ',@text).'</span></li>';
4624: }
4625: }
4626: $resulttext .= '</ul>';
4627: } else {
1.34 raeburn 4628: $resulttext = &mt('No changes made to contact information');
1.28 raeburn 4629: }
4630: } else {
4631: $resulttext = '<span class="LC_error">'.
4632: &mt('An error occurred: [_1].',$putresult).'</span>';
4633: }
4634: return $resulttext;
4635: }
4636:
4637: sub modify_usercreation {
1.27 raeburn 4638: my ($dom,%domconfig) = @_;
1.34 raeburn 4639: my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate);
1.43 raeburn 4640: my $warningmsg;
1.27 raeburn 4641: if (ref($domconfig{'usercreation'}) eq 'HASH') {
4642: foreach my $key (keys(%{$domconfig{'usercreation'}})) {
4643: $curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
4644: }
4645: }
4646: my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
1.32 raeburn 4647: my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
1.43 raeburn 4648: my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
1.100 raeburn 4649: my @contexts = ('author','course','requestcrs','selfcreate');
1.34 raeburn 4650: foreach my $item(@contexts) {
1.45 raeburn 4651: if ($item eq 'selfcreate') {
1.50 raeburn 4652: @{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item);
1.43 raeburn 4653: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
4654: if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) {
1.50 raeburn 4655: if (ref($cancreate{$item}) eq 'ARRAY') {
4656: if (grep(/^login$/,@{$cancreate{$item}})) {
4657: $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.');
4658: }
1.43 raeburn 4659: }
4660: }
1.50 raeburn 4661: } else {
4662: $cancreate{$item} = $env{'form.can_createuser_'.$item};
1.43 raeburn 4663: }
1.34 raeburn 4664: }
1.93 raeburn 4665: my ($othertitle,$usertypes,$types) =
4666: &Apache::loncommon::sorted_inst_types($dom);
4667: if (ref($types) eq 'ARRAY') {
4668: if (@{$types} > 0) {
4669: @{$cancreate{'statustocreate'}} =
4670: &Apache::loncommon::get_env_multiple('form.statustocreate');
1.103 raeburn 4671: } else {
4672: @{$cancreate{'statustocreate'}} = ();
1.93 raeburn 4673: }
4674: push(@contexts,'statustocreate');
4675: }
1.34 raeburn 4676: if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
4677: foreach my $item (@contexts) {
1.93 raeburn 4678: if (($item eq 'selfcreate') || ($item eq 'statustocreate')) {
4679: if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
1.50 raeburn 4680: foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) {
1.103 raeburn 4681: if (ref($cancreate{$item}) eq 'ARRAY') {
4682: if (!grep(/^$curr$/,@{$cancreate{$item}})) {
4683: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4684: push(@{$changes{'cancreate'}},$item);
4685: }
1.50 raeburn 4686: }
4687: }
4688: }
4689: } else {
4690: if ($curr_usercreation{'cancreate'}{$item} eq '') {
4691: if (@{$cancreate{$item}} > 0) {
4692: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4693: push(@{$changes{'cancreate'}},$item);
4694: }
4695: }
4696: } else {
4697: if ($curr_usercreation{'cancreate'}{$item} eq 'any') {
4698: if (@{$cancreate{$item}} < 3) {
4699: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4700: push(@{$changes{'cancreate'}},$item);
4701: }
4702: }
4703: } elsif ($curr_usercreation{'cancreate'}{$item} eq 'none') {
4704: if (@{$cancreate{$item}} > 0) {
4705: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4706: push(@{$changes{'cancreate'}},$item);
4707: }
4708: }
4709: } elsif (!grep(/^$curr_usercreation{'cancreate'}{$item}$/,@{$cancreate{$item}})) {
4710: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4711: push(@{$changes{'cancreate'}},$item);
4712: }
4713: }
4714: }
4715: }
4716: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4717: foreach my $type (@{$cancreate{$item}}) {
4718: if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
4719: if (!grep(/^$type$/,@{$curr_usercreation{'cancreate'}{$item}})) {
4720: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4721: push(@{$changes{'cancreate'}},$item);
4722: }
4723: }
4724: } elsif (($curr_usercreation{'cancreate'}{$item} ne 'any') &&
4725: ($curr_usercreation{'cancreate'}{$item} ne 'none')) {
4726: if ($curr_usercreation{'cancreate'}{$item} ne $type) {
4727: if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
4728: push(@{$changes{'cancreate'}},$item);
4729: }
4730: }
4731: }
4732: }
4733: }
4734: } else {
4735: if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) {
4736: push(@{$changes{'cancreate'}},$item);
4737: }
4738: }
1.27 raeburn 4739: }
1.34 raeburn 4740: } elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
4741: foreach my $item (@contexts) {
1.43 raeburn 4742: if (!grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) {
1.34 raeburn 4743: if ($cancreate{$item} ne 'any') {
4744: push(@{$changes{'cancreate'}},$item);
4745: }
4746: } else {
4747: if ($cancreate{$item} ne 'none') {
4748: push(@{$changes{'cancreate'}},$item);
4749: }
1.27 raeburn 4750: }
4751: }
4752: } else {
1.43 raeburn 4753: foreach my $item (@contexts) {
1.34 raeburn 4754: push(@{$changes{'cancreate'}},$item);
4755: }
1.27 raeburn 4756: }
1.34 raeburn 4757:
1.27 raeburn 4758: if (ref($curr_usercreation{'username_rule'}) eq 'ARRAY') {
4759: foreach my $type (@{$curr_usercreation{'username_rule'}}) {
4760: if (!grep(/^\Q$type\E$/,@username_rule)) {
4761: push(@{$changes{'username_rule'}},$type);
4762: }
4763: }
4764: foreach my $type (@username_rule) {
4765: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'username_rule'}})) {
4766: push(@{$changes{'username_rule'}},$type);
4767: }
4768: }
4769: } else {
4770: push(@{$changes{'username_rule'}},@username_rule);
4771: }
4772:
1.32 raeburn 4773: if (ref($curr_usercreation{'id_rule'}) eq 'ARRAY') {
4774: foreach my $type (@{$curr_usercreation{'id_rule'}}) {
4775: if (!grep(/^\Q$type\E$/,@id_rule)) {
4776: push(@{$changes{'id_rule'}},$type);
4777: }
4778: }
4779: foreach my $type (@id_rule) {
4780: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'id_rule'}})) {
4781: push(@{$changes{'id_rule'}},$type);
4782: }
4783: }
4784: } else {
4785: push(@{$changes{'id_rule'}},@id_rule);
4786: }
4787:
1.43 raeburn 4788: if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') {
4789: foreach my $type (@{$curr_usercreation{'email_rule'}}) {
4790: if (!grep(/^\Q$type\E$/,@email_rule)) {
4791: push(@{$changes{'email_rule'}},$type);
4792: }
4793: }
4794: foreach my $type (@email_rule) {
4795: if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'email_rule'}})) {
4796: push(@{$changes{'email_rule'}},$type);
4797: }
4798: }
4799: } else {
4800: push(@{$changes{'email_rule'}},@email_rule);
4801: }
4802:
4803: my @authen_contexts = ('author','course','domain');
1.28 raeburn 4804: my @authtypes = ('int','krb4','krb5','loc');
4805: my %authhash;
1.43 raeburn 4806: foreach my $item (@authen_contexts) {
1.28 raeburn 4807: my @authallowed = &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');
4808: foreach my $auth (@authtypes) {
4809: if (grep(/^\Q$auth\E$/,@authallowed)) {
4810: $authhash{$item}{$auth} = 1;
4811: } else {
4812: $authhash{$item}{$auth} = 0;
4813: }
4814: }
4815: }
4816: if (ref($curr_usercreation{'authtypes'}) eq 'HASH') {
1.43 raeburn 4817: foreach my $item (@authen_contexts) {
1.28 raeburn 4818: if (ref($curr_usercreation{'authtypes'}{$item}) eq 'HASH') {
4819: foreach my $auth (@authtypes) {
4820: if ($authhash{$item}{$auth} ne $curr_usercreation{'authtypes'}{$item}{$auth}) {
4821: push(@{$changes{'authtypes'}},$item);
4822: last;
4823: }
4824: }
4825: }
4826: }
4827: } else {
1.43 raeburn 4828: foreach my $item (@authen_contexts) {
1.28 raeburn 4829: push(@{$changes{'authtypes'}},$item);
4830: }
4831: }
4832:
1.27 raeburn 4833: my %usercreation_hash = (
1.28 raeburn 4834: usercreation => {
1.34 raeburn 4835: cancreate => \%cancreate,
1.27 raeburn 4836: username_rule => \@username_rule,
1.32 raeburn 4837: id_rule => \@id_rule,
1.43 raeburn 4838: email_rule => \@email_rule,
1.32 raeburn 4839: authtypes => \%authhash,
1.27 raeburn 4840: }
4841: );
4842:
4843: my $putresult = &Apache::lonnet::put_dom('configuration',\%usercreation_hash,
4844: $dom);
1.50 raeburn 4845:
4846: my %selfcreatetypes = (
4847: sso => 'users authenticated by institutional single sign on',
4848: login => 'users authenticated by institutional log-in',
4849: email => 'users who provide a valid e-mail address for use as the username',
4850: );
1.27 raeburn 4851: if ($putresult eq 'ok') {
4852: if (keys(%changes) > 0) {
4853: $resulttext = &mt('Changes made:').'<ul>';
4854: if (ref($changes{'cancreate'}) eq 'ARRAY') {
1.34 raeburn 4855: my %lt = &usercreation_types();
4856: foreach my $type (@{$changes{'cancreate'}}) {
1.100 raeburn 4857: my $chgtext;
4858: unless ($type eq 'statustocreate') {
4859: $chgtext = $lt{$type}.', ';
4860: }
1.45 raeburn 4861: if ($type eq 'selfcreate') {
1.50 raeburn 4862: if (@{$cancreate{$type}} == 0) {
1.43 raeburn 4863: $chgtext .= &mt('creation of a new user account is not permitted.');
1.50 raeburn 4864: } else {
1.100 raeburn 4865: $chgtext .= &mt('creation of a new account is permitted for:').'<ul>';
1.50 raeburn 4866: foreach my $case (@{$cancreate{$type}}) {
4867: $chgtext .= '<li>'.$selfcreatetypes{$case}.'</li>';
4868: }
4869: $chgtext .= '</ul>';
1.100 raeburn 4870: if (ref($cancreate{$type}) eq 'ARRAY') {
4871: if (grep(/^(login|sso)$/,@{$cancreate{$type}})) {
4872: if (ref($cancreate{'statustocreate'}) eq 'ARRAY') {
4873: if (@{$cancreate{'statustocreate'}} == 0) {
4874: $chgtext .= '<br /><span class="LC_warning">'.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'</span>';
4875: }
4876: }
4877: }
4878: }
1.43 raeburn 4879: }
1.93 raeburn 4880: } elsif ($type eq 'statustocreate') {
1.96 raeburn 4881: if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') &&
4882: (ref($cancreate{'statustocreate'}) eq 'ARRAY')) {
4883: if (@{$cancreate{'selfcreate'}} > 0) {
4884: if (@{$cancreate{'statustocreate'}} == 0) {
1.100 raeburn 4885:
4886: $chgtext .= &mt("Institutional affiliations permitted to create accounts set to 'None'.");
1.96 raeburn 4887: if (!grep(/^email$/,@{$cancreate{'selfcreate'}})) {
1.100 raeburn 4888: $chgtext .= '<br /><span class="LC_warning">'.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'</span>';
4889: }
1.96 raeburn 4890: } elsif (ref($usertypes) eq 'HASH') {
4891: if (grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
1.100 raeburn 4892: $chgtext .= &mt('Creation of a new account for an institutional user is restricted to the following institutional affiliation(s):');
4893: } else {
4894: $chgtext .= &mt('Institutional affiliations permitted to create accounts with institutional authentication were set as follows:');
4895: }
4896: $chgtext .= '<ul>';
4897: foreach my $case (@{$cancreate{$type}}) {
4898: if ($case eq 'default') {
4899: $chgtext .= '<li>'.$othertitle.'</li>';
4900: } else {
4901: $chgtext .= '<li>'.$usertypes->{$case}.'</li>';
1.93 raeburn 4902: }
4903: }
1.100 raeburn 4904: $chgtext .= '</ul>';
4905: if (!grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
4906: $chgtext .= '<br /><span class="LC_warning">'.&mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').'</span>';
4907: }
4908: }
4909: } else {
4910: if (@{$cancreate{$type}} == 0) {
4911: $chgtext .= &mt("Institutional affiliations permitted to create accounts were set to 'none'.");
4912: } else {
4913: $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 4914: }
4915: }
4916: }
1.43 raeburn 4917: } else {
4918: if ($cancreate{$type} eq 'none') {
4919: $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.');
4920: } elsif ($cancreate{$type} eq 'any') {
4921: $chgtext .= &mt('creation of new users is permitted for both institutional and non-institutional usernames.');
4922: } elsif ($cancreate{$type} eq 'official') {
4923: $chgtext .= &mt('creation of new users is only permitted for institutional usernames.');
4924: } elsif ($cancreate{$type} eq 'unofficial') {
4925: $chgtext .= &mt('creation of new users is only permitted for non-institutional usernames.');
4926: }
1.34 raeburn 4927: }
4928: $resulttext .= '<li>'.$chgtext.'</li>';
1.27 raeburn 4929: }
4930: }
4931: if (ref($changes{'username_rule'}) eq 'ARRAY') {
1.32 raeburn 4932: my ($rules,$ruleorder) =
4933: &Apache::lonnet::inst_userrules($dom,'username');
1.27 raeburn 4934: my $chgtext = '<ul>';
4935: foreach my $type (@username_rule) {
4936: if (ref($rules->{$type}) eq 'HASH') {
4937: $chgtext .= '<li>'.$rules->{$type}{'name'}.'</li>';
4938: }
4939: }
4940: $chgtext .= '</ul>';
4941: if (@username_rule > 0) {
4942: $resulttext .= '<li>'.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
4943: } else {
1.28 raeburn 4944: $resulttext .= '<li>'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'</li>';
1.27 raeburn 4945: }
4946: }
1.32 raeburn 4947: if (ref($changes{'id_rule'}) eq 'ARRAY') {
4948: my ($idrules,$idruleorder) =
4949: &Apache::lonnet::inst_userrules($dom,'id');
4950: my $chgtext = '<ul>';
4951: foreach my $type (@id_rule) {
4952: if (ref($idrules->{$type}) eq 'HASH') {
4953: $chgtext .= '<li>'.$idrules->{$type}{'name'}.'</li>';
4954: }
4955: }
4956: $chgtext .= '</ul>';
4957: if (@id_rule > 0) {
4958: $resulttext .= '<li>'.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>';
4959: } else {
4960: $resulttext .= '<li>'.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'</li>';
4961: }
4962: }
1.43 raeburn 4963: if (ref($changes{'email_rule'}) eq 'ARRAY') {
4964: my ($emailrules,$emailruleorder) =
4965: &Apache::lonnet::inst_userrules($dom,'email');
4966: my $chgtext = '<ul>';
4967: foreach my $type (@email_rule) {
4968: if (ref($emailrules->{$type}) eq 'HASH') {
4969: $chgtext .= '<li>'.$emailrules->{$type}{'name'}.'</li>';
4970: }
4971: }
4972: $chgtext .= '</ul>';
4973: if (@email_rule > 0) {
4974: $resulttext .= '<li>'.&mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: ').$chgtext.'</li>';
4975: } else {
4976: $resulttext .= '<li>'.&mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.').'</li>';
4977: }
4978: }
4979:
1.28 raeburn 4980: my %authname = &authtype_names();
4981: my %context_title = &context_names();
4982: if (ref($changes{'authtypes'}) eq 'ARRAY') {
4983: my $chgtext = '<ul>';
4984: foreach my $type (@{$changes{'authtypes'}}) {
4985: my @allowed;
4986: $chgtext .= '<li><span class="LC_cusr_emph">'.$context_title{$type}.'</span> - '.&mt('assignable authentication types: ');
4987: foreach my $auth (@authtypes) {
4988: if ($authhash{$type}{$auth}) {
4989: push(@allowed,$authname{$auth});
4990: }
4991: }
1.43 raeburn 4992: if (@allowed > 0) {
4993: $chgtext .= join(', ',@allowed).'</li>';
4994: } else {
4995: $chgtext .= &mt('none').'</li>';
4996: }
1.28 raeburn 4997: }
4998: $chgtext .= '</ul>';
4999: $resulttext .= '<li>'.&mt('Authentication types available for assignment to new users').'<br />'.$chgtext;
5000: $resulttext .= '</li>';
5001: }
1.27 raeburn 5002: $resulttext .= '</ul>';
5003: } else {
1.28 raeburn 5004: $resulttext = &mt('No changes made to user creation settings');
1.27 raeburn 5005: }
5006: } else {
5007: $resulttext = '<span class="LC_error">'.
1.23 raeburn 5008: &mt('An error occurred: [_1]',$putresult).'</span>';
5009: }
1.43 raeburn 5010: if ($warningmsg ne '') {
5011: $resulttext .= '<br /><span class="LC_warning">'.$warningmsg.'</span><br />';
5012: }
1.23 raeburn 5013: return $resulttext;
5014: }
5015:
1.33 raeburn 5016: sub modify_usermodification {
5017: my ($dom,%domconfig) = @_;
5018: my ($resulttext,%curr_usermodification,%changes);
5019: if (ref($domconfig{'usermodification'}) eq 'HASH') {
5020: foreach my $key (keys(%{$domconfig{'usermodification'}})) {
5021: $curr_usermodification{$key} = $domconfig{'usermodification'}{$key};
5022: }
5023: }
1.63 raeburn 5024: my @contexts = ('author','course','selfcreate');
1.33 raeburn 5025: my %context_title = (
5026: author => 'In author context',
5027: course => 'In course context',
1.63 raeburn 5028: selfcreate => 'When self creating account',
1.33 raeburn 5029: );
5030: my @fields = ('lastname','firstname','middlename','generation',
5031: 'permanentemail','id');
5032: my %roles = (
5033: author => ['ca','aa'],
5034: course => ['st','ep','ta','in','cr'],
5035: );
1.63 raeburn 5036: my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
5037: if (ref($types) eq 'ARRAY') {
5038: push(@{$types},'default');
5039: $usertypes->{'default'} = $othertitle;
5040: }
5041: $roles{'selfcreate'} = $types;
1.33 raeburn 5042: my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
5043: my %modifyhash;
5044: foreach my $context (@contexts) {
5045: foreach my $role (@{$roles{$context}}) {
5046: my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role);
5047: foreach my $item (@fields) {
5048: if (grep(/^\Q$item\E$/,@modifiable)) {
5049: $modifyhash{$context}{$role}{$item} = 1;
5050: } else {
5051: $modifyhash{$context}{$role}{$item} = 0;
5052: }
5053: }
5054: }
5055: if (ref($curr_usermodification{$context}) eq 'HASH') {
5056: foreach my $role (@{$roles{$context}}) {
5057: if (ref($curr_usermodification{$context}{$role}) eq 'HASH') {
5058: foreach my $field (@fields) {
5059: if ($modifyhash{$context}{$role}{$field} ne
5060: $curr_usermodification{$context}{$role}{$field}) {
5061: push(@{$changes{$context}},$role);
5062: last;
5063: }
5064: }
5065: }
5066: }
5067: } else {
5068: foreach my $context (@contexts) {
5069: foreach my $role (@{$roles{$context}}) {
5070: push(@{$changes{$context}},$role);
5071: }
5072: }
5073: }
5074: }
5075: my %usermodification_hash = (
5076: usermodification => \%modifyhash,
5077: );
5078: my $putresult = &Apache::lonnet::put_dom('configuration',
5079: \%usermodification_hash,$dom);
5080: if ($putresult eq 'ok') {
5081: if (keys(%changes) > 0) {
5082: $resulttext = &mt('Changes made: ').'<ul>';
5083: foreach my $context (@contexts) {
5084: if (ref($changes{$context}) eq 'ARRAY') {
5085: $resulttext .= '<li>'.$context_title{$context}.':<ul>';
5086: if (ref($changes{$context}) eq 'ARRAY') {
5087: foreach my $role (@{$changes{$context}}) {
5088: my $rolename;
1.63 raeburn 5089: if ($context eq 'selfcreate') {
5090: $rolename = $role;
5091: if (ref($usertypes) eq 'HASH') {
5092: if ($usertypes->{$role} ne '') {
5093: $rolename = $usertypes->{$role};
5094: }
5095: }
1.33 raeburn 5096: } else {
1.63 raeburn 5097: if ($role eq 'cr') {
5098: $rolename = &mt('Custom');
5099: } else {
5100: $rolename = &Apache::lonnet::plaintext($role);
5101: }
1.33 raeburn 5102: }
5103: my @modifiable;
1.63 raeburn 5104: if ($context eq 'selfcreate') {
5105: $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): ');
5106: } else {
5107: $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');
5108: }
1.33 raeburn 5109: foreach my $field (@fields) {
5110: if ($modifyhash{$context}{$role}{$field}) {
5111: push(@modifiable,$fieldtitles{$field});
5112: }
5113: }
5114: if (@modifiable > 0) {
5115: $resulttext .= join(', ',@modifiable);
5116: } else {
5117: $resulttext .= &mt('none');
5118: }
5119: $resulttext .= '</li>';
5120: }
5121: $resulttext .= '</ul></li>';
5122: }
5123: }
5124: }
5125: $resulttext .= '</ul>';
5126: } else {
5127: $resulttext = &mt('No changes made to user modification settings');
5128: }
5129: } else {
5130: $resulttext = '<span class="LC_error">'.
5131: &mt('An error occurred: [_1]',$putresult).'</span>';
5132: }
5133: return $resulttext;
5134: }
5135:
1.43 raeburn 5136: sub modify_defaults {
5137: my ($dom,$r) = @_;
5138: my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
5139: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.68 raeburn 5140: my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def');
1.43 raeburn 5141: my @authtypes = ('internal','krb4','krb5','localauth');
5142: foreach my $item (@items) {
5143: $newvalues{$item} = $env{'form.'.$item};
5144: if ($item eq 'auth_def') {
5145: if ($newvalues{$item} ne '') {
5146: if (!grep(/^\Q$newvalues{$item}\E$/,@authtypes)) {
5147: push(@errors,$item);
5148: }
5149: }
5150: } elsif ($item eq 'lang_def') {
5151: if ($newvalues{$item} ne '') {
5152: if ($newvalues{$item} =~ /^(\w+)/) {
5153: my $langcode = $1;
1.103 raeburn 5154: if ($langcode ne 'x_chef') {
5155: if (code2language($langcode) eq '') {
5156: push(@errors,$item);
5157: }
1.43 raeburn 5158: }
5159: } else {
5160: push(@errors,$item);
5161: }
5162: }
1.54 raeburn 5163: } elsif ($item eq 'timezone_def') {
5164: if ($newvalues{$item} ne '') {
1.62 raeburn 5165: if (!DateTime::TimeZone->is_valid_name($newvalues{$item})) {
1.54 raeburn 5166: push(@errors,$item);
5167: }
5168: }
1.68 raeburn 5169: } elsif ($item eq 'datelocale_def') {
5170: if ($newvalues{$item} ne '') {
5171: my @datelocale_ids = DateTime::Locale->ids();
5172: if (!grep(/^\Q$newvalues{$item}\E$/,@datelocale_ids)) {
5173: push(@errors,$item);
5174: }
5175: }
1.43 raeburn 5176: }
5177: if (grep(/^\Q$item\E$/,@errors)) {
5178: $newvalues{$item} = $domdefaults{$item};
5179: } elsif ($domdefaults{$item} ne $newvalues{$item}) {
5180: $changes{$item} = 1;
5181: }
1.72 raeburn 5182: $domdefaults{$item} = $newvalues{$item};
1.43 raeburn 5183: }
5184: my %defaults_hash = (
1.72 raeburn 5185: defaults => \%newvalues,
5186: );
1.43 raeburn 5187: my $title = &defaults_titles();
5188: my $putresult = &Apache::lonnet::put_dom('configuration',\%defaults_hash,
5189: $dom);
5190: if ($putresult eq 'ok') {
5191: if (keys(%changes) > 0) {
5192: $resulttext = &mt('Changes made:').'<ul>';
5193: my $version = $r->dir_config('lonVersion');
5194: 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";
5195: foreach my $item (sort(keys(%changes))) {
5196: my $value = $env{'form.'.$item};
5197: if ($value eq '') {
5198: $value = &mt('none');
5199: } elsif ($item eq 'auth_def') {
5200: my %authnames = &authtype_names();
5201: my %shortauth = (
5202: internal => 'int',
5203: krb4 => 'krb4',
5204: krb5 => 'krb5',
5205: localauth => 'loc',
5206: );
5207: $value = $authnames{$shortauth{$value}};
5208: }
5209: $resulttext .= '<li>'.&mt('[_1] set to "[_2]"',$title->{$item},$value).'</li>';
5210: $mailmsgtext .= "$title->{$item} set to $value\n";
5211: }
5212: $resulttext .= '</ul>';
5213: $mailmsgtext .= "\n";
5214: my $cachetime = 24*60*60;
1.72 raeburn 5215: &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
1.68 raeburn 5216: if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'} || $changes{'datelocale_def'}) {
1.54 raeburn 5217: my $sysmail = $r->dir_config('lonSysEMail');
5218: &Apache::lonmsg::sendemail($sysmail,"LON-CAPA Domain Settings Change - $dom",$mailmsgtext);
5219: }
1.43 raeburn 5220: } else {
1.54 raeburn 5221: $resulttext = &mt('No changes made to default authentication/language/timezone settings');
1.43 raeburn 5222: }
5223: } else {
5224: $resulttext = '<span class="LC_error">'.
5225: &mt('An error occurred: [_1]',$putresult).'</span>';
5226: }
5227: if (@errors > 0) {
5228: $resulttext .= '<br />'.&mt('The following were left unchanged because the values entered were invalid:');
5229: foreach my $item (@errors) {
5230: $resulttext .= ' "'.$title->{$item}.'",';
5231: }
5232: $resulttext =~ s/,$//;
5233: }
5234: return $resulttext;
5235: }
5236:
1.46 raeburn 5237: sub modify_scantron {
1.48 raeburn 5238: my ($r,$dom,$confname,%domconfig) = @_;
1.46 raeburn 5239: my ($resulttext,%confhash,%changes,$errors);
5240: my $custom = 'custom.tab';
5241: my $default = 'default.tab';
5242: my $servadm = $r->dir_config('lonAdmEMail');
5243: my ($configuserok,$author_ok,$switchserver) =
5244: &config_check($dom,$confname,$servadm);
5245: if ($env{'form.scantronformat.filename'} ne '') {
5246: my $error;
5247: if ($configuserok eq 'ok') {
5248: if ($switchserver) {
5249: $error = &mt("Upload of scantron format file is not permitted to this server: [_1]",$switchserver);
5250: } else {
5251: if ($author_ok eq 'ok') {
5252: my ($result,$scantronurl) =
5253: &publishlogo($r,'upload','scantronformat',$dom,
5254: $confname,'scantron','','',$custom);
5255: if ($result eq 'ok') {
5256: $confhash{'scantron'}{'scantronformat'} = $scantronurl;
1.48 raeburn 5257: $changes{'scantronformat'} = 1;
1.46 raeburn 5258: } else {
5259: $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$custom,$result);
5260: }
5261: } else {
5262: $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);
5263: }
5264: }
5265: } else {
5266: $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);
5267: }
5268: if ($error) {
5269: &Apache::lonnet::logthis($error);
5270: $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
5271: }
5272: }
1.48 raeburn 5273: if (ref($domconfig{'scantron'}) eq 'HASH') {
5274: if ($domconfig{'scantron'}{'scantronformat'} ne '') {
5275: if ($env{'form.scantronformat_del'}) {
5276: $confhash{'scantron'}{'scantronformat'} = '';
5277: $changes{'scantronformat'} = 1;
1.46 raeburn 5278: }
5279: }
5280: }
5281: if (keys(%confhash) > 0) {
5282: my $putresult = &Apache::lonnet::put_dom('configuration',\%confhash,
5283: $dom);
5284: if ($putresult eq 'ok') {
5285: if (keys(%changes) > 0) {
1.48 raeburn 5286: if (ref($confhash{'scantron'}) eq 'HASH') {
5287: $resulttext = &mt('Changes made:').'<ul>';
5288: if ($confhash{'scantron'}{'scantronformat'} eq '') {
5289: $resulttext .= '<li>'.&mt('[_1] scantron format file removed; [_2] file will be used for courses in this domain.',$custom,$default).'</li>';
5290: } else {
5291: $resulttext .= '<li>'.&mt('Custom scantron format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>';
1.46 raeburn 5292: }
1.48 raeburn 5293: $resulttext .= '</ul>';
5294: } else {
5295: $resulttext = &mt('Changes made to scantron format file.');
1.46 raeburn 5296: }
5297: $resulttext .= '</ul>';
5298: &Apache::loncommon::devalidate_domconfig_cache($dom);
5299: } else {
5300: $resulttext = &mt('No changes made to scantron format file');
5301: }
5302: } else {
5303: $resulttext = '<span class="LC_error">'.
5304: &mt('An error occurred: [_1]',$putresult).'</span>';
5305: }
5306: } else {
5307: $resulttext = &mt('No changes made to scantron format file');
5308: }
5309: if ($errors) {
5310: $resulttext .= &mt('The following errors occurred: ').'<ul>'.
5311: $errors.'</ul>';
5312: }
5313: return $resulttext;
5314: }
5315:
1.48 raeburn 5316: sub modify_coursecategories {
5317: my ($dom,%domconfig) = @_;
1.57 raeburn 5318: my ($resulttext,%deletions,%reorderings,%needreordering,%adds,%changes,$errors,
5319: $cathash);
1.48 raeburn 5320: my @deletecategory = &Apache::loncommon::get_env_multiple('form.deletecategory');
1.55 raeburn 5321: if (ref($domconfig{'coursecategories'}) eq 'HASH') {
1.57 raeburn 5322: $cathash = $domconfig{'coursecategories'}{'cats'};
5323: if ($domconfig{'coursecategories'}{'togglecats'} ne $env{'form.togglecats'}) {
5324: $changes{'togglecats'} = 1;
5325: $domconfig{'coursecategories'}{'togglecats'} = $env{'form.togglecats'};
5326: }
5327: if ($domconfig{'coursecategories'}{'categorize'} ne $env{'form.categorize'}) {
5328: $changes{'categorize'} = 1;
5329: $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
5330: }
5331: } else {
5332: $changes{'togglecats'} = 1;
5333: $changes{'categorize'} = 1;
1.87 raeburn 5334: $domconfig{'coursecategories'} = {
5335: togglecats => $env{'form.togglecats'},
5336: categorize => $env{'form.categorize'},
5337: };
1.57 raeburn 5338: }
5339: if (ref($cathash) eq 'HASH') {
5340: if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) {
1.55 raeburn 5341: push (@deletecategory,'instcode::0');
5342: }
1.48 raeburn 5343: }
1.57 raeburn 5344: my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail);
5345: if (ref($cathash) eq 'HASH') {
1.48 raeburn 5346: if (@deletecategory > 0) {
5347: #FIXME Need to remove category from all courses using a deleted category
1.57 raeburn 5348: &Apache::loncommon::extract_categories($cathash,\@predelcats,\@predeltrails,\%predelallitems);
1.48 raeburn 5349: foreach my $item (@deletecategory) {
1.57 raeburn 5350: if ($domconfig{'coursecategories'}{'cats'}{$item} ne '') {
5351: delete($domconfig{'coursecategories'}{'cats'}{$item});
1.48 raeburn 5352: $deletions{$item} = 1;
1.57 raeburn 5353: &recurse_cat_deletes($item,$cathash,\%deletions);
1.48 raeburn 5354: }
5355: }
5356: }
1.57 raeburn 5357: foreach my $item (keys(%{$cathash})) {
1.48 raeburn 5358: my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$item);
1.57 raeburn 5359: if ($cathash->{$item} ne $env{'form.'.$item}) {
1.48 raeburn 5360: $reorderings{$item} = 1;
1.57 raeburn 5361: $domconfig{'coursecategories'}{'cats'}{$item} = $env{'form.'.$item};
1.48 raeburn 5362: }
5363: if ($env{'form.addcategory_name_'.$item} ne '') {
5364: my $newcat = $env{'form.addcategory_name_'.$item};
5365: my $newdepth = $depth+1;
5366: my $newitem = &escape($newcat).':'.&escape($cat).':'.$newdepth;
1.57 raeburn 5367: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos_'.$item};
1.48 raeburn 5368: $adds{$newitem} = 1;
5369: }
5370: if ($env{'form.subcat_'.$item} ne '') {
5371: my $newcat = $env{'form.subcat_'.$item};
5372: my $newdepth = $depth+1;
5373: my $newitem = &escape($newcat).':'.&escape($cat).':'.$newdepth;
1.57 raeburn 5374: $domconfig{'coursecategories'}{'cats'}{$newitem} = 0;
1.48 raeburn 5375: $adds{$newitem} = 1;
5376: }
5377: }
5378: }
5379: if ($env{'form.instcode'} eq '1') {
1.57 raeburn 5380: if (ref($cathash) eq 'HASH') {
1.48 raeburn 5381: my $newitem = 'instcode::0';
1.57 raeburn 5382: if ($cathash->{$newitem} eq '') {
5383: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.instcode_pos'};
1.48 raeburn 5384: $adds{$newitem} = 1;
5385: }
5386: } else {
5387: my $newitem = 'instcode::0';
1.57 raeburn 5388: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.instcode_pos'};
1.48 raeburn 5389: $adds{$newitem} = 1;
5390: }
5391: }
5392: if ($env{'form.addcategory_name'} ne '') {
5393: my $newitem = &escape($env{'form.addcategory_name'}).'::0';
1.57 raeburn 5394: $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
1.48 raeburn 5395: $adds{$newitem} = 1;
5396: }
1.57 raeburn 5397: my $putresult;
1.48 raeburn 5398: if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
5399: if (keys(%deletions) > 0) {
5400: foreach my $key (keys(%deletions)) {
5401: if ($predelallitems{$key} ne '') {
5402: $sort_by_deltrail{$predelallitems{$key}} = $predeltrails[$predelallitems{$key}];
5403: }
5404: }
5405: }
5406: my (@chkcats,@chktrails,%chkallitems);
1.57 raeburn 5407: &Apache::loncommon::extract_categories($domconfig{'coursecategories'}{'cats'},\@chkcats,\@chktrails,\%chkallitems);
1.48 raeburn 5408: if (ref($chkcats[0]) eq 'ARRAY') {
5409: my $depth = 0;
5410: my $chg = 0;
5411: for (my $i=0; $i<@{$chkcats[0]}; $i++) {
5412: my $name = $chkcats[0][$i];
5413: my $item;
5414: if ($name eq '') {
5415: $chg ++;
5416: } else {
5417: $item = &escape($name).'::0';
5418: if ($chg) {
1.57 raeburn 5419: $domconfig{'coursecategories'}{'cats'}{$item} -= $chg;
1.48 raeburn 5420: }
5421: $depth ++;
1.57 raeburn 5422: &recurse_check(\@chkcats,$domconfig{'coursecategories'}{'cats'},$depth,$name);
1.48 raeburn 5423: $depth --;
5424: }
5425: }
5426: }
1.57 raeburn 5427: }
5428: if ((keys(%changes) > 0) || (keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
5429: $putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);
1.48 raeburn 5430: if ($putresult eq 'ok') {
1.57 raeburn 5431: my %title = (
5432: togglecats => 'Show/Hide a course in the catalog',
5433: categorize => 'Category assigned to course',
5434: );
5435: my %level = (
5436: dom => 'set from "Modify Course" (Domain)',
5437: crs => 'set from "Parameters" (Course)',
5438: );
1.48 raeburn 5439: $resulttext = &mt('Changes made:').'<ul>';
1.57 raeburn 5440: if ($changes{'togglecats'}) {
5441: $resulttext .= '<li>'.&mt("$title{'togglecats'} $level{$env{'form.togglecats'}}").'</li>';
5442: }
5443: if ($changes{'categorize'}) {
5444: $resulttext .= '<li>'.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'</li>';
1.48 raeburn 5445: }
1.57 raeburn 5446: if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
5447: my $cathash;
5448: if (ref($domconfig{'coursecategories'}) eq 'HASH') {
5449: $cathash = $domconfig{'coursecategories'}{'cats'};
5450: } else {
5451: $cathash = {};
5452: }
5453: my (@cats,@trails,%allitems);
5454: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems);
5455: if (keys(%deletions) > 0) {
5456: $resulttext .= '<li>'.&mt('Deleted categories:').'<ul>';
5457: foreach my $predeltrail (sort {$a <=> $b } (keys(%sort_by_deltrail))) {
5458: $resulttext .= '<li>'.$predeltrails[$predeltrail].'</li>';
5459: }
5460: $resulttext .= '</ul></li>';
5461: }
5462: if (keys(%reorderings) > 0) {
5463: my %sort_by_trail;
5464: $resulttext .= '<li>'.&mt('Reordered categories:').'<ul>';
5465: foreach my $key (keys(%reorderings)) {
5466: if ($allitems{$key} ne '') {
5467: $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
5468: }
1.48 raeburn 5469: }
1.57 raeburn 5470: foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
5471: $resulttext .= '<li>'.$trails[$trail].'</li>';
5472: }
5473: $resulttext .= '</ul></li>';
1.48 raeburn 5474: }
1.57 raeburn 5475: if (keys(%adds) > 0) {
5476: my %sort_by_trail;
5477: $resulttext .= '<li>'.&mt('Added categories:').'<ul>';
5478: foreach my $key (keys(%adds)) {
5479: if ($allitems{$key} ne '') {
5480: $sort_by_trail{$allitems{$key}} = $trails[$allitems{$key}];
5481: }
5482: }
5483: foreach my $trail (sort {$a <=> $b } (keys(%sort_by_trail))) {
5484: $resulttext .= '<li>'.$trails[$trail].'</li>';
1.48 raeburn 5485: }
1.57 raeburn 5486: $resulttext .= '</ul></li>';
1.48 raeburn 5487: }
5488: }
5489: $resulttext .= '</ul>';
5490: } else {
5491: $resulttext = '<span class="LC_error">'.
1.57 raeburn 5492: &mt('An error occurred: [_1]',$putresult).'</span>';
1.48 raeburn 5493: }
5494: } else {
5495: $resulttext = &mt('No changes made to course categories');
5496: }
5497: return $resulttext;
5498: }
5499:
1.69 raeburn 5500: sub modify_serverstatuses {
5501: my ($dom,%domconfig) = @_;
5502: my ($resulttext,%changes,%currserverstatus,%newserverstatus);
5503: if (ref($domconfig{'serverstatuses'}) eq 'HASH') {
5504: %currserverstatus = %{$domconfig{'serverstatuses'}};
5505: }
5506: my @pages = &serverstatus_pages();
5507: foreach my $type (@pages) {
5508: $newserverstatus{$type}{'namedusers'} = '';
5509: $newserverstatus{$type}{'machines'} = '';
5510: if (defined($env{'form.'.$type.'_namedusers'})) {
5511: my @users = split(/,/,$env{'form.'.$type.'_namedusers'});
5512: my @okusers;
5513: foreach my $user (@users) {
5514: my ($uname,$udom) = split(/:/,$user);
5515: if (($udom =~ /^$match_domain$/) &&
5516: (&Apache::lonnet::domain($udom)) &&
5517: ($uname =~ /^$match_username$/)) {
5518: if (!grep(/^\Q$user\E/,@okusers)) {
5519: push(@okusers,$user);
5520: }
5521: }
5522: }
5523: if (@okusers > 0) {
5524: @okusers = sort(@okusers);
5525: $newserverstatus{$type}{'namedusers'} = join(',',@okusers);
5526: }
5527: }
5528: if (defined($env{'form.'.$type.'_machines'})) {
5529: my @machines = split(/,/,$env{'form.'.$type.'_machines'});
5530: my @okmachines;
5531: foreach my $ip (@machines) {
5532: my @parts = split(/\./,$ip);
5533: next if (@parts < 4);
5534: my $badip = 0;
5535: for (my $i=0; $i<4; $i++) {
5536: if (!(($parts[$i] >= 0) && ($parts[$i] <= 255))) {
5537: $badip = 1;
5538: last;
5539: }
5540: }
5541: if (!$badip) {
5542: push(@okmachines,$ip);
5543: }
5544: }
5545: @okmachines = sort(@okmachines);
5546: $newserverstatus{$type}{'machines'} = join(',',@okmachines);
5547: }
5548: }
5549: my %serverstatushash = (
5550: serverstatuses => \%newserverstatus,
5551: );
5552: my %changes;
5553: foreach my $type (@pages) {
1.83 raeburn 5554: foreach my $setting ('namedusers','machines') {
1.84 raeburn 5555: my (@current,@new);
1.83 raeburn 5556: if (ref($currserverstatus{$type}) eq 'HASH') {
1.84 raeburn 5557: if ($currserverstatus{$type}{$setting} ne '') {
5558: @current = split(/,/,$currserverstatus{$type}{$setting});
5559: }
5560: }
5561: if ($newserverstatus{$type}{$setting} ne '') {
5562: @new = split(/,/,$newserverstatus{$type}{$setting});
1.83 raeburn 5563: }
5564: if (@current > 0) {
5565: if (@new > 0) {
5566: foreach my $item (@current) {
5567: if (!grep(/^\Q$item\E$/,@new)) {
5568: $changes{$type}{$setting} = 1;
1.82 raeburn 5569: last;
5570: }
5571: }
1.84 raeburn 5572: foreach my $item (@new) {
5573: if (!grep(/^\Q$item\E$/,@current)) {
5574: $changes{$type}{$setting} = 1;
5575: last;
1.82 raeburn 5576: }
5577: }
5578: } else {
1.83 raeburn 5579: $changes{$type}{$setting} = 1;
1.69 raeburn 5580: }
1.83 raeburn 5581: } elsif (@new > 0) {
5582: $changes{$type}{$setting} = 1;
1.69 raeburn 5583: }
5584: }
5585: }
5586: if (keys(%changes) > 0) {
1.81 raeburn 5587: my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
1.69 raeburn 5588: my $putresult = &Apache::lonnet::put_dom('configuration',
5589: \%serverstatushash,$dom);
5590: if ($putresult eq 'ok') {
5591: $resulttext .= &mt('Changes made:').'<ul>';
5592: foreach my $type (@pages) {
1.84 raeburn 5593: if (ref($changes{$type}) eq 'HASH') {
1.69 raeburn 5594: $resulttext .= '<li>'.$titles->{$type}.'<ul>';
1.84 raeburn 5595: if ($changes{$type}{'namedusers'}) {
1.69 raeburn 5596: if ($newserverstatus{$type}{'namedusers'} eq '') {
5597: $resulttext .= '<li>'.&mt("Access terminated for all specific (named) users").'</li>'."\n";
5598: } else {
5599: $resulttext .= '<li>'.&mt("Access available for the following specified users: ").$newserverstatus{$type}{'namedusers'}.'</li>'."\n";
5600: }
1.84 raeburn 5601: }
5602: if ($changes{$type}{'machines'}) {
1.69 raeburn 5603: if ($newserverstatus{$type}{'machines'} eq '') {
5604: $resulttext .= '<li>'.&mt("Access terminated for all specific IP addresses").'</li>'."\n";
5605: } else {
5606: $resulttext .= '<li>'.&mt("Access available for the following specified IP addresses: ").$newserverstatus{$type}{'machines'}.'</li>'."\n";
5607: }
5608:
5609: }
5610: $resulttext .= '</ul></li>';
5611: }
5612: }
5613: $resulttext .= '</ul>';
5614: } else {
5615: $resulttext = '<span class="LC_error">'.
5616: &mt('An error occurred saving access settings for server status pages: [_1].',$putresult).'</span>';
5617:
5618: }
5619: } else {
5620: $resulttext = &mt('No changes made to access to server status pages');
5621: }
5622: return $resulttext;
5623: }
5624:
1.48 raeburn 5625: sub recurse_check {
5626: my ($chkcats,$categories,$depth,$name) = @_;
5627: if (ref($chkcats->[$depth]{$name}) eq 'ARRAY') {
5628: my $chg = 0;
5629: for (my $j=0; $j<@{$chkcats->[$depth]{$name}}; $j++) {
5630: my $category = $chkcats->[$depth]{$name}[$j];
5631: my $item;
5632: if ($category eq '') {
5633: $chg ++;
5634: } else {
5635: my $deeper = $depth + 1;
5636: $item = &escape($category).':'.&escape($name).':'.$depth;
5637: if ($chg) {
5638: $categories->{$item} -= $chg;
5639: }
5640: &recurse_check($chkcats,$categories,$deeper,$category);
5641: $deeper --;
5642: }
5643: }
5644: }
5645: return;
5646: }
5647:
5648: sub recurse_cat_deletes {
5649: my ($item,$coursecategories,$deletions) = @_;
5650: my ($deleted,$container,$depth) = map { &unescape($_); } split(/:/,$item);
5651: my $subdepth = $depth + 1;
5652: if (ref($coursecategories) eq 'HASH') {
5653: foreach my $subitem (keys(%{$coursecategories})) {
5654: my ($child,$parent,$itemdepth) = map { &unescape($_); } split(/:/,$subitem);
5655: if (($parent eq $deleted) && ($itemdepth == $subdepth)) {
5656: delete($coursecategories->{$subitem});
5657: $deletions->{$subitem} = 1;
5658: &recurse_cat_deletes($subitem,$coursecategories,$deletions);
5659: }
5660: }
5661: }
5662: return;
5663: }
5664:
1.3 raeburn 5665: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>