--- loncom/interface/domainprefs.pm 2012/12/12 01:57:37 1.160.6.9
+++ loncom/interface/domainprefs.pm 2013/12/18 01:30:52 1.213
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.9 2012/12/12 01:57:37 raeburn Exp $
+# $Id: domainprefs.pm,v 1.213 2013/12/18 01:30:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -45,7 +45,7 @@ described at http://www.lon-capa.org.
=head1 OVERVIEW
Each institution using LON-CAPA will typically have a single domain designated
-for use by individuals affliated with the institution. Accordingly, each domain
+for use by individuals affiliated with the institution. Accordingly, each domain
may define a default set of logos and a color scheme which can be used to "brand"
the LON-CAPA instance. In addition, an institution will typically have a language
and timezone which are used for the majority of courses.
@@ -86,7 +86,7 @@ $dom,$settings,$rowtotal,$action.
$dom is the domain, $settings is a reference to a hash of current settings for
the current context, $rowtotal is a reference to the scalar used to record the
-number of rows displayed on the page, and $action is the context (quotas,
+number of rows displayed on the page, and $action is the context (quotas,
requestcourses or requestauthor).
The print_quotas routine was orginally created to display/store information
@@ -94,7 +94,8 @@ about default quota sizes for portfolio
institutional affiliation in the domain (e.g., Faculty, Staff, Student etc.),
but is now also used to manage availability of user tools:
i.e., blogs, aboutme page, and portfolios, and the course request tool,
-used by course owners to request creation of a course.
+used by course owners to request creation of a course, and to display/store
+default quota sizes for authoring spaces.
Outputs: 1
@@ -210,13 +211,15 @@ sub handler {
'quotas','autoenroll','autoupdate','autocreate',
'directorysrch','usercreation','usermodification',
'contacts','defaults','scantron','coursecategories',
- 'serverstatuses','requestcourses','usersessions',
- 'loadbalancing','requestauthor'],$dom);
+ 'serverstatuses','requestcourses','helpsettings',
+ 'coursedefaults','usersessions','loadbalancing',
+ 'requestauthor'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','autocreate','directorysrch','contacts',
'usercreation','usermodification','scantron',
'requestcourses','requestauthor','coursecategories',
- 'serverstatuses','usersessions');
+ 'serverstatuses','helpsettings',
+ 'coursedefaults','usersessions');
my %existing;
if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
%existing = %{$domconfig{'loadbalancing'}};
@@ -252,11 +255,11 @@ sub handler {
col2 => 'Value'}],
},
'quotas' =>
- { text => 'Blogs, personal web pages, webDAV, portfolios',
+ { text => 'Blogs, personal web pages, webDAV/quotas, portfolios',
help => 'Domain_Configuration_Quotas',
header => [{col1 => 'User affiliation',
col2 => 'Available tools',
- col3 => 'Portfolio quota',}],
+ col3 => 'Quotas, MB; (Authoring requires role)',}],
},
'autoenroll' =>
{ text => 'Auto-enrollment settings',
@@ -353,6 +356,26 @@ sub handler {
col3 => 'Specific IPs',
}],
},
+ 'helpsettings' =>
+ {text => 'Help page settings',
+ help => 'Domain_Configuration_Help_Settings',
+ header => [{col1 => 'Help Settings (logged-in users)',
+ col2 => 'Value'}],
+ },
+ 'coursedefaults' =>
+ {text => 'Course/Community defaults',
+ help => 'Domain_Configuration_Course_Defaults',
+ header => [{col1 => 'Defaults which can be overridden in each course by a CC',
+ col2 => 'Value',},
+ {col1 => 'Defaults which can be overridden for each course by a DC',
+ col2 => 'Value',},],
+ },
+ 'privacy' =>
+ {text => 'User Privacy',
+ help => 'Domain_Configuration_User_Privacy',
+ header => [{col1 => 'Setting',
+ col2 => 'Value',}],
+ },
'usersessions' =>
{text => 'User session hosting/offloading',
help => 'Domain_Configuration_User_Sessions',
@@ -368,7 +391,7 @@ sub handler {
help => 'Domain_Configuration_Load_Balancing',
header => [{col1 => 'Balancers',
col2 => 'Default destinations',
- col3 => 'User affliation',
+ col3 => 'User affiliation',
col4 => 'Overrides'},
],
},
@@ -384,16 +407,24 @@ sub handler {
col2 => 'Value'}],
};
}
+
my @roles = ('student','coordinator','author','admin');
my @actions = &Apache::loncommon::get_env_multiple('form.actions');
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'pickactions')",
text=>"Settings to display/modify"});
my $confname = $dom.'-domainconfig';
+
if ($phase eq 'process') {
- &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);
+ my $result = &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,
+ \%prefs,\%domconfig,$confname,\@roles);
+ if (ref($result) eq 'HASH') {
+ $r->rflush();
+ &devalidate_remote_domconfs($dom,$result);
+ }
} elsif ($phase eq 'display') {
- my $js = &recaptcha_js();
+ my $js = &recaptcha_js().
+ &credits_js();
if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($dom);
@@ -405,6 +436,34 @@ sub handler {
}
&Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);
} else {
+# check if domconfig user exists for the domain.
+ my $servadm = $r->dir_config('lonAdmEMail');
+ my ($configuserok,$author_ok,$switchserver) =
+ &config_check($dom,$confname,$servadm);
+ unless ($configuserok eq 'ok') {
+ &Apache::lonconfigsettings::print_header($r,$phase,$context);
+ $r->print(&mt('The domain configuration user "[_1]" has yet to be created.',
+ $confname).
+ ' '
+ );
+ if ($switchserver) {
+ $r->print(&mt('Ordinarily, that domain configuration user is created when the ./UPDATE script is run to install LON-CAPA for the first time.').
+ ' '.
+ &mt('However, that does not apply when new domains are added to a multi-domain server, and ./UPDATE has not been run recently.').
+ ' '.
+ &mt('The "[_1]" user can be created automatically when a Domain Coordinator visits the web-based "Set domain configuration" screen, in a session hosted on the primary library server.',$confname).
+ ' '.
+ &mt('To do that now, use the following link: [_1]',$switchserver)
+ );
+ } else {
+ $r->print(&mt('To create that user from the command line run the ./UPDATE script found in the top level directory of the extracted LON-CAPA tarball.').
+ ' '.
+ &mt('Once that is done, you will be able to use the web-based "Set domain configuration" to configure the domain')
+ );
+ }
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ }
if (keys(%domconfig) == 0) {
my $primarylibserv = &Apache::lonnet::domain($dom,'primary');
my @ids=&Apache::lonnet::current_machine_ids();
@@ -444,21 +503,21 @@ sub handler {
}
sub process_changes {
- my ($r,$dom,$confname,$action,$roles,$values) = @_;
+ my ($r,$dom,$confname,$action,$roles,$values,$lastactref) = @_;
my %domconfig;
if (ref($values) eq 'HASH') {
%domconfig = %{$values};
}
my $output;
if ($action eq 'login') {
- $output = &modify_login($r,$dom,$confname,%domconfig);
+ $output = &modify_login($r,$dom,$confname,$lastactref,%domconfig);
} elsif ($action eq 'rolecolors') {
$output = &modify_rolecolors($r,$dom,$confname,$roles,
- %domconfig);
+ $lastactref,%domconfig);
} elsif ($action eq 'quotas') {
- $output = &modify_quotas($dom,$action,%domconfig);
+ $output = &modify_quotas($dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'autoenroll') {
- $output = &modify_autoenroll($dom,%domconfig);
+ $output = &modify_autoenroll($dom,$lastactref,%domconfig);
} elsif ($action eq 'autoupdate') {
$output = &modify_autoupdate($dom,%domconfig);
} elsif ($action eq 'autocreate') {
@@ -470,21 +529,25 @@ sub process_changes {
} elsif ($action eq 'usermodification') {
$output = &modify_usermodification($dom,%domconfig);
} elsif ($action eq 'contacts') {
- $output = &modify_contacts($dom,%domconfig);
+ $output = &modify_contacts($dom,$lastactref,%domconfig);
} elsif ($action eq 'defaults') {
- $output = &modify_defaults($dom,$r);
+ $output = &modify_defaults($dom,$lastactref,%domconfig);
} elsif ($action eq 'scantron') {
- $output = &modify_scantron($r,$dom,$confname,%domconfig);
+ $output = &modify_scantron($r,$dom,$confname,$lastactref,%domconfig);
} elsif ($action eq 'coursecategories') {
$output = &modify_coursecategories($dom,%domconfig);
} elsif ($action eq 'serverstatuses') {
$output = &modify_serverstatuses($dom,%domconfig);
} elsif ($action eq 'requestcourses') {
- $output = &modify_quotas($dom,$action,%domconfig);
+ $output = &modify_quotas($dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'requestauthor') {
- $output = &modify_quotas($dom,$action,%domconfig);
+ $output = &modify_quotas($dom,$action,$lastactref,%domconfig);
+ } elsif ($action eq 'helpsettings') {
+ $output = &modify_helpsettings($r,$dom,$confname,%domconfig);
+ } elsif ($action eq 'coursedefaults') {
+ $output = &modify_coursedefaults($dom,$lastactref,%domconfig);
} elsif ($action eq 'usersessions') {
- $output = &modify_usersessions($dom,%domconfig);
+ $output = &modify_usersessions($dom,$lastactref,%domconfig);
} elsif ($action eq 'loadbalancing') {
$output = &modify_loadbalancing($dom,%domconfig);
}
@@ -552,6 +615,8 @@ sub print_config_box {
$output .= &print_usersessions('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
+ } elsif ($action eq 'coursedefaults') {
+ $output .= &print_coursedefaults('top',$dom,$settings,\$rowtotal);
}
$output .= '
@@ -730,7 +795,7 @@ sub print_config_box {
} elsif ($action eq 'contacts') {
$output .= &print_contacts($dom,$settings,\$rowtotal);
} elsif ($action eq 'defaults') {
- $output .= &print_defaults($dom,\$rowtotal);
+ $output .= &print_defaults($dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'serverstatuses') {
@@ -781,7 +846,7 @@ sub print_login {
'
'.
''.$choices{'directlogin'}.
' ';
- foreach my $hostid (keys(%servers)) {
+ foreach my $hostid (sort(keys(%servers))) {
next if ($servers{$hostid} eq $servers{$lonhost});
my $selected = '';
if (ref($disallowed{$lonhost}) eq 'HASH') {
@@ -824,10 +889,11 @@ sub print_login {
} elsif ($caller eq 'page') {
my %defaultchecked = (
'coursecatalog' => 'on',
+ 'helpdesk' => 'on',
'adminmail' => 'off',
'newuser' => 'off',
);
- my @toggles = ('coursecatalog','adminmail','newuser');
+ my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
my (%checkedon,%checkedoff);
foreach my $item (@toggles) {
if ($defaultchecked{$item} eq 'on') {
@@ -1043,6 +1109,7 @@ sub login_choices {
&Apache::lonlocal::texthash (
coursecatalog => 'Display Course/Community Catalog link?',
adminmail => "Display Administrator's E-mail Address?",
+ helpdesk => 'Display "Contact Helpdesk" link',
disallowlogin => "Login page requests redirected",
hostid => "Server",
server => "Redirect to:",
@@ -1080,17 +1147,7 @@ sub print_rolecolors {
my %designhash = &Apache::loncommon::get_domainconf($dom);
my %defaultdesign = %Apache::loncommon::defaultdesign;
my (%is_custom,%designs);
- my %defaults = (
- img => $defaultdesign{$role.'.img'},
- font => $defaultdesign{$role.'.font'},
- fontmenu => $defaultdesign{$role.'.fontmenu'},
- );
- foreach my $item (@bgs) {
- $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
- }
- foreach my $item (@links) {
- $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
- }
+ my %defaults = &role_defaults($role,\@bgs,\@links,\@images);
if (ref($settings) eq 'HASH') {
if (ref($settings->{$role}) eq 'HASH') {
if ($settings->{$role}->{'img'} ne '') {
@@ -1151,6 +1208,44 @@ sub print_rolecolors {
return $datatable;
}
+sub role_defaults {
+ my ($role,$bgs,$links,$images,$logintext) = @_;
+ my %defaults;
+ unless ((ref($bgs) eq 'ARRAY') && (ref($links) eq 'ARRAY') && (ref($images) eq 'ARRAY')) {
+ return %defaults;
+ }
+ my %defaultdesign = %Apache::loncommon::defaultdesign;
+ if ($role eq 'login') {
+ %defaults = (
+ font => $defaultdesign{$role.'.font'},
+ );
+ if (ref($logintext) eq 'ARRAY') {
+ foreach my $item (@{$logintext}) {
+ $defaults{'logintext'}{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ }
+ foreach my $item (@{$images}) {
+ $defaults{'showlogo'}{$item} = 1;
+ }
+ } else {
+ %defaults = (
+ img => $defaultdesign{$role.'.img'},
+ font => $defaultdesign{$role.'.font'},
+ fontmenu => $defaultdesign{$role.'.fontmenu'},
+ );
+ }
+ foreach my $item (@{$bgs}) {
+ $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ foreach my $item (@{$links}) {
+ $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ foreach my $item (@{$images}) {
+ $defaults{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ return %defaults;
+}
+
sub display_color_options {
my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
$images,$bgs,$links,$alt_text,$rowtotal,$logintext) = @_;
@@ -1177,11 +1272,11 @@ sub display_color_options {
} else {
$datatable .= ' ';
}
- $current_color = $designs->{'fontmenu'} ?
- $designs->{'fontmenu'} : $defaults->{'fontmenu'};
+ $current_color = $designs->{'fontmenu'} ?
+ $designs->{'fontmenu'} : $defaults->{'fontmenu'};
$datatable .= ''.
' '.
' ';
}
@@ -1198,7 +1293,7 @@ sub display_color_options {
&login_header_options($img,$role,$defaults,$is_custom,$choices);
$logincolors =
&login_text_colors($img,$role,$logintext,$phase,$choices,
- $designs);
+ $designs,$defaults);
} elsif ($img ne 'domlogo') {
$datatable.= &logo_display_options($img,$defaults,$designs);
}
@@ -1277,12 +1372,12 @@ sub display_color_options {
$datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import,
$showfile,$fullsize,$role,$img,$imgfile,$logincolors);
} else {
- $datatable .= ' '.
- &mt('Upload:');
+ $datatable .= ' '.
+ &mt('Upload:').' ';
}
} else {
- $datatable .= ' '.
- &mt('Upload:');
+ $datatable .= ' '.
+ &mt('Upload:').' ';
}
if ($switchserver) {
$datatable .= &mt('Upload to library server: [_1]',$switchserver);
@@ -1310,9 +1405,10 @@ sub display_color_options {
}
$datatable .= ' '.
'';
+
foreach my $item (@{$bgs}) {
- $datatable .= '';
- my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item};
+ $datatable .= ' '.$choices->{$item};
+ my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item};
if ($designs->{'bgs'}{$item}) {
$datatable .= ' ';
}
@@ -1338,15 +1434,13 @@ sub display_color_options {
$datatable .= ' '.
'';
foreach my $item (@{$links}) {
- my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item};
- $datatable .= ''."\n";
-
+ my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item};
+ $datatable .= ' '.$choices->{$item}."\n";
if ($designs->{'links'}{$item}) {
$datatable.=' ';
}
$datatable .= ' ';
-
}
$$rowtotal += $itemcount;
return $datatable;
@@ -1399,17 +1493,13 @@ sub login_header_options {
}
sub login_text_colors {
- my ($img,$role,$logintext,$phase,$choices,$designs) = @_;
+ my ($img,$role,$logintext,$phase,$choices,$designs,$defaults) = @_;
my $color_menu = ' ';
return $color_menu;
@@ -1441,20 +1531,12 @@ sub image_changes {
$role.'_del_'.$img.'" value="1" />'.&mt('Delete?').
' '.&mt('Replace:').' ';
} else {
- $output .= ''.$logincolors.&mt('Upload:').' ';
+ $output .= ' '.$logincolors.&mt('Upload:').' ';
}
}
return $output;
}
-sub color_pick {
- my ($phase,$role,$item,$desc,$curcol) = @_;
- my $link = ''.$desc.' ';
- return $link;
-}
-
sub print_quotas {
my ($dom,$settings,$rowtotal,$action) = @_;
my $context;
@@ -1463,7 +1545,7 @@ sub print_quotas {
} else {
$context = $action;
}
- my ($datatable,$defaultquota,@usertools,@options,%validations);
+ my ($datatable,$defaultquota,$authorquota,@usertools,@options,%validations);
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
my $typecount = 0;
my ($css_class,%titles);
@@ -1482,15 +1564,18 @@ sub print_quotas {
}
if (ref($types) eq 'ARRAY') {
foreach my $type (@{$types}) {
- my $currdefquota;
+ my ($currdefquota,$currauthorquota);
unless (($context eq 'requestcourses') ||
($context eq 'requestauthor')) {
if (ref($settings) eq 'HASH') {
if (ref($settings->{defaultquota}) eq 'HASH') {
- $currdefquota = $settings->{defaultquota}->{$type};
+ $currdefquota = $settings->{defaultquota}->{$type};
} else {
$currdefquota = $settings->{$type};
}
+ if (ref($settings->{authorquota}) eq 'HASH') {
+ $currauthorquota = $settings->{authorquota}->{$type};
+ }
}
}
if (defined($usertypes->{$type})) {
@@ -1604,10 +1689,15 @@ sub print_quotas {
unless (($context eq 'requestcourses') ||
($context eq 'requestauthor')) {
$datatable .=
- ' '.
+ ' '.
+ ''.&mt('Portfolio').': '.
' Mb ';
+ '" size="5" />'.(' ' x 2).
+ ''.&mt('Authoring').': '.
+ ' ';
}
$datatable .= ' ';
}
@@ -1615,12 +1705,16 @@ sub print_quotas {
}
unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
$defaultquota = '20';
+ $authorquota = '500';
if (ref($settings) eq 'HASH') {
if (ref($settings->{'defaultquota'}) eq 'HASH') {
$defaultquota = $settings->{'defaultquota'}->{'default'};
} elsif (defined($settings->{'default'})) {
$defaultquota = $settings->{'default'};
}
+ if (ref($settings->{'authorquota'}) eq 'HASH') {
+ $authorquota = $settings->{'authorquota'}->{'default'};
+ }
}
}
$typecount ++;
@@ -1731,15 +1825,19 @@ sub print_quotas {
}
$datatable .= '';
unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
- $datatable .= ''.
+ $datatable .= ' '.
+ ''.&mt('Portfolio').': '.
' Mb ';
+ $defaultquota.'" size="5" />'.(' ' x2).
+ ''.&mt('Authoring').': '.
+ ' ';
}
$datatable .= '';
$typecount ++;
$css_class = $typecount%2?' class="LC_odd_row"':'';
$datatable .= ''.
- ''.&mt('LON-CAPA Advanced Users').' ';
+ ' '.&mt('LON-CAPA Advanced Users').' ';
if ($context eq 'requestcourses') {
$datatable .= &mt('(overrides affiliation, if set)').
' '.
@@ -1866,35 +1964,16 @@ sub print_quotas {
sub print_requestmail {
my ($dom,$action,$settings,$rowtotal) = @_;
- my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows);
+ my ($now,$datatable,%currapp);
$now = time;
- $rows = 0;
- %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);
- foreach my $server (keys(%dompersonnel)) {
- foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
- my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);
- if (!grep(/^$uname:$udom$/,@domcoord)) {
- push(@domcoord,$uname.':'.$udom);
- }
- }
- }
if (ref($settings) eq 'HASH') {
if (ref($settings->{'notify'}) eq 'HASH') {
if ($settings->{'notify'}{'approval'} ne '') {
- @currapproval = split(',',$settings->{'notify'}{'approval'});
- }
- }
- }
- if (@currapproval) {
- foreach my $dc (@currapproval) {
- unless (grep(/^\Q$dc\E$/,@domcoord)) {
- push(@domcoord,$dc);
+ map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'});
}
}
}
- @domcoord = sort(@domcoord);
- my $numinrow = 4;
- my $numdc = @domcoord;
+ my $numinrow = 2;
my $css_class = 'class="LC_odd_row"';
my $text;
if ($action eq 'requestcourses') {
@@ -1905,42 +1984,12 @@ sub print_requestmail {
$datatable = ' '.
' '.$text.' '.
' ';
- if (@domcoord > 0) {
- $datatable .= '';
+ my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox',
+ 'reqapprovalnotify',%currapp);
+ if ($numdc > 0) {
+ $datatable .= $table;
} else {
$datatable .= &mt('There are no active Domain Coordinators');
- $rows ++;
}
$datatable .=' ';
$$rowtotal += $rows;
@@ -2095,8 +2144,7 @@ sub print_autoupdate {
sub print_autocreate {
my ($dom,$settings,$rowtotal) = @_;
- my (%createon,%createoff);
- my $curr_dc;
+ my (%createon,%createoff,%currhash);
my @types = ('xml','req');
if (ref($settings) eq 'HASH') {
foreach my $item (@types) {
@@ -2109,7 +2157,9 @@ sub print_autocreate {
}
}
}
- $curr_dc = $settings->{'xmldc'};
+ if ($settings->{'xmldc'} ne '') {
+ $currhash{$settings->{'xmldc'}} = 1;
+ }
} else {
foreach my $item (@types) {
$createoff{$item} = ' checked="checked" ';
@@ -2117,6 +2167,7 @@ sub print_autocreate {
}
}
$$rowtotal += 2;
+ my $numinrow = 2;
my $datatable=''.
''.&mt('Create pending official courses from XML files').' '.
''.
@@ -2131,15 +2182,16 @@ sub print_autocreate {
$createon{'req'}.' value="1" />'.&mt('Yes').' '.
' '.&mt('No').' ';
- my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc);
+ my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio',
+ 'autocreate_xmldc',%currhash);
if ($numdc > 1) {
$datatable .= ' '.
&mt('Course creation processed as: (choose Dom. Coord.)').
' '.$dctable.' ';
- $$rowtotal ++ ;
} else {
$datatable .= $dctable.'';
}
+ $$rowtotal += $rows;
return $datatable;
}
@@ -2262,7 +2314,7 @@ sub print_contacts {
my @contacts = ('adminemail','supportemail');
my (%checked,%to,%otheremails,%bccemails);
my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail',
- 'requestsmail');
+ 'requestsmail','updatesmail','idconflictsmail');
foreach my $type (@mailings) {
$otheremails{$type} = '';
}
@@ -2298,21 +2350,22 @@ sub print_contacts {
$checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
$checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
$checked{'requestsmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'updatesmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'idconflictsmail'}{'adminemail'} = ' checked="checked" ';
}
my ($titles,$short_titles) = &contact_titles();
my $rownum = 0;
my $css_class;
foreach my $item (@contacts) {
- $rownum ++;
$css_class = $rownum%2?' class="LC_odd_row"':'';
$datatable .= ''.
''.$titles->{$item}.
' '.
' ';
+ $rownum ++;
}
foreach my $type (@mailings) {
- $rownum ++;
$css_class = $rownum%2?' class="LC_odd_row"':'';
$datatable .= ''.
''.
@@ -2335,7 +2388,21 @@ sub print_contacts {
'value="'.$bccemails{$type}.'" />';
}
$datatable .= ' '."\n";
+ $rownum ++;
}
+ my %choices;
+ $choices{'reporterrors'} = &mt('E-mail error reports to [_1]',
+ &Apache::loncommon::modal_link('http://loncapa.org/core.html',
+ &mt('LON-CAPA core group - MSU'),600,500));
+ $choices{'reportupdates'} = &mt('E-mail record of completed LON-CAPA updates to [_1]',
+ &Apache::loncommon::modal_link('http://loncapa.org/core.html',
+ &mt('LON-CAPA core group - MSU'),600,500));
+ my @toggles = ('reporterrors','reportupdates');
+ my %defaultchecked = ('reporterrors' => 'on',
+ 'reportupdates' => 'on');
+ (my $reports,$rownum) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+ \%choices,$rownum);
+ $datatable .= $reports;
$$rowtotal += $rownum;
return $datatable;
}
@@ -2357,7 +2424,8 @@ sub print_helpsettings {
}
sub radiobutton_prefs {
- my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;
+ my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick,
+ $additional) = @_;
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
(ref($choices) eq 'HASH'));
@@ -2383,17 +2451,22 @@ sub radiobutton_prefs {
}
}
}
+ if ($onclick) {
+ $onclick = ' onclick="'.$onclick.'"';
+ }
foreach my $item (@{$toggles}) {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .=
- ''.$choices->{$item}.
+ ''.
+ ''.$choices->{$item}.
' '.
''.
' '.&mt('Yes').
+ $item.'" '.$checkedon{$item}.' value="1"'.$onclick.' />'.&mt('Yes').
' '.&mt('No').' '.
- ' '.
+ $checkedoff{$item}.' value="0"'.$onclick.' />'.&mt('No').''.
+ ''.$additional.
+ ''.
' ';
$itemcount ++;
}
@@ -2402,42 +2475,100 @@ sub radiobutton_prefs {
sub print_coursedefaults {
my ($position,$dom,$settings,$rowtotal) = @_;
- my ($css_class,$datatable);
+ my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles);
my $itemcount = 1;
+ my %choices = &Apache::lonlocal::texthash (
+ canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
+ uploadquota => 'Default quota for files uploaded directly to course/community using Course Editor (MB)',
+ anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
+ coursecredits => 'Credits can be specified for courses',
+ );
+ my %staticdefaults = (
+ anonsurvey_threshold => 10,
+ uploadquota => 500,
+ );
if ($position eq 'top') {
- my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
- %choices =
- &Apache::lonlocal::texthash (
- canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
- );
%defaultchecked = ('canuse_pdfforms' => 'off');
- @toggles = ('canuse_pdfforms',);
+ @toggles = ('canuse_pdfforms');
($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
\%choices,$itemcount);
- $$rowtotal += $itemcount;
} else {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
- my %choices =
- &Apache::lonlocal::texthash (
- anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
- );
- my $currdefresponder;
+ my ($currdefresponder,$def_official_credits,$def_unofficial_credits,%curruploadquota);
+ my $currusecredits = 0;
+ my @types = ('official','unofficial','community');
if (ref($settings) eq 'HASH') {
$currdefresponder = $settings->{'anonsurvey_threshold'};
+ if (ref($settings->{'uploadquota'}) eq 'HASH') {
+ foreach my $type (keys(%{$settings->{'uploadquota'}})) {
+ $curruploadquota{$type} = $settings->{'uploadquota'}{$type};
+ }
+ }
+ if (ref($settings->{'coursecredits'}) eq 'HASH') {
+ $def_official_credits = $settings->{'coursecredits'}->{'official'};
+ $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'};
+ if (($def_official_credits ne '') || ($def_unofficial_credits ne '')) {
+ $currusecredits = 1;
+ }
+ }
}
if (!$currdefresponder) {
- $currdefresponder = 10;
+ $currdefresponder = $staticdefaults{'anonsurvey_threshold'};
} elsif ($currdefresponder < 1) {
$currdefresponder = 1;
}
+ foreach my $type (@types) {
+ if ($curruploadquota{$type} eq '') {
+ $curruploadquota{$type} = $staticdefaults{'uploadquota'};
+ }
+ }
$datatable .=
- ''.$choices{'anonsurvey_threshold'}.
+ ''.
+ $choices{'anonsurvey_threshold'}.
' '.
''.
' '.
- ' ';
+ ' '."\n".
+ ''.
+ $choices{'uploadquota'}.
+ ' '.
+ ''.
+ ' '."\n";
+ $itemcount += 2;
+ my $onclick = 'toggleCredits(this.form);';
+ my $display = 'none';
+ if ($currusecredits) {
+ $display = 'block';
+ }
+ my $additional = ''.
+ ''.
+ &mt('Default credits for official courses [_1]',
+ ' ').
+ ' '.
+ ''.
+ &mt('Default credits for unofficial courses [_1]',
+ ' ').
+ '
'."\n";
+ %defaultchecked = ('coursecredits' => 'off');
+ @toggles = ('coursecredits');
+ my $current = {
+ 'coursecredits' => $currusecredits,
+ };
+ (my $table,$itemcount) =
+ &radiobutton_prefs($current,\@toggles,\%defaultchecked,
+ \%choices,$itemcount,$onclick,$additional);
+ $datatable .= $table;
}
+ $$rowtotal += $itemcount;
return $datatable;
}
@@ -2728,7 +2859,10 @@ sub spares_row {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
$datatable .= '
- '.$server.' when busy, offloads to: '."\n";
+ '.
+ &mt('[_1] when busy, offloads to:'
+ ,''.$server.' ').
+ "\n";
my (%current,%canselect);
my @choices =
&possible_newspares($server,$spareid->{$server},$serverhomes,$altids);
@@ -2864,7 +2998,7 @@ sub print_loadbalancing {
}
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($dom);
- my $rownum = 6;
+ my $rownum = 8;
if (ref($types) eq 'ARRAY') {
$rownum += scalar(@{$types});
}
@@ -2977,7 +3111,6 @@ sub print_loadbalancing {
' ';
}
}
- my $cssidx = $balnum%2;
$datatable .= ' '.
&loadbalancing_rules($dom,$intdom,$currrules{$lonhost},
$othertitle,$usertypes,$types,\%servers,
@@ -3044,7 +3177,7 @@ sub loadbalancing_rules {
if (ref($currrules) eq 'HASH') {
$current = $currrules->{$type};
}
- if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) {
+ if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) {
if ($dom ne &Apache::lonnet::host_domain($lonhost)) {
$current = '';
}
@@ -3065,8 +3198,10 @@ sub loadbalancing_titles {
'_LC_author' => &mt('Users from [_1] with author role',$dom),
'_LC_internetdom' => &mt('Users not from [_1], but from [_2]',$dom,$intdom),
'_LC_external' => &mt('Users not from [_1]',$intdom),
+ '_LC_ipchangesso' => &mt('SSO users from [_1], with IP mismatch',$dom),
+ '_LC_ipchange' => &mt('Non-SSO users with IP mismatch'),
);
- my @alltypes = ('_LC_adv','_LC_author','_LC_internetdom','_LC_external');
+ my @alltypes = ('_LC_adv','_LC_author','_LC_internetdom','_LC_external','_LC_ipchangesso','_LC_ipchange');
if (ref($types) eq 'ARRAY') {
unshift(@alltypes,@{$types},'default');
}
@@ -3091,16 +3226,21 @@ sub loadbalancing_titles {
sub loadbalance_rule_row {
my ($type,$title,$current,$servers,$currbalancer,$lonhost,$dom,
$targets_div_style,$homedom_div_style,$css_class,$balnum,$num,$islast) = @_;
- my @rulenames = ('default','homeserver');
+ my @rulenames;
my %ruletitles = &offloadtype_text();
- if ($type eq '_LC_external') {
- push(@rulenames,'externalbalancer');
+ if (($type eq '_LC_ipchangesso') || ($type eq '_LC_ipchange')) {
+ @rulenames = ('balancer','offloadedto');
} else {
- push(@rulenames,'specific');
+ @rulenames = ('default','homeserver');
+ if ($type eq '_LC_external') {
+ push(@rulenames,'externalbalancer');
+ } else {
+ push(@rulenames,'specific');
+ }
+ push(@rulenames,'none');
}
- push(@rulenames,'none');
my $style = $targets_div_style;
- if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) {
+ if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) {
$style = $homedom_div_style;
}
my $space;
@@ -3165,6 +3305,8 @@ sub offloadtype_text {
'externalbalancer' => "Offloads to Load Balancer in user's domain",
'specific' => 'Offloads to specific server',
'none' => 'No offload',
+ 'balancer' => 'Session hosted on Load Balancer, after re-authentication',
+ 'offloadedto' => 'Session hosted on offload server, after re-authentication',
);
return %ruletitles;
}
@@ -3186,6 +3328,8 @@ sub contact_titles {
'helpdeskmail' => 'Helpdesk requests to be e-mailed to',
'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)',
'requestsmail' => 'E-mail from course requests requiring approval',
+ 'updatesmail' => 'E-mail from nightly check of LON-CAPA module integrity/updates',
+ 'idconflictsmail' => 'E-mail from bi-nightly check for multiple users sharing same student/employee ID',
);
my %short_titles = &Apache::lonlocal::texthash (
adminemail => 'Admin E-mail address',
@@ -3233,7 +3377,7 @@ sub authorrequest_titles {
sub courserequest_conditions {
my %conditions = &Apache::lonlocal::texthash (
approval => '(Processing of request subject to approval by Domain Coordinator).',
- validate => '(Processing of request subject to instittutional validation).',
+ validate => '(Processing of request subject to institutional validation).',
);
return %conditions;
}
@@ -3616,10 +3760,18 @@ sub print_usermodification {
}
sub print_defaults {
- my ($dom,$rowtotal) = @_;
+ my ($dom,$settings,$rowtotal) = @_;
my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
'datelocale_def','portal_def');
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ my %defaults;
+ if (ref($settings) eq 'HASH') {
+ %defaults = %{$settings};
+ } else {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
+ foreach my $item (@items) {
+ $defaults{$item} = $domdefaults{$item};
+ }
+ }
my $titles = &defaults_titles($dom);
my $rownum = 0;
my ($datatable,$css_class);
@@ -3643,7 +3795,7 @@ sub print_defaults {
my %authnames = &authtype_names();
foreach my $auth (@authtypes) {
my $checked = ' ';
- if ($domdefaults{$item} eq $auth) {
+ if ($defaults{$item} eq $auth) {
$checked = ' checked="checked" ';
}
$datatable .= ' ';
+ $defaults{$item}.'"'.$size.' />';
}
$datatable .= ' ';
$rownum ++;
@@ -3820,8 +3972,8 @@ sub print_scantronformat {
$datatable .= ''.&mt('Default in use:').' '.
'';
if ($scantronurl) {
- $datatable .= ''.
- &mt('Default bubblesheet format file').' ';
+ $datatable .= &Apache::loncommon::modal_link($scantronurl,&mt('Default bubblesheet format file'),600,500,
+ undef,undef,undef,undef,'background-color:#ffffff');
} else {
$datatable = &mt('File unavailable for display');
}
@@ -3846,11 +3998,12 @@ sub print_scantronformat {
}
$datatable .= ' '.$errorstr.' ';
} elsif ($scantronurl) {
+ my $link = &Apache::loncommon::modal_link($scantronurl,&mt('Custom bubblesheet format file'),600,500,
+ undef,undef,undef,undef,'background-color:#ffffff');
$datatable .= ' '.
- ''.
- &mt('Custom bubblesheet format file').' '.
- ' '.&mt('Delete?').' '.
+ $link.
+ ' '.&mt('Delete?').' '.
' '.
&mt('Replace:').' ';
}
@@ -4148,7 +4301,7 @@ sub print_serverstatuses {
sub serverstatus_pages {
return ('userstatus','lonstatus','loncron','server-status','codeversions',
- 'clusterstatus','metadata_keywords','metadata_harvest',
+ 'checksums','clusterstatus','metadata_keywords','metadata_harvest',
'takeoffline','takeonline','showenv','toggledebug','ping','domconf');
}
@@ -4306,7 +4459,7 @@ sub build_category_rows {
if (ref($cats->[$depth]{$parent}) eq 'ARRAY') {
my $numchildren = @{$cats->[$depth]{$parent}};
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
- $text .= '';
+ $text .= '';
my ($idxnum,$parent_name,$parent_item);
my $higher = $depth - 1;
if ($higher == 0) {
@@ -4598,11 +4751,12 @@ sub usertype_update_row {
}
sub modify_login {
- my ($r,$dom,$confname,%domconfig) = @_;
+ my ($r,$dom,$confname,$lastactref,%domconfig) = @_;
my ($resulttext,$errors,$colchgtext,%changes,%colchanges,%newfile,%newurl,
%curr_loginvia,%loginhash,@currlangs,@newlangs,$addedfile,%title,@offon);
%title = ( coursecatalog => 'Display course catalog',
adminmail => 'Display administrator E-mail address',
+ helpdesk => 'Display "Contact Helpdesk" link',
newuser => 'Link for visitors to create a user account',
loginheader => 'Log-in box header');
@offon = ('off','on');
@@ -4615,7 +4769,7 @@ sub modify_login {
}
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
- my @toggles = ('coursecatalog','adminmail','newuser');
+ my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
foreach my $item (@toggles) {
$loginhash{login}{$item} = $env{'form.'.$item};
}
@@ -4803,9 +4957,10 @@ sub modify_login {
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
- my @toggles = ('coursecatalog','adminmail','newuser');
+ my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
my %defaultchecked = (
'coursecatalog' => 'on',
+ 'helpdesk' => 'on',
'adminmail' => 'off',
'newuser' => 'off',
);
@@ -4834,6 +4989,9 @@ sub modify_login {
}
if (keys(%changes) > 0 || $colchgtext) {
&Apache::loncommon::devalidate_domconfig_cache($dom);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domainconfig'} = 1;
+ }
$resulttext = &mt('Changes made:').'';
foreach my $item (sort(keys(%changes))) {
if ($item eq 'loginvia') {
@@ -4954,7 +5112,7 @@ sub color_font_choices {
links => "Link colors",
images => "Images",
font => "Font color",
- fontmenu => "Font Menu",
+ fontmenu => "Font menu",
pgbg => "Page",
tabbg => "Header",
sidebg => "Border",
@@ -4966,7 +5124,7 @@ sub color_font_choices {
}
sub modify_rolecolors {
- my ($r,$dom,$confname,$roles,%domconfig) = @_;
+ my ($r,$dom,$confname,$roles,$lastactref,%domconfig) = @_;
my ($resulttext,%rolehash);
$rolehash{'rolecolors'} = {};
if (ref($domconfig{'rolecolors'}) ne 'HASH') {
@@ -4981,6 +5139,9 @@ sub modify_rolecolors {
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
&Apache::loncommon::devalidate_domconfig_cache($dom);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domainconfig'} = 1;
+ }
$resulttext = &display_colorchgs($dom,\%changes,$roles,
$rolehash{'rolecolors'});
} else {
@@ -5006,24 +5167,45 @@ sub modify_colors {
my @images;
my $servadm = $r->dir_config('lonAdmEMail');
my $errors;
+ my %defaults;
foreach my $role (@{$roles}) {
if ($role eq 'login') {
%choices = &login_choices();
@logintext = ('textcol','bgcol');
} else {
%choices = &color_font_choices();
- $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
}
if ($role eq 'login') {
@images = ('img','logo','domlogo','login');
@bgs = ('pgbg','mainbg','sidebg');
} else {
@images = ('img');
- @bgs = ('pgbg','tabbg','sidebg');
+ @bgs = ('pgbg','tabbg','sidebg');
+ }
+ my %defaults = &role_defaults($role,\@bgs,\@links,\@images,\@logintext);
+ unless ($env{'form.'.$role.'_font'} eq $defaults{'font'}) {
+ $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
+ }
+ if ($role eq 'login') {
+ foreach my $item (@logintext) {
+ unless ($env{'form.'.$role.'_'.$item} eq $defaults{'logintext'}{$item}) {
+ $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ }
+ }
+ } else {
+ unless($env{'form.'.$role.'_fontmenu'} eq $defaults{'fontmenu'}) {
+ $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
+ }
+ }
+ foreach my $item (@bgs) {
+ unless ($env{'form.'.$role.'_'.$item} eq $defaults{'bgs'}{$item} ) {
+ $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ }
}
- $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
- foreach my $item (@bgs,@links,@logintext) {
- $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ foreach my $item (@links) {
+ unless ($env{'form.'.$role.'_'.$item} eq $defaults{'links'}{$item}) {
+ $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ }
}
my ($configuserok,$author_ok,$switchserver) =
&config_check($dom,$confname,$servadm);
@@ -5379,7 +5561,7 @@ sub publishlogo {
if ($fname=~m|/|) {
($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
}
- my @parts=split(/\//,"$filepath/$relpath/$fnamepath");
+ my @parts=split(/\//,"$filepath/$relpath/$fnamepath");
my $count;
for ($count=5;$count<=$#parts;$count++) {
$filepath.="/$parts[$count]";
@@ -5391,19 +5573,19 @@ sub publishlogo {
if ($file=~/\.(\w+)$/ &&
(&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
$output =
- &mt('Invalid file extension ([_1]) - reserved for LONCAPA use.',$1);
+ &mt('Invalid file extension ([_1]) - reserved for internal use.',$1);
} elsif ($file=~/\.(\w+)$/ &&
!defined(&Apache::loncommon::fileembstyle($1))) {
$output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1);
} elsif ($file=~/\.(\d+)\.(\w+)$/) {
- $output = &mt('File name not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
+ $output = &mt('Filename not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
} elsif (-d "$filepath/$file") {
- $output = &mt('File name is a directory name - rename the file and re-upload');
+ $output = &mt('Filename is a directory name - rename the file and re-upload');
} else {
my $source = $filepath.'/'.$file;
my $logfile;
if (!open($logfile,">>$source".'.log')) {
- return (&mt('No write permission to Construction Space'));
+ return (&mt('No write permission to Authoring Space'));
}
print $logfile
"\n================= Publish ".localtime()." ================\n".
@@ -5550,7 +5732,7 @@ sub write_metadata {
print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
my $mfh;
if (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
- foreach (sort keys %metadatafields) {
+ foreach (sort(keys(%metadatafields))) {
unless ($_=~/\./) {
my $unikey=$_;
$unikey=~/^([A-Za-z]+)/;
@@ -5634,18 +5816,18 @@ sub check_switchserver {
my @ids=&Apache::lonnet::current_machine_ids();
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
- $switchserver=''.&mt('Switch Server').' ';
+ $switchserver=''.&mt('Switch Server').' ';
}
return $switchserver;
}
sub modify_quotas {
- my ($dom,$action,%domconfig) = @_;
+ my ($dom,$action,$lastactref,%domconfig) = @_;
my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,
%limithash,$toolregexp,%conditions,$resulttext,%changes);
if ($action eq 'quotas') {
$context = 'tools';
- } else {
+ } else {
$context = $action;
}
if ($context eq 'requestcourses') {
@@ -5662,7 +5844,7 @@ sub modify_quotas {
@usertools = ('aboutme','blog','webdav','portfolio');
%titles = &tool_titles();
}
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
foreach my $key (keys(%env)) {
if ($context eq 'requestcourses') {
@@ -5682,8 +5864,9 @@ sub modify_quotas {
} else {
if ($key =~ /^form\.quota_(.+)$/) {
$confhash{'defaultquota'}{$1} = $env{$key};
- }
- if ($key =~ /^form\.\Q$context\E_(.+)$/) {
+ } elsif ($key =~ /^form\.authorquota_(.+)$/) {
+ $confhash{'authorquota'}{$1} = $env{$key};
+ } elsif ($key =~ /^form\.\Q$context\E_(.+)$/) {
@{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
}
}
@@ -5709,6 +5892,7 @@ sub modify_quotas {
}
} else {
$confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
+ $confhash{'authorquota'}{'default'} = $env{'form.authorquota'};
}
foreach my $item (@usertools) {
foreach my $type (@{$types},'default','_LC_adv') {
@@ -5796,6 +5980,17 @@ sub modify_quotas {
}
}
}
+ if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
+ foreach my $key (keys(%{$domconfig{'quotas'}{'authorquota'}})) {
+ if (exists($confhash{'authorquota'}{$key})) {
+ if ($confhash{'authorquota'}{$key} ne $domconfig{'quotas'}{'authorquota'}{$key}) {
+ $changes{'authorquota'}{$key} = 1;
+ }
+ } else {
+ $confhash{'authorquota'}{$key} = $domconfig{'quotas'}{'authorquota'}{$key};
+ }
+ }
+ }
}
if (ref($confhash{'defaultquota'}) eq 'HASH') {
foreach my $key (keys(%{$confhash{'defaultquota'}})) {
@@ -5814,6 +6009,21 @@ sub modify_quotas {
}
}
}
+ if (ref($confhash{'authorquota'}) eq 'HASH') {
+ foreach my $key (keys(%{$confhash{'authorquota'}})) {
+ if (ref($domconfig{'quotas'}) eq 'HASH') {
+ if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
+ if (!exists($domconfig{'quotas'}{'authorquota'}{$key})) {
+ $changes{'authorquota'}{$key} = 1;
+ }
+ } else {
+ $changes{'authorquota'}{$key} = 1;
+ }
+ } else {
+ $changes{'authorquota'}{$key} = 1;
+ }
+ }
+ }
}
if ($context eq 'requestauthor') {
@@ -5833,7 +6043,9 @@ sub modify_quotas {
if (keys(%changes) > 0) {
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
-
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
$resulttext = &mt('Changes made:').'';
unless (($context eq 'requestcourses') ||
($context eq 'requestauthor')) {
@@ -5845,7 +6057,20 @@ sub modify_quotas {
if ($type eq 'default') {
$typetitle = $othertitle;
}
- $resulttext .= ''.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'defaultquota'}{$type}).' ';
+ $resulttext .= ''.&mt('[_1] set to [_2] MB',$typetitle,$confhash{'defaultquota'}{$type}).' ';
+ }
+ }
+ $resulttext .= ' ';
+ }
+ if (ref($changes{'authorquota'}) eq 'HASH') {
+ $resulttext .= ''.&mt('Authoring space default quotas').'';
+ foreach my $type (@{$types},'default') {
+ if (defined($changes{'authorquota'}{$type})) {
+ my $typetitle = $usertypes->{$type};
+ if ($type eq 'default') {
+ $typetitle = $othertitle;
+ }
+ $resulttext .= ''.&mt('[_1] set to [_2] MB',$typetitle,$confhash{'authorquota'}{$type}).' ';
}
}
$resulttext .= ' ';
@@ -5963,7 +6188,7 @@ sub modify_quotas {
}
sub modify_autoenroll {
- my ($dom,%domconfig) = @_;
+ my ($dom,$lastactref,%domconfig) = @_;
my ($resulttext,%changes);
my %currautoenroll;
if (ref($domconfig{'autoenroll'}) eq 'HASH') {
@@ -6031,6 +6256,9 @@ sub modify_autoenroll {
if ($changes{'coowners'}) {
$resulttext .= ''.&mt("$title{'coowners'} set to $offon[$env{'form.autoassign_coowners'}]").' ';
&Apache::loncommon::devalidate_domconfig_cache($dom);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domainconfig'} = 1;
+ }
}
$resulttext .= ' ';
} else {
@@ -6281,13 +6509,16 @@ sub modify_autocreate {
foreach my $item (@types) {
if ($changes{$item}) {
my $newtxt = $offon[$newvals{$item}];
- $resulttext .= ''.&mt("$title{$item} set to [_1]$newtxt [_2]",'',' ').' ';
+ $resulttext .= ''.
+ &mt("$title{$item} set to [_1]$newtxt [_2]",
+ '',' ').
+ ' ';
}
}
if ($changes{'xmldc'}) {
my ($dcname,$dcdom) = split(':',$newvals{'xmldc'});
my $newtxt = &Apache::loncommon::plainname($dcname,$dcdom);
- $resulttext .= ''.&mt("$title{'xmldc'} set to [_1]$newtxt [_2]",'',' ').' ';
+ $resulttext .= ''.&mt("$title{'xmldc'} set to [_1]",''.$newtxt.' ').' ';
}
$resulttext .= '';
} else {
@@ -6433,7 +6664,11 @@ sub modify_directorysrch {
} else {
$chgtext =~ s/\; $//;
}
- $resulttext .= ''.&mt("Users from domain '[_1] ' permitted to search the institutional directory set to: [_2]",$dom,$chgtext).' ';
+ $resulttext .=
+ ''.
+ &mt("Users from domain '[_1]' permitted to search the institutional directory set to: [_2]",
+ ''.$dom.' ',$chgtext).
+ ' ';
}
}
}
@@ -6461,7 +6696,7 @@ sub modify_directorysrch {
}
}
$chgtext =~ s/\; $//;
- $resulttext .= ''.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).' ';
+ $resulttext .= ''.&mt($title{'searchtypes'}.' set to: "[_1]"',$chgtext).' ';
}
$resulttext .= '';
} else {
@@ -6475,7 +6710,7 @@ sub modify_directorysrch {
}
sub modify_contacts {
- my ($dom,%domconfig) = @_;
+ my ($dom,$lastactref,%domconfig) = @_;
my ($resulttext,%currsetting,%newsetting,%changes,%contacts_hash);
if (ref($domconfig{'contacts'}) eq 'HASH') {
foreach my $key (keys(%{$domconfig{'contacts'}})) {
@@ -6485,7 +6720,8 @@ sub modify_contacts {
my (%others,%to,%bcc);
my @contacts = ('supportemail','adminemail');
my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail',
- 'requestsmail');
+ 'requestsmail','updatesmail','idconflictsmail');
+ my @toggles = ('reporterrors','reportupdates');
foreach my $type (@mailings) {
@{$newsetting{$type}} =
&Apache::loncommon::get_env_multiple('form.'.$type);
@@ -6507,6 +6743,11 @@ sub modify_contacts {
$to{$item} = $env{'form.'.$item};
$contacts_hash{'contacts'}{$item} = $to{$item};
}
+ foreach my $item (@toggles) {
+ if ($env{'form.'.$item} =~ /^(0|1)$/) {
+ $contacts_hash{'contacts'}{$item} = $env{'form.'.$item};
+ }
+ }
if (keys(%currsetting) > 0) {
foreach my $item (@contacts) {
if ($to{$item} ne $currsetting{$item}) {
@@ -6541,10 +6782,11 @@ sub modify_contacts {
$default{'helpdeskmail'} = 'supportemail';
$default{'lonstatusmail'} = 'adminemail';
$default{'requestsmail'} = 'adminemail';
+ $default{'updatesmail'} = 'adminemail';
foreach my $item (@contacts) {
if ($to{$item} ne $default{$item}) {
$changes{$item} = 1;
- }
+ }
}
foreach my $type (@mailings) {
if ((@{$newsetting{$type}} != 1) || ($newsetting{$type}[0] ne $default{$type})) {
@@ -6561,10 +6803,22 @@ sub modify_contacts {
}
}
}
+ foreach my $item (@toggles) {
+ if (($env{'form.'.$item} == 1) && ($currsetting{$item} == 0)) {
+ $changes{$item} = 1;
+ } elsif ((!$env{'form.'.$item}) &&
+ (($currsetting{$item} eq '') || ($currsetting{$item} == 1))) {
+ $changes{$item} = 1;
+ }
+ }
my $putresult = &Apache::lonnet::put_dom('configuration',\%contacts_hash,
$dom);
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
+ &Apache::loncommon::devalidate_domconfig_cache($dom);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domainconfig'} = 1;
+ }
my ($titles,$short_titles) = &contact_titles();
$resulttext = &mt('Changes made:').'';
foreach my $item (@contacts) {
@@ -6595,6 +6849,23 @@ sub modify_contacts {
$resulttext .= '';
}
}
+ my @offon = ('off','on');
+ if ($changes{'reporterrors'}) {
+ $resulttext .= ''.
+ &mt('E-mail error reports to [_1] set to "'.
+ $offon[$env{'form.reporterrors'}].'".',
+ &Apache::loncommon::modal_link('http://loncapa.org/core.html',
+ &mt('LON-CAPA core group - MSU'),600,500)).
+ ' ';
+ }
+ if ($changes{'reportupdates'}) {
+ $resulttext .= ''.
+ &mt('E-mail record of completed LON-CAPA updates to [_1] set to "'.
+ $offon[$env{'form.reportupdates'}].'".',
+ &Apache::loncommon::modal_link('http://loncapa.org/core.html',
+ &mt('LON-CAPA core group - MSU'),600,500)).
+ ' ';
+ }
$resulttext .= ' ';
} else {
$resulttext = &mt('No changes made to contact information');
@@ -6622,7 +6893,7 @@ sub modify_usercreation {
foreach my $item(@contexts) {
if ($item eq 'selfcreate') {
@{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item);
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) {
if (ref($cancreate{$item}) eq 'ARRAY') {
if (grep(/^login$/,@{$cancreate{$item}})) {
@@ -7047,10 +7318,12 @@ sub process_captcha {
if (ref($current->{'recaptchakeys'}) eq 'HASH') {
$currpub = $current->{'recaptchakeys'}{'public'};
$currpriv = $current->{'recaptchakeys'}{'private'};
- $newsettings->{'recaptchakeys'} = {
- public => '',
- private => '',
- }
+ unless ($newsettings->{'captcha'} eq 'recaptcha') {
+ $newsettings->{'recaptchakeys'} = {
+ public => '',
+ private => '',
+ }
+ }
}
if (($newpub ne $currpub) || ($newpriv ne $currpriv)) {
if ($container eq 'cancreate') {
@@ -7187,9 +7460,9 @@ sub modify_usermodification {
}
sub modify_defaults {
- my ($dom,$r) = @_;
+ my ($dom,$lastactref,%domconfig) = @_;
my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def','portal_def');
my @authtypes = ('internal','krb4','krb5','localauth');
foreach my $item (@items) {
@@ -7249,7 +7522,7 @@ sub modify_defaults {
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'';
- my $version = $r->dir_config('lonVersion');
+ my $version = &Apache::lonnet::get_server_loncaparev($dom);
my $mailmsgtext = "Changes made to domain settings in a LON-CAPA installation - domain: $dom (running version: $version) - dns_domain.tab needs to be updated with the following changes, to support legacy 2.4, 2.5 and 2.6 versions of LON-CAPA.\n\n";
foreach my $item (sort(keys(%changes))) {
my $value = $env{'form.'.$item};
@@ -7272,9 +7545,21 @@ sub modify_defaults {
$mailmsgtext .= "\n";
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
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);
+ my $notify = 1;
+ if (ref($domconfig{'contacts'}) eq 'HASH') {
+ if ($domconfig{'contacts'}{'reportupdates'} == 0) {
+ $notify = 0;
+ }
+ }
+ if ($notify) {
+ &Apache::lonmsg::sendemail('installrecord@loncapa.org',
+ "LON-CAPA Domain Settings Change - $dom",
+ $mailmsgtext);
+ }
}
} else {
$resulttext = &mt('No changes made to default authentication/language/timezone settings');
@@ -7294,7 +7579,7 @@ sub modify_defaults {
}
sub modify_scantron {
- my ($r,$dom,$confname,%domconfig) = @_;
+ my ($r,$dom,$confname,$lastactref,%domconfig) = @_;
my ($resulttext,%confhash,%changes,$errors);
my $custom = 'custom.tab';
my $default = 'default.tab';
@@ -7355,6 +7640,9 @@ sub modify_scantron {
}
$resulttext .= ' ';
&Apache::loncommon::devalidate_domconfig_cache($dom);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domainconfig'} = 1;
+ }
} else {
$resulttext = &mt('No changes made to bubblesheet format file');
}
@@ -7744,7 +8032,7 @@ sub modify_helpsettings {
} elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
$changes{$item} = 1;
}
- }
+ }
if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
$helphash{'helpsettings'}{$item} = $env{'form.'.$item};
}
@@ -7778,11 +8066,17 @@ sub modify_helpsettings {
}
sub modify_coursedefaults {
- my ($dom,%domconfig) = @_;
+ my ($dom,$lastactref,%domconfig) = @_;
my ($resulttext,$errors,%changes,%defaultshash);
my %defaultchecked = ('canuse_pdfforms' => 'off');
- my @offon = ('off','on');
my @toggles = ('canuse_pdfforms');
+ my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial',
+ 'uploadquota_community');
+ my @types = ('official','unofficial','community');
+ my %staticdefaults = (
+ anonsurvey_threshold => 10,
+ uploadquota => 500,
+ );
$defaultshash{'coursedefaults'} = {};
@@ -7798,7 +8092,7 @@ sub modify_coursedefaults {
if (($domconfig{'coursedefaults'}{$item} eq '') &&
($env{'form.'.$item} eq '0')) {
$changes{$item} = 1;
- } elsif ($domconfig{'coursdefaults'}{$item} ne $env{'form.'.$item}) {
+ } elsif ($domconfig{'coursedefaults'}{$item} ne $env{'form.'.$item}) {
$changes{$item} = 1;
}
} elsif ($defaultchecked{$item} eq 'off') {
@@ -7811,28 +8105,84 @@ sub modify_coursedefaults {
}
$defaultshash{'coursedefaults'}{$item} = $env{'form.'.$item};
}
- my $currdefresponder = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
- my $newdefresponder = $env{'form.anonsurvey_threshold'};
- $newdefresponder =~ s/\D//g;
- if ($newdefresponder eq '' || $newdefresponder < 1) {
- $newdefresponder = 1;
- }
- $defaultshash{'coursedefaults'}{'anonsurvey_threshold'} = $newdefresponder;
- if ($currdefresponder ne $newdefresponder) {
- unless ($currdefresponder eq '' && $newdefresponder == 10) {
- $changes{'anonsurvey_threshold'} = 1;
+ foreach my $item (@numbers) {
+ my ($currdef,$newdef);
+ $newdef = $env{'form.'.$item};
+ if ($item eq 'anonsurvey_threshold') {
+ $currdef = $domconfig{'coursedefaults'}{$item};
+ $newdef =~ s/\D//g;
+ if ($newdef eq '' || $newdef < 1) {
+ $newdef = 1;
+ }
+ $defaultshash{'coursedefaults'}{$item} = $newdef;
+ } else {
+ my ($type) = ($item =~ /^\Quploadquota_\E(\w+)$/);
+ if (ref($domconfig{'coursedefaults'}{'uploadquota'}) eq 'HASH') {
+ $currdef = $domconfig{'coursedefaults'}{'uploadquota'}{$type};
+ }
+ $newdef =~ s/[^\w.\-]//g;
+ $defaultshash{'coursedefaults'}{'uploadquota'}{$type} = $newdef;
+ }
+ if ($currdef ne $newdef) {
+ my $staticdef;
+ if ($item eq 'anonsurvey_threshold') {
+ unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) {
+ $changes{$item} = 1;
+ }
+ } else {
+ unless (($currdef eq '') && ($newdef == $staticdefaults{'uploadquota'})) {
+ $changes{'uploadquota'} = 1;
+ }
+ }
+ }
+ }
+ my $officialcreds = $env{'form.official_credits'};
+ $officialcreds =~ s/^[^\d\.]//g;
+ my $unofficialcreds = $env{'form.unofficial_credits'};
+ $unofficialcreds =~ s/^[^\d\.]//g;
+ if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') &&
+ ($env{'form.coursecredits'} eq '1')) {
+ $changes{'coursecredits'} = 1;
+ } else {
+ if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds) ||
+ ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds)) {
+ $changes{'coursecredits'} = 1;
}
}
+ $defaultshash{'coursedefaults'}{'coursecredits'} = {
+ official => $officialcreds,
+ unofficial => $unofficialcreds,
+ }
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
- if ($changes{'canuse_pdfforms'}) {
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
+ if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || ($changes{'uploadquota'})) {
+ if ($changes{'canuse_pdfforms'}) {
+ $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
+ }
+ if ($changes{'coursecredits'}) {
+ if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
+ $domdefaults{'officialcredits'} =
+ $defaultshash{'coursedefaults'}{'coursecredits'}{'official'};
+ $domdefaults{'unofficialcredits'} =
+ $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'};
+ }
+ }
+ if ($changes{'uploadquota'}) {
+ if (ref($defaultshash{'coursedefaults'}{'uploadquota'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'quota'}=$defaultshash{'coursedefaults'}{'uploadquota'}{$type};
+ }
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
}
$resulttext = &mt('Changes made:').'';
foreach my $item (sort(keys(%changes))) {
@@ -7843,7 +8193,33 @@ sub modify_coursedefaults {
$resulttext .= ''.&mt('Course/Community users can create/upload PDF forms set to "off"').' ';
}
} elsif ($item eq 'anonsurvey_threshold') {
- $resulttext .= ''.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).' ';
+ $resulttext .= ''.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).' ';
+ } elsif ($item eq 'uploadquota') {
+ if (ref($defaultshash{'coursedefaults'}{'uploadquota'}) eq 'HASH') {
+ $resulttext .= ''.&mt('Default quota for content uploaded to a course/community via Course Editor set as follows:').''.
+ ''.&mt('Official courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'official'}.' ').' '.
+ ''.&mt('Unofficial courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'unofficial'}.' ').' '.
+ ''.&mt('Communities: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'community'}.' ').' '.
+ ' '.
+ ' ';
+ } else {
+ $resulttext .= ''.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).' ';
+ }
+ } elsif ($item eq 'coursecredits') {
+ if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
+ if (($domdefaults{'officialcredits'} eq '') &&
+ ($domdefaults{'unofficialcredits'} eq '')) {
+ $resulttext .= ''.&mt('Student credits not in use for courses in this domain').' ';
+ } else {
+ $resulttext .= ''.&mt('Student credits can be set per course by a Domain Coordinator, with the following defaults applying:').''.
+ ''.&mt('Official courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'official'}).' '.
+ ''.&mt('Unofficial courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}).' '.
+ ' '.
+ ' ';
+ }
+ } else {
+ $resulttext .= ''.&mt('Student credits not in use for courses in this domain').' ';
+ }
}
}
$resulttext .= ' ';
@@ -7858,7 +8234,7 @@ sub modify_coursedefaults {
}
sub modify_usersessions {
- my ($dom,%domconfig) = @_;
+ my ($dom,$lastactref,%domconfig) = @_;
my @hostingtypes = ('version','excludedomain','includedomain');
my @offloadtypes = ('primary','default');
my %types = (
@@ -7875,7 +8251,7 @@ sub modify_usersessions {
foreach my $prefix (@prefixes) {
$defaultshash{'usersessions'}{$prefix} = {};
}
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
my $resulttext;
my %iphost = &Apache::lonnet::get_iphost();
foreach my $prefix (@prefixes) {
@@ -8051,6 +8427,9 @@ sub modify_usersessions {
}
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
if (keys(%changes) > 0) {
my %lt = &usersession_titles();
$resulttext = &mt('Changes made:').'';
@@ -8062,7 +8441,8 @@ sub modify_usersessions {
foreach my $lonhost (sort(keys(%{$changes{$prefix}}))) {
$resulttext .= ''.$lonhost.' ';
my $lonhostdom = &Apache::lonnet::host_domain($lonhost);
- &Apache::lonnet::remote_devalidate_cache($lonhost,'spares',$lonhostdom);
+ my $cachekey = &escape('spares').':'.&escape($lonhostdom);
+ &Apache::lonnet::remote_devalidate_cache($lonhost,[$cachekey]);
if (ref($changes{$prefix}{$lonhost}) eq 'HASH') {
foreach my $type (@{$types{$prefix}}) {
if ($changes{$prefix}{$lonhost}{$type}) {
@@ -8244,13 +8624,13 @@ sub modify_loadbalancing {
}
my $putresult = &Apache::lonnet::put_dom('configuration',
\%defaultshash,$dom);
-
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
if (ref($changes{'delete'}) eq 'ARRAY') {
foreach my $balancer (sort(@{$changes{'delete'}})) {
$resulttext .= ''.&mt('Load Balancing discontinued for: [_1]',$balancer).' ';
- &Apache::lonnet::remote_devalidate_cache($balancer,'loadbalancing',$dom);
+ my $cachekey = &escape('loadbalancing').':'.&escape($dom);
+ &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]);
}
}
if (ref($changes{'add'}) eq 'ARRAY') {
@@ -8295,17 +8675,19 @@ sub modify_loadbalancing {
my $balancetext;
if ($rule eq '') {
$balancetext = $ruletitles{'default'};
- } elsif (($rule eq 'homeserver') || ($rule eq 'externalbalancer')) {
+ } elsif (($rule eq 'homeserver') || ($rule eq 'externalbalancer') ||
+ ($rule eq 'balancer') || ($rule eq 'offloadedto')) {
$balancetext = $ruletitles{$rule};
} else {
$balancetext = &mt('offload to [_1]',$defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type});
}
- $resulttext .= ''.&mt('Load Balancer: [_1] -- balancing for [_2] set to - "[_3]"',$balancer,$titles->{$type},$balancetext).' ';
+ $resulttext .= ''.&mt('Load Balancer: [_1] -- balancing for [_2] set to - "[_3]"',$balancer,$titles->{$type},$balancetext).' ';
}
}
}
}
- &Apache::lonnet::remote_devalidate_cache($balancer,'loadbalancing',$dom);
+ my $cachekey = &scape('loadbalancing').':'.&escape($dom);
+ &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]);
}
}
if ($resulttext ne '') {
@@ -8360,7 +8742,7 @@ sub recurse_cat_deletes {
delete($coursecategories->{$subitem});
$deletions->{$subitem} = 1;
&recurse_cat_deletes($subitem,$coursecategories,$deletions);
- }
+ }
}
}
return;
@@ -8368,72 +8750,94 @@ sub recurse_cat_deletes {
sub get_active_dcs {
my ($dom) = @_;
- my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']);
+ my $now = time;
+ my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);
my %domcoords;
my $numdcs = 0;
- my $now = time;
foreach my $server (keys(%dompersonnel)) {
foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);
- my ($end,$start) = split(':',$dompersonnel{$server}{$user});
- if (($end eq '') || ($end == 0) || ($end > $now)) {
- if ($start <= $now) {
- $domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user};
- }
- }
+ $domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user};
}
}
return %domcoords;
}
sub active_dc_picker {
- my ($dom,$curr_dc) = @_;
+ my ($dom,$numinrow,$inputtype,$name,%currhash) = @_;
my %domcoords = &get_active_dcs($dom);
- my @dcs = sort(keys(%domcoords));
- my $numdcs = scalar(@dcs);
- my $datatable;
- my $numinrow = 2;
+ my @domcoord = keys(%domcoords);
+ if (keys(%currhash)) {
+ foreach my $dc (keys(%currhash)) {
+ unless (exists($domcoords{$dc})) {
+ push(@domcoord,$dc);
+ }
+ }
+ }
+ @domcoord = sort(@domcoord);
+ my $numdcs = scalar(@domcoord);
+ my $rows = 0;
+ my $table;
if ($numdcs > 1) {
- $datatable = '';
- for (my $i=0; $i<@dcs; $i++) {
+ $table = '';
- } elsif (@dcs) {
- $datatable .= ' ';
+ $table .= '
';
+ } elsif ($numdcs == 1) {
+ if ($inputtype eq 'radio') {
+ $table .= ' ';
+ } else {
+ my $check;
+ if (exists($currhash{$domcoord[0]})) {
+ $check = ' checked="checked"';
+ }
+ $table .= ' ';
+ $rows ++;
+ }
}
- return ($numdcs,$datatable);
+ return ($numdcs,$table,$rows);
}
sub usersession_titles {
@@ -8576,7 +8980,6 @@ function showSpares(balancer,ishomedom,b
} else {
document.getElementById('balanceruletitle_'+balnum+'_'+insttypes[k]).style.display='none';
document.getElementById('balancerule_'+balnum+'_'+insttypes[k]).style.display='none';
-
}
} else {
document.getElementById('balanceruletitle_'+balnum+'_'+insttypes[k]).style.display='block';
@@ -8593,7 +8996,6 @@ function showSpares(balancer,ishomedom,b
if ((currBalancers.indexOf(alltargets[m]) == -1) && (alltargets[m] != balancer)) {
idx ++;
item.options[idx] = new Option(alltargets[m],alltargets[m],false,false);
-
}
}
}
@@ -8666,7 +9068,7 @@ function singleServerToggle(balnum,type)
function balanceruleChange(formname,balnum,type) {
if (type == '_LC_external') {
- return;
+ return;
}
var typesRules = getIndicesByName(formname,'loadbalancing_rules_'+balnum+'_'+type);
for (var i=0; i
+//
+
+
+END
+
+}
+
sub captcha_phrases {
return &Apache::lonlocal::texthash (
priv => 'Private key',
@@ -8972,4 +9408,28 @@ sub captcha_phrases {
);
}
+sub devalidate_remote_domconfs {
+ my ($dom,$cachekeys) = @_;
+ return unless (ref($cachekeys) eq 'HASH');
+ my %servers = &Apache::lonnet::internet_dom_servers($dom);
+ my %thismachine;
+ map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
+ my @posscached = ('domainconfig','domdefaults');
+ if (keys(%servers) > 1) {
+ foreach my $server (keys(%servers)) {
+ next if ($thismachine{$server});
+ my @cached;
+ foreach my $name (@posscached) {
+ if ($cachekeys->{$name}) {
+ push(@cached,&escape($name).':'.&escape($dom));
+ }
+ }
+ if (@cached) {
+ &Apache::lonnet::remote_devalidate_cache($server,\@cached);
+ }
+ }
+ }
+ return;
+}
+
1;