Diff for /loncom/interface/loncommon.pm between versions 1.584 and 1.585

version 1.584, 2007/09/11 23:36:46 version 1.585, 2007/09/12 23:32:59
Line 5908  END_BLOCK Line 5908  END_BLOCK
     return $output;      return $output;
 }  }
   
   sub username_rule_check {
       my ($srch,$caller) = @_;
       my ($response,@curr_rules,%inst_results,$rulematch);
       my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($srch->{'srchdomain'});
       if (ref($srch) eq 'HASH') {
           (my $inst_response,%inst_results) = 
               &Apache::lonnet::get_instuser($srch->{'srchdomain'},
                                             $srch->{'srchterm'});
           my %domconfig = &Apache::lonnet::get_dom('configuration',
                                 ['usercreation'],$srch->{'srchdomain'});
           if (ref($domconfig{'usercreation'}) eq 'HASH') {
               if (ref($domconfig{'usercreation'}{'username_rule'}) eq 'ARRAY') {
                   @curr_rules = @{$domconfig{'usercreation'}{'username_rule'}};
               }
           }
           if (@curr_rules > 0) {
               my $domdesc = &Apache::lonnet::domain($srch->{'srchdomain'},'description');
               my $instuser_reqd;
               my %rule_check = &Apache::lonnet::inst_rulecheck($srch->{'srchdomain'},$srch->{'srchterm'},\@curr_rules);
               foreach my $rule (@curr_rules) {
                   if ($rule_check{$rule}) {
                       $rulematch = $rule;
                       if ($inst_response eq 'ok') {
                           if (keys(%inst_results) == 0) {
                               if ($caller eq 'new') {
                                   $response = &mt('The username you chose matches the format of usernames defined for <span class="LC_cusr_emph">[_1]</span>, but the user does not exist in the institutional directory.',$domdesc).'<br />'.&mt("You must choose a username with a different format -- one that will not conflict with 'official' institutional usernames.");
                               }
                           }
                       }
                       last;
                   }
               }
               if ($response) {
                   if ((ref($rules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) {
                       if (@{$ruleorder} > 0) {
                           $response .= '<br />'.&mt('Usernames with the following format(s) may <span class="LC_cusr_emph">only</span> be used for verified users at [_1]:',$domdesc).' <ul>';
                           foreach my $rule (@{$ruleorder}) {
                               if (grep(/^\Q$rule\E$/,@curr_rules)) {
                                   if (ref($rules->{$rule}) eq 'HASH') {
                                       $response .= '<li>'.$rules->{$rule}{'name'}.': '.
                                                    $rules->{$rule}{'desc'}.'</li>';
                                   }
                               }
                           }
                       }
                       $response .= '</ul>';
                   }
               }
           }
       }
       return ($response,$rulematch,$rules,%inst_results);
   }
   
 =pod  =pod
   
 =back  =back

Removed from v.1.584  
changed lines
  Added in v.1.585


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>