Diff for /loncom/interface/lonsupportreq.pm between versions 1.79.2.10 and 1.106

version 1.79.2.10, 2022/01/19 13:57:19 version 1.106, 2024/07/15 17:12:40
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 406  ENDJS Line 404  ENDJS
             }              }
         }          }
     }      }
     unless ($helpform{'user'} eq 'no') {      unless (($helpform{'user'} eq 'no') || ($env{'request.lti.login'})) {
         $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'unme'}/$html_lt{'doma'}",undef,$css[$i]);          $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'unme'}/$html_lt{'doma'}",undef,$css[$i]);
         my $udom_input = '<input type="hidden" name="udom" value="'.          my $udom_input = '<input type="hidden" name="udom" value="'.
                          &HTML::Entities::encode($udom,'"<>&').'" />'."\n";                           &HTML::Entities::encode($udom,'"<>&').'" />'."\n";
Line 443  ENDJS Line 441  ENDJS
         }          }
         $output .= &Apache::lonhtmlcommon::row_closure();          $output .= &Apache::lonhtmlcommon::row_closure();
         $num ++;          $num ++;
           $i = $num%2;
       }
       unless ($env{'request.lti.login'}) {
           $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'urlp'}",undef,$css[$i]).
                      $server."\n".'<input type="hidden" name="sourceurl" value="'.
                      &HTML::Entities::encode($sourceurl,'"<>&').'" />'."\n".
                      &Apache::lonhtmlcommon::row_closure();
     }      }
     $i = $num%2;  
     $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'urlp'}",undef,$css[$i]).  
                $server."\n".'<input type="hidden" name="sourceurl" value="'.  
                &HTML::Entities::encode($sourceurl,'"<>&').'" />'."\n".  
                &Apache::lonhtmlcommon::row_closure();  
     unless ($helpform{'phone'} eq 'no') {      unless ($helpform{'phone'} eq 'no') {
         my $reqd;          my $reqd;
         if ($helpform{'phone'} eq 'req') {          if ($helpform{'phone'} eq 'req') {
Line 460  ENDJS Line 460  ENDJS
         $num ++;          $num ++;
         $i = $num%2;          $i = $num%2;
     }      }
     unless ($helpform{'course'} eq 'no') {      unless (($helpform{'course'} eq 'no') || ($env{'request.lti.login'})) {
         $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'crsd'}$details_title",undef,$css[$i]);          $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'crsd'}$details_title",undef,$css[$i]);
         if ($totcodes > 0) {          if ($totcodes > 0) {
             my $numtitles = @codetitles;              my $numtitles = @codetitles;
             if ($numtitles == 0) {              if ($numtitles == 0) {
                 $output .= $html_lt{'enin'}.':&nbsp;                  $output .= $html_lt{'enin'}.':&nbsp;
                   <input type="text" name="coursecode" size="15" value="" />'."\n";                    <input type="text" name="coursecode" size="15" value="'.&HTML::Entities::encode($ccode,'\'"&<>').'" />'."\n";
             } else {              } else {
                 my @standardnames = &Apache::loncommon::get_standard_codeitems();                  my @standardnames = &Apache::loncommon::get_standard_codeitems();
                 my $lasttitle = $numtitles;                  my $lasttitle = $numtitles;
Line 535  ENDJS Line 535  ENDJS
         $num ++;          $num ++;
         $i = $num%2;          $i = $num%2;
     }      }
     unless ($helpform{'section'} eq 'no') {      unless (($helpform{'section'} eq 'no') || ($env{'request.lti.login'})) {
         $output .= &Apache::lonhtmlcommon::row_title($html_lt{'secn'},undef,$css[$i]);          $output .= &Apache::lonhtmlcommon::row_title($html_lt{'secn'},undef,$css[$i]);
         if ($sectionlist) {          if ($sectionlist) {
             $output .= "<div id=\"LC_helpdesk_sectionlist\"><select name=\"sectionsel\">\n".              $output .= "<div id=\"LC_helpdesk_sectionlist\"><select name=\"sectionsel\">\n".
Line 710  sub print_request_receipt { Line 710  sub print_request_receipt {
     unless ($helpform{'phone'} eq 'no') {      unless ($helpform{'phone'} eq 'no') {
         $formvars{'phone'} = 1;          $formvars{'phone'} = 1;
     }      }
     unless ($helpform{'section'} eq 'no') {      unless (($helpform{'section'} eq 'no') || ($env{'request.lti.login'})) {
         $formvars{'section'} = 1;          $formvars{'section'} = 1;
     }      }
     unless ($helpform{'course'} eq 'no') {      unless (($helpform{'course'} eq 'no') || ($env{'request.lti.login'})) {
         $formvars{'course'} = 1;          $formvars{'course'} = 1;
     }      }
     unless (($helpform{'cc'} eq 'no') || ($by_ip)) {      unless (($helpform{'cc'} eq 'no') || ($by_ip)) {
Line 722  sub print_request_receipt { Line 722  sub print_request_receipt {
     unless ($helpform{'screenshot'} eq 'no') {      unless ($helpform{'screenshot'} eq 'no') {
         $formvars{'screenshot'} = 1;          $formvars{'screenshot'} = 1;
     }      }
     my $coursecode;      my ($coursecode,$sourceurl);
     if ($formvars{'course'}) {      if ($formvars{'course'}) {
         $coursecode = $env{'form.coursecode'};          $coursecode = $env{'form.coursecode'};
         if ($coursecode eq '') {          if ($coursecode eq '') {
Line 762  sub print_request_receipt { Line 762  sub print_request_receipt {
                  secn        => 'Section',                   secn        => 'Section',
                  warn        => 'Warning: Problem with support e-mail address',                   warn        => 'Warning: Problem with support e-mail address',
                  your        => 'Your support request contained the following information',                   your        => 'Your support request contained the following information',
                    belo        => 'Below is your support request which could not be sent',
                    ifyk        => 'If you know an IT support address for your institution, you could copy this information and send it to that email address.',
                  sect        => 'section',                   sect        => 'section',
                  info        => 'Information supplied',                   info        => 'Information supplied',
                  adin        => 'Additional information recorded',                   adin        => 'Additional information recorded',
Line 820  sub print_request_receipt { Line 822  sub print_request_receipt {
             $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: '). &Apache::loncommon::cleanup_html(join(', ',@bad_ccs));              $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: '). &Apache::loncommon::cleanup_html(join(', ',@bad_ccs));
         }          }
     }      }
     $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";      if ($env{'request.lti.login'}) {
           if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
               $env{'form.user'} = "'".$env{'user.name'}.':'.$env{'user.domain'}."'";
           }
           $sourceurl = &Apache::lonnet::absolute_url().$url;
       } else {
           $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";
           $sourceurl = $env{'form.sourceurl'};
       }
     if ($formvars{'course'}) {      if ($formvars{'course'}) {
         $env{'form.crsi'} = $env{'form.title'};          $env{'form.crsi'} = $env{'form.title'};
         if ($coursecode ne '') {          if ($coursecode ne '') {
Line 859  sub print_request_receipt { Line 869  sub print_request_receipt {
     }      }
     $supportmsg .= "$lt{'subject'}: $env{'form.subject'}      $supportmsg .= "$lt{'subject'}: $env{'form.subject'}
 $lt{'description'}: $env{'form.description'}  $lt{'description'}: $env{'form.description'}
 $lt{'sourceurl'}: $env{'form.sourceurl'}  $lt{'sourceurl'}: $sourceurl
 $lt{'date'}: $reporttime  $lt{'date'}: $reporttime
 ";  ";
   
Line 893  $lt{'date'}: $reporttime Line 903  $lt{'date'}: $reporttime
                     next if ($helpform{$item} eq 'no');                      next if ($helpform{$item} eq 'no');
                 }                  }
                 next if (($item eq 'crsi') && ($helpform{'course'} eq 'no'));                  next if (($item eq 'crsi') && ($helpform{'course'} eq 'no'));
                   next if (($item eq 'user') && ($env{'request.lti.login'}));
                 my $showitem = $env{'form.'.$item};                  my $showitem = $env{'form.'.$item};
                 $showitem = &Apache::loncommon::cleanup_html($showitem);                  $showitem = &Apache::loncommon::cleanup_html($showitem);
                 $displaymsg .=                   $displaymsg .= 
Line 981  END Line 992  END
   
     my $message;      my $message;
     if (!$bad_email) {      if (!$bad_email) {
         $message = &Apache::lonhtmlcommon::confirm_success(          $message = &mt('A support request has been sent to [_1]','<tt>'.$to.'</tt>');
             &mt('A support request has been sent to [_1]','<tt>'.$to.'</tt>'));  
     } else {      } else {
         $message = &Apache::lonhtmlcommon::confirm_success(          $message = $lt{'warn'}.'<br />';
             $lt{'warn'}.'<br />'          if ($to eq '') {
            .&mt('As the e-mail address provided for this LON-CAPA server ([_1]) does not appear to be a valid e-mail address, your support request has [_2]not[_3] been sent to the LON-CAPA support staff or administrator at your institution.','<tt>'.$to.'</tt>','<b>','</b>')              $message .= &mt('For this LON-CAPA server no e-mail address has been configured to receive support requests, so your support request has [_1]not[_2] been sent to the LON-CAPA support staff or administrator at your institution.','<b>','</b>');
            .' '.&mt('Instead a copy has been sent to the LON-CAPA support team at Michigan State University.'),1);           } else {
         $to = 'helpdesk@lon-capa.org';              $message .= &mt('As the e-mail address provided for this LON-CAPA server ([_1]) does not appear to be a valid e-mail address, your support request has [_2]not[_3] been sent to the LON-CAPA support staff or administrator at your institution.','<tt>'.$to.'</tt>','<b>','</b>');
           }
     }      }
     $r->print(&Apache::loncommon::confirmwrapper($message));      $r->print(&Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($message,$bad_email)));
   
     if ($reqemail ne '') {      if ($reqemail ne '') {
         $from = $reqemail;          $from = $reqemail;
Line 1045  END Line 1056  END
     if ($$cookie{'lonLinkID'} =~ /lonLinkID=([a-f0-9]+_linked);/) {      if ($$cookie{'lonLinkID'} =~ /lonLinkID=([a-f0-9]+_linked);/) {
         $cookies{'lonLinkID'} = $1;          $cookies{'lonLinkID'} = $1;
     }      }
       my $lti_info;
       if (($env{'request.lti.login'}) && ($env{'request.course.id'})) {
           my $ltidom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           if ($ltidom) {
               my %lti = &Apache::lonnet::get_domain_lti($ltidom,'provider');
               if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
                   if ($lti{$env{'request.lti.login'}}{'consumer'}) {
                       $lti_info = "LTI consumer: ".$lti{$env{'request.lti.login'}}{'consumer'}."\n";
                   }
               }
           }
       }
     if ($attachmentpath =~ m-/([^/]+)$-) {      if ($attachmentpath =~ m-/([^/]+)$-) {
         $fname = $1;          $fname = $1;
         $displaymsg .= '<br />'          $displaymsg .= '<br />'
Line 1063  END Line 1086  END
         foreach my $var (@envvars) {          foreach my $var (@envvars) {
             $supportmsg .= "$var: $env{$var}\n";              $supportmsg .= "$var: $env{$var}\n";
         }          }
           if ($lti_info) {
               $supportmsg .= $lti_info;
           }
     }      }
   
     my $cc_string;      my $cc_string;
Line 1087  END Line 1113  END
         foreach my $var (@loncvars) {          foreach my $var (@loncvars) {
             $attachment_text .= "$var: $env{$var}\n";              $attachment_text .= "$var: $env{$var}\n";
         }          }
           if ($lti_info) {
               $attachment_text .= $lti_info;
           }
     }      }
   
     if ($addtext) {      if ($addtext) {
Line 1099  END Line 1128  END
         }          }
     }      }
   
     my $msg = MIME::Lite->new(      if ($bad_email) {
                  From    => $from,          $r->print('<b>'.$lt{'belo'}.'</b><br />'.
                  To      => $to,                    $lt{'ifyk'}.'<br /><br />'."\n");
                  Subject => $subject,      } else {
                  Type    =>'TEXT',          # Compose and send a MIME email
                  Data    => $supportmsg,          &Apache::loncommon::mime_email($from,'',$to,$subject,$supportmsg,$cc_string,
                  );                                         $bcc,$attachmentpath,$fname,$attachment_text);
     if ($homeserver) {          $r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n");
         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);
     }      }
     $r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n");  
     $r->print('<div style="width:620px;">'.      $r->print('<div style="width:620px;">'.
               &Apache::lonhtmlcommon::start_pick_box().                &Apache::lonhtmlcommon::start_pick_box().
               &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n".                &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n".

Removed from v.1.79.2.10  
changed lines
  Added in v.1.106


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