version 1.26, 2007/09/01 21:20:14
|
version 1.27, 2007/09/12 12:01:04
|
Line 67 sub handler {
|
Line 67 sub handler {
|
} |
} |
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['login','rolecolors', |
&Apache::lonnet::get_dom('configuration',['login','rolecolors', |
'quotas','autoenroll','autoupdate','directorysrch'],$dom); |
'quotas','autoenroll','autoupdate','directorysrch', |
|
'usercreation'],$dom); |
my @prefs = ( |
my @prefs = ( |
{ text => 'Default color schemes', |
{ text => 'Default color schemes', |
help => 'Default_Color_Schemes', |
help => 'Default_Color_Schemes', |
Line 113 sub handler {
|
Line 114 sub handler {
|
header => [{col1 => 'Setting', |
header => [{col1 => 'Setting', |
col2 => 'Value',}], |
col2 => 'Value',}], |
}, |
}, |
|
{ text => 'User creation', |
|
help => 'Domain_User_Creation', |
|
action => 'usercreation', |
|
header => [{col1 => 'Setting', |
|
col2 => 'Value',}], |
|
}, |
); |
); |
my @roles = ('student','coordinator','author','admin'); |
my @roles = ('student','coordinator','author','admin'); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
Line 197 sub process_changes {
|
Line 204 sub process_changes {
|
$output = &modify_autoupdate($dom,%domconfig); |
$output = &modify_autoupdate($dom,%domconfig); |
} elsif ($action eq 'directorysrch') { |
} elsif ($action eq 'directorysrch') { |
$output = &modify_directorysrch($dom,%domconfig); |
$output = &modify_directorysrch($dom,%domconfig); |
|
} elsif ($action eq 'usercreation') { |
|
$output = &modify_user_creation($dom,%domconfig); |
} |
} |
return $output; |
return $output; |
} |
} |
Line 289 sub print_config_box {
|
Line 298 sub print_config_box {
|
$r->print(&print_autoenroll($dom,$settings)); |
$r->print(&print_autoenroll($dom,$settings)); |
} elsif ($action eq 'directorysrch') { |
} elsif ($action eq 'directorysrch') { |
$r->print(&print_directorysrch($dom,$settings)); |
$r->print(&print_directorysrch($dom,$settings)); |
} |
} elsif ($action eq 'usercreation') { |
|
$r->print(&print_usercreation($dom,$settings)); |
|
} |
} |
} |
$r->print(' |
$r->print(' |
</table> |
</table> |
Line 1000 sub print_directorysrch {
|
Line 1011 sub print_directorysrch {
|
return $datatable; |
return $datatable; |
} |
} |
|
|
|
sub print_usercreation { |
|
my ($dom,$settings) = @_; |
|
my $numinrow = 4; |
|
my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom); |
|
my %checked; |
|
if (ref($settings) eq 'HASH') { |
|
if (ref($settings->{'cancreate'}) eq 'ARRAY') { |
|
foreach my $item (@{$settings->{'cancreate'}}) { |
|
$checked{$item} = ' checked="checked" '; |
|
} |
|
} |
|
} |
|
my $datatable = '<td>'.&mt('User creation other than by DC: ').'</td>'. |
|
'<td class="LC_left_item"><table><tr><td>'. |
|
'<span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="can_createuser" '. |
|
$checked{'author'}.' value="author" />'. |
|
&mt('When adding a co-author/assistant author'). |
|
'</label><span></td></tr>'. |
|
'<tr><td>'. |
|
'<span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="can_createuser" '. |
|
$checked{'course'}.' value="course" />'. |
|
&mt('When adding users to a course'). |
|
'</label><span></td></tr></table></td></tr>'; |
|
if (ref($rules) eq 'HASH') { |
|
if (keys(%{$rules}) > 0) { |
|
$datatable .= &username_formats_row($settings,$rules,$ruleorder, |
|
$numinrow); |
|
} |
|
} |
|
return $datatable; |
|
} |
|
|
|
sub username_formats_row { |
|
my ($settings,$rules,$ruleorder,$numinrow) = @_; |
|
my $output = '<tr class="LC_odd_row">'. |
|
'<td>'.&mt('Format rules to check for new usernames'). |
|
'</td><td class="LC_left_item" colspan="2"><table>'; |
|
my $rem; |
|
if (ref($ruleorder) eq 'ARRAY') { |
|
for (my $i=0; $i<@{$ruleorder}; $i++) { |
|
if (ref($rules->{$ruleorder->[$i]}) eq 'HASH') { |
|
my $rem = $i%($numinrow); |
|
if ($rem == 0) { |
|
if ($i > 0) { |
|
$output .= '</tr>'; |
|
} |
|
$output .= '<tr>'; |
|
} |
|
my $check = ' '; |
|
if (ref($settings->{'username_rule'}) eq 'ARRAY') { |
|
if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{'username_rule'}})) { |
|
$check = ' checked="checked" '; |
|
} |
|
} |
|
$output .= '<td class="LC_left_item">'. |
|
'<span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="username_rule" '. |
|
'value="'.$ruleorder->[$i].'"'.$check.'/>'. |
|
$rules->{$ruleorder->[$i]}{'name'}.'</label></span></td>'; |
|
} |
|
} |
|
$rem = @{$ruleorder}%($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) = @_; |
my $output = '<tr class="LC_odd_row">'. |
my $output = '<tr class="LC_odd_row">'. |
Line 2156 sub modify_directorysrch {
|
Line 2243 sub modify_directorysrch {
|
} |
} |
} else { |
} else { |
$resulttext = '<span class="LC_error">'. |
$resulttext = '<span class="LC_error">'. |
|
&mt('An error occurred: [_1]',$putresult).'</span>'; |
|
} |
|
return $resulttext; |
|
} |
|
|
|
sub modify_user_creation { |
|
my ($dom,%domconfig) = @_; |
|
my ($resulttext,%curr_usercreation,%changes); |
|
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
|
foreach my $key (keys(%{$domconfig{'usercreation'}})) { |
|
$curr_usercreation{$key} = $domconfig{'usercreation'}{$key}; |
|
} |
|
} |
|
my %title = &Apache::lonlocal::texthash ( |
|
author => 'adding co-authors/assistant authors', |
|
course => 'adding users to a course', |
|
); |
|
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule'); |
|
my @cancreate = &Apache::loncommon::get_env_multiple('form.can_createuser'); |
|
if (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') { |
|
foreach my $type (@{$curr_usercreation{'cancreate'}}) { |
|
if (!grep(/^\Q$type\E$/,@cancreate)) { |
|
push(@{$changes{'cancreate'}},$type); |
|
} |
|
} |
|
foreach my $type (@cancreate) { |
|
if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'cancreate'}})) { |
|
push(@{$changes{'cancreate'}},$type); |
|
} |
|
} |
|
} else { |
|
push(@{$changes{'cancreate'}},@cancreate); |
|
} |
|
if (ref($curr_usercreation{'username_rule'}) eq 'ARRAY') { |
|
foreach my $type (@{$curr_usercreation{'username_rule'}}) { |
|
if (!grep(/^\Q$type\E$/,@username_rule)) { |
|
push(@{$changes{'username_rule'}},$type); |
|
} |
|
} |
|
foreach my $type (@username_rule) { |
|
if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'username_rule'}})) { |
|
push(@{$changes{'username_rule'}},$type); |
|
} |
|
} |
|
} else { |
|
push(@{$changes{'username_rule'}},@username_rule); |
|
} |
|
|
|
my %usercreation_hash = ( |
|
usercreation => { |
|
cancreate => \@cancreate, |
|
username_rule => \@username_rule, |
|
} |
|
); |
|
|
|
my $putresult = &Apache::lonnet::put_dom('configuration',\%usercreation_hash, |
|
$dom); |
|
if ($putresult eq 'ok') { |
|
if (keys(%changes) > 0) { |
|
$resulttext = &mt('Changes made:').'<ul>'; |
|
my $chgtext; |
|
if (ref($changes{'cancreate'}) eq 'ARRAY') { |
|
my $chgtext = '<ul>'; |
|
foreach my $type (@cancreate) { |
|
$chgtext .= '<li>'.$title{$type}.'</li>'; |
|
} |
|
$chgtext .= '</ul>'; |
|
if (@cancreate > 0) { |
|
$resulttext .= '<li>'.&mt('Creation of new users is permitted by a Domain Coordinator, and also by other users when: ').$chgtext.'</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt("Creation of new users is now only allowed when the user's role is Domain Coordinator.").'</li>'; |
|
} |
|
} |
|
if (ref($changes{'username_rule'}) eq 'ARRAY') { |
|
my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom); |
|
my $chgtext = '<ul>'; |
|
foreach my $type (@username_rule) { |
|
if (ref($rules->{$type}) eq 'HASH') { |
|
$chgtext .= '<li>'.$rules->{$type}{'name'}.'</li>'; |
|
} |
|
} |
|
$chgtext .= '</ul>'; |
|
if (@username_rule > 0) { |
|
$resulttext .= '<li>'.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('There are now no username formats currenty restricted to verified users in the institutional directory.').'</li>'; |
|
} |
|
} |
|
$resulttext .= '</ul>'; |
|
} else { |
|
$resulttext = &mt('No changes made to log-in page 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; |