Diff for /loncom/interface/lonuserutils.pm between versions 1.184.4.10.2.1 and 1.184.4.10.2.7

version 1.184.4.10.2.1, 2022/02/20 19:48:31 version 1.184.4.10.2.7, 2024/01/05 04:09:47
Line 103  sub modifystudent { Line 103  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 134  sub modifyuserrole { Line 134  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 510  END Line 529  END
 ";  ";
     } elsif ($mode eq 'modifycourse') {      } elsif ($mode eq 'modifycourse') {
         $auth_checks .= "          $auth_checks .= "
     if (vf.elements[current.argfield].value == null || vf.elements[current.argfield].value == '') {      if ((current.argfield !== null) && (current.argfield !== undefined) && (current.argfield !== '') && (vf.elements[current.argfield].value == null || vf.elements[current.argfield].value == '')) {
 ";  ";
     }      }
     if ( ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) {      if ( ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) {
Line 1588  sub print_userlist { Line 1607  sub print_userlist {
     if (! exists($env{'form.sortby'})) {      if (! exists($env{'form.sortby'})) {
         $env{'form.sortby'} = 'username';          $env{'form.sortby'} = 'username';
     }      }
       my ($showstart,$showend);
       if (($env{'form.Status'} eq '') && ($env{'form.phase'} eq '') &&
           ($env{'form.showrole'} eq '') && ($context eq 'course') &&
           ($env{'request.course.id'} ne '') &&
           ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'} ne '')) {
           my $now = time;
           my $startaccess = $env{'course.'.$env{'request.course.id'}.'.default_enrollment_start_date'};
           my $endaccess = $env{'course.'.$env{'request.course.id'}.'.default_enrollment_end_date'};
           if (($startaccess) && ($startaccess > $now)) {
               $env{'form.Status'} = 'Future';
               $showstart = 1;
           }
           if (($endaccess ne '') && ($endaccess != 0) && ($endaccess < $now)) {
               $env{'form.Status'} = 'Expired';
               undef($showstart);
               $showend = 1;
           }
       }
     if ($env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) {      if ($env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) {
         $env{'form.Status'} = 'Active';          $env{'form.Status'} = 'Active';
     }      }
Line 1655  sub print_userlist { Line 1692  sub print_userlist {
         $r->print(&section_group_filter($cnum,$cdom));          $r->print(&section_group_filter($cnum,$cdom));
     }      }
     $r->print('</div><div class="LC_left_float">'.      $r->print('</div><div class="LC_left_float">'.
               &column_checkboxes($context,$mode,$formname,$showcredits).                &column_checkboxes($context,$mode,$formname,$showcredits,$showstart,$showend).
               '</div>');                '</div>');
     if ($env{'form.phase'} eq '') {      if ($env{'form.phase'} eq '') {
         $r->print('<br clear="all" />'.          $r->print('<br clear="all" />'.
Line 2044  sub get_cols_array { Line 2081  sub get_cols_array {
 }  }
   
 sub column_checkboxes {  sub column_checkboxes {
     my ($context,$mode,$formname,$showcredits) = @_;      my ($context,$mode,$formname,$showcredits,$showstart,$showend) = @_;
     my @cols = &get_cols_array($context,$mode,$showcredits);      my @cols = &get_cols_array($context,$mode,$showcredits);
     my @showncols = &Apache::loncommon::get_env_multiple('form.showcol');      my @showncols = &Apache::loncommon::get_env_multiple('form.showcol');
     my (%disabledchk,%unchecked);      my (%disabledchk,%unchecked);
Line 2057  sub column_checkboxes { Line 2094  sub column_checkboxes {
             if ($showcredits) {              if ($showcredits) {
                 $unchecked{'credits'} = 1;                  $unchecked{'credits'} = 1;
             }              }
         } elsif ($context eq 'domain') {               my %curr_groups = &Apache::longroup::coursegroups();
               unless (keys(%curr_groups)) {
                   $unchecked{'groups'} = 1;
               }
           } elsif ($context eq 'domain') {
             $unchecked{'extent'} = 1;               $unchecked{'extent'} = 1; 
         }          }
         $unchecked{'start'} = 1;          if ($showstart) {
         $unchecked{'end'} = 1;              $unchecked{'lastlogin'} = 1;
           } else {
               $unchecked{'start'} = 1;
           }
           unless ($showend) {
               $unchecked{'end'} = 1;
           }
     } else {      } else {
         if ($env{'form.Status'} ne 'Any') {          if ($env{'form.Status'} ne 'Any') {
             $disabledchk{'status'} = 1;              $disabledchk{'status'} = 1;
Line 4159  sub upfile_drop_add { Line 4206  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);      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'};
         $crstype = &Apache::loncommon::course_type();          $crstype = &Apache::loncommon::course_type();
           $crsdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           $crsnum = $env{'course.'.$env{'request.course.id'}.'.num'};
     } elsif ($setting eq 'course') {      } elsif ($setting eq 'course') {
         if (&Apache::lonnet::is_course($env{'form.dcdomain'},$env{'form.dccourse'})) {          if (&Apache::lonnet::is_course($env{'form.dcdomain'},$env{'form.dccourse'})) {
             $cid = $env{'form.dcdomain'}.'_'.$env{'form.dccourse'};              $cid = $env{'form.dcdomain'}.'_'.$env{'form.dccourse'};
             $crstype = &Apache::loncommon::course_type($cid);              $crstype = &Apache::loncommon::course_type($cid);
               $crsdom = $env{'form.dcdomain'};
               $crsnum = $env{'form.dccourse'};
               if (exists($env{'course.'.$cid.'.internal.userdomains'})) {
                   $oldcrsuserdoms = 1;
               }
               my %coursedesc = &Apache::lonnet::coursedescription($cid,{ one_time => 1 });
               $env{'course.'.$cid.'.internal.userdomains'} = $coursedesc{'internal.userdomains'};
         }          }
     }      }
     my ($startdate,$enddate) = &get_dates_from_form();      my ($startdate,$enddate) = &get_dates_from_form();
Line 4866  sub upfile_drop_add { Line 4938  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) {
Line 4888  sub upfile_drop_add { Line 4960  sub upfile_drop_add {
             } # end of loop              } # end of loop
             $r->print('</ul>');              $r->print('</ul>');
             &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);              &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
               if (($context eq 'domain') && ($setting eq 'course')) {
                   unless ($oldcrsuserdoms) {
                       if (exists($env{'course.'.$cid.'.internal.userdomains'})) {
                           delete($env{'course.'.$cid.'.internal.userdomains'});
                       }
                   }
               }
         }          }
         # Flush the course logs so reverse user roles immediately updated          # Flush the course logs so reverse user roles immediately updated
         $r->register_cleanup(\&Apache::lonnet::flushcourselogs);          $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
Line 6066  sub get_permission { Line 6145  sub get_permission {
                     $permission{'selfenrolladmin'} = 1;                      $permission{'selfenrolladmin'} = 1;
                 }                  }
             }              }
               unless ($permission{'selfenrolladmin'}) {
                   $permission{'selfenrollview'} = 1;
               }
         }          }
         if ($env{'request.course.id'}) {          if ($env{'request.course.id'}) {
             my $user;              my $user;
Line 6114  sub get_permission { Line 6196  sub get_permission {
         }          }
     }      }
     my $allowed = 0;      my $allowed = 0;
     foreach my $perm (values(%permission)) {      foreach my $key (keys(%permission)) {
         if ($perm) { $allowed=1; last; }          next if (($key eq 'owner') || ($key eq 'co-owner'));
           if ($permission{$key}) { $allowed=1; last; }
     }      }
     return (\%permission,$allowed);      return (\%permission,$allowed);
 }  }
Line 6528  sub selfenrollment_administration { Line 6611  sub selfenrollment_administration {
         }          }
     }      }
     if ($settings{'internal.selfenrollmgrdc'} ne '') {      if ($settings{'internal.selfenrollmgrdc'} ne '') {
         my @in_domain = split(/,/,$settings{'internal.selfenrollmgrdc'});          @in_domain = split(/,/,$settings{'internal.selfenrollmgrdc'});
         my @diffs = &Apache::loncommon::compare_arrays(\@in_domain,$possconfigs);          my @diffs = &Apache::loncommon::compare_arrays(\@in_domain,$possconfigs);
         unless (@diffs) {          unless (@diffs) {
             return (\@in_course,\@in_domain);              return (\@in_course,\@in_domain);

Removed from v.1.184.4.10.2.1  
changed lines
  Added in v.1.184.4.10.2.7


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