--- loncom/interface/domainprefs.pm 2008/07/08 03:04:23 1.61
+++ loncom/interface/domainprefs.pm 2008/07/19 02:28:44 1.64
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.61 2008/07/08 03:04:23 raeburn Exp $
+# $Id: domainprefs.pm,v 1.64 2008/07/19 02:28:44 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,6 +41,7 @@ use LONCAPA;
use LONCAPA::Enrollment;
use File::Copy;
use Locale::Language;
+use DateTime::TimeZone;
sub handler {
my $r=shift;
@@ -150,7 +151,9 @@ sub handler {
header => [{col1 => 'Target user has role',
col2 => 'User information updateable in author context'},
{col1 => 'Target user has role',
- col2 => 'User information updateable in course context'}],
+ col2 => 'User information updateable in course context'},
+ {col1 => "Status of user",
+ col2 => 'Information settable when self-creating account (if directory data blank)'}],
},
'scantron' =>
{ text => 'Scantron format file',
@@ -390,7 +393,10 @@ sub print_config_box {
if (($action eq 'autoupdate') || ($action eq 'rolecolors') ||
($action eq 'usercreation') || ($action eq 'usermodification') ||
($action eq 'coursecategories')) {
- my $colspan = ($action eq 'rolecolors')?' colspan="2"':'';
+ my $colspan = '';
+ if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {
+ $colspan = ' colspan="2"';
+ }
$output .= '
@@ -420,7 +426,6 @@ sub print_config_box {
'.&mt($item->{'header'}->[1]->{'col1'}).' | ';
- my $colspan = ($action eq 'coursecategories')?' colspan="2"':'';
$output .= '
'.&mt($item->{'header'}->[1]->{'col2'}).' |
';
@@ -441,7 +446,19 @@ sub print_config_box {
&print_usercreation('bottom',$dom,$settings,\$rowtotal);
$rowtotal ++;
} elsif ($action eq 'usermodification') {
- $output .= &print_usermodification('bottom',$dom,$settings,\$rowtotal);
+ $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal).'
+
+ |
+
+
+
+
+
+ '.&mt($item->{'header'}->[2]->{'col1'}).' |
+ '.&mt($item->{'header'}->[2]->{'col2'}).' | '.
+
+ &print_usermodification('bottom',$dom,$settings,\$rowtotal);
+ $rowtotal ++;
} elsif ($action eq 'coursecategories') {
$output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
} else {
@@ -1682,10 +1699,14 @@ sub user_formats_row {
);
my $css_class = $rowcount%2?' class="LC_odd_row"':'';
$output = ''.
- ''.
- &mt("Format rules to check for $text{$type}: ").
- ' | '.
- '';
+ '';
+ if ($type eq 'email') {
+ $output .= &mt("Formats disallowed for $text{$type}: ");
+ } else {
+ $output .= &mt("Format rules to check for $text{$type}: ");
+ }
+ $output .= ' | '.
+ '';
my $rem;
if (ref($ruleorder) eq 'ARRAY') {
for (my $i=0; $i<@{$ruleorder}; $i++) {
@@ -1773,7 +1794,7 @@ sub print_usermodification {
$$rowtotal ++;
$rowcount ++;
}
- } else {
+ } elsif ($position eq 'middle') {
$context = 'course';
$rowcount = 0;
foreach my $role ('st','ep','ta','in','cr') {
@@ -1782,6 +1803,20 @@ sub print_usermodification {
$$rowtotal ++;
$rowcount ++;
}
+ } elsif ($position eq 'bottom') {
+ $context = 'selfcreate';
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ $usertypes->{'default'} = $othertitle;
+ if (ref($types) eq 'ARRAY') {
+ push(@{$types},'default');
+ $usertypes->{'default'} = $othertitle;
+ foreach my $status (@{$types}) {
+ $datatable .= &modifiable_userdata_row($context,$status,$settings,
+ $numinrow,$rowcount,$usertypes);
+ $$rowtotal ++;
+ $rowcount ++;
+ }
+ }
}
return $datatable;
}
@@ -2361,12 +2396,20 @@ sub build_category_rows {
}
sub modifiable_userdata_row {
- my ($context,$role,$settings,$numinrow,$rowcount) = @_;
+ my ($context,$role,$settings,$numinrow,$rowcount,$usertypes) = @_;
my $rolename;
- if ($role eq 'cr') {
- $rolename = &mt('Custom role');
+ if ($context eq 'selfcreate') {
+ if (ref($usertypes) eq 'HASH') {
+ $rolename = $usertypes->{$role};
+ } else {
+ $rolename = $role;
+ }
} else {
- $rolename = &Apache::lonnet::plaintext($role);
+ if ($role eq 'cr') {
+ $rolename = &mt('Custom role');
+ } else {
+ $rolename = &Apache::lonnet::plaintext($role);
+ }
}
my @fields = ('lastname','firstname','middlename','generation',
'permanentemail','id');
@@ -4089,10 +4132,11 @@ sub modify_usermodification {
$curr_usermodification{$key} = $domconfig{'usermodification'}{$key};
}
}
- my @contexts = ('author','course');
+ my @contexts = ('author','course','selfcreate');
my %context_title = (
author => 'In author context',
course => 'In course context',
+ selfcreate => 'When self creating account',
);
my @fields = ('lastname','firstname','middlename','generation',
'permanentemail','id');
@@ -4100,6 +4144,12 @@ sub modify_usermodification {
author => ['ca','aa'],
course => ['st','ep','ta','in','cr'],
);
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ if (ref($types) eq 'ARRAY') {
+ push(@{$types},'default');
+ $usertypes->{'default'} = $othertitle;
+ }
+ $roles{'selfcreate'} = $types;
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
my %modifyhash;
foreach my $context (@contexts) {
@@ -4147,13 +4197,26 @@ sub modify_usermodification {
if (ref($changes{$context}) eq 'ARRAY') {
foreach my $role (@{$changes{$context}}) {
my $rolename;
- if ($role eq 'cr') {
- $rolename = &mt('Custom');
+ if ($context eq 'selfcreate') {
+ $rolename = $role;
+ if (ref($usertypes) eq 'HASH') {
+ if ($usertypes->{$role} ne '') {
+ $rolename = $usertypes->{$role};
+ }
+ }
} else {
- $rolename = &Apache::lonnet::plaintext($role);
+ if ($role eq 'cr') {
+ $rolename = &mt('Custom');
+ } else {
+ $rolename = &Apache::lonnet::plaintext($role);
+ }
}
my @modifiable;
- $resulttext .= ''.&mt('Target user with [_1] role',$rolename).' - '.&mt('modifiable fields: ');
+ if ($context eq 'selfcreate') {
+ $resulttext .= ''.&mt('Self-creation of account by users with status: [_1] ',$rolename).' - '.&mt('modifiable fields (if institutional data blank): ');
+ } else {
+ $resulttext .= ''.&mt('Target user with [_1] role',$rolename).' - '.&mt('modifiable fields: ');
+ }
foreach my $field (@fields) {
if ($modifyhash{$context}{$role}{$field}) {
push(@modifiable,$fieldtitles{$field});
@@ -4208,8 +4271,7 @@ sub modify_defaults {
}
} elsif ($item eq 'timezone_def') {
if ($newvalues{$item} ne '') {
- my @timezones = &DateTime::TimeZone->all_names;
- if (!grep(/^\Q$newvalues{$item}\E/,@timezones)) {
+ if (!DateTime::TimeZone->is_valid_name($newvalues{$item})) {
push(@errors,$item);
}
}
| | |