--- loncom/interface/domainprefs.pm 2007/09/27 15:36:23 1.31 +++ loncom/interface/domainprefs.pm 2007/11/10 03:51:46 1.32 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.31 2007/09/27 15:36:23 raeburn Exp $ +# $Id: domainprefs.pm,v 1.32 2007/11/10 03:51:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1289,7 +1289,6 @@ sub contact_titles { sub print_usercreation { my ($position,$dom,$settings,$rowtotal) = @_; my $numinrow = 4; - my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom); my $datatable; my %lt = &Apache::lonlocal::texthash ( nondc => 'User creation other than by Domain Coordinator: ', @@ -1316,11 +1315,23 @@ sub print_usercreation { } $datatable .= ''; $$rowtotal ++; + my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username'); + my $rowcount = 0; if (ref($rules) eq 'HASH') { if (keys(%{$rules}) > 0) { - $datatable .= &username_formats_row($settings,$rules, - $ruleorder,$numinrow); + $datatable .= &user_formats_row('username',$settings,$rules, + $ruleorder,$numinrow,$rowcount); $$rowtotal ++; + $rowcount ++; + } + } + my ($idrules,$idruleorder) = &Apache::lonnet::inst_userrules($dom,'id'); + if (ref($idrules) eq 'HASH') { + if (keys(%{$idrules}) > 0) { + $datatable .= &user_formats_row('id',$settings,$idrules, + $idruleorder,$numinrow,$rowcount); + $$rowtotal ++; + $rowcount ++; } } } else { @@ -1369,13 +1380,19 @@ sub print_usercreation { return $datatable; } -sub username_formats_row { - my ($settings,$rules,$ruleorder,$numinrow) = @_; - my $output = ''. - ''. - &mt('Format rules to check for new usernames: '). - ''. - ''; +sub user_formats_row { + my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_; + my $output; + my %text = ( + 'username' => 'new usernames', + 'id' => 'IDs', + ); + my $css_class = $rowcount%2?' class="LC_odd_row"':''; + $output = ''. + ''. + '
'. + &mt("Format rules to check for $text{$type}: "). + ''; my $rem; if (ref($ruleorder) eq 'ARRAY') { for (my $i=0; $i<@{$ruleorder}; $i++) { @@ -1388,14 +1405,14 @@ sub username_formats_row { $output .= ''; } my $check = ' '; - if (ref($settings->{'username_rule'}) eq 'ARRAY') { - if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{'username_rule'}})) { + if (ref($settings->{$type.'_rule'}) eq 'ARRAY') { + if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) { $check = ' checked="checked" '; } } $output .= ''; } @@ -2728,6 +2745,7 @@ sub modify_usercreation { course => 'adding users to a course', ); 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'}}) { @@ -2758,6 +2776,21 @@ sub modify_usercreation { push(@{$changes{'username_rule'}},@username_rule); } + if (ref($curr_usercreation{'id_rule'}) eq 'ARRAY') { + foreach my $type (@{$curr_usercreation{'id_rule'}}) { + if (!grep(/^\Q$type\E$/,@id_rule)) { + push(@{$changes{'id_rule'}},$type); + } + } + foreach my $type (@id_rule) { + if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'id_rule'}})) { + push(@{$changes{'id_rule'}},$type); + } + } + } else { + push(@{$changes{'id_rule'}},@id_rule); + } + my @contexts = ('author','course','domain'); my @authtypes = ('int','krb4','krb5','loc'); my %authhash; @@ -2792,7 +2825,8 @@ sub modify_usercreation { usercreation => { cancreate => \@cancreate, username_rule => \@username_rule, - authtypes => \%authhash, + id_rule => \@id_rule, + authtypes => \%authhash, } ); @@ -2814,7 +2848,8 @@ sub modify_usercreation { } } if (ref($changes{'username_rule'}) eq 'ARRAY') { - my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom); + my ($rules,$ruleorder) = + &Apache::lonnet::inst_userrules($dom,'username'); my $chgtext = '
    '; foreach my $type (@username_rule) { if (ref($rules->{$type}) eq 'HASH') { @@ -2828,6 +2863,22 @@ sub modify_usercreation { $resulttext .= '
  • '.&mt('There are now no username formats restricted to verified users in the institutional directory.').'
  • '; } } + if (ref($changes{'id_rule'}) eq 'ARRAY') { + my ($idrules,$idruleorder) = + &Apache::lonnet::inst_userrules($dom,'id'); + my $chgtext = '
      '; + foreach my $type (@id_rule) { + if (ref($idrules->{$type}) eq 'HASH') { + $chgtext .= '
    • '.$idrules->{$type}{'name'}.'
    • '; + } + } + $chgtext .= '
    '; + if (@id_rule > 0) { + $resulttext .= '
  • '.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'
  • '; + } else { + $resulttext .= '
  • '.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'
  • '; + } + } my %authname = &authtype_names(); my %context_title = &context_names(); if (ref($changes{'authtypes'}) eq 'ARRAY') {
'. '