Diff for /loncom/interface/lonuserutils.pm between versions 1.184.4.3 and 1.192

version 1.184.4.3, 2019/07/26 18:37:16 version 1.192, 2017/11/04 20:23:23
Line 943  sub print_upload_manager_footer { Line 943  sub print_upload_manager_footer {
                 &Apache::lonhtmlcommon::row_closure();                  &Apache::lonhtmlcommon::row_closure();
     }      }
   
       my ($trusted,$untrusted);
       if ($context eq 'course') {
           ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$defdom);
       } elsif ($context eq 'author') {
           ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('othcoau',$defdom);
       }
     $Str .= &Apache::lonhtmlcommon::row_title(&mt('Default domain'))      $Str .= &Apache::lonhtmlcommon::row_title(&mt('Default domain'))
            .&Apache::loncommon::select_dom_form($defdom,'defaultdomain',undef,1)             .&Apache::loncommon::select_dom_form($defdom,'defaultdomain',undef,1,undef,$trusted,$untrusted)
            .&Apache::lonhtmlcommon::row_closure();             .&Apache::lonhtmlcommon::row_closure();
   
     $Str .= &Apache::lonhtmlcommon::row_title(&mt('Starting and Ending Dates'))      $Str .= &Apache::lonhtmlcommon::row_title(&mt('Starting and Ending Dates'))
