Diff for /loncom/interface/lonsupportreq.pm between versions 1.79.2.3.2.1 and 1.89

version 1.79.2.3.2.1, 2017/10/15 03:43:52 version 1.89, 2017/01/23 19:49:07
Line 29 Line 29
 package Apache::lonsupportreq;  package Apache::lonsupportreq;
   
 use strict;  use strict;
 use MIME::Types;  
 use MIME::Lite;  
 use CGI::Cookie();  use CGI::Cookie();
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::loncommon();  use Apache::loncommon();
Line 315  $jscript Line 313  $jscript
 $loaditems  $loaditems
 // ]]>  // ]]>
 </script>  </script>
   <script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>
 ENDJS  ENDJS
     if ($recaptcha_version >=2) {      if ($recaptcha_version >=2) {
         $js.= "\n".'<script src="https://www.google.com/recaptcha/api.js"></script>'."\n";          $js.= "\n".'<script src="https://www.google.com/recaptcha/api.js"></script>'."\n";
Line 574  ENDJS Line 573  ENDJS
                     $showmax = $helpform{'maxsize'};                      $showmax = $helpform{'maxsize'};
                 }                  }
                 $showmax = ' ('.sprintf("%.2f",$showmax).' '.&mt('MB max.').')';                  $showmax = ' ('.sprintf("%.2f",$showmax).' '.&mt('MB max.').')';
                 $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i]).                  $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i])
                        ' <input type="file" name="screenshot" size="20" /><br />'.                      .' <input type="file" name="screenshot" class="flUpload" size="20" />'
                        "\n".$html_lt{'uplf'}.$showmax."\n".                      .'<input type="hidden" id="free_space" value="'.$max.'" />'
                        &Apache::lonhtmlcommon::row_closure();                      .'<br />'."\n".$html_lt{'uplf'}.$showmax."\n"
                       .&Apache::lonhtmlcommon::row_closure();
                 $num ++;                  $num ++;
                 $i = $num%2;                  $i = $num%2;
             }              }
Line 662  sub print_request_receipt { Line 662  sub print_request_receipt {
     my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};      my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
     my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};      my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
     my $defdom = &get_domain();      my $defdom = &get_domain();
       my ($to,$bcc,$addtext) =
           &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
                                                    $defdom,$origmail);
     my $from = $admin;      my $from = $admin;
     my %helpform;      my %helpform;
     my %domconfig =      my %domconfig =
Line 875  $lt{'date'}: $reporttime Line 878  $lt{'date'}: $reporttime
             }              }
         }          }
     }      }
   
     my ($requname,$requdom,$reqemail);  
     foreach my $field ('uname','udom','email') {  
         $env{'form.'.$field} =~ s/^\s+//;  
         $env{'form.'.$field} =~ s/\s+$//;  
     }  
     if ($env{'form.uname'} =~ /^$match_username$/) {  
         $requdom = $env{'form.udom'};  
     }  
     if ($env{'form.udom'} =~ /^$match_domain$/) {  
         $requdom = $env{'form.udom'};  
     }  
     if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {  
         $reqemail = $env{'form.email'};  
     }  
   
     my $dom_in_effect;  
     unless ($env{'user.domain'} eq 'public') {  
         $dom_in_effect = $env{'user.domain'};  
     }  
     if ($dom_in_effect eq '') {  
         $dom_in_effect = $requdom;  
     }  
     if ($dom_in_effect eq '') {  
         $dom_in_effect = $defdom;  
     }  
   
     $displaymsg .= '<span class="LC_helpform_receipt_cat">'.      $displaymsg .= '<span class="LC_helpform_receipt_cat">'.
                    $lt{'date'}.'</span>: '.$reporttime.'<br />'."\n";                     $lt{'date'}.'</span>: '.$reporttime.'<br />'."\n";
   
Line 924  END Line 900  END
         &print_header($r,$url,'process');          &print_header($r,$url,'process');
     }      }
     my $bad_email = 0;      my $bad_email = 0;
     my ($to,$bcc,$addtext) =  
         &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',  
                                                  $dom_in_effect,$origmail,  
                                                  $requname,$requdom,  
                                                  $reqemail);  
     if ($to =~ /,/) {      if ($to =~ /,/) {
         my @ok_email;           my @ok_email; 
         foreach my $email (split(/,/,$to)) {          foreach my $email (split(/,/,$to)) {
Line 966  END Line 937  END
     }      }
     $r->print(&Apache::loncommon::confirmwrapper($message));      $r->print(&Apache::loncommon::confirmwrapper($message));
   
     if ($reqemail ne '') {      if (defined($env{'form.email'})) {
         $from = $reqemail;          $env{'form.email'} =~ s/^\s+//;
           $env{'form.email'} =~ s/\s+$//;
           if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
               $from = $env{'form.email'};
           }
     }      }
   
     if (defined($env{'form.cc'})) {      if (defined($env{'form.cc'})) {
Line 1043  END Line 1018  END
         }          }
     }      }
   
     my $attachment_text = '';      my $attachment_text;
     unless ($homeserver && $attachmentpath) {      unless ($homeserver && $attachmentpath) {
           my $envdata = '';
         foreach my $var (@cookievars) {          foreach my $var (@cookievars) {
             $attachment_text .= "$var: $cookies{$var}\n";              $envdata .= "$var: $cookies{$var}\n";
         }          }
         foreach my $var (@ENVvars) {          foreach my $var (@ENVvars) {
             $attachment_text .= "$var: $ENV{$var}\n";              $envdata .= "$var: $ENV{$var}\n";
         }          }
         foreach my $var (@envvars) {          foreach my $var (@envvars) {
             $attachment_text .= "$var: $env{$var}\n";              $envdata .= "$var: $env{$var}\n";
         }          }
         foreach my $var (@loncvars) {          foreach my $var (@loncvars) {
             $attachment_text .= "$var: $env{$var}\n";              $envdata .= "$var: $env{$var}\n";
         }          }
           $attachment_text = $envdata;
     }      }
   
     if ($addtext) {      if ($addtext) {
Line 1069  END Line 1046  END
         }          }
     }      }
   
     my $msg = MIME::Lite->new(      # Compose and send a MIME email
                  From    => $from,      &Apache::loncommon::mime_email($from, $to, $subject, $supportmsg, $cc_string, $bcc, 
                  To      => $to,                                      $attachmentpath, $fname, $attachment_text);
                  Subject => $subject,  
                  Type    =>'TEXT',  
                  Data    => $supportmsg,  
                  );  
     if ($homeserver) {  
         if (@ok_ccs > 0) {  
             my $cc_string = join(', ',@ok_ccs);  
             $msg->add("Cc" => $cc_string);  
         }  
     }  
     if ($bcc ne '') {  
         $msg->add("Bcc" => $bcc);  
     }  
     $msg->attr("content-type"         => "text/plain");  
     $msg->attr("content-type.charset" => "UTF-8");  
   
     if ($homeserver && $attachmentpath) {  
         my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);  
         $msg->attach(Type     => $type,  
                      Path     => $attachmentpath,  
                      Filename => $fname  
                      );  
   
     } elsif ($attachment_text ne '') {  
         $msg->attach(Type => 'TEXT',  
                      Data => $attachment_text);  
     }  
   
 ### Send it:  
     $msg->send('sendmail');  
   
     if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) {      if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) {
         unlink($attachmentpath);          unlink($attachmentpath);

Removed from v.1.79.2.3.2.1  
changed lines
  Added in v.1.89


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