--- loncom/interface/domainprefs.pm 2009/04/22 12:42:16 1.92 +++ loncom/interface/domainprefs.pm 2009/05/19 20:00:24 1.96 @@ -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.96 2009/05/19 20:00:24 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -162,7 +162,7 @@ sub handler { col2 => 'Information settable when self-creating account (if directory data blank)'}], }, 'scantron' => - { text => 'Scantron format file', + { text => 'Bubblesheet format file', help => 'Domain_Configuration_Scantron_Format', header => [ {col1 => 'Item', col2 => '', @@ -204,7 +204,6 @@ sub handler { &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname); } else { if (keys(%domconfig) == 0) { - &Apache::lonconfigsettings::print_header($r,$phase,$context); my $primarylibserv = &Apache::lonnet::domain($dom,'primary'); my @ids=&Apache::lonnet::current_machine_ids(); if (!grep(/^\Q$primarylibserv\E$/,@ids)) { @@ -222,6 +221,7 @@ sub handler { } } if ($custom_img_count > 0) { + &Apache::lonconfigsettings::print_header($r,$phase,$context); my $switch_server = &check_switchserver($dom,$confname); $r->print( &mt('Domain configuration settings have yet to be saved for this domain via the web-based domain preferences interface.').'
'. @@ -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'); @@ -1823,8 +1833,8 @@ sub print_scantronformat { %confhash); my $switchserver = &check_switchserver($dom,$confname); my %lt = &Apache::lonlocal::texthash ( - default => 'Default scantron format file error', - custom => 'Custom scantron format file error', + default => 'Default bubblesheet format file error', + custom => 'Custom bubblesheet format file error', ); my %scantronfiles = ( default => 'default.tab', @@ -1897,7 +1907,7 @@ sub print_scantronformat { } } } else { - $error{'default'} = &mt("Unable to copy default scantron formatfile to domain's RES space: [_1]",$switchserver); + $error{'default'} = &mt("Unable to copy default bubblesheet formatfile to domain's RES space: [_1]",$switchserver); } } if (ref($settings) eq 'HASH') { @@ -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,29 @@ sub modify_usercreation { } $chgtext .= ''; } + } elsif ($type eq 'statustocreate') { + if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') && + (ref($cancreate{'statustocreate'}) eq 'ARRAY')) { + if (@{$cancreate{'selfcreate'}} > 0) { + if (@{$cancreate{'statustocreate'}} == 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.');