Line 1126  sub print_upload_manager_form { Line 1132  sub print_upload_manager_form {
             &Apache::loncommon::load_tmp_file($r,$datatoken);              &Apache::loncommon::load_tmp_file($r,$datatoken);
         }          }
     }      }
     if ($datatoken eq '') {  
         $r->print('<p class="LC_error">'.&mt('Error').': '.  
                   &mt('Invalid datatoken').'</p>');  
         return 'missingdata';  
     }  
     my @records=&Apache::loncommon::upfile_record_sep();      my @records=&Apache::loncommon::upfile_record_sep();
     if($env{'form.noFirstLine'}){      if($env{'form.noFirstLine'}){
         $firstLine=shift(@records);          $firstLine=shift(@records);
Line 1213  sub print_upload_manager_form { Line 1214  sub print_upload_manager_form {
     }      }
     &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear,      &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear,
                                  $context,$permission,$crstype,$showcredits);                                   $context,$permission,$crstype,$showcredits);
     return 'ok';  
 }  }
   
 sub setup_date_selectors {  sub setup_date_selectors {
Line 2287  sub build_user_record { Line 2287  sub build_user_record {
   
 sub courses_selector {  sub courses_selector {
     my ($cdom,$formname) = @_;      my ($cdom,$formname) = @_;
       my %coursecodes = ();
     my %codes = ();      my %codes = ();
     my @codetitles = ();      my @codetitles = ();
     my %cat_titles = ();      my %cat_titles = ();
Line 2299  sub courses_selector { Line 2300  sub courses_selector {
     my $jscript = '';      my $jscript = '';
   
     my $totcodes = 0;      my $totcodes = 0;
     my $instcats = &Apache::lonnet::get_dom_instcats($cdom);      $totcodes =
     if (ref($instcats) eq 'HASH') {          &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,
         if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH') &&                                                        $cdom,$totcodes);
             (ref($instcats->{'cat_titles'}) eq 'HASH') && (ref($instcats->{'cat_order'}) eq 'HASH')) {      if ($totcodes > 0) {
             %codes = %{$instcats->{'codes'}};          $format_reply =
             @codetitles = @{$instcats->{'codetitles'}};               &Apache::lonnet::auto_instcode_format($caller,$cdom,\%coursecodes,
             %cat_titles = %{$instcats->{'cat_titles'}};                                  \%codes,\@codetitles,\%cat_titles,\%cat_order);
             %cat_order = %{$instcats->{'cat_order'}};          if ($format_reply eq 'ok') {
             $totcodes = scalar(keys(%codes));  
             my $numtypes = @codetitles;              my $numtypes = @codetitles;
             &Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);              &Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
             my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);              my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);
Line 4105  sub print_first_users_upload_form { Line 4105  sub print_first_users_upload_form {
            .&Apache::lonhtmlcommon::end_pick_box();             .&Apache::lonhtmlcommon::end_pick_box();
   
     $str .= '<p>'      $str .= '<p>'
            .'<input type="button" name="fileupload" value="'.&mt('Next').'"'             .'<input type="submit" name="fileupload" value="'.&mt('Next').'"'
            .' onclick="javascript:checkUpload(this.form);" />'             .' onclick="javascript:checkUpload(this.form);" />'
            .'</p>';             .'</p>';
   
Line 4146  sub upfile_drop_add { Line 4146  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);
     if ($context eq 'domain') {      if ($context eq 'domain') {
         $setting = $env{'form.roleaction'};          $setting = $env{'form.roleaction'};
     }      }
     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'};
     } 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'};
         }          }
     }      }
     my ($startdate,$enddate) = &get_dates_from_form();      my ($startdate,$enddate) = &get_dates_from_form();
Line 4167  sub upfile_drop_add { Line 4169  sub upfile_drop_add {
     my $defdom=$env{'request.role.domain'};      my $defdom=$env{'request.role.domain'};
     my $domain;      my $domain;
     if ($env{'form.defaultdomain'} ne '') {      if ($env{'form.defaultdomain'} ne '') {
         $domain = $env{'form.defaultdomain'};          if (($context eq 'course') || ($setting eq 'course')) {
               if ($env{'form.defaultdomain'} eq $crsdom) {
                   $domain = $env{'form.defaultdomain'};
               } else {
                   if (&Apache::lonnet::will_trust('enroll',$crsdom,$env{'form.defaultdomain'})) {
                       $domain = $env{'form.defaultdomain'};
                   } else {
                       $r->print('<span class="LC_error">'.&mt('Error').': '.
                                 &mt('Enrollment of users not permitted for specified default domain: [_1].',
                                     &Apache::lonnet::domain($env{'form.defaultdomain'},'description')).'</span>');
                       return;
                   }
               }
           } elsif ($context eq 'author') {
               if ($env{'form.defaultdomain'} eq $defdom) {
                   $domain = $env{'form.defaultdomain'}; 
               } else {
                   if ((&Apache::lonnet::will_trust('othcoau',$defdom,$env{'form.defaultdomain'})) &&
                       (&Apache::lonnet::will_trust('coaurem',$env{'form.defaultdomain'},$defdom))) {
                       $domain = $env{'form.defaultdomain'};
                   } else {
                       $r->print('<span class="LC_error">'.&mt('Error').': '.
                                 &mt('Addition of users not permitted for specified default domain: [_1].',
                                     &Apache::lonnet::domain($env{'form.defaultdomain'},'description')).'</span>');
                       return;
                   }
               }
           } elsif (($context eq 'domain') && ($setting eq 'domain')) {
               if ($env{'form.defaultdomain'} eq $defdom) {
                   $domain = $env{'form.defaultdomain'};
               } else {
                   if (&Apache::lonnet::will_trust('domroles',$defdom,$env{'form.defaultdomain'})) {
                       $domain = $env{'form.defaultdomain'};
                   } else {
                       $r->print('<span class="LC_error">'.&mt('Error').': '.
                                 &mt('Addition of users not permitted for specified default domain: [_1].',
                                     &Apache::lonnet::domain($env{'form.defaultdomain'},'description')).'</span>');
                       return;
                   }
               }
           }
     } else {      } else {
         $domain = $defdom;          $domain = $defdom;
     }      }
Line 4177  sub upfile_drop_add { Line 4219  sub upfile_drop_add {
     } else {      } else {
         my %home_servers = &Apache::lonnet::get_servers($defdom,'library');          my %home_servers = &Apache::lonnet::get_servers($defdom,'library');
         if (! exists($home_servers{$desiredhost})) {          if (! exists($home_servers{$desiredhost})) {
             $r->print('<p class="LC_error">'.&mt('Error').': '.              $r->print('<span class="LC_error">'.&mt('Error').': '.
                       &mt('Invalid home server specified').'</p>');                        &mt('Invalid home server specified').'</span>');
             $r->print(&Apache::loncommon::end_page());              return;
             return 'invalidhome';  
         }          }
     }      }
     # Determine authentication mechanism      # Determine authentication mechanism
Line 4207  sub upfile_drop_add { Line 4248  sub upfile_drop_add {
     }      }
     if ($amode =~ /^krb/) {      if ($amode =~ /^krb/) {
         if (! defined($genpwd) || $genpwd eq '') {          if (! defined($genpwd) || $genpwd eq '') {
             $r->print('<span class="Error">'.              $r->print('<span class="Error">'.': '.
                       &mt('Unable to enroll users').' '.                        &mt('Unable to enroll users').' '.
                       &mt('No Kerberos domain was specified.').'</span></p>');                        &mt('No Kerberos domain was specified.').'</span></p>');
             $amode = ''; # This causes the loop below to be skipped              $amode = ''; # This causes the loop below to be skipped
Line 4280  sub upfile_drop_add { Line 4321  sub upfile_drop_add {
             }              }
         }          }
     }      }
     if ($datatoken eq '') {  
         $r->print('<p class="LC_error">'.&mt('Error').': '.  
                   &mt('Invalid datatoken').'</p>');  
         return 'missingdata';  
     }  
     if ( $domain eq &LONCAPA::clean_domain($domain)      if ( $domain eq &LONCAPA::clean_domain($domain)
         && ($amode ne '')) {          && ($amode ne '')) {
         #######################################          #######################################
Line 4356  sub upfile_drop_add { Line 4392  sub upfile_drop_add {
         # Get new users list          # Get new users list
         my (%existinguser,%userinfo,%disallow,%rulematch,%inst_results,%alerts,%checkuname);          my (%existinguser,%userinfo,%disallow,%rulematch,%inst_results,%alerts,%checkuname);
         my $counter = -1;          my $counter = -1;
           my (%willtrust,%trustchecked);
         foreach my $line (@userdata) {          foreach my $line (@userdata) {
             $counter ++;              $counter ++;
             my @secs;              my @secs;
Line 4403  sub upfile_drop_add { Line 4440  sub upfile_drop_add {
                                 '"<b>'.$entries{$fields{'domain'}}.'</b>"',                                  '"<b>'.$entries{$fields{'domain'}}.'</b>"',
                                 $fname,$mname,$lname,$gen);                                  $fname,$mname,$lname,$gen);
                         next;                          next;
                       } elsif ($entries{$fields{'domain'}} ne $domain) {
                           my $possdom = $entries{$fields{'domain'}};
                           if ($context eq 'course' || $setting eq 'course') {
                               unless ($trustchecked{$possdom}) {
                                   $willtrust{$possdom} = &Apache::lonnet::will_trust('enroll',$domain,$possdom);
                                   $trustchecked{$possdom} = 1;
                               }
                           } elsif ($context eq 'author') {
                               unless ($trustchecked{$possdom}) {
                                   $willtrust{$possdom} = &Apache::lonnet::will_trust('othcoau',$domain,$possdom);
                               }
                               if ($willtrust{$possdom}) {
                                   $willtrust{$possdom} = &Apache::lonnet::will_trust('coaurem',$possdom,$domain); 
                               }
                           }
                           unless ($willtrust{$possdom}) {
                               $disallow{$counter} =
                                   &mt('Unacceptable domain [_1] for user [_2] [_3] [_4] [_5]',
                                       '"<b>'.$possdom.'</b>"',
                                       $fname,$mname,$lname,$gen);
                               next;
                           }
                     }                      }
                     my $username = $entries{$fields{'username'}};                      my $username = $entries{$fields{'username'}};
                     my $userdomain = $entries{$fields{'domain'}};                      my $userdomain = $entries{$fields{'domain'}};
Line 4875  sub upfile_drop_add { Line 4934  sub upfile_drop_add {
             }              }
         }          }
     } # end of unless      } # end of unless
     return 'ok';  
 }  }
   
 sub print_namespacing_alerts {  sub print_namespacing_alerts {

Removed from v.1.184.4.3  
changed lines
  Added in v.1.192


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