--- loncom/interface/domainprefs.pm 2008/12/01 15:03:40 1.70
+++ loncom/interface/domainprefs.pm 2009/09/14 15:59:10 1.76.4.2
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.70 2008/12/01 15:03:40 raeburn Exp $
+# $Id: domainprefs.pm,v 1.76.4.2 2009/09/14 15:59:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,7 +39,7 @@ use Apache::lonlocal;
use Apache::lonmsg();
use LONCAPA qw(:DEFAULT :match);
use LONCAPA::Enrollment;
-use LONCAPA::loncgi();
+use LONCAPA::lonauthcgi();
use File::Copy;
use Locale::Language;
use DateTime::TimeZone;
@@ -105,10 +105,11 @@ sub handler {
col2 => 'Value'}],
},
'quotas' =>
- { text => 'Default quotas for user portfolios',
+ { text => 'User blogs, home pages and portfolios',
help => 'Domain_Configuration_Quotas',
header => [{col1 => 'User type',
- col2 => 'Default quota'}],
+ col2 => 'Available tools',
+ col3 => 'Portfolio quota',}],
},
'autoenroll' =>
{ text => 'Auto-enrollment settings',
@@ -270,7 +271,7 @@ sub handler {
$r->print(''.
''."\n".
- ''.&mt('No settings chosen').
+ ''.&mt('No settings chosen').
'');
}
$r->print('');
@@ -519,10 +520,12 @@ sub print_config_box {
$output .= '
'.&mt($item->{'header'}->[0]->{'col1'}).' | ';
}
- if ($action eq 'serverstatuses') {
- $output .= ''.
- &mt($item->{'header'}->[0]->{'col2'}).
- ' ('.&mt('user1:domain1,user2:domain2 etc.').')';
+ 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'});
@@ -1238,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'};
}
}
@@ -1262,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;
}
@@ -1505,7 +1571,7 @@ sub print_contacts {
my $datatable;
my @contacts = ('adminemail','supportemail');
my (%checked,%to,%otheremails);
- my @mailings = ('errormail','packagesmail','helpdeskmail');
+ my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail');
foreach my $type (@mailings) {
$otheremails{$type} = '';
}
@@ -1525,6 +1591,8 @@ sub print_contacts {
}
$otheremails{$type} = $settings->{$type}{'others'};
}
+ } elsif ($type eq 'lonstatusmail') {
+ $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
}
}
} else {
@@ -1532,7 +1600,8 @@ sub print_contacts {
$to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
$checked{'errormail'}{'adminemail'} = ' checked="checked" ';
$checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
- $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
+ $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
+ $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
}
my ($titles,$short_titles) = &contact_titles();
my $rownum = 0;
@@ -1576,7 +1645,8 @@ sub contact_titles {
'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'
+ 'helpdeskmail' => 'Helpdesk requests to be e-mailed to',
+ 'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)',
);
my %short_titles = &Apache::lonlocal::texthash (
adminemail => 'Admin E-mail address',
@@ -1585,6 +1655,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;
@@ -2298,7 +2377,7 @@ sub print_serverstatuses {
}
}
}
- my $titles= &LONCAPA::loncgi::serverstatus_titles();
+ my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
my $rownum = 0;
my $css_class;
foreach my $type (@pages) {
@@ -3430,57 +3509,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;
+ }
}
}
}
- foreach my $key (keys(%formhash)) {
- if ($formhash{$key} ne '') {
+ 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};
+ }
+ }
+ }
+ }
+ 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 = ''.
@@ -3863,7 +4033,7 @@ sub modify_contacts {
}
my (%others,%to);
my @contacts = ('supportemail','adminemail');
- my @mailings = ('errormail','packagesmail','helpdeskmail');
+ my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail');
foreach my $type (@mailings) {
@{$newsetting{$type}} =
&Apache::loncommon::get_env_multiple('form.'.$type);
@@ -3908,6 +4078,7 @@ sub modify_contacts {
$default{'errormail'} = 'adminemail';
$default{'packagesmail'} = 'adminemail';
$default{'helpdeskmail'} = 'supportemail';
+ $default{'lonstatusmail'} = 'adminemail';
foreach my $item (@contacts) {
if ($to{$item} ne $default{$item}) {
$changes{$item} = 1;
@@ -4417,8 +4588,10 @@ sub modify_defaults {
if ($newvalues{$item} ne '') {
if ($newvalues{$item} =~ /^(\w+)/) {
my $langcode = $1;
- if (code2language($langcode) eq '') {
- push(@errors,$item);
+ if ($langcode ne 'gci' && $langcode ne 'x_chef') {
+ if (code2language($langcode) eq '') {
+ push(@errors,$item);
+ }
}
} else {
push(@errors,$item);
@@ -4443,15 +4616,11 @@ sub modify_defaults {
} 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'},
- datelocale_def => $newvalues{'datelocale_def'},
- }
- );
+ defaults => \%newvalues,
+ );
my $title = &defaults_titles();
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaults_hash,
$dom);
@@ -4480,8 +4649,7 @@ sub modify_defaults {
$resulttext .= '';
$mailmsgtext .= "\n";
my $cachetime = 24*60*60;
- &Apache::lonnet::do_cache_new('domdefaults',$dom,
- $defaults_hash{'defaults'},$cachetime);
+ &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);
@@ -4600,8 +4768,10 @@ sub modify_coursecategories {
} else {
$changes{'togglecats'} = 1;
$changes{'categorize'} = 1;
- $domconfig{'coursecategories'}{'togglecats'} = $env{'form.togglecats'};
- $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
+ $domconfig{'coursecategories'} = {
+ togglecats => $env{'form.togglecats'},
+ categorize => $env{'form.categorize'},
+ };
}
if (ref($cathash) eq 'HASH') {
if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) {
@@ -4816,58 +4986,57 @@ sub modify_serverstatuses {
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 $setting ('namedusers','machines') {
+ my (@current,@new);
+ if (ref($currserverstatus{$type}) eq 'HASH') {
+ if ($currserverstatus{$type}{$setting} ne '') {
+ @current = split(/,/,$currserverstatus{$type}{$setting});
}
}
- foreach my $item (@newmachines) {
- if (!grep(/^\Q$item\E$/,@currmachines)) {
- $changes{$type}{'machines'} = 1;
- last;
+ 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::loncgi::serverstatus_titles();
+ 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 (defined($changes{$type})) {
+ if (ref($changes{$type}) eq 'HASH') {
$resulttext .= '- '.$titles->{$type}.'
';
- if (defined($changes{$type}{'namedusers'})) {
+ 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";
}
- } elsif (defined($changes{$type}{'machines'})) {
+ }
+ if ($changes{$type}{'machines'}) {
if ($newserverstatus{$type}{'machines'} eq '') {
$resulttext .= '- '.&mt("Access terminated for all specific IP addresses").'
'."\n";
} else {