version 1.31, 2007/09/27 15:36:23
|
version 1.34, 2007/12/12 19:44:53
|
Line 68 sub handler {
|
Line 68 sub handler {
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['login','rolecolors', |
&Apache::lonnet::get_dom('configuration',['login','rolecolors', |
'quotas','autoenroll','autoupdate','directorysrch', |
'quotas','autoenroll','autoupdate','directorysrch', |
'usercreation','contacts'],$dom); |
'usercreation','usermodification','contacts'],$dom); |
my @prefs_order = ('rolecolors','login','quotas','autoenroll', |
my @prefs_order = ('rolecolors','login','quotas','autoenroll', |
'autoupdate','directorysrch','contacts', |
'autoupdate','directorysrch','contacts', |
'usercreation'); |
'usercreation','usermodification'); |
my %prefs = ( |
my %prefs = ( |
'rolecolors' => |
'rolecolors' => |
{ text => 'Default color schemes', |
{ text => 'Default color schemes', |
Line 127 sub handler {
|
Line 127 sub handler {
|
'usercreation' => |
'usercreation' => |
{ text => 'User creation', |
{ text => 'User creation', |
help => 'Domain_User_Creation', |
help => 'Domain_User_Creation', |
header => [{col1 => 'Setting', |
header => [{col1 => 'Format Rule Type', |
col2 => 'Value',}, |
col2 => 'Format Rules in force'}, |
|
{col1 => 'User account creation', |
|
col2 => 'Usernames which may be created',}, |
{col1 => 'Context', |
{col1 => 'Context', |
col2 => 'Assignable Authentication Types'}], |
col2 => 'Assignable Authentication Types'}], |
}, |
}, |
|
'usermodification' => |
|
{ text => 'User modification', |
|
help => 'Domain_User_Modification', |
|
header => [{col1 => 'Target user has role', |
|
col2 => 'User information updateable in author context'}, |
|
{col1 => 'Target user has role', |
|
col2 => 'User information updateable in course context'}], |
|
}, |
); |
); |
my @roles = ('student','coordinator','author','admin'); |
my @roles = ('student','coordinator','author','admin'); |
my @actions = &Apache::loncommon::get_env_multiple('form.actions'); |
my @actions = &Apache::loncommon::get_env_multiple('form.actions'); |
Line 306 sub process_changes {
|
Line 316 sub process_changes {
|
$output = &modify_directorysrch($dom,%domconfig); |
$output = &modify_directorysrch($dom,%domconfig); |
} elsif ($action eq 'usercreation') { |
} elsif ($action eq 'usercreation') { |
$output = &modify_usercreation($dom,%domconfig); |
$output = &modify_usercreation($dom,%domconfig); |
|
} elsif ($action eq 'usermodification') { |
|
$output = &modify_usermodification($dom,%domconfig); |
} elsif ($action eq 'contacts') { |
} elsif ($action eq 'contacts') { |
$output = &modify_contacts($dom,%domconfig); |
$output = &modify_contacts($dom,%domconfig); |
} |
} |
Line 327 sub print_config_box {
|
Line 339 sub print_config_box {
|
# </tr>'); |
# </tr>'); |
$rowtotal ++; |
$rowtotal ++; |
if (($action eq 'autoupdate') || ($action eq 'rolecolors') || |
if (($action eq 'autoupdate') || ($action eq 'rolecolors') || |
($action eq 'usercreation')) { |
($action eq 'usercreation') || ($action eq 'usermodification')) { |
my $colspan = ($action eq 'rolecolors')?' colspan="2"':''; |
my $colspan = ($action eq 'rolecolors')?' colspan="2"':''; |
$output .= ' |
$output .= ' |
<tr> |
<tr> |
Line 341 sub print_config_box {
|
Line 353 sub print_config_box {
|
if ($action eq 'autoupdate') { |
if ($action eq 'autoupdate') { |
$output .= &print_autoupdate('top',$dom,$settings,\$rowtotal); |
$output .= &print_autoupdate('top',$dom,$settings,\$rowtotal); |
} elsif ($action eq 'usercreation') { |
} elsif ($action eq 'usercreation') { |
$output .= &print_usercreation('top',$dom,$settings,\$rowtotal); |
$output .= &print_usercreation('top',$dom,$settings,\$rowtotal); |
|
} elsif ($action eq 'usermodification') { |
|
$output .= &print_usermodification('top',$dom,$settings,\$rowtotal); |
} else { |
} else { |
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal); |
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal); |
} |
} |
Line 360 sub print_config_box {
|
Line 374 sub print_config_box {
|
if ($action eq 'autoupdate') { |
if ($action eq 'autoupdate') { |
$output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal); |
$output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal); |
} elsif ($action eq 'usercreation') { |
} elsif ($action eq 'usercreation') { |
$output .= &print_usercreation('bottom',$dom,$settings,\$rowtotal); |
$output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).' |
|
</table> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td> |
|
<table class="LC_nested"> |
|
<tr class="LC_info_row"> |
|
<td class="LC_left_item"'.$colspan.'>'.$item->{'header'}->[2]->{'col1'}.'</td> |
|
<td class="LC_right_item">'.$item->{'header'}->[2]->{'col2'}.'</td> </tr>'. |
|
&print_usercreation('bottom',$dom,$settings,\$rowtotal); |
|
$rowtotal ++; |
|
} elsif ($action eq 'usermodification') { |
|
$output .= &print_usermodification('bottom',$dom,$settings,\$rowtotal); |
} else { |
} else { |
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).' |
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).' |
</table> |
</table> |
Line 1056 sub print_autoupdate {
|
Line 1083 sub print_autoupdate {
|
my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom); |
my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom); |
my @fields = ('lastname','firstname','middlename','gen', |
my @fields = ('lastname','firstname','middlename','gen', |
'permanentemail','id'); |
'permanentemail','id'); |
my %fieldtitles = &Apache::lonlocal::texthash ( |
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); |
id => 'Student/Employee ID', |
|
permanentemail => 'E-mail address', |
|
lastname => 'Last Name', |
|
firstname => 'First Name', |
|
middlename => 'Middle Name', |
|
gen => 'Generation', |
|
); |
|
my $numrows = 0; |
my $numrows = 0; |
if (ref($types) eq 'ARRAY') { |
if (ref($types) eq 'ARRAY') { |
if (@{$types} > 0) { |
if (@{$types} > 0) { |
Line 1289 sub contact_titles {
|
Line 1309 sub contact_titles {
|
sub print_usercreation { |
sub print_usercreation { |
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($position,$dom,$settings,$rowtotal) = @_; |
my $numinrow = 4; |
my $numinrow = 4; |
my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom); |
|
my $datatable; |
my $datatable; |
my %lt = &Apache::lonlocal::texthash ( |
|
nondc => 'User creation other than by Domain Coordinator: ', |
|
author => 'When adding a co-author/assistant author', |
|
course => 'When adding users to a course', |
|
); |
|
if ($position eq 'top') { |
if ($position eq 'top') { |
|
$$rowtotal ++; |
|
my $rowcount = 0; |
|
my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username'); |
|
if (ref($rules) eq 'HASH') { |
|
if (keys(%{$rules}) > 0) { |
|
$datatable .= &user_formats_row('username',$settings,$rules, |
|
$ruleorder,$numinrow,$rowcount); |
|
$$rowtotal ++; |
|
$rowcount ++; |
|
} |
|
} |
|
my ($idrules,$idruleorder) = &Apache::lonnet::inst_userrules($dom,'id'); |
|
if (ref($idrules) eq 'HASH') { |
|
if (keys(%{$idrules}) > 0) { |
|
$datatable .= &user_formats_row('id',$settings,$idrules, |
|
$idruleorder,$numinrow,$rowcount); |
|
$$rowtotal ++; |
|
$rowcount ++; |
|
} |
|
} |
|
} elsif ($position eq 'middle') { |
|
my @creators = ('author','course'); |
|
my %lt = &usercreation_types(); |
my %checked; |
my %checked; |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
if (ref($settings->{'cancreate'}) eq 'ARRAY') { |
if (ref($settings->{'cancreate'}) eq 'HASH') { |
foreach my $item (@{$settings->{'cancreate'}}) { |
foreach my $item (@creators) { |
$checked{$item} = ' checked="checked" '; |
$checked{$item} = $settings->{'cancreate'}{$item}; |
|
} |
|
} elsif (ref($settings->{'cancreate'}) eq 'ARRAY') { |
|
foreach my $item (@creators) { |
|
if (grep(/^\Q$item\E$/,@{$settings->{'cancreate'}})) { |
|
$checked{$item} = 'none'; |
|
} |
} |
} |
} |
} |
} |
} |
$datatable = '<tr class="LC_odd_row">'. |
my $rownum = 0; |
'<td><span class="LC_nobreak">'.$lt{'nondc'}. |
foreach my $item (@creators) { |
'</span></td><td class="LC_left_item"><table>'; |
$rownum ++; |
foreach my $item ('author','course') { |
if ($checked{$item} eq '') { |
$datatable .= '<tr><td><span class="LC_nobreak"><label>'. |
$checked{$item} = 'any'; |
'<input type="checkbox" name="can_createuser" '. |
|
$checked{$item}.' value="'.$item.'" />'. |
|
$lt{$item}.'</label><span></td></tr>'; |
|
} |
|
$datatable .= '</table></td></tr>'; |
|
$$rowtotal ++; |
|
if (ref($rules) eq 'HASH') { |
|
if (keys(%{$rules}) > 0) { |
|
$datatable .= &username_formats_row($settings,$rules, |
|
$ruleorder,$numinrow); |
|
$$rowtotal ++; |
|
} |
} |
|
my $css_class; |
|
if ($rownum%2) { |
|
$css_class = ''; |
|
} else { |
|
$css_class = ' class="LC_odd_row" '; |
|
} |
|
$datatable .= '<tr'.$css_class.'>'. |
|
'<td><span class="LC_nobreak">'.$lt{$item}. |
|
'</span></td><td align="right">'; |
|
foreach my $option ('any','official','unofficial','none') { |
|
my $check = ' '; |
|
if ($checked{$item} eq $option) { |
|
$check = ' checked="checked" '; |
|
} |
|
$datatable .= '<span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="can_createuser_'. |
|
$item.'" value="'.$option.'"'.$check.'/> '. |
|
$lt{$option}.'</label> </span>'; |
|
} |
|
$datatable .= '</td></tr>'; |
} |
} |
} else { |
} else { |
my @contexts = ('author','course','domain'); |
my @contexts = ('author','course','domain'); |
Line 1369 sub print_usercreation {
|
Line 1421 sub print_usercreation {
|
return $datatable; |
return $datatable; |
} |
} |
|
|
sub username_formats_row { |
sub user_formats_row { |
my ($settings,$rules,$ruleorder,$numinrow) = @_; |
my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_; |
my $output = '<tr>'. |
my $output; |
'<td><span class="LC_nobreak">'. |
my %text = ( |
&mt('Format rules to check for new usernames: '). |
'username' => 'new usernames', |
'</span></td>'. |
'id' => 'IDs', |
'<td class="LC_left_item" colspan="2"><table>'; |
); |
|
my $css_class = $rowcount%2?' class="LC_odd_row"':''; |
|
$output = '<tr '.$css_class.'>'. |
|
'<td><span class="LC_nobreak">'. |
|
&mt("Format rules to check for $text{$type}: "). |
|
'</span></td>'. |
|
'<td class="LC_left_item" colspan="2"><table>'; |
my $rem; |
my $rem; |
if (ref($ruleorder) eq 'ARRAY') { |
if (ref($ruleorder) eq 'ARRAY') { |
for (my $i=0; $i<@{$ruleorder}; $i++) { |
for (my $i=0; $i<@{$ruleorder}; $i++) { |
Line 1388 sub username_formats_row {
|
Line 1446 sub username_formats_row {
|
$output .= '<tr>'; |
$output .= '<tr>'; |
} |
} |
my $check = ' '; |
my $check = ' '; |
if (ref($settings->{'username_rule'}) eq 'ARRAY') { |
if (ref($settings->{$type.'_rule'}) eq 'ARRAY') { |
if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{'username_rule'}})) { |
if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) { |
$check = ' checked="checked" '; |
$check = ' checked="checked" '; |
} |
} |
} |
} |
$output .= '<td class="LC_left_item">'. |
$output .= '<td class="LC_left_item">'. |
'<span class="LC_nobreak"><label>'. |
'<span class="LC_nobreak"><label>'. |
'<input type="checkbox" name="username_rule" '. |
'<input type="checkbox" name="'.$type.'_rule" '. |
'value="'.$ruleorder->[$i].'"'.$check.'/>'. |
'value="'.$ruleorder->[$i].'"'.$check.'/>'. |
$rules->{$ruleorder->[$i]}{'name'}.'</label></span></td>'; |
$rules->{$ruleorder->[$i]}{'name'}.'</label></span></td>'; |
} |
} |
Line 1413 sub username_formats_row {
|
Line 1471 sub username_formats_row {
|
return $output; |
return $output; |
} |
} |
|
|
|
sub usercreation_types { |
|
my %lt = &Apache::lonlocal::texthash ( |
|
author => 'When adding a co-author', |
|
course => 'When adding a user to a course', |
|
any => 'Any', |
|
official => 'Institutional only ', |
|
unofficial => 'Non-institutional only', |
|
none => 'None', |
|
); |
|
return %lt; |
|
} |
|
|
sub authtype_names { |
sub authtype_names { |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
int => 'Internal', |
int => 'Internal', |
Line 1432 sub context_names {
|
Line 1502 sub context_names {
|
return %context_title; |
return %context_title; |
} |
} |
|
|
|
sub print_usermodification { |
|
my ($position,$dom,$settings,$rowtotal) = @_; |
|
my $numinrow = 4; |
|
my ($context,$datatable,$rowcount); |
|
if ($position eq 'top') { |
|
$rowcount = 0; |
|
$context = 'author'; |
|
foreach my $role ('ca','aa') { |
|
$datatable .= &modifiable_userdata_row($context,$role,$settings, |
|
$numinrow,$rowcount); |
|
$$rowtotal ++; |
|
$rowcount ++; |
|
} |
|
} else { |
|
$context = 'course'; |
|
$rowcount = 0; |
|
foreach my $role ('st','ep','ta','in','cr') { |
|
$datatable .= &modifiable_userdata_row($context,$role,$settings, |
|
$numinrow,$rowcount); |
|
$$rowtotal ++; |
|
$rowcount ++; |
|
} |
|
} |
|
return $datatable; |
|
} |
|
|
|
sub modifiable_userdata_row { |
|
my ($context,$role,$settings,$numinrow,$rowcount) = @_; |
|
my $rolename; |
|
if ($role eq 'cr') { |
|
$rolename = &mt('Custom role'); |
|
} else { |
|
$rolename = &Apache::lonnet::plaintext($role); |
|
} |
|
my @fields = ('lastname','firstname','middlename','generation', |
|
'permanentemail','id'); |
|
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); |
|
my $output; |
|
my $css_class = $rowcount%2?' class="LC_odd_row"':''; |
|
$output = '<tr '.$css_class.'>'. |
|
'<td><span class="LC_nobreak">'.$rolename.'</span></td>'. |
|
'<td class="LC_left_item" colspan="2"><table>'; |
|
my $rem; |
|
my %checks; |
|
if (ref($settings) eq 'HASH') { |
|
if (ref($settings->{$context}) eq 'HASH') { |
|
if (ref($settings->{$context}->{$role}) eq 'HASH') { |
|
foreach my $field (@fields) { |
|
if ($settings->{$context}->{$role}->{$field}) { |
|
$checks{$field} = ' checked="checked" '; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
for (my $i=0; $i<@fields; $i++) { |
|
my $rem = $i%($numinrow); |
|
if ($rem == 0) { |
|
if ($i > 0) { |
|
$output .= '</tr>'; |
|
} |
|
$output .= '<tr>'; |
|
} |
|
my $check = ' '; |
|
if (exists($checks{$fields[$i]})) { |
|
$check = $checks{$fields[$i]} |
|
} else { |
|
if ($role eq 'st') { |
|
if (ref($settings) ne 'HASH') { |
|
$check = ' checked="checked" '; |
|
} |
|
} |
|
} |
|
$output .= '<td class="LC_left_item">'. |
|
'<span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="canmodify_'.$role.'" '. |
|
'value="'.$fields[$i].'"'.$check.'/>'.$fieldtitles{$fields[$i]}. |
|
'</label></span></td>'; |
|
$rem = @fields%($numinrow); |
|
} |
|
my $colsleft = $numinrow - $rem; |
|
if ($colsleft > 1 ) { |
|
$output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'. |
|
' </td>'; |
|
} elsif ($colsleft == 1) { |
|
$output .= '<td class="LC_left_item"> </td>'; |
|
} |
|
$output .= '</tr></table></td></tr>'; |
|
return $output; |
|
} |
|
|
sub users_cansearch_row { |
sub users_cansearch_row { |
my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle) = @_; |
my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle) = @_; |
Line 2706 sub modify_contacts {
|
Line 2866 sub modify_contacts {
|
} |
} |
$resulttext .= '</ul>'; |
$resulttext .= '</ul>'; |
} else { |
} else { |
$resulttext = &mt('No changes made to contact information.'); |
$resulttext = &mt('No changes made to contact information'); |
} |
} |
} else { |
} else { |
$resulttext = '<span class="LC_error">'. |
$resulttext = '<span class="LC_error">'. |
Line 2717 sub modify_contacts {
|
Line 2877 sub modify_contacts {
|
|
|
sub modify_usercreation { |
sub modify_usercreation { |
my ($dom,%domconfig) = @_; |
my ($dom,%domconfig) = @_; |
my ($resulttext,%curr_usercreation,%changes,%authallowed); |
my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate); |
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
foreach my $key (keys(%{$domconfig{'usercreation'}})) { |
foreach my $key (keys(%{$domconfig{'usercreation'}})) { |
$curr_usercreation{$key} = $domconfig{'usercreation'}{$key}; |
$curr_usercreation{$key} = $domconfig{'usercreation'}{$key}; |
Line 2728 sub modify_usercreation {
|
Line 2888 sub modify_usercreation {
|
course => 'adding users to a course', |
course => 'adding users to a course', |
); |
); |
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule'); |
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule'); |
my @cancreate = &Apache::loncommon::get_env_multiple('form.can_createuser'); |
my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule'); |
if (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') { |
my @contexts = ('author','course'); |
foreach my $type (@{$curr_usercreation{'cancreate'}}) { |
foreach my $item(@contexts) { |
if (!grep(/^\Q$type\E$/,@cancreate)) { |
$cancreate{$item} = $env{'form.can_createuser_'.$item}; |
push(@{$changes{'cancreate'}},$type); |
} |
} |
if (ref($curr_usercreation{'cancreate'}) eq 'HASH') { |
|
foreach my $item (@contexts) { |
|
if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) { |
|
push(@{$changes{'cancreate'}},$item); |
|
} |
} |
} |
foreach my $type (@cancreate) { |
} elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') { |
if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'cancreate'}})) { |
foreach my $item (@contexts) { |
push(@{$changes{'cancreate'}},$type); |
if (grep(/^\Q$item\E$/,@{$curr_usercreation{'cancreate'}})) { |
|
if ($cancreate{$item} ne 'any') { |
|
push(@{$changes{'cancreate'}},$item); |
|
} |
|
} else { |
|
if ($cancreate{$item} ne 'none') { |
|
push(@{$changes{'cancreate'}},$item); |
|
} |
} |
} |
} |
} |
} else { |
} else { |
push(@{$changes{'cancreate'}},@cancreate); |
foreach my $item ('author','course') { |
|
push(@{$changes{'cancreate'}},$item); |
|
} |
} |
} |
|
|
if (ref($curr_usercreation{'username_rule'}) eq 'ARRAY') { |
if (ref($curr_usercreation{'username_rule'}) eq 'ARRAY') { |
foreach my $type (@{$curr_usercreation{'username_rule'}}) { |
foreach my $type (@{$curr_usercreation{'username_rule'}}) { |
if (!grep(/^\Q$type\E$/,@username_rule)) { |
if (!grep(/^\Q$type\E$/,@username_rule)) { |
Line 2758 sub modify_usercreation {
|
Line 2932 sub modify_usercreation {
|
push(@{$changes{'username_rule'}},@username_rule); |
push(@{$changes{'username_rule'}},@username_rule); |
} |
} |
|
|
|
if (ref($curr_usercreation{'id_rule'}) eq 'ARRAY') { |
|
foreach my $type (@{$curr_usercreation{'id_rule'}}) { |
|
if (!grep(/^\Q$type\E$/,@id_rule)) { |
|
push(@{$changes{'id_rule'}},$type); |
|
} |
|
} |
|
foreach my $type (@id_rule) { |
|
if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'id_rule'}})) { |
|
push(@{$changes{'id_rule'}},$type); |
|
} |
|
} |
|
} else { |
|
push(@{$changes{'id_rule'}},@id_rule); |
|
} |
|
|
my @contexts = ('author','course','domain'); |
my @contexts = ('author','course','domain'); |
my @authtypes = ('int','krb4','krb5','loc'); |
my @authtypes = ('int','krb4','krb5','loc'); |
my %authhash; |
my %authhash; |
Line 2790 sub modify_usercreation {
|
Line 2979 sub modify_usercreation {
|
|
|
my %usercreation_hash = ( |
my %usercreation_hash = ( |
usercreation => { |
usercreation => { |
cancreate => \@cancreate, |
cancreate => \%cancreate, |
username_rule => \@username_rule, |
username_rule => \@username_rule, |
authtypes => \%authhash, |
id_rule => \@id_rule, |
|
authtypes => \%authhash, |
} |
} |
); |
); |
|
|
Line 2802 sub modify_usercreation {
|
Line 2992 sub modify_usercreation {
|
if (keys(%changes) > 0) { |
if (keys(%changes) > 0) { |
$resulttext = &mt('Changes made:').'<ul>'; |
$resulttext = &mt('Changes made:').'<ul>'; |
if (ref($changes{'cancreate'}) eq 'ARRAY') { |
if (ref($changes{'cancreate'}) eq 'ARRAY') { |
my $chgtext = '<ul>'; |
my %lt = &usercreation_types(); |
foreach my $type (@cancreate) { |
foreach my $type (@{$changes{'cancreate'}}) { |
$chgtext .= '<li>'.$title{$type}.'</li>'; |
my $chgtext; |
} |
if ($cancreate{$type} eq 'none') { |
$chgtext .= '</ul>'; |
$chgtext = $lt{$type}.' '.&mt('creation of new users is not permitted, except by a Domain Coordinator.'); |
if (@cancreate > 0) { |
} elsif ($cancreate{$type} eq 'any') { |
$resulttext .= '<li>'.&mt('Creation of new users is permitted by a Domain Coordinator, and also by other users when: ').$chgtext.'</li>'; |
$chgtext = $lt{$type}.' '.&mt('creation of new users is permitted for both institutional and non-institutional usernames.'); |
} else { |
} elsif ($cancreate{$type} eq 'official') { |
$resulttext .= '<li>'.&mt("Creation of new users is now only allowed when the user's role is Domain Coordinator.").'</li>'; |
$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 .= '<li>'.$chgtext.'</li>'; |
} |
} |
} |
} |
if (ref($changes{'username_rule'}) eq 'ARRAY') { |
if (ref($changes{'username_rule'}) eq 'ARRAY') { |
my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom); |
my ($rules,$ruleorder) = |
|
&Apache::lonnet::inst_userrules($dom,'username'); |
my $chgtext = '<ul>'; |
my $chgtext = '<ul>'; |
foreach my $type (@username_rule) { |
foreach my $type (@username_rule) { |
if (ref($rules->{$type}) eq 'HASH') { |
if (ref($rules->{$type}) eq 'HASH') { |
Line 2828 sub modify_usercreation {
|
Line 3023 sub modify_usercreation {
|
$resulttext .= '<li>'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'</li>'; |
$resulttext .= '<li>'.&mt('There are now no username formats restricted to verified users in the institutional directory.').'</li>'; |
} |
} |
} |
} |
|
if (ref($changes{'id_rule'}) eq 'ARRAY') { |
|
my ($idrules,$idruleorder) = |
|
&Apache::lonnet::inst_userrules($dom,'id'); |
|
my $chgtext = '<ul>'; |
|
foreach my $type (@id_rule) { |
|
if (ref($idrules->{$type}) eq 'HASH') { |
|
$chgtext .= '<li>'.$idrules->{$type}{'name'}.'</li>'; |
|
} |
|
} |
|
$chgtext .= '</ul>'; |
|
if (@id_rule > 0) { |
|
$resulttext .= '<li>'.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'</li>'; |
|
} |
|
} |
my %authname = &authtype_names(); |
my %authname = &authtype_names(); |
my %context_title = &context_names(); |
my %context_title = &context_names(); |
if (ref($changes{'authtypes'}) eq 'ARRAY') { |
if (ref($changes{'authtypes'}) eq 'ARRAY') { |
my @unchanged; |
|
my $chgtext = '<ul>'; |
my $chgtext = '<ul>'; |
foreach my $type (@{$changes{'authtypes'}}) { |
foreach my $type (@{$changes{'authtypes'}}) { |
my @allowed; |
my @allowed; |
Line 2853 sub modify_usercreation {
|
Line 3063 sub modify_usercreation {
|
} |
} |
} else { |
} else { |
$resulttext = '<span class="LC_error">'. |
$resulttext = '<span class="LC_error">'. |
|
&mt('An error occurred: [_1]',$putresult).'</span>'; |
|
} |
|
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: ').'<ul>'; |
|
foreach my $context (@contexts) { |
|
if (ref($changes{$context}) eq 'ARRAY') { |
|
$resulttext .= '<li>'.$context_title{$context}.':<ul>'; |
|
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 .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&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 .= '</li>'; |
|
} |
|
$resulttext .= '</ul></li>'; |
|
} |
|
} |
|
} |
|
$resulttext .= '</ul>'; |
|
} else { |
|
$resulttext = &mt('No changes made to user modification settings'); |
|
} |
|
} else { |
|
$resulttext = '<span class="LC_error">'. |
&mt('An error occurred: [_1]',$putresult).'</span>'; |
&mt('An error occurred: [_1]',$putresult).'</span>'; |
} |
} |
return $resulttext; |
return $resulttext; |