Diff for /loncom/interface/loncommon.pm between versions 1.1287 and 1.1291

version 1.1287, 2017/08/07 20:22:13 version 1.1291, 2017/08/11 19:27:35
Line 2477  sub create_text_file { Line 2477  sub create_text_file {
 # ------------------------------------------  # ------------------------------------------
   
 sub domain_select {  sub domain_select {
     my ($name,$value,$multiple)=@_;      my ($name,$value,$multiple,$incdoms,$excdoms)=@_;
       my @possdoms;
       if (ref($incdoms) eq 'ARRAY') {
           @possdoms = @{$incdoms};
       } else {
           @possdoms = &Apache::lonnet::all_domains();
       }
   
     my %domains=map {       my %domains=map { 
  $_ => $_.' '. &Apache::lonnet::domain($_,'description')    $_ => $_.' '. &Apache::lonnet::domain($_,'description') 
     } &Apache::lonnet::all_domains();      } @possdoms;
   
       if ((ref($excdoms) eq 'ARRAY') && (@{$excdoms} > 0)) {
           foreach my $dom (@{$excdoms}) {
               delete($domains{$dom});
           }
       }
   
     if ($multiple) {      if ($multiple) {
  $domains{''}=&mt('Any domain');   $domains{''}=&mt('Any domain');
  $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))];   $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))];
Line 10138  sub user_picker { Line 10152  sub user_picker {
         $domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,[$currdom]);          $domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,[$currdom]);
     } else {      } else {
         my $defdom = $env{'request.role.domain'};          my $defdom = $env{'request.role.domain'};
         my ($trustedref,$untrustedref);          my ($trusted,$untrusted);
         if (($context eq 'requestcrs') || ($context eq 'course')) {          if (($context eq 'requestcrs') || ($context eq 'course')) {
             ($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('enroll',$defdom);              ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$defdom);
         } elsif ($context eq 'author') {          } elsif ($context eq 'author') {
             ($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('othcoau',$defdom);              ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('othcoau',$defdom);
         } elsif ($context eq 'domain') {          } elsif ($context eq 'domain') {
             ($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('domroles',$defdom);              ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('domroles',$defdom);
         }          }
         $domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,$trustedref,$untrustedref);          $domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,$trusted,$untrusted);
     }      }
     my $srchinsel = ' <select name="srchin">';      my $srchinsel = ' <select name="srchin">';
   
Line 13656  sub upfile_store { Line 13670  sub upfile_store {
   
 =pod  =pod
   
 =item * &load_tmp_file($r)  =item * &load_tmp_file($r,$datatoken)
   
 Load uploaded file from tmp, $r should be the HTTP Request object,  Load uploaded file from tmp, $r should be the HTTP Request object,
 needs $env{'form.datatoken'},  $datatoken is the name to assign to the temporary file.
 sets $env{'form.upfile'} to the contents of the file  sets $env{'form.upfile'} to the contents of the file
   
 =cut  =cut
   
 sub load_tmp_file {  sub load_tmp_file {
     my $r=shift;      my ($r,$datatoken) = @_;
       return if ($datatoken eq '');
     my @studentdata=();      my @studentdata=();
     {      {
         my $studentfile = $r->dir_config('lonDaemons').          my $studentfile = $r->dir_config('lonDaemons').
                               '/tmp/'.$env{'form.datatoken'}.'.tmp';                                '/tmp/'.$datatoken.'.tmp';
         if ( open(my $fh,"<$studentfile") ) {          if ( open(my $fh,"<$studentfile") ) {
             @studentdata=<$fh>;              @studentdata=<$fh>;
             close($fh);              close($fh);
Line 13678  sub load_tmp_file { Line 13693  sub load_tmp_file {
     $env{'form.upfile'}=join('',@studentdata);      $env{'form.upfile'}=join('',@studentdata);
 }  }
   
   sub valid_datatoken {
       my ($datatoken) = @_;
       if ($datatoken =~ /^$match_username\_$match_domain\_enroll_$match_domain\_$match_courseid\_\d+_\d+$/) {
           return $datatoken;
       }
       return;
   }
   
 =pod  =pod
   
 =item * &upfile_record_sep()  =item * &upfile_record_sep()

Removed from v.1.1287  
changed lines
  Added in v.1.1291


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