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