--- loncom/interface/domainprefs.pm 2019/05/06 01:30:14 1.358
+++ 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.358 2019/05/06 01:30:14 raeburn Exp $
+# $Id: domainprefs.pm,v 1.359 2019/05/06 19:28:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6300,29 +6300,60 @@ sub print_passwords {
' '.&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;
}
@@ -14588,7 +14619,7 @@ sub modify_passwords {
my $ruleok;
if ($rule eq 'expire') {
if ($env{'form.passwords_'.$rule} =~ /^\d+(|\.\d*)$/) {
- $ruleok = 1;
+ $ruleok = 1;
}
} elsif ($env{'form.passwords_'.$rule} =~ /^\d+$/) {
$ruleok = 1;
@@ -14628,13 +14659,36 @@ sub modify_passwords {
}
}
}
- if ($env{'form.passwords_crsowner'}) {
- $newvalues{'crsownerchg'} = 1;
- unless ($current{'crsownerchg'}) {
- $changes{'crsownerchg'} = 1;
+ my %crsownerchg = (
+ by => [],
+ for => [],
+ );
+ foreach my $item ('by','for') {
+ my @posstypes = &Apache::loncommon::get_env_multiple('form.passwords_crsowner_'.$item);
+ foreach my $type (sort(@posstypes)) {
+ if (grep(/^\Q$type\E$/,@oktypes)) {
+ push(@{$crsownerchg{$item}},$type);
+ }
+ }
+ }
+ $newvalues{'crsownerchg'} = \%crsownerchg;
+ if (ref($current{'crsownerchg'}) eq 'HASH') {
+ foreach my $item ('by','for') {
+ if (ref($current{'crsownerchg'}{$item}) eq 'ARRAY') {
+ my @diffs = &Apache::loncommon::compare_arrays($current{'crsownerchg'}{$item},$crsownerchg{$item});
+ if (@diffs > 0) {
+ $changes{'crsownerchg'} = 1;
+ last;
+ }
+ }
+ }
+ } elsif (!exists($domconfig{passwords})) {
+ foreach my $item ('by','for') {
+ if (@{$crsownerchg{$item}} > 0) {
+ $changes{'crsownerchg'} = 1;
+ last;
+ }
}
- } elsif ($current{'crsownerchg'}) {
- $changes{'crsownerchg'} = 1;
}
my %confighash = (
@@ -14786,10 +14840,29 @@ sub modify_passwords {
}
}
} elsif ($key eq 'crsownerchg') {
- if ($confighash{'passwords'}{'crsownerchg'}) {
- $resulttext .= ''.&mt('Course owner may change student passwords.').'';
+ if (ref($confighash{'passwords'}{'crsownerchg'}) eq 'HASH') {
+ if ((@{$confighash{'passwords'}{'crsownerchg'}{'by'}} == 0) ||
+ (@{$confighash{'passwords'}{'crsownerchg'}{'for'}} == 0)) {
+ $resulttext .= ''.&mt('Course owner may not change student passwords.').'';
+ } else {
+ my %crsownerstr;
+ foreach my $item ('by','for') {
+ if (ref($confighash{'passwords'}{'crsownerchg'}{$item}) eq 'ARRAY') {
+ foreach my $type (@{$confighash{'passwords'}{'crsownerchg'}{$item}}) {
+ if ($type eq 'default') {
+ $crsownerstr{$item} .= $othertitle.', ';
+ } elsif ($usertypes->{$type} ne '') {
+ $crsownerstr{$item} .= $usertypes->{$type}.', ';
+ }
+ }
+ $crsownerstr{$item} =~ s/\Q, \E$//;
+ }
+ }
+ $resulttext .= ''.&mt('Course owner (with status: [_1]) may change passwords for students (with status: [_2]).',
+ $crsownerstr{'by'},$crsownerstr{'for'}).'';
+ }
} else {
- $resulttext .= ''.&mt('Course owner may not change student passwords.');
+ $resulttext .= ''.&mt('Course owner may not change student passwords.').'';
}
}
$resulttext .= '';