version 1.33, 2007/12/11 00:44:23
|
version 1.34, 2007/12/12 19:44:53
|
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'}], |
}, |
}, |
Line 372 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') { |
} elsif ($action eq 'usermodification') { |
$output .= &print_usermodification('bottom',$dom,$settings,\$rowtotal); |
$output .= &print_usermodification('bottom',$dom,$settings,\$rowtotal); |
} else { |
} else { |
Line 1297 sub print_usercreation {
|
Line 1310 sub print_usercreation {
|
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($position,$dom,$settings,$rowtotal) = @_; |
my $numinrow = 4; |
my $numinrow = 4; |
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') { |
my %checked; |
|
if (ref($settings) eq 'HASH') { |
|
if (ref($settings->{'cancreate'}) eq 'ARRAY') { |
|
foreach my $item (@{$settings->{'cancreate'}}) { |
|
$checked{$item} = ' checked="checked" '; |
|
} |
|
} |
|
} |
|
$datatable = '<tr class="LC_odd_row">'. |
|
'<td><span class="LC_nobreak">'.$lt{'nondc'}. |
|
'</span></td><td class="LC_left_item"><table>'; |
|
foreach my $item ('author','course') { |
|
$datatable .= '<tr><td><span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="can_createuser" '. |
|
$checked{$item}.' value="'.$item.'" />'. |
|
$lt{$item}.'</label><span></td></tr>'; |
|
} |
|
$datatable .= '</table></td></tr>'; |
|
$$rowtotal ++; |
$$rowtotal ++; |
my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username'); |
|
my $rowcount = 0; |
my $rowcount = 0; |
|
my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username'); |
if (ref($rules) eq 'HASH') { |
if (ref($rules) eq 'HASH') { |
if (keys(%{$rules}) > 0) { |
if (keys(%{$rules}) > 0) { |
$datatable .= &user_formats_row('username',$settings,$rules, |
$datatable .= &user_formats_row('username',$settings,$rules, |
Line 1341 sub print_usercreation {
|
Line 1331 sub print_usercreation {
|
$rowcount ++; |
$rowcount ++; |
} |
} |
} |
} |
|
} elsif ($position eq 'middle') { |
|
my @creators = ('author','course'); |
|
my %lt = &usercreation_types(); |
|
my %checked; |
|
if (ref($settings) eq 'HASH') { |
|
if (ref($settings->{'cancreate'}) eq 'HASH') { |
|
foreach my $item (@creators) { |
|
$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'; |
|
} |
|
} |
|
} |
|
} |
|
my $rownum = 0; |
|
foreach my $item (@creators) { |
|
$rownum ++; |
|
if ($checked{$item} eq '') { |
|
$checked{$item} = 'any'; |
|
} |
|
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'); |
my @authtypes = ('int','krb4','krb5','loc'); |
my @authtypes = ('int','krb4','krb5','loc'); |
Line 1437 sub user_formats_row {
|
Line 1471 sub user_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 2820 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 2831 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 2843 sub modify_usercreation {
|
Line 2889 sub modify_usercreation {
|
); |
); |
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule'); |
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule'); |
my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule'); |
my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule'); |
my @cancreate = &Apache::loncommon::get_env_multiple('form.can_createuser'); |
my @contexts = ('author','course'); |
if (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') { |
foreach my $item(@contexts) { |
foreach my $type (@{$curr_usercreation{'cancreate'}}) { |
$cancreate{$item} = $env{'form.can_createuser_'.$item}; |
if (!grep(/^\Q$type\E$/,@cancreate)) { |
} |
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 2920 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, |
id_rule => \@id_rule, |
id_rule => \@id_rule, |
authtypes => \%authhash, |
authtypes => \%authhash, |
Line 2933 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') { |