'.&mt('Creation of new users is permitted by a Domain Coordinator, and also by other users when: ').$chgtext.'
';
- } else {
- $resulttext .= '
'.&mt("Creation of new users is now only allowed when the user's role is Domain Coordinator.").'
';
+ my %lt = &usercreation_types();
+ foreach my $type (@{$changes{'cancreate'}}) {
+ my $chgtext;
+ if ($cancreate{$type} eq 'none') {
+ $chgtext = $lt{$type}.' '.&mt('creation of new users is not permitted, except by a Domain Coordinator.');
+ } elsif ($cancreate{$type} eq 'any') {
+ $chgtext = $lt{$type}.' '.&mt('creation of new users is permitted for both institutional and non-institutional usernames.');
+ } elsif ($cancreate{$type} eq 'official') {
+ $chgtext = $lt{$type}.' '.&mt('creation of new users is only permitted for institutional usernames.',$lt{$type});
+ } elsif ($cancreate{$type} eq 'unofficial') {
+ $chgtext = $lt{$type}.' '.&mt('creation of new users is only permitted for non-institutional usernames.',$lt{$type});
+ }
+ $resulttext .= '
'.$chgtext.'
';
}
}
if (ref($changes{'username_rule'}) eq 'ARRAY') {
@@ -2882,7 +3069,6 @@ sub modify_usercreation {
my %authname = &authtype_names();
my %context_title = &context_names();
if (ref($changes{'authtypes'}) eq 'ARRAY') {
- my @unchanged;
my $chgtext = '
';
foreach my $type (@{$changes{'authtypes'}}) {
my @allowed;
@@ -2904,6 +3090,106 @@ sub modify_usercreation {
}
} else {
$resulttext = ''.
+ &mt('An error occurred: [_1]',$putresult).'';
+ }
+ return $resulttext;
+}
+
+sub modify_usermodification {
+ my ($dom,%domconfig) = @_;
+ my ($resulttext,%curr_usermodification,%changes);
+ if (ref($domconfig{'usermodification'}) eq 'HASH') {
+ foreach my $key (keys(%{$domconfig{'usermodification'}})) {
+ $curr_usermodification{$key} = $domconfig{'usermodification'}{$key};
+ }
+ }
+ my @contexts = ('author','course');
+ my %context_title = (
+ author => 'In author context',
+ course => 'In course context',
+ );
+ my @fields = ('lastname','firstname','middlename','generation',
+ 'permanentemail','id');
+ my %roles = (
+ author => ['ca','aa'],
+ course => ['st','ep','ta','in','cr'],
+ );
+ my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
+ my %modifyhash;
+ foreach my $context (@contexts) {
+ foreach my $role (@{$roles{$context}}) {
+ my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role);
+ foreach my $item (@fields) {
+ if (grep(/^\Q$item\E$/,@modifiable)) {
+ $modifyhash{$context}{$role}{$item} = 1;
+ } else {
+ $modifyhash{$context}{$role}{$item} = 0;
+ }
+ }
+ }
+ if (ref($curr_usermodification{$context}) eq 'HASH') {
+ foreach my $role (@{$roles{$context}}) {
+ if (ref($curr_usermodification{$context}{$role}) eq 'HASH') {
+ foreach my $field (@fields) {
+ if ($modifyhash{$context}{$role}{$field} ne
+ $curr_usermodification{$context}{$role}{$field}) {
+ push(@{$changes{$context}},$role);
+ last;
+ }
+ }
+ }
+ }
+ } else {
+ foreach my $context (@contexts) {
+ foreach my $role (@{$roles{$context}}) {
+ push(@{$changes{$context}},$role);
+ }
+ }
+ }
+ }
+ my %usermodification_hash = (
+ usermodification => \%modifyhash,
+ );
+ my $putresult = &Apache::lonnet::put_dom('configuration',
+ \%usermodification_hash,$dom);
+ if ($putresult eq 'ok') {
+ if (keys(%changes) > 0) {
+ $resulttext = &mt('Changes made: ').'
';
+ foreach my $context (@contexts) {
+ if (ref($changes{$context}) eq 'ARRAY') {
+ $resulttext .= '
'.$context_title{$context}.':
';
+ if (ref($changes{$context}) eq 'ARRAY') {
+ foreach my $role (@{$changes{$context}}) {
+ my $rolename;
+ if ($role eq 'cr') {
+ $rolename = &mt('Custom');
+ } else {
+ $rolename = &Apache::lonnet::plaintext($role);
+ }
+ my @modifiable;
+ $resulttext .= '
'.&mt('Target user with [_1] role',$rolename).' - '.&mt('modifiable fields: ');
+ foreach my $field (@fields) {
+ if ($modifyhash{$context}{$role}{$field}) {
+ push(@modifiable,$fieldtitles{$field});
+ }
+ }
+ if (@modifiable > 0) {
+ $resulttext .= join(', ',@modifiable);
+ } else {
+ $resulttext .= &mt('none');
+ }
+ $resulttext .= '