Diff for /loncom/interface/lonuserutils.pm between versions 1.218 and 1.220

version 1.218, 2023/11/03 01:12:15 version 1.220, 2023/12/07 04:47:00
Line 104  sub modifystudent { Line 104  sub modifystudent {
 sub modifyuserrole {  sub modifyuserrole {
     my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass,      my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass,
         $first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role,          $first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role,
         $end,$start,$checkid,$inststatus) = @_;          $end,$start,$checkid,$inststatus,$emptyok) = @_;
     my ($scope,$userresult,$authresult,$roleresult,$idresult);      my ($scope,$userresult,$authresult,$roleresult,$idresult);
     if ($setting eq 'course' || $context eq 'course') {      if ($setting eq 'course' || $context eq 'course') {
         $scope = '/'.$cid;          $scope = '/'.$cid;
Line 139  sub modifyuserrole { Line 139  sub modifyuserrole {
                                   generation => $gene,                                    generation => $gene,
                                   id         => $uid,                                    id         => $uid,
                                  );                                   );
   
                   # When "Update ID in user's course(s)" and "Force change of existing ID"
                   # checkboxes both checked, prevent replacement of name information
                   # in classlist.db file(s) for the user's course(s) with blank(s),
                   # in the case where the uploaded csv file was without column(s) for
                   # the particular field. Fields are: First Name, Middle Names/Initials,
                   # Last Name (or the composite: Last Name, First Names), and Generation.
   
                   my %emptyallowed;
                   if ((ref($emptyok) eq 'HASH') && (keys(%{$emptyok}) > 0)) {
                       %emptyallowed = %{$emptyok};
                   }
                   foreach my $field (keys(%userupdate)) {
                       if ($userupdate{$field} eq '') {
                           unless ($emptyallowed{$field}) {
                               delete($userupdate{$field});
                           }
                       }
                   }
                 $idresult = &propagate_id_change($uname,$udom,\%userupdate);                  $idresult = &propagate_id_change($uname,$udom,\%userupdate);
             }              }
         }          }
Line 2632  sub get_cols_array { Line 2651  sub get_cols_array {
             push(@cols,'photo');              push(@cols,'photo');
         }          }
         if ($context eq 'domain') {          if ($context eq 'domain') {
             push (@cols,('authorusage','authorquota','extent'));              push(@cols,('authorusage','authorquota','extent'));
           }
           if ($context eq 'author') {
               push(@cols,'manager');
         }          }
     }      }
     return @cols;      return @cols;
Line 2673  sub column_checkboxes { Line 2695  sub column_checkboxes {
             } elsif ($env{'form.roletype'} eq 'domain') {              } elsif ($env{'form.roletype'} eq 'domain') {
                 $disabledchk{'extent'} = 1;                   $disabledchk{'extent'} = 1; 
             }              }
           } elsif ($context eq 'author') {
               if (($env{'form.Status'} eq 'Expired') ||
                   ($env{'form.showrole'} eq 'aa')) {
                   $disabledchk{'manager'} = 1;
               }
         }          }
     }      }
     my $numposs = scalar(@cols);      my $numposs = scalar(@cols);
