--- loncom/interface/domainprefs.pm 2007/12/11 00:44:23 1.33 +++ loncom/interface/domainprefs.pm 2008/01/01 18:48:17 1.38 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.33 2007/12/11 00:44:23 raeburn Exp $ +# $Id: domainprefs.pm,v 1.38 2008/01/01 18:48:17 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -127,8 +127,10 @@ sub handler { 'usercreation' => { text => 'User creation', help => 'Domain_User_Creation', - header => [{col1 => 'Setting', - col2 => 'Value',}, + header => [{col1 => 'Format Rule Type', + col2 => 'Format Rules in force'}, + {col1 => 'User account creation', + col2 => 'Usernames which may be created',}, {col1 => 'Context', col2 => 'Assignable Authentication Types'}], }, @@ -279,11 +281,24 @@ sub handler { ' /> '. '
'); + ' />'.&mt('Display using: ')."\n".
' '.
@@ -372,7 +387,18 @@ sub print_config_box {
if ($action eq 'autoupdate') {
$output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'usercreation') {
- $output .= &print_usercreation('bottom',$dom,$settings,\$rowtotal);
+ $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'
+
+
+
+
+
+
+
+ '.
+ &print_usercreation('bottom',$dom,$settings,\$rowtotal);
+ $rowtotal ++;
} elsif ($action eq 'usermodification') {
$output .= &print_usermodification('bottom',$dom,$settings,\$rowtotal);
} else {
@@ -1297,33 +1323,10 @@ sub print_usercreation {
my ($position,$dom,$settings,$rowtotal) = @_;
my $numinrow = 4;
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') {
- my %checked;
- if (ref($settings) eq 'HASH') {
- if (ref($settings->{'cancreate'}) eq 'ARRAY') {
- foreach my $item (@{$settings->{'cancreate'}}) {
- $checked{$item} = ' checked="checked" ';
- }
- }
- }
- $datatable = ''.$item->{'header'}->[2]->{'col1'}.'
+ '.$item->{'header'}->[2]->{'col2'}.' '.
- ' ';
$$rowtotal ++;
- my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username');
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,
@@ -1341,6 +1344,59 @@ sub print_usercreation {
$rowcount ++;
}
}
+ } elsif ($position eq 'middle') {
+ my @creators = ('author','course');
+ my ($rules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($dom,'username');
+ 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 .= ''.$lt{'nondc'}.
- ' ';
- foreach my $item ('author','course') {
- $datatable .= '
';
- }
- $datatable .= ''.
+ ' ';
+ }
} else {
my @contexts = ('author','course','domain');
my @authtypes = ('int','krb4','krb5','loc');
@@ -1357,8 +1413,13 @@ sub print_usercreation {
}
}
}
+ } else {
+ foreach my $item (@contexts) {
+ foreach my $auth (@authtypes) {
+ $checked{$item}{$auth} = ' checked="checked" ';
+ }
+ }
}
- my @authtypes = ('int','krb4','krb5','loc');
my %title = &context_names();
my %authname = &authtype_names();
my $rownum = 0;
@@ -1437,6 +1498,18 @@ sub user_formats_row {
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 {
my %lt = &Apache::lonlocal::texthash(
int => 'Internal',
@@ -2058,7 +2131,7 @@ sub check_configuser {
sub check_authorstatus {
my ($dom,$confname,%currroles) = @_;
my $author_ok;
- if (!$currroles{':'.$dom.':au'}) {
+ if (!$currroles{$confname.':'.$dom.':au'}) {
my $start = time;
my $end = 0;
$author_ok =
@@ -2820,7 +2893,7 @@ sub modify_contacts {
}
$resulttext .= '';
} else {
- $resulttext = &mt('No changes made to contact information.');
+ $resulttext = &mt('No changes made to contact information');
}
} else {
$resulttext = ''.
@@ -2831,7 +2904,7 @@ sub modify_contacts {
sub modify_usercreation {
my ($dom,%domconfig) = @_;
- my ($resulttext,%curr_usercreation,%changes,%authallowed);
+ my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate);
if (ref($domconfig{'usercreation'}) eq 'HASH') {
foreach my $key (keys(%{$domconfig{'usercreation'}})) {
$curr_usercreation{$key} = $domconfig{'usercreation'}{$key};
@@ -2843,21 +2916,34 @@ sub modify_usercreation {
);
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
my @id_rule = &Apache::loncommon::get_env_multiple('form.id_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);
- }
+ my @contexts = ('author','course');
+ foreach my $item(@contexts) {
+ $cancreate{$item} = $env{'form.can_createuser_'.$item};
+ }
+ 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) {
- if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'cancreate'}})) {
- push(@{$changes{'cancreate'}},$type);
+ } elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') {
+ foreach my $item (@contexts) {
+ 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 {
- push(@{$changes{'cancreate'}},@cancreate);
+ foreach my $item ('author','course') {
+ push(@{$changes{'cancreate'}},$item);
+ }
}
+
if (ref($curr_usercreation{'username_rule'}) eq 'ARRAY') {
foreach my $type (@{$curr_usercreation{'username_rule'}}) {
if (!grep(/^\Q$type\E$/,@username_rule)) {
@@ -2920,7 +3006,7 @@ sub modify_usercreation {
my %usercreation_hash = (
usercreation => {
- cancreate => \@cancreate,
+ cancreate => \%cancreate,
username_rule => \@username_rule,
id_rule => \@id_rule,
authtypes => \%authhash,
@@ -2933,15 +3019,19 @@ sub modify_usercreation {
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').''.$lt{$item}.
+ ' ';
+ my @options = ('any');
+ if (ref($rules) eq 'HASH') {
+ if (keys(%{$rules}) > 0) {
+ push(@options,('official','unofficial'));
+ }
+ }
+ push(@options,'none');
+ foreach my $option (@options) {
+ my $check = ' ';
+ if ($checked{$item} eq $option) {
+ $check = ' checked="checked" ';
+ }
+ $datatable .= ' ';
+ }
+ $datatable .= ' ';
if (ref($changes{'cancreate'}) eq 'ARRAY') {
- my $chgtext = '
';
- foreach my $type (@cancreate) {
- $chgtext .= '
';
- if (@cancreate > 0) {
- $resulttext .= '