--- loncom/interface/domainprefs.pm 2008/06/30 03:47:12 1.58
+++ loncom/interface/domainprefs.pm 2008/07/13 00:00:50 1.63
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.58 2008/06/30 03:47:12 raeburn Exp $
+# $Id: domainprefs.pm,v 1.63 2008/07/13 00:00:50 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',
@@ -396,8 +399,8 @@ sub print_config_box {
- '.$item->{'header'}->[0]->{'col1'}.' |
- '.$item->{'header'}->[0]->{'col2'}.' |
+ '.&mt($item->{'header'}->[0]->{'col1'}).' |
+ '.&mt($item->{'header'}->[0]->{'col2'}).' |
';
$rowtotal ++;
if ($action eq 'autoupdate') {
@@ -419,10 +422,10 @@ sub print_config_box {
- '.$item->{'header'}->[1]->{'col1'}.' | ';
+ '.&mt($item->{'header'}->[1]->{'col1'}).' | ';
my $colspan = ($action eq 'coursecategories')?' colspan="2"':'';
$output .= '
- '.$item->{'header'}->[1]->{'col2'}.' |
+ '.&mt($item->{'header'}->[1]->{'col2'}).' |
';
$rowtotal ++;
if ($action eq 'autoupdate') {
@@ -436,12 +439,24 @@ sub print_config_box {
- '.$item->{'header'}->[2]->{'col1'}.' |
- '.$item->{'header'}->[2]->{'col2'}.' | '.
+ '.&mt($item->{'header'}->[2]->{'col1'}).' |
+ '.&mt($item->{'header'}->[2]->{'col2'}).' | '.
&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 {
@@ -453,8 +468,8 @@ sub print_config_box {
- '.$item->{'header'}->[2]->{'col1'}.' |
- '.$item->{'header'}->[2]->{'col2'}.' |
+ '.&mt($item->{'header'}->[2]->{'col1'}).' |
+ '.&mt($item->{'header'}->[2]->{'col2'}).' |
'.
&print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'
@@ -464,8 +479,8 @@ sub print_config_box {
|
- '.$item->{'header'}->[3]->{'col1'}.' |
- '.$item->{'header'}->[3]->{'col2'}.' |
+ '.&mt($item->{'header'}->[3]->{'col1'}).' |
+ '.&mt($item->{'header'}->[3]->{'col2'}).' |
'.
&print_rolecolors($phase,'admin',$dom,$confname,$settings,\$rowtotal);
$rowtotal += 2;
@@ -478,13 +493,13 @@ sub print_config_box {
';
if (($action eq 'login') || ($action eq 'directorysrch')) {
$output .= '
- '.$item->{'header'}->[0]->{'col1'}.' | ';
+ '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
} else {
$output .= '
- '.$item->{'header'}->[0]->{'col1'}.' | ';
+ '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
}
$output .= '
- '.$item->{'header'}->[0]->{'col2'}.' |
+ '.&mt($item->{'header'}->[0]->{'col2'}).' |
';
$rowtotal ++;
if ($action eq 'login') {
@@ -1682,10 +1697,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 +1792,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 +1801,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;
}
@@ -1847,7 +1880,8 @@ sub defaults_titles {
sub print_scantronformat {
my ($r,$dom,$confname,$settings,$rowtotal) = @_;
my $itemcount = 1;
- my ($datatable,$css_class,$scantronurl,$is_custom,%error,%scantronurls);
+ my ($datatable,$css_class,$scantronurl,$is_custom,%error,%scantronurls,
+ %confhash);
my $switchserver = &check_switchserver($dom,$confname);
my %lt = &Apache::lonlocal::texthash (
default => 'Default scantron format file error',
@@ -1874,23 +1908,52 @@ sub print_scantronformat {
);
my %md5chk;
foreach my $type (keys(%legacyfile)) {
- $md5chk{$type} = split(/ /,`md5sum $legacyfile{$type}`);
- chop($md5chk{$type});
+ ($md5chk{$type}) = split(/ /,`md5sum $legacyfile{$type}`);
+ chomp($md5chk{$type});
}
if ($md5chk{'default'} ne $md5chk{'custom'}) {
foreach my $type (keys(%legacyfile)) {
- ($scantronurls{$type},$error{$type}) =
+ ($scantronurls{$type},my $error) =
&legacy_scantronformat($r,$dom,$confname,
$type,$legacyfile{$type},
$scantronurls{$type},
$scantronfiles{$type});
+ if ($error ne '') {
+ $error{$type} = $error;
+ }
+ }
+ if (keys(%error) == 0) {
+ $is_custom = 1;
+ $confhash{'scantron'}{'scantronformat'} =
+ $scantronurls{'custom'};
+ my $putresult =
+ &Apache::lonnet::put_dom('configuration',
+ \%confhash,$dom);
+ if ($putresult ne 'ok') {
+ $error{'custom'} =
+ ''.
+ &mt('An error occurred updating the domain configuration: [_1]',$putresult).'';
+ }
}
} else {
- ($scantronurls{'default'},$error{'default'}) =
+ ($scantronurls{'default'},my $error) =
&legacy_scantronformat($r,$dom,$confname,
'default',$legacyfile{'default'},
$scantronurls{'default'},
$scantronfiles{'default'});
+ if ($error eq '') {
+ $confhash{'scantron'}{'scantronformat'} = '';
+ my $putresult =
+ &Apache::lonnet::put_dom('configuration',
+ \%confhash,$dom);
+ if ($putresult ne 'ok') {
+ $error{'default'} =
+ ''.
+ &mt('An error occurred updating the domain configuration: [_1]',$putresult).'';
+ }
+ } else {
+ $error{'default'} = $error;
+ }
}
}
}
@@ -1911,7 +1974,11 @@ sub print_scantronformat {
$scantronurl = $scantronurls{'default'};
}
} else {
- $scantronurl = $scantronurls{'default'};
+ if ($is_custom) {
+ $scantronurl = $scantronurls{'custom'};
+ } else {
+ $scantronurl = $scantronurls{'default'};
+ }
}
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= '';
@@ -1923,16 +1990,29 @@ sub print_scantronformat {
} else {
$datatable = &mt('File unavailable for display');
}
- $datatable .= ''.&mt('Upload:').' ';
+ $datatable .= ' | ';
+ if (keys(%error) == 0) {
+ $datatable .= '';
+ if (!$switchserver) {
+ $datatable .= &mt('Upload:').' ';
+ }
+ } else {
+ my $errorstr;
+ foreach my $key (sort(keys(%error))) {
+ $errorstr .= $lt{$key}.': '.$error{$key}.' ';
+ }
+ $datatable .= ' | '.$errorstr;
+ }
} else {
if (keys(%error) > 0) {
my $errorstr;
foreach my $key (sort(keys(%error))) {
$errorstr .= $lt{$key}.': '.$error{$key}.' ';
}
- $datatable .= ' | '.$errorstr.' | ';
+ $datatable .= ' | '.$errorstr.' | ';
} elsif ($scantronurl) {
- $datatable .= ' | ' .&mt('Custom scantron format file').''
+ $datatable .= ' | '
+ .&mt('Custom scantron format file').''
.' | '
@@ -1990,7 +2070,7 @@ sub print_coursecategories {
);
my %level = &Apache::lonlocal::texthash (
dom => 'Set in "Modify Course" (Domain)',
- crs => 'Set in "Parameters" (Course)',
+ crs => 'Set in "Modify Parameters" (Course)',
);
$datatable = ' '.
''.$title{'togglecats'}.' | '.
@@ -2081,7 +2161,7 @@ sub print_coursecategories {
}
$datatable .= '';
}
- $datatable .= ''.&mt('New:').' '
+ $datatable .= ' | '.&mt('Add category:').' '
.' | '
.' '."\n";
$itemcount ++;
@@ -2282,7 +2362,7 @@ sub build_category_rows {
pop(@{$path});
}
} else {
- $text .= &mt('New:').' '.&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});
@@ -4161,8 +4269,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);
}
}
| | | | | |