Line 2764  sub get_column_names { Line 2791  sub get_column_names {
         'ca'         => "check all",          'ca'         => "check all",
         'ua'         => "uncheck all",          'ua'         => "uncheck all",
         'clicker'    => "clicker-ID",          'clicker'    => "clicker-ID",
           'manager'    => "co-author manager",
     );      );
     if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {      if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
         $lt{'extent'} = &mt('course(s): description, section(s), status');          $lt{'extent'} = &mt('course(s): description, section(s), status');
Line 3048  sub make_keylist_array { Line 3076  sub make_keylist_array {
     $index->{'instsec'} = &Apache::loncoursedata::CL_INSTSEC();      $index->{'instsec'} = &Apache::loncoursedata::CL_INSTSEC();
     $index->{'authorquota'} = &Apache::loncoursedata::CL_AUTHORQUOTA();      $index->{'authorquota'} = &Apache::loncoursedata::CL_AUTHORQUOTA();
     $index->{'authorusage'} = &Apache::loncoursedata::CL_AUTHORUSAGE();      $index->{'authorusage'} = &Apache::loncoursedata::CL_AUTHORUSAGE();
       $index->{'manager'} = &Apache::loncoursedata::CL_CAMANAGER();
     foreach my $key (keys(%{$index})) {      foreach my $key (keys(%{$index})) {
         $keylist->[$index->{$key}] = $key;          $keylist->[$index->{$key}] = $key;
     }      }
Line 3122  sub show_users_list { Line 3151  sub show_users_list {
             (($env{'form.showrole'} eq 'Any') || ($env{'form.showrole'} eq 'au'))) {              (($env{'form.showrole'} eq 'Any') || ($env{'form.showrole'} eq 'au'))) {
             push(@sortable,('authorusage','authorquota'));              push(@sortable,('authorusage','authorquota'));
         }          }
           if ($context eq 'author') {
               push(@sortable,'manager');
           }
     }      }
     if ($mode eq 'pickauthor') {      if ($mode eq 'pickauthor') {
         @sortable = ('username','fullname','email','status');          @sortable = ('username','fullname','email','status');
Line 3439  END Line 3471  END
     foreach my $idx (@$keylist) {      foreach my $idx (@$keylist) {
         $index{$idx} = $i++;          $index{$idx} = $i++;
     }      }
       my $now = time;
     my $usercount = 0;      my $usercount = 0;
     my ($secfilter,$grpfilter);      my ($secfilter,$grpfilter);
     if ($context eq 'course') {      if ($context eq 'course') {
Line 3456  END Line 3489  END
                                                 Future  => 'Future',                                                  Future  => 'Future',
                                                 Expired => 'Expired',                                                  Expired => 'Expired',
                                                );                                                 );
     # If this is for a single course get last course "log-in".      my (%crslogins,%camanagers);
     my %crslogins;  
     if ($context eq 'course') {      if ($context eq 'course') {
           # If this is for a single course get last course "log-in".
         %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum);          %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum);
       } elsif ($context eq 'author') {
           map { $camanagers{$_.':ca'} = 1; } split(/,/,$env{'environment.authormanagers'});
     }      }
     # Get groups, role, permanent e-mail so we can sort on them if      # Get groups, role, permanent e-mail so we can sort on them if
     # necessary.      # necessary.
Line 3559  END Line 3594  END
                 }                  }
             }              }
         }          }
           if ($context eq 'author') {
               if (($camanagers{$user}) &&
                   ((!defined($userlist->{$user}->[$index{'end'}])) ||
                    ($userlist->{$user}->[$index{'end'}] == 0) ||
                    ($userlist->{$user}->[$index{'end'}] > $now))) {
                   $userlist->{$user}->[$index{'manager'}] = &mt('Yes');
               } else {
                   $userlist->{$user}->[$index{'manager'}] = &mt('No');
               }
           }
         my %emails   = &Apache::loncommon::getemails($uname,$udom);          my %emails   = &Apache::loncommon::getemails($uname,$udom);
         if ($emails{'permanentemail'} =~ /\S/) {          if ($emails{'permanentemail'} =~ /\S/) {
             $userlist->{$user}->[$index{'email'}] = $emails{'permanentemail'};              $userlist->{$user}->[$index{'email'}] = $emails{'permanentemail'};
Line 4754  sub upfile_drop_add { Line 4799  sub upfile_drop_add {
         $fieldstype{$field.'_choice'} = 'scalar';          $fieldstype{$field.'_choice'} = 'scalar';
     }      }
     &Apache::loncommon::store_course_settings('enrollment_upload',\%fieldstype);      &Apache::loncommon::store_course_settings('enrollment_upload',\%fieldstype);
     my ($cid,$crstype,$setting,$crsdom,$crsnum,$oldcrsuserdoms);      my ($cid,$crstype,$setting,$crsdom,$crsnum,$oldcrsuserdoms,%emptyok);
     if ($context eq 'domain') {      if ($context eq 'domain') {
         $setting = $env{'form.roleaction'};          $setting = $env{'form.roleaction'};
           if (exists($fields{'names'})) {
               map { $emptyok{$_} = 1; } ('lastname','firstname','middlename');
           } else {
               if (exists($fields{'lname'})) {
                   $emptyok{'lastname'} = 1;
               }
               if (exists($fields{'fname'})) {
                   $emptyok{'firstname'} = 1;
               }
               if (exists($fields{'mname'})) {
                   $emptyok{'middlename'} = 1;
               }
           }
           if (exists($fields{'gen'})) {
               $emptyok{'generation'} = 1;
           }
     }      }
     if ($env{'request.course.id'} ne '') {      if ($env{'request.course.id'} ne '') {
         $cid = $env{'request.course.id'};          $cid = $env{'request.course.id'};
Line 5578  sub upfile_drop_add { Line 5639  sub upfile_drop_add {
                                                 $mname,$lname,$gen,$singlesec,                                                  $mname,$lname,$gen,$singlesec,
                                                 $env{'form.forceid'},$desiredhost,                                                  $env{'form.forceid'},$desiredhost,
                                                 $email,$role,$enddate,$startdate,                                                  $email,$role,$enddate,$startdate,
                                                 $checkid,$inststatus);                                                  $checkid,$inststatus,\%emptyok);
                         }                          }
                     }                      }
                     if ($multiple) {                      if ($multiple) {

Removed from v.1.218  
changed lines
  Added in v.1.220


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