Diff for /loncom/interface/lonuserutils.pm between versions 1.171 and 1.173

version 1.171, 2015/08/05 18:47:21 version 1.173, 2016/04/02 04:30:21
Line 4297  sub upfile_drop_add { Line 4297  sub upfile_drop_add {
         my $newuserdom = $env{'request.role.domain'};          my $newuserdom = $env{'request.role.domain'};
         map { $cancreate{$_} = &can_create_user($newuserdom,$context,$_); } keys(%longtypes);          map { $cancreate{$_} = &can_create_user($newuserdom,$context,$_); } keys(%longtypes);
         # Get new users list          # Get new users list
         my (%existinguser,%userinfo,%disallow,%rulematch,%inst_results,%idinst_results,%alerts,%checkuname);          my (%existinguser,%userinfo,%disallow,%rulematch,%inst_results,%alerts,%checkuname);
         my $counter = -1;          my $counter = -1;
         foreach my $line (@userdata) {          foreach my $line (@userdata) {
             $counter ++;              $counter ++;
Line 4507  sub upfile_drop_add { Line 4507  sub upfile_drop_add {
                         }                          }
                         $checkid = 1;                          $checkid = 1;
                         $newuser = 1;                          $newuser = 1;
                         $checkuname{$username.':'.$newuserdom} = { 'newuser' => 1, 'id' => 1 };                          $checkuname{$username.':'.$newuserdom} = { 'newuser' => $newuser, 'id' => $id };
                     } else {                      } else {
                         if ($context eq 'course' || $context eq 'author') {                          if ($context eq 'course' || $context eq 'author') {
                             if ($userdomain eq $domain ) {                              if ($userdomain eq $domain ) {
Line 4566  sub upfile_drop_add { Line 4566  sub upfile_drop_add {
         } # end of foreach (@userdata)          } # end of foreach (@userdata)
         if ($counter > -1) {          if ($counter > -1) {
             my $total = $counter + 1;              my $total = $counter + 1;
             my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,$total);  
             my %checkids;              my %checkids;
             if (keys(%existinguser)) {              if ((keys(%existinguser)) || (keys(%checkuname))) {
                 foreach my $dom (keys(%existinguser)) {                  $r->print(&mt('Please be patient -- checking for institutional data ...'));
                     if (ref($existinguser{$dom}) eq 'HASH') {                  $r->rflush();
                         my %idhash = &Apache::lonnet::idrget($dom,keys(%{$existinguser{$dom}}));                  if (keys(%existinguser)) {
                         foreach my $username (keys(%{$existinguser{$dom}})) {                      foreach my $dom (keys(%existinguser)) {
                             if ($idhash{$username} ne $existinguser{$dom}{$username}) {                          if (ref($existinguser{$dom}) eq 'HASH') {
                                 $checkids{$username.':'.$dom} = { 'id' => $existinguser{$dom}{$username} };                              my %idhash = &Apache::lonnet::idrget($dom,keys(%{$existinguser{$dom}}));
                               foreach my $username (keys(%{$existinguser{$dom}})) {
                                   if ($idhash{$username} ne $existinguser{$dom}{$username}) {
                                       $checkids{$username.':'.$dom} = {
                                                                       'id' => $existinguser{$dom}{$username},
                                                                       };
                                   }
                               }
                               if (keys(%checkids)) {
                                   &Apache::loncommon::user_rule_check(\%checkids,{ 'id' => 1 },
                                                                       \%alerts,\%rulematch,
                                                                       \%inst_results,\%curr_rules,
                                                                       \%got_rules);
                             }                              }
                         }  
                         if (keys(%checkids)) {  
                             &Apache::loncommon::user_rule_check(\%checkids,{ 'id' => 1 },  
                                                                 \%alerts,\%rulematch,  
                                                                 \%idinst_results,\%curr_rules,  
                                                                 \%got_rules);  
                         }                          }
                     }                      }
                 }                  }
                   if (keys(%checkuname)) {
                       &Apache::loncommon::user_rule_check(\%checkuname,{ 'username' => 1, 'id' => 1, },
                                                           \%alerts,\%rulematch,\%inst_results,
                                                           \%curr_rules,\%got_rules);
                   }
                   $r->print(' '.&mt('done').'<br /><br />');
                   $r->rflush();
             }              }
             if (keys(%checkuname)) {              my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,$total);
                 &Apache::loncommon::user_rule_check(\%checkuname,{ 'username' => 1 },  
                                                     \%alerts,\%rulematch,\%inst_results,  
                                                     \%curr_rules,\%got_rules);  
             }  
             $r->print('<ul>');              $r->print('<ul>');
             for (my $i=0; $i<=$counter; $i++) {              for (my $i=0; $i<=$counter; $i++) {
                 &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state);  
                 if ($disallow{$i}) {                  if ($disallow{$i}) {
                     $r->print('<li>'.$disallow{$i}.'</li>');                      $r->print('<li>'.$disallow{$i}.'</li>');
                 } elsif (ref($userinfo{$i}) eq 'HASH') {                  } elsif (ref($userinfo{$i}) eq 'HASH') {
Line 4627  sub upfile_drop_add { Line 4634  sub upfile_drop_add {
                                 }                                  }
                             }                              }
                         }                          }
                           if (ref($inst_results{$user}) eq 'HASH') {
                               if ($inst_results{$user}{'firstname'} ne '') {
                                   $fname = $inst_results{$user}{'firstname'};
                               }
                               if ($inst_results{$user}{'middlename'} ne '') {
                                   $mname = $inst_results{$user}{'middlename'};
                               }
                               if ($inst_results{$user}{'lasttname'} ne '') {
                                   $lname = $inst_results{$user}{'lastname'};
                               }
                               if ($inst_results{$user}{'permanentemail'} ne '') {
                                   $email = $inst_results{$user}{'permanentemail'};
                               }
                               if ($inst_results{$user}{'id'} ne '') {
                                   $id = $inst_results{$user}{'id'};
                                   $checkid = 0;
                               }
                               if (ref($inst_results{$user}{'inststatus'}) eq 'ARRAY') {
                                   $inststatus = join(':',@{$inst_results{$user}{'inststatus'}});
                               }
                           }
                           if (($checkid) && ($id ne '')) {
                               if (ref($alerts{'id'}) eq 'HASH') {
                                   if (ref($alerts{'id'}{$userdomain}) eq 'HASH') {
                                       if ($alerts{'id'}{$userdomain}{$username}) {
                                           $r->print('<li>'.
                                                     &mt('[_1]: has a student/employee ID matching the format at your institution, but the ID is not found by your directory service.',
                                                     '<b>'.$username.'</b>').'<br />'.
                                                     &mt('Consequently, the user was not created.').'</li>');
                                           next;
                                       }
                                   }
                               }
                           }
                         my $usertype = 'unofficial';                          my $usertype = 'unofficial';
                         if (ref($rulematch{$user}) eq 'HASH') {                          if (ref($rulematch{$user}) eq 'HASH') {
                             if ($rulematch{$user}{'username'}) {                              if ($rulematch{$user}{'username'}) {
Line 4639  sub upfile_drop_add { Line 4680  sub upfile_drop_add {
                                       &mt('[_1]: The user does not exist, and you are not permitted to create users of type: [_2].','<b>'.$username.'</b>',$showtype).'</li>');                                        &mt('[_1]: The user does not exist, and you are not permitted to create users of type: [_2].','<b>'.$username.'</b>',$showtype).'</li>');
                             next;                              next;
                         }                          }
                     }                      } elsif ($id ne '') {
                     if ($id ne '') {  
                         if (exists($checkids{$user})) {                          if (exists($checkids{$user})) {
                             $checkid = 1;                               $checkid = 1; 
                             if (ref($alerts{'id'}) eq 'HASH') {                              if (ref($alerts{'id'}) eq 'HASH') {
                                 if (ref($alerts{'id'}{$userdomain}) eq 'HASH') {                                  if (ref($alerts{'id'}{$userdomain}) eq 'HASH') {
                                     if ($alerts{'id'}{$userdomain}{$id}) {                                      if ($alerts{'id'}{$userdomain}{$username}) {
                                         $r->print('<li>'.                                          $r->print('<li>'.
                                                   &mt('[_1]: has a student/employee ID matching the format at your institution, but the ID is found by your directory service.',                                                    &mt('[_1]: has a student/employee ID matching the format at your institution, but the ID is not found by your directory service.',
                                                   '<b>'.$username.'</b>').'<br />'.                                                    '<b>'.$username.'</b>').'<br />'.
                                                   &mt('Consequently, the user was not created.').'</li>');                                                    &mt('Consequently, the ID was not changed.').'</li>');
                                         next;                                          $id = '';
                                     }                                      }
                                 }                                  }
                             }                              }
Line 4729  sub upfile_drop_add { Line 4769  sub upfile_drop_add {
                                                 $username,$userdomain,\%userchg);                                                  $username,$userdomain,\%userchg);
                     }                      }
                 }                  }
                 $r->print('</ul>');                  &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last user');
             } # end of loop              } # end of loop
               $r->print('</ul>');
             &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);              &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
         }          }
         # Flush the course logs so reverse user roles immediately updated          # Flush the course logs so reverse user roles immediately updated
Line 6201  sub get_extended_type { Line 6242  sub get_extended_type {
     }      }
     if ($crstype eq 'Community') {      if ($crstype eq 'Community') {
         $type = 'community';          $type = 'community';
       } elsif ($crstype eq 'Placement') {
           $type = 'placement';
     } elsif ($settings{'internal.coursecode'}) {      } elsif ($settings{'internal.coursecode'}) {
         $type = 'official';          $type = 'official';
     } elsif ($settings{'internal.textbook'}) {      } elsif ($settings{'internal.textbook'}) {

Removed from v.1.171  
changed lines
  Added in v.1.173


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