+
+
+
+ '.&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 +483,10 @@ sub print_config_box {
- '.&mt($item->{'header'}->[2]->{'col1'}).' |
- '.&mt($item->{'header'}->[2]->{'col2'}).' |
+ '.
+ &mt($item->{'header'}->[2]->{'col1'}).' |
+ '.
+ &mt($item->{'header'}->[2]->{'col2'}).' |
'.
&print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'
@@ -479,13 +511,35 @@ sub print_config_box {
if (($action eq 'login') || ($action eq 'directorysrch')) {
$output .= '
| '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
+ } elsif ($action eq 'serverstatuses') {
+ $output .= '
+ '.&mt($item->{'header'}->[0]->{'col1'}).
+ ' ('.&mt('Automatic access for Dom. Coords.').') | ';
+
} else {
$output .= '
- '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
+ '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
}
- $output .= '
- '.&mt($item->{'header'}->[0]->{'col2'}).' |
- ';
+ if (defined($item->{'header'}->[0]->{'col3'})) {
+ $output .= ''.
+ &mt($item->{'header'}->[0]->{'col2'});
+ if ($action eq 'serverstatuses') {
+ $output .= ' ('.&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 +555,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 .= '
@@ -644,6 +700,7 @@ sub print_login {
);
foreach my $item (@images) {
$defaults{$item} = $defaultdesign{'login.'.$item};
+ $defaults{'showlogo'}{$item} = 1;
}
foreach my $item (@bgs) {
$defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
@@ -665,10 +722,13 @@ sub print_login {
}
}
foreach my $item (@images) {
- if ($settings->{$item} ne '') {
+ if (defined($settings->{$item})) {
$designs{$item} = $settings->{$item};
$is_custom{$item} = 1;
}
+ if (defined($settings->{'showlogo'}{$item})) {
+ $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
+ }
}
foreach my $item (@logintext) {
if ($settings->{$item} ne '') {
@@ -757,9 +817,9 @@ sub login_choices {
bgs => "Background colors",
links => "Link colors",
font => "Font color",
- pgbg => "Page",
- mainbg => "Main panel",
- sidebg => "Side panel",
+ pgbg => "Header",
+ mainbg => "Page",
+ sidebg => "Login box",
link => "Link",
alink => "Active link",
vlink => "Visited link",
@@ -862,20 +922,27 @@ sub display_color_options {
$itemcount ++;
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= ''.
- ''.$choices->{$img}.' | ';
+ ''.$choices->{$img};
my ($imgfile,$img_import,$login_hdr_pick,$logincolors);
+ if ($role eq 'login') {
+ if ($img eq 'login') {
+ $login_hdr_pick =
+ &login_header_options($img,$role,$defaults,$is_custom,$choices,
+ $loginheader);
+ $logincolors =
+ &login_text_colors($img,$role,$logintext,$phase,$choices,
+ $designs);
+ } elsif ($img ne 'domlogo') {
+ $datatable.= &logo_display_options($img,$defaults,$designs);
+ }
+ }
+ $datatable .= ' | ';
if ($designs->{$img} ne '') {
$imgfile = $designs->{$img};
$img_import = ($imgfile =~ m{^/adm/});
} else {
$imgfile = $defaults->{$img};
}
- if ($img eq 'login') {
- $login_hdr_pick = &login_header_options($img,$role,$defaults,$is_custom,$choices,
- $loginheader);
- $logincolors =
- &login_text_colors($img,$role,$logintext,$phase,$choices,$designs);
- }
if ($imgfile) {
my ($showfile,$fullsize);
if ($imgfile =~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
@@ -964,7 +1031,7 @@ sub display_color_options {
my $bgs_def;
foreach my $item (@{$bgs}) {
if (!$is_custom->{$item}) {
- $bgs_def .= ''.$choices->{$item}.' '.$defaults->{'bgs'}{$item}.' | ';
+ $bgs_def .= ''.$choices->{$item}.' '.$defaults->{'bgs'}{$item}.' | ';
}
}
if ($bgs_def) {
@@ -1015,6 +1082,32 @@ sub display_color_options {
return $datatable;
}
+sub logo_display_options {
+ my ($img,$defaults,$designs) = @_;
+ my $checkedon;
+ if (ref($defaults) eq 'HASH') {
+ if (ref($defaults->{'showlogo'}) eq 'HASH') {
+ if ($defaults->{'showlogo'}{$img}) {
+ $checkedon = 'checked="checked" ';
+ }
+ }
+ }
+ if (ref($designs) eq 'HASH') {
+ if (ref($designs->{'showlogo'}) eq 'HASH') {
+ if (defined($designs->{'showlogo'}{$img})) {
+ if ($designs->{'showlogo'}{$img} == 0) {
+ $checkedon = '';
+ } elsif ($designs->{'showlogo'}{$img} == 1) {
+ $checkedon = 'checked="checked" ';
+ }
+ }
+ }
+ }
+ return ' '."\n";
+}
+
sub login_header_options {
my ($img,$role,$defaults,$is_custom,$choices,$loginheader) = @_;
my $image_checked = ' checked="checked" ';
@@ -1066,7 +1159,7 @@ sub image_changes {
my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;
my $output;
if (!$is_custom) {
- if ($img eq 'login') {
+ if ($img ne 'domlogo') {
$output .= &mt('Default image:').' ';
} else {
$output .= &mt('Default in use:').' ';
@@ -1148,23 +1241,50 @@ sub print_quotas {
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
my $typecount = 0;
my $css_class;
+ my @usertools = ('aboutme','blog','portfolio');
+ my %titles = &tool_titles();
if (ref($types) eq 'ARRAY') {
foreach my $type (@{$types}) {
+ my $currdefquota;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{defaultquota}) eq 'HASH') {
+ $currdefquota = $settings->{defaultquota}->{$type};
+ } else {
+ $currdefquota = $settings->{$type};
+ }
+ }
if (defined($usertypes->{$type})) {
$typecount ++;
$css_class = $typecount%2?' class="LC_odd_row"':'';
- $datatable .= ' '.
+ $datatable .= ' '.
''.$usertypes->{$type}.' | '.
- ''.
+ ' | ';
+ foreach my $item (@usertools) {
+ my $checked = 'checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$item}) eq 'HASH') {
+ if ($settings->{$item}->{$type} == 0) {
+ $checked = '';
+ }
+ }
+ }
+ $datatable .= ' ';
+ }
+ $datatable .= ' | '.
' Mb | ';
}
}
}
my $defaultquota = '20';
if (ref($settings) eq 'HASH') {
- if (defined($settings->{'default'})) {
+ if (ref($settings->{'defaultquota'}) eq 'HASH') {
+ $defaultquota = $settings->{'defaultquota'}->{'default'};
+ } elsif (defined($settings->{'default'})) {
$defaultquota = $settings->{'default'};
}
}
@@ -1172,9 +1292,45 @@ sub print_quotas {
$css_class = $typecount%2?' class="LC_odd_row"':'';
$datatable .= ''.
''.$othertitle.' | '.
- ''.
+ ' | ';
+ foreach my $item (@usertools) {
+ my $checked = 'checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$item}) eq 'HASH') {
+ if ($settings->{$item}->{'default'} == 0) {
+ $checked = '';
+ }
+ }
+ }
+ $datatable .= ' ';
+ }
+ $datatable .= ' | '.
' Mb | ';
+ $typecount ++;
+ $css_class = $typecount%2?' class="LC_odd_row"':'';
+ $datatable .= ''.
+ ' '.&mt('LON-CAPA Advanced Users').' | '.
+ ' ';
+ foreach my $item (@usertools) {
+ my $checked = 'checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$item}) eq 'HASH') {
+ if ($settings->{$item}->{'_LC_adv'} == 0) {
+ $checked = '';
+ }
+ }
+ }
+ $datatable .= ' ';
+ }
+ $datatable .= '('.&mt('overrides affiliation').
+ ') | ';
$$rowtotal += $typecount;
return $datatable;
}
@@ -1448,24 +1604,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 +1631,6 @@ sub print_contacts {
''.
' '."\n";
- $rownum ++;
}
$$rowtotal += $rownum;
return $datatable;
@@ -1491,7 +1639,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'
@@ -1503,6 +1651,15 @@ sub contact_titles {
return (\%titles,\%short_titles);
}
+sub tool_titles {
+ my %titles = &Apache::lonlocal::texthash (
+ aboutme => 'Personal Home Page',
+ blog => 'Blog',
+ portfolio => 'Portfolio',
+ );
+ return %titles;
+}
+
sub print_usercreation {
my ($position,$dom,$settings,$rowtotal) = @_;
my $numinrow = 4;
@@ -1682,10 +1839,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++) {
@@ -1733,7 +1894,7 @@ sub usercreation_types {
any => 'Any',
official => 'Institutional only ',
unofficial => 'Non-institutional only',
- email => 'Email address',
+ email => 'E-mail address',
login => 'Institutional Login',
sso => 'SSO',
none => 'None',
@@ -1773,7 +1934,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 +1943,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 +1999,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 +2019,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);
}
@@ -1950,14 +2130,15 @@ sub print_scantronformat {
$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 .= ' | ';
+ $datatable .= '';
if (keys(%error) == 0) {
$datatable .= '';
if (!$switchserver) {
@@ -1978,19 +2159,21 @@ sub print_scantronformat {
}
$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 .= ' | ';
@@ -2166,6 +2349,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::lonauthcgi::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);
@@ -2361,12 +2596,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');
@@ -2716,6 +2959,13 @@ sub modify_colors {
$domconfig->{$role} = {};
}
foreach my $img (@images) {
+ if (($role eq 'login') && (($img eq 'img') || ($img eq 'logo'))) {
+ if (defined($env{'form.login_showlogo_'.$img})) {
+ $confhash->{$role}{'showlogo'}{$img} = 1;
+ } else {
+ $confhash->{$role}{'showlogo'}{$img} = 0;
+ }
+ }
if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
&& !defined($domconfig->{$role}{$img})
&& !$env{'form.'.$role.'_del_'.$img}
@@ -2790,7 +3040,19 @@ sub modify_colors {
$changes{$role}{'images'}{$img} = 1;
}
}
- }
+ if (($role eq 'login') && (($img eq 'logo') || ($img eq 'img'))) {
+ if (ref($domconfig->{'login'}{'showlogo'}) eq 'HASH') {
+ if ($confhash->{$role}{'showlogo'}{$img} ne
+ $domconfig->{$role}{'showlogo'}{$img}) {
+ $changes{$role}{'showlogo'}{$img} = 1;
+ }
+ } else {
+ if ($confhash->{$role}{'showlogo'}{$img} == 0) {
+ $changes{$role}{'showlogo'}{$img} = 1;
+ }
+ }
+ }
+ }
if ($domconfig->{$role}{'font'} ne '') {
if ($confhash->{$role}{'font'} ne $domconfig->{$role}{'font'}) {
$changes{$role}{'font'} = 1;
@@ -2882,6 +3144,11 @@ sub default_change_checker {
$confhash->{$role}{$img} = '';
$changes->{$role}{'images'}{$img} = 1;
}
+ if ($role eq 'login') {
+ if ($confhash->{$role}{'showlogo'}{$img} == 0) {
+ $changes->{$role}{'showlogo'}{$img} = 1;
+ }
+ }
}
if ($confhash->{$role}{'font'}) {
$changes->{$role}{'font'} = 1;
@@ -2913,7 +3180,13 @@ sub display_colorchgs {
$resulttext .= ''.&mt($choices{$key}).':';
}
foreach my $item (sort(keys(%{$changes->{$role}{$key}}))) {
- if ($confhash->{$role}{$item} eq '') {
+ if (($role eq 'login') && ($key eq 'showlogo')) {
+ if ($confhash->{$role}{$key}{$item}) {
+ $resulttext .= '- '.&mt("$choices{$item} set to be displayed").'
';
+ } else {
+ $resulttext .= '- '.&mt("$choices{$item} set to not be displayed").'
';
+ }
+ } elsif ($confhash->{$role}{$item} eq '') {
$resulttext .= '- '.&mt("$choices{$item} set to default").'
';
} else {
my $newitem = $confhash->{$role}{$item};
@@ -3232,57 +3505,148 @@ END
sub modify_quotas {
my ($dom,%domconfig) = @_;
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
my ($resulttext,%changes);
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- my %formhash;
+ my @usertools = ('aboutme','blog','portfolio');
+ my %titles = &tool_titles();
+ my (%confhash,%toolshash);
foreach my $key (keys(%env)) {
if ($key =~ /^form\.quota_(.+)$/) {
- $formhash{$1} = $env{$key};
+ $confhash{'defaultquota'}{$1} = $env{$key};
+ } elsif ($key =~ /^form\.tools_(.+)$/) {
+ @{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
}
}
- $formhash{'default'} = $env{'form.defaultquota'};
- if (ref($domconfig{'quotas'}) eq 'HASH') {
- foreach my $key (keys(%{$domconfig{'quotas'}})) {
- if (exists($formhash{$key})) {
- if ($formhash{$key} ne $domconfig{'quotas'}{$key}) {
- $changes{$key} = 1;
+ $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
+ foreach my $item (@usertools) {
+ foreach my $type (@{$types},'default','_LC_adv') {
+ if (grep(/^\Q$type\E$/,@{$toolshash{$item}})) {
+ $confhash{$item}{$type} = 1;
+ } else {
+ $confhash{$item}{$type} = 0;
+ }
+ if (ref($domconfig{'quotas'}) eq 'HASH') {
+ if (ref($domconfig{'quotas'}{$item}) eq 'HASH') {
+ if ($domconfig{'quotas'}{$item}{$type} ne $confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
+ } else {
+ if (!$confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
}
} else {
- $formhash{$key} = $domconfig{'quotas'}{$key};
+ if (!$confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
+ }
+ }
+ }
+ if (ref($domconfig{'quotas'}) eq 'HASH') {
+ if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
+ foreach my $key (keys(%{$domconfig{'quotas'}{'defaultquota'}})) {
+ if (exists($confhash{'defaultquota'}{$key})) {
+ if ($confhash{'defaultquota'}{$key} ne $domconfig{'quotas'}{'defaultquota'}{$key}) {
+ $changes{'defaultquota'}{$key} = 1;
+ }
+ } else {
+ $confhash{'defaultquota'}{$key} = $domconfig{'quotas'}{'defaultquota'}{$key};
+ }
+ }
+ } else {
+ foreach my $key (keys(%{$domconfig{'quotas'}})) {
+ if (exists($confhash{'defaultquota'}{$key})) {
+ if ($confhash{'defaultquota'}{$key} ne $domconfig{'quotas'}{$key}) {
+ $changes{'defaultquota'}{$key} = 1;
+ }
+ } else {
+ $confhash{'defaultquota'}{$key} = $domconfig{'quotas'}{$key};
+ }
}
}
}
- foreach my $key (keys(%formhash)) {
- if ($formhash{$key} ne '') {
+ if (ref($confhash{'defaultquota'}) eq 'HASH') {
+ foreach my $key (keys(%{$confhash{'defaultquota'}})) {
if (ref($domconfig{'quotas'}) eq 'HASH') {
- if (!exists($domconfig{'quotas'}{$key})) {
- $changes{$key} = 1;
+ if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
+ if (!exists($domconfig{'quotas'}{'defaultquota'}{$key})) {
+ $changes{'defaultquota'}{$key} = 1;
+ }
+ } else {
+ if (!exists($domconfig{'quotas'}{$key})) {
+ $changes{'defaultquota'}{$key} = 1;
+ }
}
} else {
- $changes{$key} = 1;
+ $changes{'defaultquota'}{$key} = 1;
}
}
}
+
+ foreach my $key (keys(%confhash)) {
+ $domdefaults{$key} = $confhash{$key};
+ }
+
my %quotahash = (
- quotas => {%formhash},
+ quotas => { %confhash }
);
my $putresult = &Apache::lonnet::put_dom('configuration',\%quotahash,
$dom);
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+
$resulttext = &mt('Changes made:').'';
- foreach my $type (@{$types},'default') {
- if (defined($changes{$type})) {
- my $typetitle = $usertypes->{$type};
- if ($type eq 'default') {
- $typetitle = $othertitle;
+ if (ref($changes{'defaultquota'}) eq 'HASH') {
+ $resulttext .= '- '.&mt('Portfolio default quotas').'
';
+ foreach my $type (@{$types},'default') {
+ if (defined($changes{'defaultquota'}{$type})) {
+ my $typetitle = $usertypes->{$type};
+ if ($type eq 'default') {
+ $typetitle = $othertitle;
+ }
+ $resulttext .= '- '.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'defaultquota'}{$type}).'
';
+ }
+ }
+ $resulttext .= ' ';
+ }
+ my %newenv;
+ foreach my $item (@usertools) {
+ if (ref($changes{$item}) eq 'HASH') {
+ my $newacc =
+ &Apache::lonnet::usertools_access($env{'user.name'},
+ $env{'user.domain'},
+ $item,'reload');
+ if ($env{'environment.availabletools.'.$item} ne $newacc) {
+ $newenv{'environment.availabletools.'.$item} = $newacc;
+ }
+ $resulttext .= '- '.$titles{$item}.'
';
+ foreach my $type (@{$types},'default','_LC_adv') {
+ if ($changes{$item}{$type}) {
+ my $typetitle = $usertypes->{$type};
+ if ($type eq 'default') {
+ $typetitle = $othertitle;
+ } elsif ($type eq '_LC_adv') {
+ $typetitle = 'LON-CAPA Advanced Users';
+ }
+ if ($confhash{$item}{$type}) {
+ $resulttext .= '- '.&mt('Set to be available to [_1]',$typetitle).'
';
+ } else {
+ $resulttext .= '- '.&mt('Set to be unavailable to [_1]',$typetitle).'
';
+ }
+ }
}
- $resulttext .= '- '.&mt('[_1] set to [_2] Mb',$typetitle,$formhash{$type}).'
';
+ $resulttext .= ' ';
}
}
$resulttext .= ' ';
+ if (keys(%newenv)) {
+ &Apache::lonnet::appenv(\%newenv);
+ }
} else {
- $resulttext = &mt('No changes made to default quotas');
+ $resulttext = &mt('No changes made to availability of home pages, blogs, portfolios or default quotas');
}
} else {
$resulttext = ''.
@@ -4089,10 +4453,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 +4465,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 +4518,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});
@@ -4185,7 +4569,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};
@@ -4208,25 +4592,28 @@ 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};
} elsif ($domdefaults{$item} ne $newvalues{$item}) {
$changes{$item} = 1;
}
+ $domdefaults{$item} = $newvalues{$item};
}
my %defaults_hash = (
- defaults => { auth_def => $newvalues{'auth_def'},
- auth_arg_def => $newvalues{'auth_arg_def'},
- lang_def => $newvalues{'lang_def'},
- timezone_def => $newvalues{'timezone_def'},
- }
- );
+ defaults => \%newvalues,
+ );
my $title = &defaults_titles();
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaults_hash,
$dom);
@@ -4255,9 +4642,8 @@ sub modify_defaults {
$resulttext .= '
';
$mailmsgtext .= "\n";
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'}) {
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ 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);
}
@@ -4538,6 +4924,131 @@ 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 %changes;
+ foreach my $type (@pages) {
+ foreach my $setting ('namedusers','machines') {
+ my (@current,@new);
+ if (ref($currserverstatus{$type}) eq 'HASH') {
+ if ($currserverstatus{$type}{$setting} ne '') {
+ @current = split(/,/,$currserverstatus{$type}{$setting});
+ }
+ }
+ if ($newserverstatus{$type}{$setting} ne '') {
+ @new = split(/,/,$newserverstatus{$type}{$setting});
+ }
+ if (@current > 0) {
+ if (@new > 0) {
+ foreach my $item (@current) {
+ if (!grep(/^\Q$item\E$/,@new)) {
+ $changes{$type}{$setting} = 1;
+ last;
+ }
+ }
+ foreach my $item (@new) {
+ if (!grep(/^\Q$item\E$/,@current)) {
+ $changes{$type}{$setting} = 1;
+ last;
+ }
+ }
+ } else {
+ $changes{$type}{$setting} = 1;
+ }
+ } elsif (@new > 0) {
+ $changes{$type}{$setting} = 1;
+ }
+ }
+ }
+ if (keys(%changes) > 0) {
+ my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
+ my $putresult = &Apache::lonnet::put_dom('configuration',
+ \%serverstatushash,$dom);
+ if ($putresult eq 'ok') {
+ $resulttext .= &mt('Changes made:').'';
+ foreach my $type (@pages) {
+ if (ref($changes{$type}) eq 'HASH') {
+ $resulttext .= '- '.$titles->{$type}.'
';
+ if ($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";
+ }
+ }
+ if ($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) = @_;
| | |