- '.$item->{'header'}->[0]->{'col1'}.' |
- '.$item->{'header'}->[0]->{'col2'}.' |
+ '.&mt($item->{'header'}->[0]->{'col1'}).' |
+ '.&mt($item->{'header'}->[0]->{'col2'}).' |
';
- $rowtotal ++;
+ $rowtotal ++;
if ($action eq 'autoupdate') {
$output .= &print_autoupdate('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'usercreation') {
@@ -419,10 +437,9 @@ sub print_config_box {
- '.$item->{'header'}->[1]->{'col1'}.' | ';
- my $colspan = ($action eq 'coursecategories')?' colspan="2"':'';
+ '.&mt($item->{'header'}->[1]->{'col1'}).' | ';
$output .= '
- '.$item->{'header'}->[1]->{'col2'}.' |
+ '.&mt($item->{'header'}->[1]->{'col2'}).' |
';
$rowtotal ++;
if ($action eq 'autoupdate') {
@@ -436,12 +453,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 +482,10 @@ 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 +495,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,14 +509,34 @@ sub print_config_box {
';
if (($action eq 'login') || ($action eq 'directorysrch')) {
$output .= '
- '.$item->{'header'}->[0]->{'col1'}.' | ';
+ '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
+ } elsif ($action eq 'serverstatuses') {
+ $output .= '
+ '.&mt($item->{'header'}->[0]->{'col1'}).
+ ' ('.&mt('Automatic access for Dom. Coords.').') | ';
+
} else {
$output .= '
- '.$item->{'header'}->[0]->{'col1'}.' | ';
+ '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
}
- $output .= '
- '.$item->{'header'}->[0]->{'col2'}.' |
- ';
+ if ($action eq 'serverstatuses') {
+ $output .= ''.
+ &mt($item->{'header'}->[0]->{'col2'}).
+ ' ('.&mt('user1:domain1,user2:domain2 etc.').')';
+ } else {
+ $output .= ' | '.
+ &mt($item->{'header'}->[0]->{'col2'});
+ }
+ $output .= ' | ';
+ if ($item->{'header'}->[0]->{'col3'}) {
+ $output .= ''.
+ &mt($item->{'header'}->[0]->{'col3'});
+ if ($action eq 'serverstatuses') {
+ $output .= ' ('.&mt('IP1,IP2 etc.').')';
+ }
+ $output .= ' | ';
+ }
+ $output .= '';
$rowtotal ++;
if ($action eq 'login') {
$output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal);
@@ -501,6 +552,8 @@ sub print_config_box {
$output .= &print_defaults($dom,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
+ } elsif ($action eq 'serverstatuses') {
+ $output .= &print_serverstatuses($dom,$settings,\$rowtotal);
}
}
$output .= '
@@ -1448,24 +1501,17 @@ sub print_contacts {
my $rownum = 0;
my $css_class;
foreach my $item (@contacts) {
- if ($rownum%2) {
- $css_class = '';
- } else {
- $css_class = ' class="LC_odd_row" ';
- }
+ $rownum ++;
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
$datatable .= ''.
''.$titles->{$item}.
' | '.
' | ';
- $rownum ++;
}
foreach my $type (@mailings) {
- if ($rownum%2) {
- $css_class = '';
- } else {
- $css_class = ' class="LC_odd_row" ';
- }
+ $rownum ++;
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
$datatable .= ''.
''.
$titles->{$type}.': | '.
@@ -1482,7 +1528,6 @@ sub print_contacts {
''.
' '."\n";
- $rownum ++;
}
$$rowtotal += $rownum;
return $datatable;
@@ -1491,7 +1536,7 @@ sub print_contacts {
sub contact_titles {
my %titles = &Apache::lonlocal::texthash (
'supportemail' => 'Support E-mail address',
- 'adminemail' => 'Default Server Admin E-mail address',
+ 'adminemail' => 'Default Server Admin E-mail address',
'errormail' => 'Error reports to be e-mailed to',
'packagesmail' => 'Package update alerts to be e-mailed to',
'helpdeskmail' => 'Helpdesk requests to be e-mailed to'
@@ -1682,10 +1727,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 +1822,7 @@ sub print_usermodification {
$$rowtotal ++;
$rowcount ++;
}
- } else {
+ } elsif ($position eq 'middle') {
$context = 'course';
$rowcount = 0;
foreach my $role ('st','ep','ta','in','cr') {
@@ -1782,13 +1831,28 @@ 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;
}
sub print_defaults {
my ($dom,$rowtotal) = @_;
- my @items = ('auth_def','auth_arg_def','lang_def','timezone_def');
+ my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
+ 'datelocale_def');
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
my $titles = &defaults_titles();
my $rownum = 0;
@@ -1823,6 +1887,9 @@ sub print_defaults {
} elsif ($item eq 'timezone_def') {
my $includeempty = 1;
$datatable .= &Apache::loncommon::select_timezone($item,$domdefaults{$item},undef,$includeempty);
+ } elsif ($item eq 'datelocale_def') {
+ my $includeempty = 1;
+ $datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
} else {
$datatable .= '';
@@ -1840,6 +1907,7 @@ sub defaults_titles {
'auth_arg_def' => 'Default authentication argument',
'lang_def' => 'Default language',
'timezone_def' => 'Default timezone',
+ 'datelocale_def' => 'Default locale for dates',
);
return (\%titles);
}
@@ -1847,7 +1915,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 +1943,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,39 +2009,59 @@ 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 .= '';
if (!$is_custom) {
- $datatable .= ''.&mt('Default in use:').' ';
+ $datatable .= ' | '.&mt('Default in use:').' '.
+ '';
if ($scantronurl) {
$datatable .= ''.
&mt('Default scantron format file').'';
} 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').''
- .' | '
- .''.&mt('Replace:').' ';
+ $datatable .= ' | '.
+ ''.
+ &mt('Custom scantron format file').' | '.
+ ' '.
+ &mt('Replace:').' ';
}
}
if (keys(%error) == 0) {
if ($switchserver) {
$datatable .= &mt('Upload to library server: [_1]',$switchserver);
} else {
- $datatable .=' ';
+ $datatable .=' '.
+ '';
}
}
$datatable .= ' | ';
@@ -1990,7 +2108,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 +2199,7 @@ sub print_coursecategories {
}
$datatable .= '';
}
- $datatable .= ''.&mt('New:').' '
+ $datatable .= ' | '.&mt('Add category:').' '
.' | '
.' '."\n";
$itemcount ++;
@@ -2119,6 +2237,58 @@ sub print_coursecategories {
return $datatable;
}
+sub print_serverstatuses {
+ my ($dom,$settings,$rowtotal) = @_;
+ my $datatable;
+ my @pages = &serverstatus_pages();
+ my (%namedaccess,%machineaccess);
+ foreach my $type (@pages) {
+ $namedaccess{$type} = '';
+ $machineaccess{$type}= '';
+ }
+ if (ref($settings) eq 'HASH') {
+ foreach my $type (@pages) {
+ if (exists($settings->{$type})) {
+ if (ref($settings->{$type}) eq 'HASH') {
+ foreach my $key (keys(%{$settings->{$type}})) {
+ if ($key eq 'namedusers') {
+ $namedaccess{$type} = $settings->{$type}->{$key};
+ } elsif ($key eq 'machines') {
+ $machineaccess{$type} = $settings->{$type}->{$key};
+ }
+ }
+ }
+ }
+ }
+ }
+ my $titles= &LONCAPA::loncgi::serverstatus_titles();
+ my $rownum = 0;
+ my $css_class;
+ foreach my $type (@pages) {
+ $rownum ++;
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
+ $datatable .= ''.
+ ''.
+ $titles->{$type}.' | '.
+ ''.
+ ' | '.
+ ''.
+ ''.
+ ''.
+ ' | '."\n";
+ }
+ $$rowtotal += $rownum;
+ return $datatable;
+}
+
+sub serverstatus_pages {
+ return ('userstatus','lonstatus','loncron','server-status','codeversions',
+ 'clusterstatus','metadata_keywords','metadata_harvest',
+ 'takeoffline','takeonline','showenv');
+}
+
sub coursecategories_javascript {
my ($settings) = @_;
my ($output,$jstext,$cathash);
@@ -2282,7 +2452,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});
@@ -4138,7 +4336,7 @@ sub modify_defaults {
my ($dom,$r) = @_;
my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my @items = ('auth_def','auth_arg_def','lang_def','timezone_def');
+ my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def');
my @authtypes = ('internal','krb4','krb5','localauth');
foreach my $item (@items) {
$newvalues{$item} = $env{'form.'.$item};
@@ -4161,11 +4359,17 @@ 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);
}
}
+ } elsif ($item eq 'datelocale_def') {
+ if ($newvalues{$item} ne '') {
+ my @datelocale_ids = DateTime::Locale->ids();
+ if (!grep(/^\Q$newvalues{$item}\E$/,@datelocale_ids)) {
+ push(@errors,$item);
+ }
+ }
}
if (grep(/^\Q$item\E$/,@errors)) {
$newvalues{$item} = $domdefaults{$item};
@@ -4178,6 +4382,7 @@ sub modify_defaults {
auth_arg_def => $newvalues{'auth_arg_def'},
lang_def => $newvalues{'lang_def'},
timezone_def => $newvalues{'timezone_def'},
+ datelocale_def => $newvalues{'datelocale_def'},
}
);
my $title = &defaults_titles();
@@ -4210,7 +4415,7 @@ sub modify_defaults {
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,
$defaults_hash{'defaults'},$cachetime);
- if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'}) {
+ if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'} || $changes{'datelocale_def'}) {
my $sysmail = $r->dir_config('lonSysEMail');
&Apache::lonmsg::sendemail($sysmail,"LON-CAPA Domain Settings Change - $dom",$mailmsgtext);
}
@@ -4491,6 +4696,132 @@ sub modify_coursecategories {
}
return $resulttext;
}
+
+sub modify_serverstatuses {
+ my ($dom,%domconfig) = @_;
+ my ($resulttext,%changes,%currserverstatus,%newserverstatus);
+ if (ref($domconfig{'serverstatuses'}) eq 'HASH') {
+ %currserverstatus = %{$domconfig{'serverstatuses'}};
+ }
+ my @pages = &serverstatus_pages();
+ foreach my $type (@pages) {
+ $newserverstatus{$type}{'namedusers'} = '';
+ $newserverstatus{$type}{'machines'} = '';
+ if (defined($env{'form.'.$type.'_namedusers'})) {
+ my @users = split(/,/,$env{'form.'.$type.'_namedusers'});
+ my @okusers;
+ foreach my $user (@users) {
+ my ($uname,$udom) = split(/:/,$user);
+ if (($udom =~ /^$match_domain$/) &&
+ (&Apache::lonnet::domain($udom)) &&
+ ($uname =~ /^$match_username$/)) {
+ if (!grep(/^\Q$user\E/,@okusers)) {
+ push(@okusers,$user);
+ }
+ }
+ }
+ if (@okusers > 0) {
+ @okusers = sort(@okusers);
+ $newserverstatus{$type}{'namedusers'} = join(',',@okusers);
+ }
+ }
+ if (defined($env{'form.'.$type.'_machines'})) {
+ my @machines = split(/,/,$env{'form.'.$type.'_machines'});
+ my @okmachines;
+ foreach my $ip (@machines) {
+ my @parts = split(/\./,$ip);
+ next if (@parts < 4);
+ my $badip = 0;
+ for (my $i=0; $i<4; $i++) {
+ if (!(($parts[$i] >= 0) && ($parts[$i] <= 255))) {
+ $badip = 1;
+ last;
+ }
+ }
+ if (!$badip) {
+ push(@okmachines,$ip);
+ }
+ }
+ @okmachines = sort(@okmachines);
+ $newserverstatus{$type}{'machines'} = join(',',@okmachines);
+ }
+ }
+ my %serverstatushash = (
+ serverstatuses => \%newserverstatus,
+ );
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%serverstatushash,
+ $dom);
+ my %changes;
+ foreach my $type (@pages) {
+ if (ref($currserverstatus{$type}) eq 'HASH') {
+ my @currnamed = split(/,/,$currserverstatus{$type}{'namedusers'});
+ my @newusers = split(/,/,$newserverstatus{$type}{'namedusers'});
+ foreach my $item (@currnamed) {
+ if (!grep(/^\Q$item\E$/,@newusers)) {
+ $changes{$type}{'namedusers'} = 1;
+ last;
+ }
+ }
+ foreach my $item (@newusers) {
+ if (!grep(/^\Q$item\E$/,@currnamed)) {
+ $changes{$type}{'namedusers'} = 1;
+ last;
+ }
+ }
+ my @currmachines = split(/,/,$currserverstatus{$type}{'machines'});
+ my @newmachines = split(/,/,$newserverstatus{$type}{'machines'});
+ foreach my $item (@currmachines) {
+ if (!grep(/^\Q$item\E$/,@newmachines)) {
+ $changes{$type}{'machines'} = 1;
+ last;
+ }
+ }
+ foreach my $item (@newmachines) {
+ if (!grep(/^\Q$item\E$/,@currmachines)) {
+ $changes{$type}{'machines'} = 1;
+ last;
+ }
+ }
+
+ }
+ }
+ if (keys(%changes) > 0) {
+ my $titles= &LONCAPA::loncgi::serverstatus_titles();
+ my $putresult = &Apache::lonnet::put_dom('configuration',
+ \%serverstatushash,$dom);
+ if ($putresult eq 'ok') {
+ $resulttext .= &mt('Changes made:').'';
+ foreach my $type (@pages) {
+ if (defined($changes{$type})) {
+ $resulttext .= '- '.$titles->{$type}.'
';
+ if (defined($changes{$type}{'namedusers'})) {
+ if ($newserverstatus{$type}{'namedusers'} eq '') {
+ $resulttext .= '- '.&mt("Access terminated for all specific (named) users").'
'."\n";
+ } else {
+ $resulttext .= '- '.&mt("Access available for the following specified users: ").$newserverstatus{$type}{'namedusers'}.'
'."\n";
+ }
+ } elsif (defined($changes{$type}{'machines'})) {
+ if ($newserverstatus{$type}{'machines'} eq '') {
+ $resulttext .= '- '.&mt("Access terminated for all specific IP addresses").'
'."\n";
+ } else {
+ $resulttext .= '- '.&mt("Access available for the following specified IP addresses: ").$newserverstatus{$type}{'machines'}.'
'."\n";
+ }
+
+ }
+ $resulttext .= ' ';
+ }
+ }
+ $resulttext .= ' ';
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred saving access settings for server status pages: [_1].',$putresult).'';
+
+ }
+ } else {
+ $resulttext = &mt('No changes made to access to server status pages');
+ }
+ return $resulttext;
+}
sub recurse_check {
my ($chkcats,$categories,$depth,$name) = @_;
| | | | | |