'
- .'1 '
- .'2 '
- .&mt('Official courses (with institutional codes)')
- .' '
- .' '
- .&mt('Display').' '
- .' '.&mt('Do not display')
+ my ($datatable,$css_class,$chgstr);
+ my %default_names = (
+ instcode => 'Official courses (with institutional codes)',
+ communities => 'Communities',
+ );
+ my $select0 = ' selected="selected"';
+ my $select1 = '';
+ foreach my $default ('instcode','communities') {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $chgstr = ' onchange="javascript:reorderCats(this.form,'."'',$default"."_pos','0'".');"';
+ if ($default eq 'communities') {
+ $select1 = $select0;
+ $select0 = '';
+ }
+ $datatable .= ''
+ .''
+ .'1 '
+ .'2 '
+ .'3 '
+ .$default_names{$default}
+ .' '
+ .' '
+ .&mt('Display').' '
+ .' '.&mt('Do not display')
.' ';
- $itemcount ++;
+ $itemcount ++;
+ }
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','0'".');"';
$datatable .= ''
- .'1 '
- .'2 '
+ .''
+ .'1 '
+ .'2 '
+ .'3 '
.&mt('Add category').' '.&mt('Name:')
.' ';
return $datatable;
@@ -2477,10 +3633,19 @@ sub modifiable_userdata_row {
return $output;
}
-sub users_cansearch_row {
- my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle) = @_;
+sub insttypes_row {
+ my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context) = @_;
+ my %lt = &Apache::lonlocal::texthash (
+ cansearch => 'Users allowed to search',
+ statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)',
+ lockablenames => 'User preference to lock name',
+ );
+ my $showdom;
+ if ($context eq 'cansearch') {
+ $showdom = ' ('.$dom.')';
+ }
my $output = ''.
- ''.&mt('Users allowed to search').' ('.$dom.')'.
+ ' '.$lt{$context}.$showdom.
' ';
@@ -2607,6 +3782,14 @@ sub modify_login {
newuser => 'Link for visitors to create a user account',
loginheader => 'Log-in box header');
my @offon = ('off','on');
+ my %curr_loginvia;
+ if (ref($domconfig{login}) eq 'HASH') {
+ if (ref($domconfig{login}{loginvia}) eq 'HASH') {
+ foreach my $lonhost (keys(%{$domconfig{login}{loginvia}})) {
+ $curr_loginvia{$lonhost} = $domconfig{login}{loginvia}{$lonhost};
+ }
+ }
+ }
my %loginhash;
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
@@ -2619,6 +3802,93 @@ sub modify_login {
$colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
\%loginhash);
}
+
+ my %servers = &dom_servers($dom);
+ my @loginvia_attribs = ('serverpath','custompath','exempt');
+ if (keys(%servers) > 1) {
+ foreach my $lonhost (keys(%servers)) {
+ next if ($env{'form.'.$lonhost.'_server'} eq $lonhost);
+ if (ref($curr_loginvia{$lonhost}) eq 'HASH') {
+ if ($env{'form.'.$lonhost.'_server'} eq $curr_loginvia{$lonhost}{'server'}) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $curr_loginvia{$lonhost}{'server'};
+ } elsif ($curr_loginvia{$lonhost}{'server'} ne '') {
+ if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ } else {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = '';
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ } else {
+ if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ }
+ if ($loginhash{login}{loginvia}{$lonhost}{'server'} eq '') {
+ foreach my $item (@loginvia_attribs) {
+ $loginhash{login}{loginvia}{$lonhost}{$item} = '';
+ }
+ } else {
+ foreach my $item (@loginvia_attribs) {
+ my $new = $env{'form.'.$lonhost.'_'.$item};
+ if (($item eq 'serverpath') && ($new eq 'custom')) {
+ $env{'form.'.$lonhost.'_custompath'} =~ s/\s+//g;
+ if ($env{'form.'.$lonhost.'_custompath'} eq '') {
+ $new = '/';
+ }
+ }
+ if (($item eq 'custompath') &&
+ ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {
+ $new = '';
+ }
+ if ($new ne $curr_loginvia{$lonhost}{$item}) {
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ if ($item eq 'exempt') {
+ $new =~ s/^\s+//;
+ $new =~ s/\s+$//;
+ my @poss_ips = split(/\s*[,:]\s*/,$new);
+ my @okips;
+ foreach my $ip (@poss_ips) {
+ if ($ip =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
+ if (($1 <= 255) && ($2 <= 255) && ($3 <= 255) && ($4 <= 255)) {
+ push(@okips,$ip);
+ }
+ }
+ }
+ if (@okips > 0) {
+ $new = join(',',@okips);
+ } else {
+ $new = '';
+ }
+ }
+
+ $loginhash{login}{loginvia}{$lonhost}{$item} = $new;
+ }
+ }
+ } else {
+ if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ foreach my $item (@loginvia_attribs) {
+ my $new = $env{'form.'.$lonhost.'_'.$item};
+ if (($item eq 'serverpath') && ($new eq 'custom')) {
+ if ($env{'form.'.$lonhost.'_custompath'} eq '') {
+ $new = '/';
+ }
+ }
+ if (($item eq 'custompath') &&
+ ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {
+ $new = '';
+ }
+ $loginhash{login}{loginvia}{$lonhost}{$item} = $new;
+ }
+ }
+ }
+ }
+ }
+
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
@@ -2650,21 +3920,40 @@ sub modify_login {
}
}
}
- if (($domconfig{'login'}{'loginheader'} eq 'text') &&
- ($env{'form.loginheader'} eq 'image')) {
- $changes{'loginheader'} = 1;
- } elsif (($domconfig{'login'}{'loginheader'} eq '' ||
- $domconfig{'login'}{'loginheader'} eq 'image') &&
- ($env{'form.loginheader'} eq 'text')) {
- $changes{'loginheader'} = 1;
- }
}
if (keys(%changes) > 0 || $colchgtext) {
&Apache::loncommon::devalidate_domconfig_cache($dom);
$resulttext = &mt('Changes made:').'';
foreach my $item (sort(keys(%changes))) {
- if ($item eq 'loginheader') {
- $resulttext .= ''.&mt("$title{$item} set to $env{'form.loginheader'}").' ';
+ if ($item eq 'loginvia') {
+ if (ref($changes{$item}) eq 'HASH') {
+ $resulttext .= ''.&mt('Log-in page availability:').'';
+ foreach my $lonhost (sort(keys(%{$changes{$item}}))) {
+ if (defined($servers{$loginhash{login}{loginvia}{$lonhost}{'server'}})) {
+ if (ref($loginhash{login}{loginvia}{$lonhost}) eq 'HASH') {
+ my $protocol = $Apache::lonnet::protocol{$env{'form.'.$lonhost.'_server'}};
+ $protocol = 'http' if ($protocol ne 'https');
+ my $target = $protocol.'://'.$servers{$env{'form.'.$lonhost.'_server'}};
+
+ if ($loginhash{login}{loginvia}{$lonhost}{'serverpath'} eq 'custom') {
+ $target .= $loginhash{login}{loginvia}{$lonhost}{'custompath'};
+ } else {
+ $target .= $loginhash{login}{loginvia}{$lonhost}{'serverpath'};
+ }
+ $resulttext .= ''.&mt('Server: [_1] log-in page redirects to [_2].',$servers{$lonhost},''.$target.' ');
+ if ($loginhash{login}{loginvia}{$lonhost}{'exempt'} ne '') {
+ $resulttext .= ' '.&mt('No redirection for clients from following IPs:').' '.$loginhash{login}{loginvia}{$lonhost}{'exempt'};
+ }
+ $resulttext .= ' ';
+ } else {
+ $resulttext .= ''.&mt('Server: [_1] has standard log-in page.',$lonhost).' ';
+ }
+ } else {
+ $resulttext .= ''.&mt('Server: [_1] has standard log-in page.',$servers{$lonhost}).' ';
+ }
+ }
+ $resulttext .= ' ';
+ }
} else {
$resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").' ';
}
@@ -2692,6 +3981,7 @@ sub color_font_choices {
links => "Link colors",
images => "Images",
font => "Font color",
+ fontmenu => "Font Menu",
pgbg => "Page",
tabbg => "Header",
sidebg => "Border",
@@ -2749,6 +4039,7 @@ sub modify_colors {
@logintext = ('textcol','bgcol');
} else {
%choices = &color_font_choices();
+ $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
}
if ($role eq 'login') {
@images = ('img','logo','domlogo','login');
@@ -2768,6 +4059,13 @@ sub modify_colors {
$domconfig->{$role} = {};
}
foreach my $img (@images) {
+ if (($role eq 'login') && (($img eq 'img') || ($img eq 'logo'))) {
+ if (defined($env{'form.login_showlogo_'.$img})) {
+ $confhash->{$role}{'showlogo'}{$img} = 1;
+ } else {
+ $confhash->{$role}{'showlogo'}{$img} = 0;
+ }
+ }
if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
&& !defined($domconfig->{$role}{$img})
&& !$env{'form.'.$role.'_del_'.$img}
@@ -2842,7 +4140,19 @@ sub modify_colors {
$changes{$role}{'images'}{$img} = 1;
}
}
- }
+ if (($role eq 'login') && (($img eq 'logo') || ($img eq 'img'))) {
+ if (ref($domconfig->{'login'}{'showlogo'}) eq 'HASH') {
+ if ($confhash->{$role}{'showlogo'}{$img} ne
+ $domconfig->{$role}{'showlogo'}{$img}) {
+ $changes{$role}{'showlogo'}{$img} = 1;
+ }
+ } else {
+ if ($confhash->{$role}{'showlogo'}{$img} == 0) {
+ $changes{$role}{'showlogo'}{$img} = 1;
+ }
+ }
+ }
+ }
if ($domconfig->{$role}{'font'} ne '') {
if ($confhash->{$role}{'font'} ne $domconfig->{$role}{'font'}) {
$changes{$role}{'font'} = 1;
@@ -2852,6 +4162,17 @@ sub modify_colors {
$changes{$role}{'font'} = 1;
}
}
+ if ($role ne 'login') {
+ if ($domconfig->{$role}{'fontmenu'} ne '') {
+ if ($confhash->{$role}{'fontmenu'} ne $domconfig->{$role}{'fontmenu'}) {
+ $changes{$role}{'fontmenu'} = 1;
+ }
+ } else {
+ if ($confhash->{$role}{'fontmenu'}) {
+ $changes{$role}{'fontmenu'} = 1;
+ }
+ }
+ }
foreach my $item (@bgs) {
if ($domconfig->{$role}{$item} ne '') {
if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
@@ -2934,6 +4255,11 @@ sub default_change_checker {
$confhash->{$role}{$img} = '';
$changes->{$role}{'images'}{$img} = 1;
}
+ if ($role eq 'login') {
+ if ($confhash->{$role}{'showlogo'}{$img} == 0) {
+ $changes->{$role}{'showlogo'}{$img} = 1;
+ }
+ }
}
if ($confhash->{$role}{'font'}) {
$changes->{$role}{'font'} = 1;
@@ -2965,7 +4291,13 @@ sub display_colorchgs {
$resulttext .= ''.&mt($choices{$key}).':';
}
foreach my $item (sort(keys(%{$changes->{$role}{$key}}))) {
- if ($confhash->{$role}{$item} eq '') {
+ if (($role eq 'login') && ($key eq 'showlogo')) {
+ if ($confhash->{$role}{$key}{$item}) {
+ $resulttext .= ''.&mt("$choices{$item} set to be displayed").' ';
+ } else {
+ $resulttext .= ''.&mt("$choices{$item} set to not be displayed").' ';
+ }
+ } elsif ($confhash->{$role}{$item} eq '') {
$resulttext .= ''.&mt("$choices{$item} set to default").' ';
} else {
my $newitem = $confhash->{$role}{$item};
@@ -3270,71 +4602,273 @@ sub check_switchserver {
return $switchserver;
}
-sub javascript_set_colnums {
- return < 1100) {
- document.pickactions.numcols[1].checked = true;
+sub modify_quotas {
+ my ($dom,$action,%domconfig) = @_;
+ my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,
+ %limithash,$toolregexp,%conditions,$resulttext,%changes);
+ if ($action eq 'quotas') {
+ $context = 'tools';
+ } else {
+ $context = $action;
+ }
+ if ($context eq 'requestcourses') {
+ @usertools = ('official','unofficial','community');
+ @options =('norequest','approval','validate','autolimit');
+ %validations = &Apache::lonnet::auto_courserequest_checks($dom);
+ %titles = &courserequest_titles();
+ $toolregexp = join('|',@usertools);
+ %conditions = &courserequest_conditions();
} else {
- document.pickactions.numcols[0].checked = true;
+ @usertools = ('aboutme','blog','portfolio');
+ %titles = &tool_titles();
}
-}
-END
-}
-
-sub modify_quotas {
- my ($dom,%domconfig) = @_;
- my ($resulttext,%changes);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- my %formhash;
foreach my $key (keys(%env)) {
- if ($key =~ /^form\.quota_(.+)$/) {
- $formhash{$1} = $env{$key};
+ if ($context eq 'requestcourses') {
+ if ($key =~ /^form\.crsreq_($toolregexp)_(.+)$/) {
+ my $item = $1;
+ my $type = $2;
+ if ($type =~ /^limit_(.+)/) {
+ $limithash{$item}{$1} = $env{$key};
+ } else {
+ $confhash{$item}{$type} = $env{$key};
+ }
+ }
+ } else {
+ if ($key =~ /^form\.quota_(.+)$/) {
+ $confhash{'defaultquota'}{$1} = $env{$key};
+ }
+ if ($key =~ /^form\.\Q$context\E_(.+)$/) {
+ @{$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;
+ if ($context eq 'requestcourses') {
+ my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify');
+ @approvalnotify = sort(@approvalnotify);
+ $confhash{'notify'}{'approval'} = join(',',@approvalnotify);
+ if (ref($domconfig{$action}) eq 'HASH') {
+ if (ref($domconfig{$action}{'notify'}) eq 'HASH') {
+ if ($domconfig{$action}{'notify'}{'approval'} ne $confhash{'notify'}{'approval'}) {
+ $changes{'notify'}{'approval'} = 1;
}
} else {
- $formhash{$key} = $domconfig{'quotas'}{$key};
+ if ($domconfig{$action}{'notify'}{'approval'}) {
+ $changes{'notify'}{'approval'} = 1;
+ }
+ }
+ } else {
+ if ($domconfig{$action}{'notify'}{'approval'}) {
+ $changes{'notify'}{'approval'} = 1;
}
}
+ } else {
+ $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
}
- foreach my $key (keys(%formhash)) {
- if ($formhash{$key} ne '') {
- if (ref($domconfig{'quotas'}) eq 'HASH') {
- if (!exists($domconfig{'quotas'}{$key})) {
- $changes{$key} = 1;
+ foreach my $item (@usertools) {
+ foreach my $type (@{$types},'default','_LC_adv') {
+ my $unset;
+ if ($context eq 'requestcourses') {
+ $unset = '0';
+ if ($type eq '_LC_adv') {
+ $unset = '';
+ }
+ if ($confhash{$item}{$type} eq 'autolimit') {
+ $confhash{$item}{$type} .= '=';
+ unless ($limithash{$item}{$type} =~ /\D/) {
+ $confhash{$item}{$type} .= $limithash{$item}{$type};
+ }
}
} else {
- $changes{$key} = 1;
+ if (grep(/^\Q$type\E$/,@{$toolshash{$item}})) {
+ $confhash{$item}{$type} = 1;
+ } else {
+ $confhash{$item}{$type} = 0;
+ }
+ }
+ if (ref($domconfig{$action}) eq 'HASH') {
+ if (ref($domconfig{$action}{$item}) eq 'HASH') {
+ if ($domconfig{$action}{$item}{$type} ne $confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
+ } else {
+ if ($context eq 'requestcourses') {
+ if ($confhash{$item}{$type} ne $unset) {
+ $changes{$item}{$type} = 1;
+ }
+ } else {
+ if (!$confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
+ }
+ }
+ } else {
+ if ($context eq 'requestcourses') {
+ if ($confhash{$item}{$type} ne $unset) {
+ $changes{$item}{$type} = 1;
+ }
+ } else {
+ if (!$confhash{$item}{$type}) {
+ $changes{$item}{$type} = 1;
+ }
+ }
}
}
}
+ unless ($context eq 'requestcourses') {
+ 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 (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{'defaultquota'}{$key} = 1;
+ }
+ }
+ }
+ }
+
+ foreach my $key (keys(%confhash)) {
+ $domdefaults{$key} = $confhash{$key};
+ }
+
my %quotahash = (
- quotas => {%formhash},
+ $action => { %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;
+ unless ($context eq 'requestcourses') {
+ 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',$context);
+ if ($context eq 'requestcourses') {
+ if ($env{'environment.canrequest.'.$item} ne $newacc) {
+ $newenv{'environment.canrequest.'.$item} = $newacc;
+ }
+ } else {
+ 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}) {
+ if ($context eq 'requestcourses') {
+ my $cond;
+ if ($confhash{$item}{$type} =~ /^autolimit=(\d*)$/) {
+ if ($1 eq '') {
+ $cond = &mt('(Automatic processing of any request).');
+ } else {
+ $cond = &mt('(Automatic processing of requests up to limit of [quant,_1,request] per user).',$1);
+ }
+ } else {
+ $cond = $conditions{$confhash{$item}{$type}};
+ }
+ $resulttext .= ''.&mt('Set to be available to [_1].',$typetitle).' '.$cond.' ';
+ } else {
+ $resulttext .= ''.&mt('Set to be available to [_1]',$typetitle).' ';
+ }
+ } else {
+ if ($type eq '_LC_adv') {
+ if ($confhash{$item}{$type} eq '0') {
+ $resulttext .= ''.&mt('Set to be unavailable to [_1]',$typetitle).' ';
+ } else {
+ $resulttext .= ''.&mt('No override set for [_1]',$typetitle).' ';
+ }
+ } else {
+ $resulttext .= ''.&mt('Set to be unavailable to [_1]',$typetitle).' ';
+ }
+ }
+ }
+ }
+ $resulttext .= ' ';
+ }
+ }
+ if ($action eq 'requestcourses') {
+ if (ref($changes{'notify'}) eq 'HASH') {
+ if ($changes{'notify'}{'approval'}) {
+ if (ref($confhash{'notify'}) eq 'HASH') {
+ if ($confhash{'notify'}{'approval'}) {
+ $resulttext .= ''.&mt('Notification of requests requiring approval will be sent to: ').$confhash{'notify'}{'approval'}.' ';
+ } else {
+ $resulttext .= ''.&mt('No Domain Coordinators will receive notification of course requests requiring approval.').' ';
+ }
+ }
}
- $resulttext .= ''.&mt('[_1] set to [_2] Mb',$typetitle,$formhash{$type}).' ';
}
}
$resulttext .= ' ';
+ if (keys(%newenv)) {
+ &Apache::lonnet::appenv(\%newenv);
+ }
} else {
- $resulttext = &mt('No changes made to default quotas');
+ if ($context eq 'requestcourses') {
+ $resulttext = &mt('No changes made to rights to request creation of courses.');
+ } else {
+ $resulttext = &mt('No changes made to availability of personal information pages, blogs, portfolios or default quotas');
+ }
}
} else {
$resulttext = ''.
@@ -3354,7 +4888,8 @@ sub modify_autoenroll {
}
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
my %title = ( run => 'Auto-enrollment active',
- sender => 'Sender for notification messages');
+ sender => 'Sender for notification messages',
+ coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)');
my @offon = ('off','on');
my $sender_uname = $env{'form.sender_uname'};
my $sender_domain = $env{'form.sender_domain'};
@@ -3363,11 +4898,12 @@ sub modify_autoenroll {
} elsif ($sender_uname eq '') {
$sender_domain = '';
}
+ my $coowners = $env{'form.autoassign_coowners'};
my %autoenrollhash = (
- autoenroll => { run => $env{'form.autoenroll_run'},
- sender_uname => $sender_uname,
- sender_domain => $sender_domain,
-
+ autoenroll => { 'run' => $env{'form.autoenroll_run'},
+ 'sender_uname' => $sender_uname,
+ 'sender_domain' => $sender_domain,
+ 'co-owners' => $coowners,
}
);
my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
@@ -3388,6 +4924,13 @@ sub modify_autoenroll {
if ($currautoenroll{'sender_domain'} ne $sender_domain) {
$changes{'sender'} = 1;
}
+ if ($currautoenroll{'co-owners'} ne '') {
+ if ($currautoenroll{'co-owners'} ne $coowners) {
+ $changes{'coowners'} = 1;
+ }
+ } elsif ($coowners) {
+ $changes{'coowners'} = 1;
+ }
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'';
if ($changes{'run'}) {
@@ -3400,6 +4943,10 @@ sub modify_autoenroll {
$resulttext .= ''.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).' ';
}
}
+ if ($changes{'coowners'}) {
+ $resulttext .= ''.&mt("$title{'coowners'} set to $offon[$env{'form.autoassign_coowners'}]").' ';
+ &Apache::loncommon::devalidate_domconfig_cache($dom);
+ }
$resulttext .= ' ';
} else {
$resulttext = &mt('No changes made to auto-enrollment settings');
@@ -3431,7 +4978,7 @@ sub modify_autoupdate {
lastname => 'Last Name',
firstname => 'First Name',
middlename => 'Middle Name',
- gen => 'Generation',
+ generation => 'Generation',
);
my $othertitle = &mt('All users');
if (keys(%{$usertypes}) > 0) {
@@ -3439,13 +4986,35 @@ sub modify_autoupdate {
}
foreach my $key (keys(%env)) {
if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {
- push(@{$fields{$1}},$2);
+ my ($usertype,$item) = ($1,$2);
+ if (grep(/^\Q$item\E$/,keys(%fieldtitles))) {
+ if ($usertype eq 'default') {
+ push(@{$fields{$1}},$2);
+ } elsif (ref($types) eq 'ARRAY') {
+ if (grep(/^\Q$usertype\E$/,@{$types})) {
+ push(@{$fields{$1}},$2);
+ }
+ }
+ }
+ }
+ }
+ my @lockablenames = &Apache::loncommon::get_env_multiple('form.lockablenames');
+ @lockablenames = sort(@lockablenames);
+ if (ref($currautoupdate{'lockablenames'}) eq 'ARRAY') {
+ my @changed = &Apache::loncommon::compare_arrays($currautoupdate{'lockablenames'},\@lockablenames);
+ if (@changed) {
+ $changes{'lockablenames'} = 1;
+ }
+ } else {
+ if (@lockablenames) {
+ $changes{'lockablenames'} = 1;
}
}
my %updatehash = (
autoupdate => { run => $env{'form.autoupdate_run'},
classlists => $env{'form.classlists'},
fields => {%fields},
+ lockablenames => \@lockablenames,
}
);
foreach my $key (keys(%currautoupdate)) {
@@ -3463,9 +5032,11 @@ sub modify_autoupdate {
foreach my $type (@{$currautoupdate{$key}{$item}}) {
if (!exists($fields{$item})) {
$change = 1;
+ last;
} elsif (ref($fields{$item}) eq 'ARRAY') {
if (!grep(/^\Q$type\E$/,@{$fields{$item}})) {
$change = 1;
+ last;
}
}
}
@@ -3475,12 +5046,41 @@ sub modify_autoupdate {
}
}
}
+ } elsif ($key eq 'lockablenames') {
+ if (ref($currautoupdate{$key}) eq 'ARRAY') {
+ my @changed = &Apache::loncommon::compare_arrays($currautoupdate{'lockablenames'},\@lockablenames);
+ if (@changed) {
+ $changes{'lockablenames'} = 1;
+ }
+ } else {
+ if (@lockablenames) {
+ $changes{'lockablenames'} = 1;
+ }
+ }
+ }
+ }
+ unless (grep(/^\Qlockablenames\E$/,keys(%currautoupdate))) {
+ if (@lockablenames) {
+ $changes{'lockablenames'} = 1;
}
}
foreach my $item (@{$types},'default') {
if (defined($fields{$item})) {
if (ref($currautoupdate{'fields'}) eq 'HASH') {
- if (!exists($currautoupdate{'fields'}{$item})) {
+ if (ref($currautoupdate{'fields'}{$item}) eq 'ARRAY') {
+ my $change = 0;
+ if (ref($fields{$item}) eq 'ARRAY') {
+ foreach my $type (@{$fields{$item}}) {
+ if (!grep(/^\Q$type\E$/,@{$currautoupdate{'fields'}{$item}})) {
+ $change = 1;
+ last;
+ }
+ }
+ }
+ if ($change) {
+ push(@{$changes{'fields'}},$item);
+ }
+ } else {
push(@{$changes{'fields'}},$item);
}
} else {
@@ -3494,7 +5094,17 @@ sub modify_autoupdate {
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'';
foreach my $key (sort(keys(%changes))) {
- if (ref($changes{$key}) eq 'ARRAY') {
+ if ($key eq 'lockablenames') {
+ $resulttext .= '';
+ if (@lockablenames) {
+ $usertypes->{'default'} = $othertitle;
+ $resulttext .= &mt("User preference to disable replacement of user's name with institutional data (by auto-update), available for the following affiliations:").' '.
+ join(', ', map { $usertypes->{$_}; } @lockablenames).' ';
+ } else {
+ $resulttext .= &mt("User preference to disable replacement of user's name with institutional data (by auto-update) is unavailable.");
+ }
+ $resulttext .= ' ';
+ } elsif (ref($changes{$key}) eq 'ARRAY') {
foreach my $item (@{$changes{$key}}) {
my @newvalues;
foreach my $type (@{$fields{$item}}) {
@@ -3533,6 +5143,78 @@ sub modify_autoupdate {
return $resulttext;
}
+sub modify_autocreate {
+ my ($dom,%domconfig) = @_;
+ my ($resulttext,%changes,%currautocreate,%newvals,%autocreatehash);
+ if (ref($domconfig{'autocreate'}) eq 'HASH') {
+ foreach my $key (keys(%{$domconfig{'autocreate'}})) {
+ $currautocreate{$key} = $domconfig{'autocreate'}{$key};
+ }
+ }
+ my %title= ( xml => 'Auto-creation of courses in XML course description files',
+ req => 'Auto-creation of validated requests for official courses',
+ xmldc => 'Identity of course creator of courses from XML files',
+ );
+ my @types = ('xml','req');
+ foreach my $item (@types) {
+ $newvals{$item} = $env{'form.autocreate_'.$item};
+ $newvals{$item} =~ s/\D//g;
+ $newvals{$item} = 0 if ($newvals{$item} eq '');
+ }
+ $newvals{'xmldc'} = $env{'form.autocreate_xmldc'};
+ my %domcoords = &get_active_dcs($dom);
+ unless (exists($domcoords{$newvals{'xmldc'}})) {
+ $newvals{'xmldc'} = '';
+ }
+ %autocreatehash = (
+ autocreate => { xml => $newvals{'xml'},
+ req => $newvals{'req'},
+ }
+ );
+ if ($newvals{'xmldc'} ne '') {
+ $autocreatehash{'autocreate'}{'xmldc'} = $newvals{'xmldc'};
+ }
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%autocreatehash,
+ $dom);
+ if ($putresult eq 'ok') {
+ my @items = @types;
+ if ($newvals{'xml'}) {
+ push(@items,'xmldc');
+ }
+ foreach my $item (@items) {
+ if (exists($currautocreate{$item})) {
+ if ($currautocreate{$item} ne $newvals{$item}) {
+ $changes{$item} = 1;
+ }
+ } elsif ($newvals{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ if (keys(%changes) > 0) {
+ my @offon = ('off','on');
+ $resulttext = &mt('Changes made:').'';
+ foreach my $item (@types) {
+ if ($changes{$item}) {
+ my $newtxt = $offon[$newvals{$item}];
+ $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 .= ' ';
+ } else {
+ $resulttext = &mt('No changes made to auto-creation settings');
+ }
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred: [_1]',$putresult).' ';
+ }
+ return $resulttext;
+}
+
sub modify_directorysrch {
my ($dom,%domconfig) = @_;
my ($resulttext,%changes);
@@ -3715,9 +5397,10 @@ sub modify_contacts {
$currsetting{$key} = $domconfig{'contacts'}{$key};
}
}
- my (%others,%to);
+ my (%others,%to,%bcc);
my @contacts = ('supportemail','adminemail');
- my @mailings = ('errormail','packagesmail','helpdeskmail');
+ my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail',
+ 'requestsmail');
foreach my $type (@mailings) {
@{$newsetting{$type}} =
&Apache::loncommon::get_env_multiple('form.'.$type);
@@ -3730,6 +5413,10 @@ sub modify_contacts {
}
$others{$type} = $env{'form.'.$type.'_others'};
$contacts_hash{contacts}{$type}{'others'} = $others{$type};
+ if ($type eq 'helpdeskmail') {
+ $bcc{$type} = $env{'form.'.$type.'_bcc'};
+ $contacts_hash{contacts}{$type}{'bcc'} = $bcc{$type};
+ }
}
foreach my $item (@contacts) {
$to{$item} = $env{'form.'.$item};
@@ -3754,6 +5441,11 @@ sub modify_contacts {
if ($others{$type} ne $currsetting{$type}{'others'}) {
push(@{$changes{$type}},'others');
}
+ if ($type eq 'helpdeskmail') {
+ if ($bcc{$type} ne $currsetting{$type}{'bcc'}) {
+ push(@{$changes{$type}},'bcc');
+ }
+ }
}
} else {
my %default;
@@ -3762,6 +5454,8 @@ sub modify_contacts {
$default{'errormail'} = 'adminemail';
$default{'packagesmail'} = 'adminemail';
$default{'helpdeskmail'} = 'supportemail';
+ $default{'lonstatusmail'} = 'adminemail';
+ $default{'requestsmail'} = 'adminemail';
foreach my $item (@contacts) {
if ($to{$item} ne $default{$item}) {
$changes{$item} = 1;
@@ -3774,7 +5468,12 @@ sub modify_contacts {
}
if ($others{$type} ne '') {
push(@{$changes{$type}},'others');
- }
+ }
+ if ($type eq 'helpdeskmail') {
+ if ($bcc{$type} ne '') {
+ push(@{$changes{$type}},'bcc');
+ }
+ }
}
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%contacts_hash,
@@ -3802,7 +5501,13 @@ sub modify_contacts {
push(@text,$others{$type});
}
$resulttext .= ''.
- join(', ',@text).' ';
+ join(', ',@text).' ';
+ if ($type eq 'helpdeskmail') {
+ if ($bcc{$type} ne '') {
+ $resulttext .= ' '.&mt('with Bcc to').': '.$bcc{$type}.' ';
+ }
+ }
+ $resulttext .= '';
}
}
$resulttext .= '';
@@ -3828,7 +5533,7 @@ sub modify_usercreation {
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
- my @contexts = ('author','course','selfcreate');
+ my @contexts = ('author','course','requestcrs','selfcreate');
foreach my $item(@contexts) {
if ($item eq 'selfcreate') {
@{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item);
@@ -3844,14 +5549,27 @@ sub modify_usercreation {
$cancreate{$item} = $env{'form.can_createuser_'.$item};
}
}
+ my ($othertitle,$usertypes,$types) =
+ &Apache::loncommon::sorted_inst_types($dom);
+ if (ref($types) eq 'ARRAY') {
+ if (@{$types} > 0) {
+ @{$cancreate{'statustocreate'}} =
+ &Apache::loncommon::get_env_multiple('form.statustocreate');
+ } else {
+ @{$cancreate{'statustocreate'}} = ();
+ }
+ push(@contexts,'statustocreate');
+ }
if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
foreach my $item (@contexts) {
- if ($item eq 'selfcreate') {
- if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
+ if (($item eq 'selfcreate') || ($item eq 'statustocreate')) {
+ if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) {
- if (!grep(/^$curr$/,@{$cancreate{$item}})) {
- if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$item);
+ if (ref($cancreate{$item}) eq 'ARRAY') {
+ if (!grep(/^$curr$/,@{$cancreate{$item}})) {
+ if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+ push(@{$changes{'cancreate'}},$item);
+ }
}
}
}
@@ -4023,16 +5741,65 @@ sub modify_usercreation {
if (ref($changes{'cancreate'}) eq 'ARRAY') {
my %lt = &usercreation_types();
foreach my $type (@{$changes{'cancreate'}}) {
- my $chgtext = $lt{$type}.', ';
+ my $chgtext;
+ unless ($type eq 'statustocreate') {
+ $chgtext = $lt{$type}.', ';
+ }
if ($type eq 'selfcreate') {
if (@{$cancreate{$type}} == 0) {
$chgtext .= &mt('creation of a new user account is not permitted.');
} else {
- $chgtext .= &mt('creation of a new account is permitted for:');
+ $chgtext .= &mt('creation of a new account is permitted for:').'';
foreach my $case (@{$cancreate{$type}}) {
$chgtext .= ''.$selfcreatetypes{$case}.' ';
}
$chgtext .= ' ';
+ if (ref($cancreate{$type}) eq 'ARRAY') {
+ if (grep(/^(login|sso)$/,@{$cancreate{$type}})) {
+ if (ref($cancreate{'statustocreate'}) eq 'ARRAY') {
+ if (@{$cancreate{'statustocreate'}} == 0) {
+ $chgtext .= ''.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").' ';
+ }
+ }
+ }
+ }
+ }
+ } elsif ($type eq 'statustocreate') {
+ if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') &&
+ (ref($cancreate{'statustocreate'}) eq 'ARRAY')) {
+ if (@{$cancreate{'selfcreate'}} > 0) {
+ if (@{$cancreate{'statustocreate'}} == 0) {
+
+ $chgtext .= &mt("Institutional affiliations permitted to create accounts set to 'None'.");
+ if (!grep(/^email$/,@{$cancreate{'selfcreate'}})) {
+ $chgtext .= ''.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").' ';
+ }
+ } elsif (ref($usertypes) eq 'HASH') {
+ if (grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
+ $chgtext .= &mt('Creation of a new account for an institutional user is restricted to the following institutional affiliation(s):');
+ } else {
+ $chgtext .= &mt('Institutional affiliations permitted to create accounts with institutional authentication were set as follows:');
+ }
+ $chgtext .= '';
+ foreach my $case (@{$cancreate{$type}}) {
+ if ($case eq 'default') {
+ $chgtext .= ''.$othertitle.' ';
+ } else {
+ $chgtext .= ''.$usertypes->{$case}.' ';
+ }
+ }
+ $chgtext .= ' ';
+ if (!grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
+ $chgtext .= ''.&mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').' ';
+ }
+ }
+ } else {
+ if (@{$cancreate{$type}} == 0) {
+ $chgtext .= &mt("Institutional affiliations permitted to create accounts were set to 'none'.");
+ } else {
+ $chgtext .= &mt('Although institutional affiliations permitted to create accounts were changed, self creation of accounts is not currently permitted for any authentication types.');
+ }
+ }
}
} else {
if ($cancreate{$type} eq 'none') {
@@ -4222,7 +5989,7 @@ sub modify_usermodification {
}
my @modifiable;
if ($context eq 'selfcreate') {
- $resulttext .= ''.&mt('Self-creation of account by users with status: [_1] ',$rolename).' - '.&mt('modifiable fields (if institutional data blank): ');
+ $resulttext .= ''.&mt('Self-creation of account by users with status: [_1]',$rolename).' - '.&mt('modifiable fields (if institutional data blank): ');
} else {
$resulttext .= ''.&mt('Target user with [_1] role',$rolename).' - '.&mt('modifiable fields: ');
}
@@ -4257,7 +6024,7 @@ sub modify_defaults {
my ($dom,$r) = @_;
my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def');
+ 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) {
$newvalues{$item} = $env{'form.'.$item};
@@ -4271,8 +6038,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 'x_chef') {
+ if (code2language($langcode) eq '') {
+ push(@errors,$item);
+ }
}
} else {
push(@errors,$item);
@@ -4291,21 +6060,23 @@ sub modify_defaults {
push(@errors,$item);
}
}
+ } elsif ($item eq 'portal_def') {
+ if ($newvalues{$item} ne '') {
+ unless ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
+ push(@errors,$item);
+ }
+ }
}
if (grep(/^\Q$item\E$/,@errors)) {
$newvalues{$item} = $domdefaults{$item};
} elsif ($domdefaults{$item} ne $newvalues{$item}) {
$changes{$item} = 1;
}
+ $domdefaults{$item} = $newvalues{$item};
}
my %defaults_hash = (
- defaults => { auth_def => $newvalues{'auth_def'},
- auth_arg_def => $newvalues{'auth_arg_def'},
- lang_def => $newvalues{'lang_def'},
- timezone_def => $newvalues{'timezone_def'},
- datelocale_def => $newvalues{'datelocale_def'},
- }
- );
+ defaults => \%newvalues,
+ );
my $title = &defaults_titles();
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaults_hash,
$dom);
@@ -4334,8 +6105,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);
@@ -4369,7 +6139,7 @@ sub modify_scantron {
my $error;
if ($configuserok eq 'ok') {
if ($switchserver) {
- $error = &mt("Upload of scantron format file is not permitted to this server: [_1]",$switchserver);
+ $error = &mt("Upload of bubblesheet format file is not permitted to this server: [_1]",$switchserver);
} else {
if ($author_ok eq 'ok') {
my ($result,$scantronurl) =
@@ -4409,25 +6179,25 @@ sub modify_scantron {
if (ref($confhash{'scantron'}) eq 'HASH') {
$resulttext = &mt('Changes made:').'';
if ($confhash{'scantron'}{'scantronformat'} eq '') {
- $resulttext .= ''.&mt('[_1] scantron format file removed; [_2] file will be used for courses in this domain.',$custom,$default).' ';
+ $resulttext .= ''.&mt('[_1] bubblesheet format file removed; [_2] file will be used for courses in this domain.',$custom,$default).' ';
} else {
- $resulttext .= ''.&mt('Custom scantron format file ([_1]) uploaded for use with courses in this domain.',$custom).' ';
+ $resulttext .= ''.&mt('Custom bubblesheet format file ([_1]) uploaded for use with courses in this domain.',$custom).' ';
}
$resulttext .= ' ';
} else {
- $resulttext = &mt('Changes made to scantron format file.');
+ $resulttext = &mt('Changes made to bubblesheet format file.');
}
$resulttext .= '';
&Apache::loncommon::devalidate_domconfig_cache($dom);
} else {
- $resulttext = &mt('No changes made to scantron format file');
+ $resulttext = &mt('No changes made to bubblesheet format file');
}
} else {
$resulttext = ''.
&mt('An error occurred: [_1]',$putresult).' ';
}
} else {
- $resulttext = &mt('No changes made to scantron format file');
+ $resulttext = &mt('No changes made to bubblesheet format file');
}
if ($errors) {
$resulttext .= &mt('The following errors occurred: ').''.
@@ -4451,16 +6221,33 @@ sub modify_coursecategories {
$changes{'categorize'} = 1;
$domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
}
+ if ($domconfig{'coursecategories'}{'togglecatscomm'} ne $env{'form.togglecatscomm'}) {
+ $changes{'togglecatscomm'} = 1;
+ $domconfig{'coursecategories'}{'togglecatscomm'} = $env{'form.togglecatscomm'};
+ }
+ if ($domconfig{'coursecategories'}{'categorizecomm'} ne $env{'form.categorizecomm'}) {
+ $changes{'categorizecomm'} = 1;
+ $domconfig{'coursecategories'}{'categorizecomm'} = $env{'form.categorizecomm'};
+ }
} else {
$changes{'togglecats'} = 1;
$changes{'categorize'} = 1;
- $domconfig{'coursecategories'}{'togglecats'} = $env{'form.togglecats'};
- $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
+ $changes{'togglecatscomm'} = 1;
+ $changes{'categorizecomm'} = 1;
+ $domconfig{'coursecategories'} = {
+ togglecats => $env{'form.togglecats'},
+ categorize => $env{'form.categorize'},
+ togglecatscomm => $env{'form.togglecatscomm'},
+ categorizecomm => $env{'form.categorizecomm'},
+ };
}
if (ref($cathash) eq 'HASH') {
if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) {
push (@deletecategory,'instcode::0');
}
+ if (($domconfig{'coursecategories'}{'cats'}{'communities::0'} ne '') && ($env{'form.communities'} == 0)) {
+ push(@deletecategory,'communities::0');
+ }
}
my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail);
if (ref($cathash) eq 'HASH') {
@@ -4510,10 +6297,26 @@ sub modify_coursecategories {
$adds{$newitem} = 1;
}
}
+ if ($env{'form.communities'} eq '1') {
+ if (ref($cathash) eq 'HASH') {
+ my $newitem = 'communities::0';
+ if ($cathash->{$newitem} eq '') {
+ $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.communities_pos'};
+ $adds{$newitem} = 1;
+ }
+ } else {
+ my $newitem = 'communities::0';
+ $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.communities_pos'};
+ $adds{$newitem} = 1;
+ }
+ }
if ($env{'form.addcategory_name'} ne '') {
- my $newitem = &escape($env{'form.addcategory_name'}).'::0';
- $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
- $adds{$newitem} = 1;
+ if (($env{'form.addcategory_name'} ne 'instcode') &&
+ ($env{'form.addcategory_name'} ne 'communities')) {
+ my $newitem = &escape($env{'form.addcategory_name'}).'::0';
+ $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
+ $adds{$newitem} = 1;
+ }
}
my $putresult;
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
@@ -4550,12 +6353,15 @@ sub modify_coursecategories {
$putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);
if ($putresult eq 'ok') {
my %title = (
- togglecats => 'Show/Hide a course in the catalog',
- categorize => 'Category assigned to course',
+ togglecats => 'Show/Hide a course in catalog',
+ categorize => 'Assign a category to a course',
+ togglecatscomm => 'Show/Hide a community in catalog',
+ categorizecomm => 'Assign a category to a community',
);
my %level = (
- dom => 'set from "Modify Course" (Domain)',
- crs => 'set from "Parameters" (Course)',
+ dom => 'set in Domain ("Modify Course/Community")',
+ crs => 'set in Course ("Course Configuration")',
+ comm => 'set in Community ("Community Configuration")',
);
$resulttext = &mt('Changes made:').'';
if ($changes{'togglecats'}) {
@@ -4564,6 +6370,12 @@ sub modify_coursecategories {
if ($changes{'categorize'}) {
$resulttext .= ''.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").' ';
}
+ if ($changes{'togglecatscomm'}) {
+ $resulttext .= ''.&mt("$title{'togglecatscomm'} $level{$env{'form.togglecatscomm'}}").' ';
+ }
+ if ($changes{'categorizecomm'}) {
+ $resulttext .= ''.&mt("$title{'categorizecomm'} $level{$env{'form.categorizecomm'}}").' ';
+ }
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
my $cathash;
if (ref($domconfig{'coursecategories'}) eq 'HASH') {
@@ -4613,7 +6425,504 @@ sub modify_coursecategories {
&mt('An error occurred: [_1]',$putresult).'';
}
} else {
- $resulttext = &mt('No changes made to course categories');
+ $resulttext = &mt('No changes made to course and community categories');
+ }
+ return $resulttext;
+}
+
+sub modify_serverstatuses {
+ my ($dom,%domconfig) = @_;
+ my ($resulttext,%changes,%currserverstatus,%newserverstatus);
+ if (ref($domconfig{'serverstatuses'}) eq 'HASH') {
+ %currserverstatus = %{$domconfig{'serverstatuses'}};
+ }
+ my @pages = &serverstatus_pages();
+ foreach my $type (@pages) {
+ $newserverstatus{$type}{'namedusers'} = '';
+ $newserverstatus{$type}{'machines'} = '';
+ if (defined($env{'form.'.$type.'_namedusers'})) {
+ my @users = split(/,/,$env{'form.'.$type.'_namedusers'});
+ my @okusers;
+ foreach my $user (@users) {
+ my ($uname,$udom) = split(/:/,$user);
+ if (($udom =~ /^$match_domain$/) &&
+ (&Apache::lonnet::domain($udom)) &&
+ ($uname =~ /^$match_username$/)) {
+ if (!grep(/^\Q$user\E/,@okusers)) {
+ push(@okusers,$user);
+ }
+ }
+ }
+ if (@okusers > 0) {
+ @okusers = sort(@okusers);
+ $newserverstatus{$type}{'namedusers'} = join(',',@okusers);
+ }
+ }
+ if (defined($env{'form.'.$type.'_machines'})) {
+ my @machines = split(/,/,$env{'form.'.$type.'_machines'});
+ my @okmachines;
+ foreach my $ip (@machines) {
+ my @parts = split(/\./,$ip);
+ next if (@parts < 4);
+ my $badip = 0;
+ for (my $i=0; $i<4; $i++) {
+ if (!(($parts[$i] >= 0) && ($parts[$i] <= 255))) {
+ $badip = 1;
+ last;
+ }
+ }
+ if (!$badip) {
+ push(@okmachines,$ip);
+ }
+ }
+ @okmachines = sort(@okmachines);
+ $newserverstatus{$type}{'machines'} = join(',',@okmachines);
+ }
+ }
+ my %serverstatushash = (
+ serverstatuses => \%newserverstatus,
+ );
+ my %changes;
+ foreach my $type (@pages) {
+ foreach my $setting ('namedusers','machines') {
+ my (@current,@new);
+ if (ref($currserverstatus{$type}) eq 'HASH') {
+ if ($currserverstatus{$type}{$setting} ne '') {
+ @current = split(/,/,$currserverstatus{$type}{$setting});
+ }
+ }
+ if ($newserverstatus{$type}{$setting} ne '') {
+ @new = split(/,/,$newserverstatus{$type}{$setting});
+ }
+ if (@current > 0) {
+ if (@new > 0) {
+ foreach my $item (@current) {
+ if (!grep(/^\Q$item\E$/,@new)) {
+ $changes{$type}{$setting} = 1;
+ last;
+ }
+ }
+ foreach my $item (@new) {
+ if (!grep(/^\Q$item\E$/,@current)) {
+ $changes{$type}{$setting} = 1;
+ last;
+ }
+ }
+ } else {
+ $changes{$type}{$setting} = 1;
+ }
+ } elsif (@new > 0) {
+ $changes{$type}{$setting} = 1;
+ }
+ }
+ }
+ if (keys(%changes) > 0) {
+ my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
+ my $putresult = &Apache::lonnet::put_dom('configuration',
+ \%serverstatushash,$dom);
+ if ($putresult eq 'ok') {
+ $resulttext .= &mt('Changes made:').'';
+ foreach my $type (@pages) {
+ if (ref($changes{$type}) eq 'HASH') {
+ $resulttext .= ''.$titles->{$type}.'';
+ if ($changes{$type}{'namedusers'}) {
+ if ($newserverstatus{$type}{'namedusers'} eq '') {
+ $resulttext .= ''.&mt("Access terminated for all specific (named) users").' '."\n";
+ } else {
+ $resulttext .= ''.&mt("Access available for the following specified users: ").$newserverstatus{$type}{'namedusers'}.' '."\n";
+ }
+ }
+ if ($changes{$type}{'machines'}) {
+ if ($newserverstatus{$type}{'machines'} eq '') {
+ $resulttext .= ''.&mt("Access terminated for all specific IP addresses").' '."\n";
+ } else {
+ $resulttext .= ''.&mt("Access available for the following specified IP addresses: ").$newserverstatus{$type}{'machines'}.' '."\n";
+ }
+
+ }
+ $resulttext .= ' ';
+ }
+ }
+ $resulttext .= ' ';
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred saving access settings for server status pages: [_1].',$putresult).' ';
+
+ }
+ } else {
+ $resulttext = &mt('No changes made to access to server status pages');
+ }
+ return $resulttext;
+}
+
+sub modify_helpsettings {
+ my ($r,$dom,$confname,%domconfig) = @_;
+ my ($resulttext,$errors,%changes,%helphash);
+
+ my $customhelpfile = $env{'form.loginhelpurl.filename'};
+ my $defaulthelpfile = 'defaulthelp.html';
+ my $servadm = $r->dir_config('lonAdmEMail');
+ my ($configuserok,$author_ok,$switchserver) =
+ &config_check($dom,$confname,$servadm);
+
+ my %defaultchecked = ('submitbugs' => 'on');
+ my @offon = ('off','on');
+ my %title = ( submitbugs => 'Display link for users to submit a bug',
+ loginhelpurl => 'Unauthenticated login help page set to custom file');
+
+ my @toggles = ('submitbugs');
+
+ $helphash{'helpsettings'} = {};
+
+ if (ref($domconfig{'helpsettings'}) ne 'HASH') {
+ if ($domconfig{'helpsettings'} eq '') {
+ $domconfig{'helpsettings'} = {};
+ }
+ }
+
+ if (ref($domconfig{'helpsettings'}) eq 'HASH') {
+
+ foreach my $item (@toggles) {
+
+ if ($defaultchecked{$item} eq 'on') {
+ if (($domconfig{'helpsettings'}{$item} eq '') &&
+ ($env{'form.'.$item} eq '0')) {
+ $changes{$item} = 1;
+ } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ } elsif ($defaultchecked{$item} eq 'off') {
+ if (($domconfig{'helpsettings'}{$item} eq '') &&
+ ($env{'form.'.$item} eq '1')) {
+ $changes{$item} = 1;
+ } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+ }
+
+ if ($customhelpfile ne '') {
+ my $error;
+ if ($configuserok eq 'ok') {
+ if ($switchserver) {
+ $error = &mt("Upload of custom help file is not permitted to this server: [_1]",$switchserver);
+ } else {
+ if ($author_ok eq 'ok') {
+ my ($result,$loginhelpurl) =
+ &publishlogo($r,'upload','loginhelpurl',$dom,
+ $confname,'help','','',$customhelpfile);
+ if ($result eq 'ok') {
+ $helphash{'helpsettings'}{'loginhelpurl'} = $loginhelpurl;
+ $changes{'loginhelpurl'} = 1;
+ } else {
+ $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$customhelpfile,$result);
+ }
+ } else {
+ $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$customhelpfile,$confname,$dom,$author_ok);
+ }
+ }
+ } else {
+ $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$customhelpfile,$confname,$dom,$configuserok);
+ }
+ if ($error) {
+ &Apache::lonnet::logthis($error);
+ $errors .= ''.$error.' ';
+ }
+ }
+
+ if ($domconfig{'helpsettings'}{'loginhelpurl'} ne '') {
+ if ($env{'form.loginhelpurl_del'}) {
+ $helphash{'helpsettings'}{'loginhelpurl'} = '';
+ $changes{'loginhelpurl'} = 1;
+ }
+ }
+ }
+
+
+ my $putresult;
+
+ if (keys(%changes) > 0) {
+ $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
+ } else {
+ $putresult = 'ok';
+ }
+
+ if ($putresult eq 'ok') {
+ if (keys(%changes) > 0) {
+ $resulttext = &mt('Changes made:').'';
+ foreach my $item (sort(keys(%changes))) {
+ if ($item eq 'submitbugs') {
+ $resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").' ';
+ }
+ if ($item eq 'loginhelpurl') {
+ if ($helphash{'helpsettings'}{'loginhelpurl'} eq '') {
+ $resulttext .= ''.&mt('[_1] help file removed; [_2] file will be used for the unathorized help page in this domain.',$customhelpfile,$defaulthelpfile).' ';
+ } else {
+ $resulttext .= ''.&mt("$title{$item} [_1]",$customhelpfile).' ';
+ }
+ }
+ }
+ $resulttext .= ' ';
+ } else {
+ $resulttext = &mt('No changes made to help settings');
+ }
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred: [_1]',$putresult).' ';
+ }
+ if ($errors) {
+ $resulttext .= &mt('The following errors occurred: ').'';
+ }
+ return $resulttext;
+}
+
+sub modify_coursedefaults {
+ my ($dom,%domconfig) = @_;
+ my ($resulttext,$errors,%changes,%defaultshash);
+ my %defaultchecked = ('canuse_pdfforms' => 'off');
+ my @offon = ('off','on');
+ my @toggles = ();
+
+ $defaultshash{'coursedefaults'} = {};
+
+ if (ref($domconfig{'coursedefaults'}) ne 'HASH') {
+ if ($domconfig{'coursedefaults'} eq '') {
+ $domconfig{'coursedefaults'} = {};
+ }
+ }
+
+ if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
+ foreach my $item (@toggles) {
+ if ($defaultchecked{$item} eq 'on') {
+ if (($domconfig{'coursedefaults'}{$item} eq '') &&
+ ($env{'form.'.$item} eq '0')) {
+ $changes{$item} = 1;
+ } elsif ($domconfig{'coursdefaults'}{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ } elsif ($defaultchecked{$item} eq 'off') {
+ if (($domconfig{'coursedefaults'}{$item} eq '') &&
+ ($env{'form.'.$item} eq '1')) {
+ $changes{$item} = 1;
+ } elsif ($domconfig{'coursedefaults'}{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ $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;
+ }
+ }
+ }
+ 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 $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ }
+ $resulttext = &mt('Changes made:').'';
+ foreach my $item (sort(keys(%changes))) {
+ if ($item eq 'canuse_pdfforms') {
+ if ($env{'form.'.$item} eq '1') {
+ $resulttext .= ''.&mt("Course/Community users can create/upload PDF forms set to 'on'").' ';
+ } else {
+ $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 .= ' ';
+ } else {
+ $resulttext = &mt('No changes made to course defaults');
+ }
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred: [_1]',$putresult).' ';
+ }
+ return $resulttext;
+}
+
+sub modify_usersessions {
+ my ($dom,%domconfig) = @_;
+ my @types = ('version','excludedomain','includedomain');
+ my @prefixes = ('remote','hosted');
+ my @lcversions = &Apache::lonnet::all_loncaparevs();
+ my (%by_ip,%by_location,@intdoms);
+ &build_location_hashes(\@intdoms,\%by_ip,\%by_location);
+ my @locations = sort(keys(%by_location));
+ my (%defaultshash,%changes);
+ foreach my $prefix (@prefixes) {
+ $defaultshash{'usersessions'}{$prefix} = {};
+ }
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ my $resulttext;
+ my %iphost = &Apache::lonnet::get_iphost();
+ foreach my $prefix (@prefixes) {
+ foreach my $type (@types) {
+ my $inuse = $env{'form.'.$prefix.'_'.$type.'_inuse'};
+ if ($type eq 'version') {
+ my $value = $env{'form.'.$prefix.'_'.$type};
+ my $okvalue;
+ if ($value ne '') {
+ if (grep(/^\Q$value\E$/,@lcversions)) {
+ $okvalue = $value;
+ }
+ }
+ if (ref($domconfig{'usersessions'}) eq 'HASH') {
+ if (ref($domconfig{'usersessions'}{$prefix}) eq 'HASH') {
+ if ($domconfig{'usersessions'}{$prefix}{$type} ne '') {
+ if ($inuse == 0) {
+ $changes{$prefix}{$type} = 1;
+ } else {
+ if ($okvalue ne $domconfig{'usersessions'}{$prefix}{$type}) {
+ $changes{$prefix}{$type} = 1;
+ }
+ if ($okvalue ne '') {
+ $defaultshash{'usersessions'}{$prefix}{$type} = $okvalue;
+ }
+ }
+ } else {
+ if (($inuse == 1) && ($okvalue ne '')) {
+ $defaultshash{'usersessions'}{$prefix}{$type} = $okvalue;
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ } else {
+ if (($inuse == 1) && ($okvalue ne '')) {
+ $defaultshash{'usersessions'}{$prefix}{$type} = $okvalue;
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ } else {
+ if (($inuse == 1) && ($okvalue ne '')) {
+ $defaultshash{'usersessions'}{$prefix}{$type} = $okvalue;
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ } else {
+ my @vals = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_'.$type);
+ my @okvals;
+ foreach my $val (@vals) {
+ if ($val =~ /:/) {
+ my @items = split(/:/,$val);
+ foreach my $item (@items) {
+ if (ref($by_location{$item}) eq 'ARRAY') {
+ push(@okvals,$item);
+ }
+ }
+ } else {
+ if (ref($by_location{$val}) eq 'ARRAY') {
+ push(@okvals,$val);
+ }
+ }
+ }
+ @okvals = sort(@okvals);
+ if (ref($domconfig{'usersessions'}) eq 'HASH') {
+ if (ref($domconfig{'usersessions'}{$prefix}) eq 'HASH') {
+ if (ref($domconfig{'usersessions'}{$prefix}{$type}) eq 'ARRAY') {
+ if ($inuse == 0) {
+ $changes{$prefix}{$type} = 1;
+ } else {
+ $defaultshash{'usersessions'}{$prefix}{$type} = \@okvals;
+ my @changed = &Apache::loncommon::compare_arrays($domconfig{'usersessions'}{$prefix}{$type},$defaultshash{'usersessions'}{$prefix}{$type});
+ if (@changed > 0) {
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ } else {
+ if ($inuse == 1) {
+ $defaultshash{'usersessions'}{$prefix}{$type} = \@okvals;
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ } else {
+ if ($inuse == 1) {
+ $defaultshash{'usersessions'}{$prefix}{$type} = \@okvals;
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ } else {
+ if ($inuse == 1) {
+ $defaultshash{'usersessions'}{$prefix}{$type} = \@okvals;
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ }
+ }
+ }
+ if (keys(%changes) > 0) {
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
+ $dom);
+ if ($putresult eq 'ok') {
+ if (ref($defaultshash{'usersessions'}) eq 'HASH') {
+ if (ref($defaultshash{'usersessions'}{'remote'}) eq 'HASH') {
+ $domdefaults{'remotesessions'} = $defaultshash{'usersessions'}{'remote'};
+ }
+ if (ref($defaultshash{'usersessions'}{'hosted'}) eq 'HASH') {
+ $domdefaults{'hostedsessions'} = $defaultshash{'usersessions'}{'hosted'};
+ }
+ }
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ my %lt = &usersession_titles();
+ $resulttext = &mt('Changes made:').'';
+ foreach my $prefix (@prefixes) {
+ if (ref($changes{$prefix}) eq 'HASH') {
+ $resulttext .= ''.$lt{$prefix}.'';
+ foreach my $type (@types) {
+ if (defined($changes{$prefix}{$type})) {
+ my $newvalue;
+ if (ref($defaultshash{'usersessions'}) eq 'HASH') {
+ if (ref($defaultshash{'usersessions'}{$prefix})) {
+ if ($type eq 'version') {
+ $newvalue = $defaultshash{'usersessions'}{$prefix}{$type};
+ } elsif (ref($defaultshash{'usersessions'}{$prefix}{$type}) eq 'ARRAY') {
+ if (@{$defaultshash{'usersessions'}{$prefix}{$type}} > 0) {
+ $newvalue = join(', ',@{$defaultshash{'usersessions'}{$prefix}{$type}});
+ }
+ }
+ }
+ }
+ if ($newvalue eq '') {
+ if ($type eq 'version') {
+ $resulttext .= ''.&mt('[_1] set to: off',$lt{$type}).' ';
+ } else {
+ $resulttext .= ''.&mt('[_1] set to: none',$lt{$type}).' ';
+ }
+ } else {
+ if ($type eq 'version') {
+ $newvalue .= ' '.&mt('(or later)');
+ }
+ $resulttext .= ''.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).' ';
+ }
+ }
+ }
+ $resulttext .= ' ';
+ }
+ }
+ $resulttext .= ' ';
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred: [_1]',$putresult).' ';
+ }
+ } else {
+ $resulttext = &mt('No changes made to settings for user session hosting.');
}
return $resulttext;
}
@@ -4658,4 +6967,118 @@ sub recurse_cat_deletes {
return;
}
+sub dom_servers {
+ my ($dom) = @_;
+ my (%uniqservers,%servers);
+ my $primaryserver = &Apache::lonnet::hostname(&Apache::lonnet::domain($dom,'primary'));
+ my @machinedoms = &Apache::lonnet::machine_domains($primaryserver);
+ foreach my $mdom (@machinedoms) {
+ my %currservers = %servers;
+ my %server = &Apache::lonnet::get_servers($mdom);
+ %servers = (%currservers,%server);
+ }
+ my %by_hostname;
+ foreach my $id (keys(%servers)) {
+ push(@{$by_hostname{$servers{$id}}},$id);
+ }
+ foreach my $hostname (sort(keys(%by_hostname))) {
+ if (@{$by_hostname{$hostname}} > 1) {
+ my $match = 0;
+ foreach my $id (@{$by_hostname{$hostname}}) {
+ if (&Apache::lonnet::host_domain($id) eq $dom) {
+ $uniqservers{$id} = $hostname;
+ $match = 1;
+ }
+ }
+ unless ($match) {
+ $uniqservers{$by_hostname{$hostname}[0]} = $hostname;
+ }
+ } else {
+ $uniqservers{$by_hostname{$hostname}[0]} = $hostname;
+ }
+ }
+ return %uniqservers;
+}
+
+sub get_active_dcs {
+ my ($dom) = @_;
+ my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']);
+ 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};
+ }
+ }
+ }
+ }
+ return %domcoords;
+}
+
+sub active_dc_picker {
+ my ($dom,$curr_dc) = @_;
+ my %domcoords = &get_active_dcs($dom);
+ my @dcs = sort(keys(%domcoords));
+ my $numdcs = scalar(@dcs);
+ my $datatable;
+ my $numinrow = 2;
+ if ($numdcs > 1) {
+ $datatable = '';
+ } elsif (@dcs) {
+ $datatable .= ' ';
+ }
+ return ($numdcs,$datatable);
+}
+
+sub usersession_titles {
+ return &Apache::lonlocal::texthash(
+ hosted => 'Hosting of sessions for users from other domains on servers in this domain',
+
+ remote => 'Hosting of sessions for users in this domain on servers in other domains',
+ version => 'LON-CAPA version requirement',
+ excludedomain => 'Allow all, but exclude specific domains',
+ includedomain => 'Deny all, but include specific domains',
+ );
+}
+
1;