Diff for /loncom/interface/loncommon.pm between versions 1.611 and 1.618

version 1.611, 2007/11/09 23:05:47 version 1.618, 2007/12/03 22:58:46
Line 4834  table.LC_descriptive_input td.LC_descrip Line 4834  table.LC_descriptive_input td.LC_descrip
   font-weight: bold;    font-weight: bold;
 }  }
 div.LC_feedback_link {  div.LC_feedback_link {
     clear: both;
   background: white;    background: white;
   width: 100%;      width: 100%;  
 }  }
Line 5097  span.LC_grade_check_note { Line 5098  span.LC_grade_check_note {
   right: 1em;    right: 1em;
 }  }
   
   table.LC_scantron_action {
     width: 100%;
   }
   table.LC_scantron_action tr th {
     font: normal bold $sans;
   }
   
 div.LC_edit_problem_header {  div.LC_edit_problem_header, 
   div.LC_edit_problem_footer {
   font: normal medium $sans;    font: normal medium $sans;
   margin: 2px;    margin: 2px;
 }  }
 div.LC_edit_problem_header,  div.LC_edit_problem_header,
 div.LC_edit_problem_header div,  div.LC_edit_problem_header div,
   div.LC_edit_problem_footer,
   div.LC_edit_problem_footer div,
 div.LC_edit_problem_editxml_header,  div.LC_edit_problem_editxml_header,
 div.LC_edit_problem_editxml_header div {  div.LC_edit_problem_editxml_header div {
   margin-top: 5px;    margin-top: 5px;
Line 5851  sub get_course_users { Line 5861  sub get_course_users {
         my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist($cdom,$cnum);          my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist($cdom,$cnum);
         my $now = time;          my $now = time;
         foreach my $student (keys(%{$classlist})) {          foreach my $student (keys(%{$classlist})) {
             my $status;  
             my $match = 0;              my $match = 0;
             my $secmatch = 0;              my $secmatch = 0;
             my $section = $$classlist{$student}[$idx{section}];              my $section = $$classlist{$student}[$idx{section}];
Line 6430  END_BLOCK Line 6439  END_BLOCK
     return $output;      return $output;
 }  }
   
 sub username_rule_check {  sub user_rule_check {
     my ($srch,$caller) = @_;      my ($usershash,$checks,$alerts,$rulematch,$inst_results,$curr_rules,$got_rules) = @_;
     my ($response,@curr_rules,%inst_results,$rulematch);      my $response;
     my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($srch->{'srchdomain'});      if (ref($usershash) eq 'HASH') {
     if (ref($srch) eq 'HASH') {          foreach my $user (keys(%{$usershash})) {
         (my $inst_response,%inst_results) =               my ($uname,$udom) = split(/:/,$user);
             &Apache::lonnet::get_instuser($srch->{'srchdomain'},              next if ($udom eq '' || $uname eq '');
                                           $srch->{'srchterm'});              my ($id,$newuser);
         my %domconfig = &Apache::lonnet::get_dom('configuration',              if (ref($usershash->{$user}) eq 'HASH') {
                               ['usercreation'],$srch->{'srchdomain'});                  $newuser = $usershash->{$user}->{'newuser'};
         if (ref($domconfig{'usercreation'}) eq 'HASH') {                  $id = $usershash->{$user}->{'id'};
             if (ref($domconfig{'usercreation'}{'username_rule'}) eq 'ARRAY') {              }
                 @curr_rules = @{$domconfig{'usercreation'}{'username_rule'}};              my $inst_response;
             }              if (ref($checks) eq 'HASH') {
         }                  if (defined($checks->{'username'})) {
         if (@curr_rules > 0) {                      ($inst_response,%{$inst_results->{$user}}) = 
             my $domdesc = &Apache::lonnet::domain($srch->{'srchdomain'},'description');                          &Apache::lonnet::get_instuser($udom,$uname);
             my $instuser_reqd;                  } elsif (defined($checks->{'id'})) {
             my %rule_check = &Apache::lonnet::inst_rulecheck($srch->{'srchdomain'},$srch->{'srchterm'},\@curr_rules);                      ($inst_response,%{$inst_results->{$user}}) =
             foreach my $rule (@curr_rules) {                          &Apache::lonnet::get_instuser($udom,undef,$id);
                 if ($rule_check{$rule}) {                  }
                     $rulematch = $rule;              } else {
                     if ($inst_response eq 'ok') {                  ($inst_response,%{$inst_results->{$user}}) =
                         if (keys(%inst_results) == 0) {                      &Apache::lonnet::get_instuser($udom,$uname);
                             if ($caller eq 'new') {                  return;
                                 $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.");              }
                             }              if (!$got_rules->{$udom}) {
                   my %domconfig = &Apache::lonnet::get_dom('configuration',
                                                     ['usercreation'],$udom);
                   if (ref($domconfig{'usercreation'}) eq 'HASH') {
                       foreach my $item ('username','id') {
                           if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') {
                               $$curr_rules{$udom}{$item} = 
                                   $domconfig{'usercreation'}{$item.'_rule'};
                         }                          }
                     }                      }
                     last;  
                 }                  }
                   $got_rules->{$udom} = 1;  
             }              }
             if ($response) {              foreach my $item (keys(%{$checks})) {
                 if ((ref($rules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) {                  if (ref($$curr_rules{$udom}) eq 'HASH') {
                     if (@{$ruleorder} > 0) {                      if (ref($$curr_rules{$udom}{$item}) eq 'ARRAY') {
                         $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>';                          if (@{$$curr_rules{$udom}{$item}} > 0) {
                         foreach my $rule (@{$ruleorder}) {                              my %rule_check = &Apache::lonnet::inst_rulecheck($udom,$uname,$id,$item,$$curr_rules{$udom}{$item});
                             if (grep(/^\Q$rule\E$/,@curr_rules)) {                              foreach my $rule (@{$$curr_rules{$udom}{$item}}) {
                                 if (ref($rules->{$rule}) eq 'HASH') {                                  if ($rule_check{$rule}) {
                                     $response .= '<li>'.$rules->{$rule}{'name'}.': '.                                      $$rulematch{$user}{$item} = $rule;
                                                  $rules->{$rule}{'desc'}.'</li>';                                      if ($inst_response eq 'ok') {
                                           if (ref($inst_results) eq 'HASH') {
                                               if (ref($inst_results->{$user}) eq 'HASH') {
                                                   if (keys(%{$inst_results->{$user}}) == 0) {
                                                       $$alerts{$item}{$udom}{$uname} = 1;
                                                   }
                                               }
                                           }
                                       }
                                       last;
                                 }                                  }
                             }                              }
                         }                          }
                     }                      }
                     $response .= '</ul>';  
                 }                  }
             }              }
         }          }
     }      }
     return ($response,$rulematch,$rules,%inst_results);      return;
   }
   
   sub user_rule_formats {
       my ($domain,$domdesc,$curr_rules,$check) = @_;
       my %text = ( 
                    'username' => 'Usernames',
                    'id'       => 'IDs',
                  );
       my $output;
       my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($domain,$check);
       if ((ref($rules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) {
           if (@{$ruleorder} > 0) {
               $output = '<br />'.&mt("$text{$check} 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 (ref($curr_rules) eq 'ARRAY') {
                       if (grep(/^\Q$rule\E$/,@{$curr_rules})) {
                           if (ref($rules->{$rule}) eq 'HASH') {
                               $output .= '<li>'.$rules->{$rule}{'name'}.': '.
                                           $rules->{$rule}{'desc'}.'</li>';
                           }
                       }
                   }
               }
               $output .= '</ul>';
           }
       }
       return $output;
   }
   
   sub instrule_disallow_msg {
       my ($checkitem,$domdesc,$count,$mode) = @_;
       my $response;
       my %text = (
                     item   => 'username',
                     items  => 'usernames',
                     match  => 'matches',
                     do     => 'does',
                     action => 'a username',
                     one    => 'one',
                  );
       if ($count > 1) {
           $text{'item'} = 'usernames';
           $text{'match'} ='match';
           $text{'do'} = 'do';
           $text{'action'} = 'usernames',
           $text{'one'} = 'ones';
       }
       if ($checkitem eq 'id') {
           $text{'items'} = 'IDs';
           $text{'item'} = 'ID';
           $text{'action'} = 'an ID';
           if ($count > 1) {
               $text{'item'} = 'IDs';
               $text{'action'} = 'IDs';
           }
       }
       $response = &mt("The $text{'item'} you chose $text{'match'} the format of $text{'items'} defined for <span class=\"LC_cusr_emph\">[_1]</span>, but the $text{'item'} $text{'do'} not exist in the institutional directory.",$domdesc).'<br />';
       if ($mode eq 'upload') {
           if ($checkitem eq 'username') {
               $response .= &mt("You will need to modify your upload file so it will include $text{'action'} with a different format --  $text{'one'} that will not conflict with 'official' institutional $text{'items'}.");
           } elsif ($checkitem eq 'id') {
               $response .= &mt("Either upload a file which includes $text{'action'} with a different format --  $text{'one'} that will not conflict with 'official' institutional $text{'items'}, or when associating fields with data columns, omit an association for the ID/Student Number field.");
           }
       } else {
           if ($checkitem eq 'username') {
               $response .= &mt("You must choose $text{'action'} with a different format --  $text{'one'} that will not conflict with 'official' institutional $text{'items'}.");
           } elsif ($checkitem eq 'id') {
               $response .= &mt("You must either choose $text{'action'} with a different format --  $text{'one'} that will not conflict with 'official' institutional $text{'items'}, or leave the ID field blank.");
           }
       }
       return $response;
 }  }
   
 =pod  =pod
Line 7541  sub restore_settings { Line 7636  sub restore_settings {
     }      }
 }  }
   
   #######################################################
   #######################################################
   
   =pod
   
   =head1 Domain E-mail Routines  
   
   =over 4
   
   =item &build_recipient_list
   
   Build recipient lists for three types of e-mail:
   (a) Error Reports, (b) Package Updates, (c) Help requests, generated by
   lonerrorhandler.pm, CHECKRPMS and lonhelpdesk.pm respectively.
   
   Inputs:
   Request object, defmail (scalar - email address of default recipient), 
   mailing type (scalar - errormail, packagesmail, or helpdeskmail), 
   defdom (domain for which to retrieve configuration settings).
   
   Returns: comma separated list of addresses to which to send e-mail.   
   
   =cut
   
   ############################################################
   ############################################################
   sub build_recipient_list {
       my ($r,$defmail,$mailing,$defdom) = @_;
       my @recipients;
       my $otheremails;
       my $defdom = $r->dir_config('lonDefDomain');
       my %domconfig =
            &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);
       if (ref($domconfig{'contacts'}) eq 'HASH') {
           if (ref($domconfig{'contacts'}{$mailing}) eq 'HASH') {
               my @contacts = ('adminemail','supportemail');
               foreach my $item (@contacts) {
                   if ($domconfig{'contacts'}{$mailing}{$item}) {
                       push(@recipients,$domconfig{'contacts'}{$item});
                   }
                   $otheremails = $domconfig{'contacts'}{$mailing}{'others'};
               }
           } else {
               push(@recipients,$r->dir_config('lonAdmEMail'));
           }
       }
       if ($defmail ne '') {
           push(@recipients,$defmail);
       }
       my $recipientlist = join(',',@recipients);
       if ($otheremails) {
           if ($recipientlist ne '') {
               $recipientlist .= ','.$otheremails;
           } else {
               $recipientlist = $otheremails;
           }
       }
       return $recipientlist;
   }
   
 ############################################################  ############################################################
 ############################################################  ############################################################
   

Removed from v.1.611  
changed lines
  Added in v.1.618


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