[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm
raeburn
raeburn@source.lon-capa.org
Mon, 08 Dec 2008 22:42:43 -0000
This is a MIME encoded message
--raeburn1228776163
Content-Type: text/plain
raeburn Mon Dec 8 22:42:43 2008 EDT
Modified files:
/loncom/interface domainprefs.pm
Log:
- Bug 5839. DCs can set defaults for availability of User Tools (About Me, Portfolio, Blog) to users in a domain.
- Defaults defined for different institutional affiliation.
- Default for users with $env{'user.adv'} will override default based on affiliation.
- Storage of default portfolio quota will now be in a hash in $quotas{'defaultquota'}, instead of in top level hash in $quotas in configuration.db
- backwards compatibility maintained.
--raeburn1228776163
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20081208224243.txt"
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.71 loncom/interface/domainprefs.pm:1.72
--- loncom/interface/domainprefs.pm:1.71 Wed Dec 3 13:09:56 2008
+++ loncom/interface/domainprefs.pm Mon Dec 8 22:42:43 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.71 2008/12/03 13:09:56 muellerd Exp $
+# $Id: domainprefs.pm,v 1.72 2008/12/08 22:42:43 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -105,10 +105,11 @@
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',
@@ -519,10 +520,12 @@
$output .= '
<td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
}
- if ($action eq 'serverstatuses') {
- $output .= '<td class="LC_left_item" valign="top">'.
- &mt($item->{'header'}->[0]->{'col2'}).
- '<br />(<tt>'.&mt('user1:domain1,user2:domain2 etc.').'</tt>)';
+ if (defined($item->{'header'}->[0]->{'col3'})) {
+ $output .= '<td class="LC_left_item" valign="top">'.
+ &mt($item->{'header'}->[0]->{'col2'});
+ if ($action eq 'serverstatuses') {
+ $output .= '<br />(<tt>'.&mt('user1:domain1,user2:domain2 etc.').'</tt>)';
+ }
} else {
$output .= '<td class="LC_right_item" valign="top">'.
&mt($item->{'header'}->[0]->{'col2'});
@@ -1238,23 +1241,46 @@
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->{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 .= '<tr'.$css_class.'>'.
+ $datatable .= '<tr'.$css_class.'>'.
'<td>'.$usertypes->{$type}.'</td>'.
- '<td class="LC_right_item"><span class="LC_nobreak">'.
+ '<td class="LC_left_item">';
+ foreach my $item (@usertools) {
+ my $checked = 'checked="checked" ';
+ if (ref($settings->{$item}) eq 'HASH') {
+ if ($settings->{$item}->{$type} == 0) {
+ $checked = '';
+ }
+ }
+ $datatable .= '<span class="LC_nobreak"><label>'.
+ '<input type="checkbox" name="tools_'.$item.
+ '" value="'.$type.'" '.$checked.'/>'.$titles{$item}.
+ '</label></span> ';
+ }
+ $datatable .= '</td><td class="LC_right_item"><span class="LC_nobreak">'.
'<input type="text" name="quota_'.$type.
- '" value="'.$settings->{$type}.
+ '" value="'.$currdefquota.
'" size="5" /> Mb</span></td></tr>';
}
}
}
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 +1288,40 @@
$css_class = $typecount%2?' class="LC_odd_row"':'';
$datatable .= '<tr'.$css_class.'>'.
'<td>'.$othertitle.'</td>'.
- '<td class="LC_right_item"><span class="LC_nobreak">'.
+ '<td class="LC_left_item">';
+ foreach my $item (@usertools) {
+ my $checked = 'checked="checked" ';
+ if (ref($settings->{$item}) eq 'HASH') {
+ if ($settings->{$item}->{'default'} == 0) {
+ $checked = '';
+ }
+ }
+ $datatable .= '<span class="LC_nobreak"><label>'.
+ '<input type="checkbox" name="tools_'.$item.
+ '" value="default" '.$checked.'/>'.$titles{$item}.
+ '</label></span> ';
+ }
+ $datatable .= '</td><td class="LC_right_item"><span class="LC_nobreak">'.
'<input type="text" name="defaultquota" value="'.
$defaultquota.'" size="5" /> Mb</span></td></tr>';
+ $typecount ++;
+ $css_class = $typecount%2?' class="LC_odd_row"':'';
+ $datatable .= '<tr'.$css_class.'>'.
+ '<td><br/>'.&mt('LON-CAPA Advanced Users').'</td>'.
+ '<td class="LC_left_item" colspan="2"><br />';
+ foreach my $item (@usertools) {
+ my $checked = 'checked="checked" ';
+ if (ref($settings->{$item}) eq 'HASH') {
+ if ($settings->{$item}->{'_LC_adv'} == 0) {
+ $checked = '';
+ }
+ }
+ $datatable .= '<span class="LC_nobreak"><label>'.
+ '<input type="checkbox" name="tools_'.$item.
+ '" value="_LC_adv" '.$checked.'/>'.$titles{$item}.
+ '</label></span> ';
+ }
+ $datatable .= '('.&mt('overrides affiliation').')</td></tr>';
$$rowtotal += $typecount;
return $datatable;
}
@@ -1585,6 +1642,15 @@
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;
@@ -3430,57 +3496,137 @@
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:').'<ul>';
- 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 .= '<li>'.&mt('Portfolio default quotas').'<ul>';
+ foreach my $type (@{$types},'default') {
+ if (defined($changes{'defaultquota'}{$type})) {
+ my $typetitle = $usertypes->{$type};
+ if ($type eq 'default') {
+ $typetitle = $othertitle;
+ }
+ $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'defaultquota'}{$type}).'</li>';
+ }
+ }
+ $resulttext .= '</ul></li>';
+ }
+ foreach my $item (@usertools) {
+ if (ref($changes{$item}) eq 'HASH') {
+ $resulttext .= '<li>'.$titles{$item}.'<ul>';
+ 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 .= '<li>'.&mt('Set to be available to [_1]',$typetitle).'</li>';
+ } else {
+ $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
+ }
+ }
}
- $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$formhash{$type}).'</li>';
+ $resulttext .= '</ul></li>';
}
}
$resulttext .= '</ul>';
} 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 = '<span class="LC_error">'.
@@ -4443,15 +4589,11 @@
} 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 +4622,7 @@
$resulttext .= '</ul>';
$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);
--raeburn1228776163--