--- loncom/interface/domainprefs.pm 2019/04/26 20:15:30 1.355
+++ loncom/interface/domainprefs.pm 2019/05/06 19:28:17 1.359
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.355 2019/04/26 20:15:30 raeburn Exp $
+# $Id: domainprefs.pm,v 1.359 2019/05/06 19:28:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -219,7 +219,7 @@ sub handler {
'serverstatuses','requestcourses','helpsettings',
'coursedefaults','usersessions','loadbalancing',
'requestauthor','selfenrollment','inststatus',
- 'ltitools','ssl','trust','lti','passwords'],$dom);
+ 'ltitools','ssl','trust','lti','privacy','passwords'],$dom);
my %encconfig =
&Apache::lonnet::get_dom('encconfig',['ltitools','lti'],$dom);
if (ref($domconfig{'ltitools'}) eq 'HASH') {
@@ -247,7 +247,7 @@ sub handler {
}
}
my @prefs_order = ('rolecolors','login','defaults','passwords','quotas','autoenroll',
- 'autoupdate','autocreate','directorysrch','contacts',
+ 'autoupdate','autocreate','directorysrch','contacts','privacy',
'usercreation','selfcreation','usermodification','scantron',
'requestcourses','requestauthor','coursecategories',
'serverstatuses','helpsettings','coursedefaults',
@@ -497,10 +497,16 @@ sub handler {
modify => \&modify_selfenrollment,
},
'privacy' =>
- {text => 'User Privacy',
+ {text => 'Availability of User Information',
help => 'Domain_Configuration_User_Privacy',
- header => [{col1 => 'Setting',
- col2 => 'Value',}],
+ header => [{col1 => 'Role assigned in different domain',
+ col2 => 'Approval options'},
+ {col1 => 'Role assigned in different domain to user of type',
+ col2 => 'User information available in that domain'},
+ {col1 => "Role assigned in user's domain",
+ col2 => 'Information viewable by privileged user'},
+ {col1 => "Role assigned in user's domain",
+ col2 => 'Information viewable by unprivileged user'}],
print => \&print_privacy,
modify => \&modify_privacy,
},
@@ -771,6 +777,8 @@ sub process_changes {
$output = &modify_trust($dom,$lastactref,%domconfig);
} elsif ($action eq 'lti') {
$output = &modify_lti($r,$dom,$action,$lastactref,%domconfig);
+ } elsif ($action eq 'privacy') {
+ $output = &modify_privacy($dom,%domconfig);
} elsif ($action eq 'passwords') {
$output = &modify_passwords($r,$dom,$confname,$lastactref,%domconfig);
}
@@ -844,7 +852,7 @@ sub print_config_box {
($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'ssl') ||
($action eq 'directorysrch') || ($action eq 'trust') || ($action eq 'helpsettings') ||
- ($action eq 'contacts')) {
+ ($action eq 'contacts') || ($action eq 'privacy')) {
$output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'passwords') {
$output .= $item->{'print'}->('top',$dom,$confname,$settings,\$rowtotal);
@@ -879,7 +887,8 @@ sub print_config_box {
if (($action eq 'autoupdate') || ($action eq 'usercreation') ||
($action eq 'selfcreation') || ($action eq 'selfenrollment') ||
($action eq 'usersessions') || ($action eq 'coursecategories') ||
- ($action eq 'trust') || ($action eq 'contacts') || ($action eq 'passwords')) {
+ ($action eq 'trust') || ($action eq 'contacts') ||
+ ($action eq 'privacy') || ($action eq 'passwords')) {
if ($action eq 'coursecategories') {
$output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal);
$colspan = ' colspan="2"';
@@ -932,7 +941,7 @@ sub print_config_box {
'."\n";
if ($action eq 'coursecategories') {
$output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
- } elsif (($action eq 'contacts') || ($action eq 'passwords')) {
+ } elsif (($action eq 'contacts') || ($action eq 'privacy') || ($action eq 'passwords')) {
if ($action eq 'passwords') {
$output .= $item->{'print'}->('lower',$dom,$confname,$settings,\$rowtotal);
} else {
@@ -5800,6 +5809,124 @@ sub print_validation_rows {
return $datatable;
}
+sub print_privacy {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my ($datatable,$css_class,$numinrow,@items,%names,$othertitle,$usertypes,$types);
+ my $itemcount = 0;
+ unless ($position eq 'top') {
+ @items = ('domain','author','course','community');
+ %names = &Apache::lonlocal::texthash (
+ domain => 'Assigned domain role(s)',
+ author => 'Assigned co-author role(s)',
+ course => 'Assigned course role(s)',
+ community => 'Assigned community role',
+ );
+ $numinrow = 4;
+ ($othertitle,$usertypes,$types) =
+ &Apache::loncommon::sorted_inst_types($dom);
+ }
+ if (($position eq 'top') || ($position eq 'middle')) {
+ my (%by_ip,%by_location,@intdoms,@instdoms);
+ &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms);
+ if ($position eq 'top') {
+ my %curr;
+ my @options = ('none','user','domain','auto');
+ my %titles = &Apache::lonlocal::texthash (
+ none => 'Not allowed',
+ user => 'User authorizes',
+ domain => 'DC authorizes',
+ auto => 'Unrestricted',
+ instdom => 'Other domain shares institution/provider',
+ extdom => 'Other domain has different institution/provider',
+ );
+ my %names = &Apache::lonlocal::texthash (
+ domain => 'Domain role',
+ author => 'Co-author role',
+ course => 'Course role',
+ community => 'Community role',
+ );
+ my $primary_id = &Apache::lonnet::domain($dom,'primary');
+ my $intdom = &Apache::lonnet::internet_dom($primary_id);
+ foreach my $domtype ('instdom','extdom') {
+ my (%checked,$skip);
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= '
'.$titles{$domtype}.' | '.
+ '';
+ if ($domtype eq 'instdom') {
+ unless (@instdoms > 1) {
+ $datatable .= &mt('Nothing to set, as no domains besides [_1] are hosted by [_2]',$dom,$intdom);
+ $skip = 1;
+ }
+ } elsif ($domtype eq 'extdom') {
+ if (keys(%by_location) == 0) {
+ $datatable .= &mt('Nothing to set, as no other hosts besides [_1]',$intdom);
+ $skip = 1;
+ }
+ }
+ unless ($skip) {
+ foreach my $roletype ('domain','author','course','community') {
+ $checked{'auto'} = ' checked="checked"';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{approval}) eq 'HASH') {
+ if (ref($settings->{approval}->{$domtype}) eq 'HASH') {
+ if ($settings->{approval}->{$domtype}->{$roletype}=~ /^(none|user|domain)$/) {
+ $checked{$1} = ' checked="checked"';
+ $checked{'auto'} = '';
+ }
+ }
+ }
+ }
+ $datatable .= '';
+ }
+ }
+ $datatable .= ' |
';
+ $itemcount ++;
+ }
+ } elsif ($position eq 'middle') {
+ if ((@instdoms > 1) || (keys(%by_location) > 0)) {
+ if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) {
+ foreach my $item (@{$types}) {
+ $datatable .= &modifiable_userdata_row('privacy','othdom_'.$item,$settings,
+ $numinrow,$itemcount,'','','','','',
+ '',$usertypes->{$item});
+ $itemcount ++;
+ }
+ }
+ $datatable .= &modifiable_userdata_row('privacy','othdom_default',$settings,
+ $numinrow,$itemcount,'','','','','',
+ '',$othertitle);
+ $itemcount ++;
+ } else {
+ $datatable .= &mt('Nothing to set here, as there are no other domains');
+ }
+ }
+ } else {
+ my $prefix;
+ if ($position eq 'lower') {
+ $prefix = 'priv';
+ } else {
+ $prefix = 'unpriv';
+ }
+ foreach my $item (@items) {
+ $datatable .= &modifiable_userdata_row('privacy',$prefix.'_'.$item,$settings,
+ $numinrow,$itemcount,'','','','','',
+ '',$names{$item});
+ $itemcount ++;
+ }
+ }
+ if (ref($rowtotal)) {
+ $$rowtotal += $itemcount;
+ }
+ return $datatable;
+}
+
sub print_passwords {
my ($position,$dom,$confname,$settings,$rowtotal) = @_;
my ($datatable,$css_class);
@@ -5822,6 +5949,7 @@ sub print_passwords {
max => 'Maximum password length',
chars => 'Required characters',
expire => 'Password expiration (days)',
+ numsaved => 'Number of previous passwords to save and disallow reuse',
);
if ($position eq 'top') {
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
@@ -6085,7 +6213,7 @@ sub print_passwords {
$itemcount ++;
}
} elsif ($position eq 'lower') {
- my ($min,$max,%chars,$expire);
+ my ($min,$max,%chars,$expire,$numsaved);
if (ref($settings) eq 'HASH') {
if ($settings->{min}) {
$min = $settings->{min};
@@ -6099,6 +6227,9 @@ sub print_passwords {
if ($settings->{expire}) {
$expire = $settings->{expire};
}
+ if ($settings->{numsaved}) {
+ $numsaved = $settings->{numsaved};
+ }
} else {
$min = '7';
}
@@ -6161,30 +6292,68 @@ sub print_passwords {
''.
' '.&mt('(Leave blank for no expiration)').''.
'';
+ $itemcount ++;
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= ''.$titles{'numsaved'}.' | '.
+ ''.
+ ''.
+ ' '.&mt('(Leave blank to not save previous passwords)').''.
+ ' |
';
} else {
- my $checkedon;
- my $checkedoff = ' checked="checked"';
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my %ownerchg = (
+ by => {},
+ for => {},
+ );
+ my %ownertitles = &Apache::lonlocal::texthash (
+ by => 'Course owner status(es) allowed',
+ for => 'Student status(es) allowed',
+ );
if (ref($settings) eq 'HASH') {
- if ($settings->{crsownerchg}) {
- $checkedon = $checkedoff;
- $checkedoff = '';
+ if (ref($settings->{crsownerchg}) eq 'HASH') {
+ if (ref($settings->{crsownerchg}{'by'}) eq 'ARRAY') {
+ map { $ownerchg{by}{$_} = 1; } (@{$settings->{crsownerchg}{'by'}});
+ }
+ if (ref($settings->{crsownerchg}{'for'}) eq 'ARRAY') {
+ map { $ownerchg{for}{$_} = 1; } (@{$settings->{crsownerchg}{'for'}});
+ }
}
}
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= ''.
''.
&mt('Requirements').''.
- '- '.&mt("Course 'type' is not a Community").'
'.
+ '- '.&mt("Course 'type' is not a Community or Placement Test").'
'.
'- '.&mt('User is Course Coordinator and also course owner').'
'.
'- '.&mt("Student's only active roles are student role(s) in course(s) owned by this user").'
'.
+ '- '.&mt('User, course, and student share same domain').'
'.
' '.
' | '.
- ''.
- ' '.
- ''.
- ' |
';
-
+ '';
+ foreach my $item ('by','for') {
+ $datatable .= '';
+ }
+ $datatable .= ' | ';
}
return $datatable;
}
@@ -9355,7 +9524,7 @@ sub build_category_rows {
sub modifiable_userdata_row {
my ($context,$item,$settings,$numinrow,$rowcount,$usertypes,$fieldsref,$titlesref,
- $rowid,$customcss,$rowstyle) = @_;
+ $rowid,$customcss,$rowstyle,$itemdesc) = @_;
my ($role,$rolename,$statustype);
$role = $item;
if ($context eq 'cancreate') {
@@ -9378,6 +9547,8 @@ sub modifiable_userdata_row {
}
} elsif ($context eq 'lti') {
$rolename = &mt('Institutional data used (if available)');
+ } elsif ($context eq 'privacy') {
+ $rolename = $itemdesc;
} else {
if ($role eq 'cr') {
$rolename = &mt('Custom role');
@@ -9427,6 +9598,13 @@ sub modifiable_userdata_row {
if (ref($settings) eq 'HASH') {
$hashref = $settings->{'instdata'};
}
+ } elsif ($context eq 'privacy') {
+ my ($key,$inner) = split(/_/,$role);
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$key}) eq 'HASH') {
+ $hashref = $settings->{$key}->{$inner};
+ }
+ }
} elsif (ref($settings->{$context}) eq 'HASH') {
if (ref($settings->{$context}->{$role}) eq 'HASH') {
$hashref = $settings->{'lti_instdata'};
@@ -9465,6 +9643,24 @@ sub modifiable_userdata_row {
unless ($role eq 'emailusername') {
if (exists($checks{$fields[$i]})) {
$check = $checks{$fields[$i]};
+ } elsif ($context eq 'privacy') {
+ if ($role =~ /^priv_(domain|course)$/) {
+ if (ref($settings) ne 'HASH') {
+ $check = ' checked="checked" ';
+ }
+ } elsif ($role =~ /^priv_(author|community)$/) {
+ if (ref($settings) ne 'HASH') {
+ unless ($fields[$i] eq 'id') {
+ $check = ' checked="checked" ';
+ }
+ }
+ } elsif ($role =~ /^(unpriv|othdom)_/) {
+ if (ref($settings) ne 'HASH') {
+ if (($fields[$i] eq 'lastname') || ($fields[$i] eq 'firstname')) {
+ $check = ' checked="checked" ';
+ }
+ }
+ }
} elsif ($context ne 'lti') {
if ($role eq 'st') {
if (ref($settings) ne 'HASH') {
@@ -9493,6 +9689,8 @@ sub modifiable_userdata_row {
} else {
if ($context eq 'lti') {
$prefix = 'lti';
+ } elsif ($context eq 'privacy') {
+ $prefix = 'privacy';
}
$output .= '