--- loncom/interface/domainprefs.pm 2009/04/22 12:42:16 1.92 +++ loncom/interface/domainprefs.pm 2009/04/22 14:09:13 1.93 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.92 2009/04/22 12:42:16 raeburn Exp $ +# $Id: domainprefs.pm,v 1.93 2009/04/22 14:09:13 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1299,8 +1299,8 @@ sub print_directorysrch { $$rowtotal += 2; if (ref($usertypes) eq 'HASH') { if (keys(%{$usertypes}) > 0) { - $datatable .= &users_cansearch_row($settings,$types,$usertypes,$dom, - $numinrow,$othertitle); + $datatable .= &insttypes_row($settings,$types,$usertypes,$dom, + $numinrow,$othertitle,'cansearch'); $cansrchrow = 1; } } @@ -1315,7 +1315,7 @@ sub print_directorysrch { foreach my $title (@{$titleorder}) { if (defined($searchtitles->{$title})) { my $check = ' '; - if (ref($settings) eq 'HASH') { + if (ref($settings) eq 'HASH') { if (ref($settings->{'searchby'}) eq 'ARRAY') { if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) { $check = ' checked="checked" '; @@ -1570,6 +1570,16 @@ sub print_usercreation { } $datatable .= ''; } + my ($othertitle,$usertypes,$types) = + &Apache::loncommon::sorted_inst_types($dom); + if (ref($usertypes) eq 'HASH') { + if (keys(%{$usertypes}) > 0) { + $datatable .= &insttypes_row($settings->{cancreate},$types,$usertypes, + $dom,$numinrow,$othertitle, + 'statustocreate'); + $$rowtotal ++; + } + } } else { my @contexts = ('author','course','domain'); my @authtypes = ('int','krb4','krb5','loc'); @@ -2460,10 +2470,18 @@ sub modifiable_userdata_row { return $output; } -sub users_cansearch_row { - my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle) = @_; +sub insttypes_row { + my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context) = @_; + my %lt = &Apache::lonlocal::texthash ( + cansearch => 'Users allowed to search', + statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)', + ); + my $showdom; + if ($context eq 'cansearch') { + $showdom = ' ('.$dom.')'; + } my $output = ''. - ''.&mt('Users allowed to search').' ('.$dom.')'. + ''.$lt{$context}.$showdom. ''; my $rem; if (ref($types) eq 'ARRAY') { @@ -2477,14 +2495,16 @@ sub users_cansearch_row { $output .= ''; } my $check = ' '; - if (ref($settings->{'cansearch'}) eq 'ARRAY') { - if (grep(/^\Q$types->[$i]\E$/,@{$settings->{'cansearch'}})) { + if (ref($settings->{$context}) eq 'ARRAY') { + if (grep(/^\Q$types->[$i]\E$/,@{$settings->{$context}})) { $check = ' checked="checked" '; } + } elsif ($context eq 'statustocreate') { + $check = ' checked="checked" '; } $output .= ''; } @@ -2499,13 +2519,15 @@ sub users_cansearch_row { $output .= ''. '
'. ''; } my $defcheck = ' '; - if (ref($settings->{'cansearch'}) eq 'ARRAY') { - if (grep(/^default$/,@{$settings->{'cansearch'}})) { + if (ref($settings->{$context}) eq 'ARRAY') { + if (grep(/^default$/,@{$settings->{$context}})) { $defcheck = ' checked="checked" '; } + } elsif ($context eq 'statustocreate') { + $defcheck = ' checked="checked" '; } $output .= '
'; @@ -3978,10 +4000,19 @@ sub modify_usercreation { $cancreate{$item} = $env{'form.can_createuser_'.$item}; } } + my ($othertitle,$usertypes,$types) = + &Apache::loncommon::sorted_inst_types($dom); + if (ref($types) eq 'ARRAY') { + if (@{$types} > 0) { + @{$cancreate{'statustocreate'}} = + &Apache::loncommon::get_env_multiple('form.statustocreate'); + } + push(@contexts,'statustocreate'); + } if (ref($curr_usercreation{'cancreate'}) eq 'HASH') { foreach my $item (@contexts) { - if ($item eq 'selfcreate') { - if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') { + if (($item eq 'selfcreate') || ($item eq 'statustocreate')) { + if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') { foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) { if (!grep(/^$curr$/,@{$cancreate{$item}})) { if (!grep(/^$item$/,@{$changes{'cancreate'}})) { @@ -4168,6 +4199,26 @@ sub modify_usercreation { } $chgtext .= ''; } + } elsif ($type eq 'statustocreate') { + if (@{$cancreate{'selfcreate'}} > 0) { + if (@{$cancreate{$type}} == 0) { + if (!grep(/^email$/,@{$cancreate{'selfcreate'}})) { + $chgtext .= &mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts."); + } + } elsif (ref($usertypes) eq 'HASH') { + if (grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) { + $chgtext .= &mt('creation of a new account for an institutional user is restricted to the following institutional affiliation(s):').''; + } + } + } } else { if ($cancreate{$type} eq 'none') { $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.');