Diff for /loncom/interface/lonsupportreq.pm between versions 1.41 and 1.77

version 1.41, 2006/12/21 18:32:54 version 1.77, 2014/01/17 17:17:42
Line 27 Line 27
 package Apache::lonsupportreq;  package Apache::lonsupportreq;
   
 use strict;  use strict;
 use lib qw(/home/httpd/lib/perl);  
 use MIME::Types;  use MIME::Types;
 use MIME::Lite;  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();
   use Apache::lonhtmlcommon;
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonacc();  use Apache::lonacc();
   use Apache::lonauth();
 use Apache::courseclassifier;  use Apache::courseclassifier;
 use LONCAPA;  use LONCAPA qw(:DEFAULT :match);
    use HTML::Entities;
   
 sub handler {  sub handler {
     my ($r) = @_;      my ($r) = @_;
Line 48  sub handler { Line 49  sub handler {
     if ($r->header_only) {      if ($r->header_only) {
         return OK;          return OK;
     }      }
       if ($r->uri eq '/adm/helpdesk') {
    &Apache::lonlocal::get_language_handle($r);
       }
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']);
     if ($r->uri eq '/adm/helpdesk') {      if ($r->uri eq '/adm/helpdesk') {
         &Apache::lonacc::get_posted_cgi($r);          &Apache::lonacc::get_posted_cgi($r);
     }      }
     my $function = $env{'form.function'};      my $function;
     my $origurl = &unescape($env{'form.origurl'});      if ($env{'form.function'}) {
     my $action = $env{'form.action'};          if (($env{'form.function'} eq 'norole')  ||
               ($env{'form.function'} eq 'student') ||
               ($env{'form.function'} eq 'admin')   ||
               ($env{'form.function'} eq 'author')) {
               $function = $env{'form.function'};
           }
       }
       my $origurl = $env{'form.origurl'};
       $origurl =~ s{^https?://}{};
       $origurl =~ s/(`)//g;
       $origurl =~ s/\$/\(\$\)/g;
       my $command = $env{'form.command'};
   
     if ($action eq 'process') {      if ($command eq 'process') {
         &print_request_receipt($r,$origurl,$function);          &print_request_receipt($r,$origurl,$function);
     } else {      } else {
         &print_request_form($r,$origurl,$function);          &print_request_form($r,$origurl,$function);
Line 66  sub handler { Line 82  sub handler {
           
 sub print_request_form {  sub print_request_form {
     my ($r,$origurl,$function) = @_;      my ($r,$origurl,$function) = @_;
     my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,$formname);      my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,
     my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');          $cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,
     if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {          $formname,$public,$homeserver);
         $tablecolor = '#EEEE99';      $function = &Apache::loncommon::get_users_function() if (!$function);
     }  
     $ccode = '';      $ccode = '';
     $os = $env{'browser.os'};      $os = $env{'browser.os'};
     $browser = $env{'browser.type'};      $browser = $env{'browser.type'};
     $bversion = $env{'browser.version'};      $bversion = $env{'browser.version'};
     $uhost = $env{'request.host'};      $uhost = $env{'request.host'};
     $uname = $env{'user.name'};      if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
     $udom = $env{'user.domain'};          $public = 1;
     $uhome = $env{'user.home'};  
     $urole = $env{'request.role'};  
     $usec = $env{'request.course.sec'};  
     $cid = $env{'request.course.id'};  
     $formname = 'logproblem';  
     my $machine = &Apache::lonnet::absolute_url();  
     if ($origurl =~ m-^https?://-) {  
         $server = $origurl;  
     } else {      } else {
         $server = $machine.$origurl;          if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
               $homeserver = &Apache::lonnet::homeserver($env{'user.name'},
                                                         $env{'user.domain'});
               if ($homeserver eq 'no_host') {
                   undef($homeserver); 
               } else {
                   $uname = $env{'user.name'};
                   $udom = $env{'user.domain'};
               }
           }
     }      }
       if ($homeserver) {
           $uhome = $env{'user.home'};
           $urole = $env{'request.role'};
           $usec = $env{'request.course.sec'};
           $cid = $env{'request.course.id'};
       }
       $formname = 'logproblem';
       my $machine = &Apache::lonnet::absolute_url();
       my $sourceurl = $machine.$origurl;
       $server = $machine.&Apache::loncommon::cleanup_html($origurl);
       $server =~ s/\?.*$//;
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                   email => 'The e-mail address you entered',                    email => 'The e-mail address you entered',
                   notv => 'is not a valid e-mail address',                    notv => 'is not a valid e-mail address',
Line 96  sub print_request_form { Line 123  sub print_request_form {
                   rdes => 'You must include a description',                    rdes => 'You must include a description',
                   name => 'Name',                    name => 'Name',
                   subm => 'Submit Request',                    subm => 'Submit Request',
                   emad => 'E-mail address',                    emad => 'Your e-mail address',
                     emac => 'Cc', 
                   unme => 'username',                    unme => 'username',
                   doma => 'domain',                    doma => 'domain',
                   entr => 'Enter the username you use to log-in to your LON-CAPA system, and choose your domain.',                    entu => 'Enter the username you use to log-in to LON-CAPA',
                     chdo => 'Choose your LON-CAPA domain',
                     entr => 'Enter the username you use to log-in to LON-CAPA, and your domain.',
                   urlp => 'URL of page',                    urlp => 'URL of page',
                   phon => 'Phone',                    phon => 'Phone',
                   crsd => 'Course Details',                    crsd => 'Course Details',
Line 113  sub print_request_form { Line 143  sub print_request_form {
                   subj => 'Subject',                    subj => 'Subject',
                   detd => 'Detailed Description',                    detd => 'Detailed Description',
                   opfi => 'Optional file upload',                    opfi => 'Optional file upload',
                   uplf => 'Upload a file (e.g., a screenshot) relevant to your support request (128 KB max. size)',                    uplf => 'Upload a file (e.g., a screenshot) relevant to your help request (128 KB max.)',
                   fini => 'Finish',                    fini => 'Finish',
                   clfm => 'Clear Form',                    clfm => 'Clear Form',
     );      );
Line 135  function validate() { Line 165  function validate() {
 }  }
   
 END  END
     $scripttag .= <<'END';      $scripttag .= &Apache::lonhtmlcommon::javascript_valid_email();
 function validmail(field) {      if ($cid) {
     var str = field.value;          $cdom = $env{'course.'.$cid.'.domain'};
     if (window.RegExp) {          $cnum = $env{'course.'.$cid.'.num'};
         var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";  
         var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"  
         var reg1 = new RegExp(reg1str);  
         var reg2 = new RegExp(reg2str);  
         if (!reg1.test(str) && reg2.test(str)) {  
             return true;  
         }  
         return false;  
     }  
     else  
     {  
         if(str.indexOf("@") >= 0) {  
             return true;  
         }  
         return false;  
     }  
 }  
 END  
   
     if ($cid =~ m/_/) {  
         ($cdom,$cnum) = split(/_/,$cid);  
     }      }
     if ($cdom && $cnum) {      if ($cdom && $cnum) {
         my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);          my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);
Line 167  END Line 176  END
         $ccode = $csettings{'internal.coursecode'};          $ccode = $csettings{'internal.coursecode'};
         $sectionlist = $csettings{'internal.sectionnums'};          $sectionlist = $csettings{'internal.sectionnums'};
     }      }
     if ($env{'environment.critnotification'}) {  
         $email = $env{'environment.critnotification'};      if ($homeserver) {
     }          if ($env{'environment.permanentemail'}) {
     if (!$email && $env{'environment.notification'}) {              $email = $env{'environment.permanentemail'};
         $email = $env{'environment.notification'};          } elsif ($env{'environment.critnotification'}) {
     }              $email = $env{'environment.critnotification'};
     if ($env{'environment.lastname'}) {          } elsif ($env{'environment.notification'}) {
         $lastname = $env{'environment.lastname'};              $email = $env{'environment.notification'};
     }          }
     if ($env{'environment.firstname'}) {          if ($env{'environment.lastname'}) {
         $firstname = $env{'environment.firstname'};              $lastname = $env{'environment.lastname'};
           }
           if ($env{'environment.firstname'}) {
               $firstname = $env{'environment.firstname'};
           }
     }      }
     my @sections = split(/,/,$sectionlist);      my @sections = split(/,/,$sectionlist);
     my %groupid;      my %groupid;
Line 185  END Line 198  END
         my ($sec,$grp) = split(/:/,$section);          my ($sec,$grp) = split(/:/,$section);
         $groupid{$sec} = $grp;          $groupid{$sec} = $grp;
     }      }
     my $codedom = $Apache::lonnet::perlvar{'lonDefDomain'};      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom',
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom']);                                                   'useremail','useraccount']);
     if (exists($env{'form.codedom'})) {      if ($env{'form.origurl'} eq '/adm/createaccount') {
         $codedom = $env{'form.codedom'};          if ($email eq '') {
               if ($env{'form.useremail'} =~ /^[^\@]+\@[^\@]+$/) {
                   $email = &HTML::Entities::encode($env{'form.useremail'},'"<>&');
               }
           }
           if ($uname eq '') {
               if ($env{'form.useraccount'} =~ /^$match_username$/) {
                   $uname = &HTML::Entities::encode($env{'form.useraccount'},'"<>&');
               }
           }
     }      }
       my $codedom = &get_domain();
     my $details_title;      my $details_title;
     if ($codedom) {      if ($codedom) {
         $details_title = '<br />('.$codedom.')';          $details_title = '<br />('.$codedom.')';
Line 211  function initialize_codes() { Line 234  function initialize_codes() {
     return;      return;
 }  }
     |;      |;
     if ($cdom) {  
         $codedom = $cdom;  
     }  
     if ($cnum) {      if ($cnum) {
         $coursecodes{$cnum} = $ccode;          $coursecodes{$cnum} = $ccode;
         if ($ccode eq '') {          if ($ccode eq '') {
Line 243  function initialize_codes() { Line 263  function initialize_codes() {
         }          }
     }      }
   
     my $js = '<script type"text/javascript">'."\n$scripttag\n$jscript\n".      my $js = <<"ENDJS";
  '</script>';  <script type="text/javascript">
     my %add_entries = (topmargin    => "0",  // <![CDATA[
        marginheight => "0",  $scripttag
        onLoad       =>"initialize_codes()",);  $jscript
   $loaditems
   // ]]>
   </script>
   ENDJS
       my %add_entries = (
                          style    => "margin-top:0px;margin-bottom:0px;",
                          onload   => "initialize_codes();",
                         );
   
     my $start_page =      
  &Apache::loncommon::start_page('Support Request',$js,      $r->print(&Apache::loncommon::start_page('Support Request',$js,
        { 'function'    => $function,         { 'function'    => $function,
  'add_entries' => \%add_entries,   'add_entries' => \%add_entries,
  'only_body'   => 1,});   'only_body'   => 1,}));
     $r->print($start_page);  
   
     if ($r->uri eq '/adm/helpdesk') {      if ($r->uri eq '/adm/helpdesk') {
         &print_header($r,$origurl);          &print_header($r,$origurl);
     }      }
     $r->print(<<"END");      my @css = ('LC_evenrow_value','LC_oddrow_value');
 <form method="post" name="logproblem" enctype="multipart/form-data">      my $num = 1;
  <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">      my $i = $num%2;
   <tr>      my $formtype;
    <td>      if ($homeserver) {
     <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">          $formtype = ' enctype="multipart/form-data"';
      <tr>      }
       <td>      $r->print('<form method="post" action="" name="logproblem"'.$formtype.'>'."\n");
        <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">      my $output = &Apache::lonhtmlcommon::start_pick_box().
         <tr>  #                 &Apache::lonhtmlcommon::row_headline().
          <td>  #                 '<span class="LC_info">'.
   <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">  #                 &mt('(All fields marked with * are required.)').
            <tr>  #                 '</span>'.
             <td width="140" bgcolor="$tablecolor">  #                 &Apache::lonhtmlcommon::row_closure().
              <table width="140" border="0" cellpadding="8" cellspacing="0">                   &Apache::lonhtmlcommon::row_title($lt{'name'},undef,$css[$num])."\n";
               <tr>  
                <td align="right"><b>$lt{'name'}:</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
 END  
     my $fullname = '';      my $fullname = '';
     if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) {      if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) {
         $fullname = "$firstname $lastname";           $fullname = "$firstname $lastname"; 
         $r->print("$fullname<input type=\"hidden\" name=\"username\" value=\"$fullname\" />");          $output .= $fullname.'<input type="hidden" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n";
     } else {      } else {
         if (defined($firstname) && $firstname ne '') {          if (defined($firstname) && $firstname ne '') {
             $fullname = $firstname;              $fullname = $firstname;
         } elsif (defined($lastname) && $lastname ne '') {          } elsif (defined($lastname) && $lastname ne '') {
             $fullname= " $lastname";              $fullname = " $lastname";
         }          }
         $r->print('<input type="text" size="20" name="username" value="'.$fullname.'" />');          $output .= '<input type="text" size="20" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n";
     }      }
     $r->print(<<END);      $output .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="'.$lt{'subm'}.'" onclick="validate()" />&nbsp;'.
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="$lt{'subm'}" onClick="validate()" />&nbsp;                  &Apache::lonhtmlcommon::row_closure()."\n";
                </td>      $num ++;
               </tr>      $i = $num%2;
              </table>      $output .= &Apache::lonhtmlcommon::row_title($lt{'emad'},undef,$css[$i]).
             </td>                 '<input type="text" size="20" name="email" value="'.
            </tr>                 &HTML::Entities::encode($email,'"<>&').'" /><br />'."\n".
            <tr>                 &Apache::lonhtmlcommon::row_closure();
             <td width="100%" colspan="2" bgcolor="#000000">      $num ++;
              <img src="/adm/lonMisc/blackdot.gif" /><br />      $i = $num%2;
             </td>      if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
            </tr>          if ($homeserver) { 
            <tr>              $output .= &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,$css[$i]).
             <td width="140" bgcolor="$tablecolor">                         '<input type="text" size="50" name="cc" value="" /><br />'."\n".
              <table width="140" border="0" cellpadding="8" cellspacing="0">                         &Apache::lonhtmlcommon::row_closure();
               <tr>              $num ++;
                <td align="right"><b>$lt{'emad'}:</b>              $i = $num%2;
                </td>          }
               </tr>      }
              </table>      $output .= &Apache::lonhtmlcommon::row_title("$lt{'unme'}/$lt{'doma'}",undef,$css[$i]);
             </td>      my $udom_input = '<input type="hidden" name="udom" value="'.
             <td width="100%" valign="top">                       &HTML::Entities::encode($udom,'"<>&').'" />'."\n";
              <table width="100%" border="0" cellpadding="8" cellspacing="0">      my $uname_input = '<input type="hidden" name="uname" value="'.
               <tr>                        &HTML::Entities::encode($uname,'"<>&').'" />'."\n"; 
                <td>      if (($env{'user.name'} =~ /^$match_username$/) && 
                 <input type="text" size="20" name="email" value="$email" /><br />          ($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
                </td>          $output .= '<i>'.$lt{'unme'}.'</i>:&nbsp;'.$uname.'&nbsp;&nbsp;<i>'.$lt{'doma'}.'</i>:&nbsp;'.$udom.$udom_input.$uname_input;
               </tr>  
              </table>  
             </td>  
            </tr>  
            <tr>  
             <td width="100%" colspan="2" bgcolor="#000000">  
              <img src="/adm/lonMisc/blackdot.gif" /><br />  
             </td>  
            </tr>  
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>$lt{'unme'}/$lt{'doma'}:</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
 END  
     my $udom_input = '<input type="hidden" name="udom" value="'.$udom.'" />';  
     my $uname_input = '<input type="hidden" name="uname" value="'.$uname.'" />';   
     if (defined($uname) && defined($udom)) {  
         $r->print('<i>'.$lt{'unme'}.'</i>:&nbsp;'.$uname.'&nbsp;&nbsp;<i>'.$lt{'doma'}.'</i>:&nbsp;'.$udom.$udom_input.$uname_input);  
     } else {      } else {
         my $udomform = '';          my $udomform = '';
         my $unameform = '';          my $unameform = '';
         if (defined($udom)) {          if (($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
             $udomform = '<i>'.$lt{'doma'}.'</i>:&nbsp;'.$udom.$udom_input;              $output .= $lt{'entu'};
         } elsif (defined($uname)) {          } elsif (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { 
             $unameform = '<i>'.$lt{'unme'}.'</i>:&nbsp;'.$uname.'&nbsp;&nbsp;'.$uname_input;              $output .= $lt{'chdo'};
           } else {
               $output .= $lt{'entr'};
           }
           $output .= '<br />'."\n";
           if (!$public) {
               if ($env{'user.domain'} =~ /^$match_domain$/) {
                   $udomform = '<i>'.$lt{'doma'}.'</i>:&nbsp;'.$udom.$udom_input;
               } elsif ($env{'user.name'} =~ /^$match_username$/) {
                   $unameform = '<i>'.$lt{'unme'}.'</i>:&nbsp;'.$uname.'&nbsp;&nbsp;'.$uname_input;
               }
         }          }
         if ($udomform eq '') {          if ($udomform eq '') {
             $udomform = '<i>'.$lt{'doma'}.'</i>:&nbsp;';              $udomform = '<i>'.$lt{'doma'}.'</i>:&nbsp;';
             $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom');              $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom')."\n";
         }          }
         if ($unameform eq '') {          if ($unameform eq '') {
             $unameform= '<i>'.$lt{'unme'}.'</i>:&nbsp;<input type="text" size="12" name="uname" value="'.$uname.'" />&nbsp;&nbsp;';              $unameform= '<i>'.$lt{'unme'}.'</i>:&nbsp;<input type="text" size="20" name="uname" value="'.$uname.'" />&nbsp;&nbsp;';
         }          }
         $r->print($unameform.$udomform.'<br />'.$lt{'entr'});          $output .= $unameform.$udomform;
     }      }
     $r->print(<<END);      $output .= &Apache::lonhtmlcommon::row_closure();
                </td>      $num ++;
               </tr>      $i = $num%2;
              </table>      $output .= &Apache::lonhtmlcommon::row_title("$lt{'urlp'}",undef,$css[$i]).
             </td>                 $server."\n".'<input type="hidden" name="sourceurl" value="'.
            </tr>                 &HTML::Entities::encode($sourceurl,'"<>&').'" />'."\n".
            <tr>                 &Apache::lonhtmlcommon::row_closure().
             <td width="100%" colspan="2" bgcolor="#000000">                 &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_evenrow_value').
              <img src="/adm/lonMisc/blackdot.gif" /><br />                 '<input type="text" size="15" name="phone" /><br />'."\n".
             </td>                 &Apache::lonhtmlcommon::row_closure();
            </tr>      $num ++;
            <tr>      $i = $num%2; 
             <td width="140" bgcolor="$tablecolor">      $output .= &Apache::lonhtmlcommon::row_title("$lt{'crsd'}$details_title",undef,$css[$i]);
              <table width="140" border="0" cellpadding="8" cellspacing="0">      if ($cnum) {
               <tr>  
                <td align="right"><b>$lt{'urlp'}:</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
                 $server<input type="hidden" name="sourceurl" value="$server" />  
                </td>  
               </tr>  
              </table>  
             </td>  
            </tr>  
            <tr>  
             <td width="100%" colspan="2" bgcolor="#000000">  
              <img src="/adm/lonMisc/blackdot.gif" /><br />  
             </td>  
            </tr>  
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>$lt{'phon'} #:</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
                 <input type="text" size="15" name="phone"><br>  
                </td>  
               </tr>  
              </table>  
             </td>  
            </tr>  
            <tr>  
             <td width="100%" colspan="2" bgcolor="#000000">  
              <img src="/adm/lonMisc/blackdot.gif" /><br />  
             </td>  
            </tr>  
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>$lt{'crsd'}:</b>$details_title  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table border="0" cellpadding="3" cellspacing="3">  
               <tr>  
                <td>  
 END  
     if ($cnum) {   
         if ($coursecodes{$cnum}) {          if ($coursecodes{$cnum}) {
             foreach my $item (@codetitles) {              foreach my $item (@codetitles) {
                 $r->print('<i>'.$item.'</i>:&nbsp;'.$codes{$cnum}{$item}.';&nbsp;');                  $output .= '<i>'.$item.'</i>:&nbsp;'.$codes{$cnum}{$item}.';&nbsp;';
             }              }
             $r->print('&nbsp;<input type="hidden" name="coursecode" value="'.$coursecodes{$cnum}.'" />');              $output .= '&nbsp;<input type="hidden" name="coursecode" value="'.&HTML::Entities::encode($coursecodes{$cnum},'"<>&').'" />'."\n";
         } else {          } else {
             $r->print($lt{'enin'}.':&nbsp;              $output .= $lt{'enin'}.':&nbsp;
                   <input type="text" name="coursecode" size="15" value="" />');                    <input type="text" name="coursecode" size="15" value="" />'."\n";
         }          }
     } else {      } else {
         if ($totcodes > 0) {          if ($totcodes > 0) {
             my $numtitles = @codetitles;              my $numtitles = @codetitles;
             if ($numtitles == 0) {              if ($numtitles == 0) {
                 $r->print($lt{'enin'}.':&nbsp;                  $output .= $lt{'enin'}.':&nbsp;
                   <input type="text" name="coursecode" size="15" value="" />');                    <input type="text" name="coursecode" size="15" value="" />'."\n";
             } else {              } else {
                   my @standardnames = &Apache::loncommon::get_standard_codeitems();
                 my $lasttitle = $numtitles;                  my $lasttitle = $numtitles;
                 if ($numtitles > 4) {                  if ($numtitles > 4) {
                     $lasttitle = 4;                      $lasttitle = 4;
                 }                   } 
                 $r->print('<table><tr><td>'.$codetitles[0].'<br />'."\n".                  $output .= '<table><tr><td>'.$codetitles[0].'<br />'."\n".
                       '<select name="'.$codetitles[0].'" onChange="courseSet('."'$codetitles[0]'".')">'."\n".                        '<select name="'.$standardnames[0].'" onchange="courseSet('."'$codetitles[0]'".')">'."\n".
                       ' <option value="-1" />'.$lt{'sele'}."\n");                        ' <option value="-1">'.$lt{'sele'}."</option>\n";
                 my @items = ();                  my @items = ();
                 my @longitems = ();                  my @longitems = ();
                 if ($idlist{$codetitles[0]} =~ /","/) {                  if ($idlist{$codetitles[0]} =~ /","/) {
Line 487  END Line 426  END
                     @longitems = @items;                      @longitems = @items;
                 }                  }
                 for (my $i=0; $i<@items; $i++) {                  for (my $i=0; $i<@items; $i++) {
                     $r->print(' <option value="'.$items[$i].'">'.$longitems[$i].'</option>');                      $output .= ' <option value="'.$items[$i].'">'.$longitems[$i].'</option>'."\n";
                 }                  }
                 $r->print('</select></td>');                  $output .= '</select></td>';
                 for (my $i=1; $i<$numtitles; $i++) {                  for (my $i=1; $i<$numtitles; $i++) {
                     $r->print('<td>'.$codetitles[$i].'<br />'."\n".                      $output .= '<td>'.$codetitles[$i].'<br />'."\n".
                      '<select name="'.$codetitles[$i].'" onChange="courseSet('."'$codetitles[$i]'".')">'."\n".                       '<select name="'.$standardnames[$i].'" onchange="courseSet('."'$codetitles[$i]'".')">'."\n".
                      '<option value="-1">&lt;-'.$lt{'pick'}.' '.$codetitles[$i-1].'</option>'."\n".                       '<option value="-1">&lt;-'.$lt{'pick'}.' '.$codetitles[$i-1].'</option>'."\n".
                      '</select>'."\n".                       '</select>'."\n".
                      '</td>'                       '</td>'."\n";
                     );  
                 }                  }
                 $r->print('</tr></table>');                  $output .= '</tr></table>';
                 if ($numtitles > 4) {                  if ($numtitles > 4) {
                     $r->print('<br /><br />'.$codetitles[$numtitles].'<br />'."\n".                      $output .= '<br /><br />'.$codetitles[$numtitles].'<br />'."\n".
                           '<select name="'.$codetitles[$numtitles].'" onChange="courseSet('."'$codetitles[$numtitles]'".')">'."\n".                            '<select name="'.$standardnames[$numtitles].'" onchange="courseSet('."'$codetitles[$numtitles]'".')">'."\n".
                           '<option value="-1">&lt;-'.$lt{'pick'}.' '.$codetitles[$numtitles-1].'</option>'."\n".                            '<option value="-1">&lt;-'.$lt{'pick'}.' '.$codetitles[$numtitles-1].'</option>'."\n".
                           '</select>'."\n");                            '</select>'."\n";
                 }                  }
             }              }
         } else {          } else {
             $r->print($lt{'enin'}.':&nbsp;              $output .= $lt{'enin'}.':&nbsp;
                   <input type="text" name="coursecode" size="15" value="" />');                    <input type="text" name="coursecode" size="15" value="" />'."\n";
         }          }
     }      }
     if ($ctitle) {      if ($ctitle) {
         $r->print('<br /><i>'.$lt{'titl'}.'</i>:&nbsp;'.$ctitle.'<input type="hidden" name="title" value="'.$ctitle.'" />');          $output .= '<br /><i>'.$lt{'titl'}.'</i>:&nbsp;'.$ctitle.
                      '<input type="hidden" name="title" value="'.
                      &HTML::Entities::encode($ctitle,'"<>&').'" />'."\n";
     } else {      } else {
         $r->print('<br />'.$lt{'enct'}.':&nbsp;          $output .= '<br />'.$lt{'enct'}.':&nbsp;
                  <input type="text" name="title" size="25" value="" />');                   <input type="text" name="title" size="25" value="" />'."\n";
     }      }
     $r->print(<<END);      $output .= &Apache::lonhtmlcommon::row_closure();
                </td>      $num ++;
               </tr>      $i = $num%2;
              </table>      $output .= &Apache::lonhtmlcommon::row_title($lt{'secn'},undef,$css[$i]);
             </td>  
            </tr>  
            <tr>  
             <td width="100%" colspan="2" bgcolor="#000000">  
              <img src="/adm/lonMisc/blackdot.gif" /><br />  
             </td>  
            </tr>  
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>$lt{'secn'}: </b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
 END  
     if ($sectionlist) {      if ($sectionlist) {
         $r->print("<select name=\"section\"\n>".          $output .= "<select name=\"section\"\n>".
                   "  <option value=\"\" selected=\"selected\">$lt{'sele'}</option>\n");                     "  <option value=\"\" selected=\"selected\">$lt{'sele'}</option>\n";
         foreach my $id (sort(keys(%groupid))) {          foreach my $id (sort(keys(%groupid))) {
             if ($id eq $groupid{$id} || $groupid{$id} eq '') {              if ($id eq $groupid{$id} || $groupid{$id} eq '') {
                 $r->print("  <option value=\"$id\" >$id</option>\n");                  $output .= "  <option value=".
                              &HTML::Entities::encode($id,'"<>&').
                              " >$id</option>\n";
             } else {              } else {
                 $r->print("  <option value=\"$id\" >$id - ($lt{'lsec'}: $groupid{$id})</option>\n");                  $output .= "  <option value=".
                              &HTML::Entities::encode($id,'"<>&').
                              " >$id - ($lt{'lsec'}: $groupid{$id})</option>\n";
             }              }
         }          }
         $r->print("</select>");          $output .= "</select>";
     } else {      } else {
         $r->print("<input type=\"text\" name=\"section\" size=\"10\"/>");          $output .= '<input type="text" name="section" size="10" />'."\n";
     }      }
     $r->print(<<END);      $output .= &Apache::lonhtmlcommon::row_closure();
                </td>      $num ++;
               </tr>      $i = $num%2; 
              </table>      $output .= &Apache::lonhtmlcommon::row_title($lt{'subj'},undef,'LC_oddrow_value').
             </td>                 '  <input type="text" size="40" name="subject" />'."\n".
            </tr>                 &Apache::lonhtmlcommon::row_closure().
            <tr>                 &Apache::lonhtmlcommon::row_title($lt{'detd'},undef,'LC_evenrow_value').
             <td width="100%" colspan="2" bgcolor="#000000">                 '  <textarea rows="10" cols="45" name="description" style="word-wrap:normal;">'.
              <img src="/adm/lonMisc/blackdot.gif" /><br />                 '</textarea>'."\n".
             </td>                 &Apache::lonhtmlcommon::row_closure();
            </tr>      $num ++;
            <tr>      $i = $num%2; 
             <td width="140" bgcolor="$tablecolor">      if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
              <table width="140" border="0" cellpadding="8" cellspacing="0">          if ($homeserver) {
               <tr>              $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]).
                <td align="right"><b>$lt{'subj'}</b>                         ' <input type="file" name="screenshot" size="20" /><br />'.
                </td>                         "\n".$lt{'uplf'}."\n".
               </tr>                         &Apache::lonhtmlcommon::row_closure();
              </table>              $num ++;
             </td>              $i = $num%2;
             <td width="100%" valign="top">          }
              <table width="100%" border="0" cellpadding="8" cellspacing="0">      } else {
               <tr>          my $lonhost = $r->dir_config('lonHostID');
                <td>          my ($captchaform,$error) = 
                 <input type="text" size="40" name="subject">              &Apache::loncommon::captcha_display('login',$lonhost);
                </td>          if ($captchaform) {
               </tr>              $output .= &Apache::lonhtmlcommon::row_title(&mt('Validation'),undef,
              </table>                                                           $css[$i])."\n".
             </td>                         $captchaform."\n".
            </tr>                         &Apache::lonhtmlcommon::row_closure();
            <tr>              $num ++;
             <td width="100%" colspan="2" bgcolor="#000000">              $i = $num%2;
              <img src="/adm/lonMisc/blackdot.gif" /><br />          }
             </td>  
            </tr>  
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>$lt{'detd'}:</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
                 <textarea rows="10" cols="45" name="description" wrap="virtual"></textarea>  
                </td>  
               </tr>  
              </table>  
             </td>  
            </tr>  
            <tr>  
     <td width="100%" colspan="2" bgcolor="#000000">  
              <img src="/adm/lonMisc/blackdot.gif" /><br />  
     </td>  
    </tr>  
 END  
     if (defined($env{'user.name'})) {  
         $r->print(<<END);  
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>$lt{'opfi'}:</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
                 <input type="file" name="screenshot" size="20" /><br />$lt{'uplf'}  
                </td>  
               </tr>  
              </table>  
             </td>  
            </tr>  
            <tr>  
             <td width="100%" colspan="2" bgcolor="#000000">  
              <img src="/adm/lonMisc/blackdot.gif" /><br />  
             </td>  
            </tr>  
 END  
     }      }
       $output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$css[$i]);
     $r->print(<<END);      $output .= <<END;
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>$lt{'fini'}:</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table border="0" cellpadding="8" cellspacing="0">               <table border="0" cellpadding="8" cellspacing="0">
               <tr>                <tr>
                <td>                 <td>
                 <input type="hidden" name="action" value="process" />                  <input type="hidden" name="command" value="process" />
                 <input type="button" value="$lt{'subm'}" onClick="validate()"/> &nbsp;                  <input type="button" value="$lt{'subm'}" onclick="validate()" /> &nbsp;
                </td>                 </td>
                <td>&nbsp;</td>                 <td>&nbsp;</td>
                <td>                 <td>
                 <input type="reset" value="$lt{'clfm'}">                  <input type="reset" value="$lt{'clfm'}" />
                </td>                 </td>
               </tr>                </tr>
              </table>               </table>
             </td>  END
            </tr>      $output .= &Apache::lonhtmlcommon::row_closure(1);
           </table>      $output .= &Apache::lonhtmlcommon::end_pick_box();
          </td>      $r->print(<<END);
         </tr>  $output
        </table>  
       </td>  
      </tr>  
     </table>  
    </td>  
   </tr>  
  </table>  
 </form>  </form>
   <br />
 END  END
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
     return;      return;
Line 688  END Line 541  END
   
 sub print_request_receipt {  sub print_request_receipt {
     my ($r,$url,$function) = @_;      my ($r,$url,$function) = @_;
       my $public;
       if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
           $public = 1;
       }
       unless (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
           my $lonhost = $r->dir_config('lonHostID');
           my ($captcha_chk,$captcha_error) = 
               &Apache::loncommon::captcha_response('login',$lonhost);
           if ($captcha_chk != 1) {
               $r->print(&Apache::loncommon::start_page('Support request failed',undef,
                                          {'function'    => $function,
                                           'add_entries' => {
                                               topmargin    => "0",
                                               marginheight => "0",
                                           },
                                           'only_body'   => 1,}));
               if ($r->uri eq '/adm/helpdesk') {
                   &print_header($r,$url,'process');
               }
               $r->print(
                   '<h2>'.&mt('Support request failed').'</h2>'.
                         &Apache::lonhtmlcommon::confirm_success(
                           &mt('Validation of the code you entered failed.'),1).
                   '<br /><br />'.
                   &Apache::lonhtmlcommon::actionbox([
                       &mt('[_1]Go back[_2] and try again',
                           '<a href="javascript:history.go(-1)">','</a>')]).
                         &Apache::loncommon::end_page());
               return;
           }
       }
     my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');      my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');
     my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role');      my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role');
     my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');      my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
     my @cookievars = ('lonID');      my @cookievars = ('lonID');
   
     my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};      my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
     my $to =  $Apache::lonnet::perlvar{'lonSupportEMail'};      my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
       my $defdom = &get_domain();
       my $to = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
                                                         $defdom,$origmail);
     my $from = $admin;      my $from = $admin;
       my $bcc;
       my %domconfig =
            &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);
       if (ref($domconfig{'contacts'}) eq 'HASH') {
           if (exists($domconfig{'contacts'}{'helpdeskmail'})) {
               if (ref($domconfig{'contacts'}{'helpdeskmail'}) eq 'HASH') {
                   my $bccmail = $domconfig{'contacts'}{'helpdeskmail'}{'bcc'};
                   if ($bccmail ne '') {
                       my @bccs = split(/,/,$bccmail);
                       my @ok_bccs;
                       foreach my $bcc (@bccs) {
                           $bcc =~ s/^\s+//g;
                           $bcc =~ s/\s+$//g;
                           if ($bcc =~ m/^[^\@]+\@[^\@]+$/) {
                               if (!(grep(/^\Q$bcc\E$/,@ok_bccs))) {
                                   push(@ok_bccs,$bcc);
                               }
                           }
                       }
                       if (@ok_bccs > 0) {
                           $bcc = join(', ',@ok_bccs);
                       }
                   }
               }
           }
       }
     my $reporttime = &Apache::lonlocal::locallocaltime(time);      my $reporttime = &Apache::lonlocal::locallocaltime(time);
     my $fontcolor = &Apache::loncommon::designparm($function.'.font');  
     my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink');  
     my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');  
     my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot');      my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot');
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);
     my $coursecode = $env{'form.coursecode'};      my $coursecode = $env{'form.coursecode'};
     if ($coursecode eq '') {      if ($coursecode eq '') {
         if (defined($env{'form.Year'})) {          my $totcodes = 0;
             $coursecode .= $env{'form.Year'};          my %coursecodes;
         }          $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$defdom,$totcodes);
         if (defined($env{'form.Semester'})) {          my @standardnames = &Apache::loncommon::get_standard_codeitems();
             $coursecode .= $env{'form.Semester'};          if ($totcodes > 0) {
         }              my $noregexps = 1;
         if (defined($env{'form.Department'})) {              $coursecode = 
             $coursecode .= $env{'form.Department'};                  &Apache::courseclassifier::instcode_from_selectors($defdom,$noregexps);
         }          } 
         if (defined($env{'form.Number'})) {          if ($coursecode eq '') {
             $coursecode .= $env{'form.Number'};              foreach my $item (@standardnames) {
                   if ((defined($env{'form.'.$item})) && ($env{'form.'.$item} ne '-1')) {
                       $coursecode .= $env{'form.'.$item};
                   }
               }
         }          }
     }      }
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                  name => 'Name',                   username    => 'Name',
                  email => 'Email',                   email       => 'E-mail',
                  unme => 'Username/domain',                   cc          => 'Cc',
                  tel => 'Tel',                   user        => 'Username/domain',
                  crsi => 'Course Information',                   phone       => 'Phone',
                  subj => 'Subject',                   crsi        => 'Course Information',
                  desc => 'Description',                   subject     => 'Subject',
                  date => 'Date/Time',                   description => 'Description',
                  secn => 'Section',                   sourceurl   => 'URL',
                  asup => 'A support request has been sent to',                   date        => 'Date/Time',
                  warn => 'Warning: Problem with support e-mail address',                   secn        => 'Section',
                  your => 'Your support request contained the following information',                   warn        => 'Warning: Problem with support e-mail address',
                  sect => 'section',                   your        => 'Your support request contained the following information',
                  info => 'Information supplied',                   sect        => 'section',
                  adin => 'Additional information recorded',                   info        => 'Information supplied',
                    adin        => 'Additional information recorded',
     );      );
   
     my $supportmsg = qq|      my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist,$homeserver);
 $lt{'name'}: $env{'form.username'}      unless ($public) {
           if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
               $homeserver = &Apache::lonnet::homeserver($env{'user.name'},
                                                         $env{'user.domain'});
           }
       }
   
       if (($homeserver) && (defined($env{'form.cc'}))) {
           my @ccs;
           if ($env{'form.cc'} =~ /,/) {
               @ccs = split(/,/,$env{'form.cc'});
           } else {
               $env{'form.cc'} =~ s/^\s+//;
               $env{'form.cc'} =~ s/\s+$//;
               @ccs = $env{'form.cc'};
           }
           foreach my $cc (@ccs) {
               $cc =~ s/^\s+//g;
               $cc =~ s/\s+$//g;
               if ($cc =~ m/^[^\@]+\@[^\@]+$/) {
                   if (!(grep(/^\Q$cc\E$/,@ok_ccs))) {
                       push(@ok_ccs,$cc);
                   }
               } elsif ($cc ne '') {
                   if (!(grep(/^\Q$cc\E$/,@bad_ccs))) {
                       push(@bad_ccs,$cc);
                   }
               }
           }
           if (@ok_ccs > 0) {
              $okcclist = join(', ',@ok_ccs); 
           } 
           if (@bad_ccs == 1) {
               if ($bad_ccs[0] ne '') {
                   $badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').&Apache::loncommon::cleanup_html($bad_ccs[0]);
               }
           } elsif (@bad_ccs > 1) {
               $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'}."'";
       $env{'form.crsi'} = $env{'form.title'}.' - '.$coursecode.' - '.$lt{'sect'}.': '.$env{'form.section'};
       my $supportmsg = <<END;
   $lt{'username'}: $env{'form.username'}
 $lt{'email'}: $env{'form.email'}  $lt{'email'}: $env{'form.email'}
 $lt{'unme'}: $env{'form.uname'} - $env{'form.udom'}  $lt{'cc'}: $okcclist
 $lt{'tel'}: $env{'form.phone'}  $lt{'user'}: $env{'form.user'}
 $lt{'crsi'}: $env{'form.title'} - $coursecode - $lt{'secn'}: $env{'form.section'}  $lt{'phone'}: $env{'form.phone'}
 $lt{'subj'}: $env{'form.subject'}  $lt{'crsi'}: $env{'form.crsi'}
 $lt{'desc'}: $env{'form.description'}  $lt{'subject'}: $env{'form.subject'}
 URL: $env{'form.sourceurl'}  $lt{'description'}: $env{'form.description'}
   $lt{'sourceurl'}: $env{'form.sourceurl'}
 $lt{'date'}: $reporttime  $lt{'date'}: $reporttime
   
     |;  END
     my $descrip = $env{'form.description'};      my $displaymsg;
     $descrip =~ s#\n#<br />#g;      foreach my $item ('username','email','cc','user','phone','crsi','subject','description','sourceurl') {
     my $displaymsg = qq|          if ($env{'form.'.$item} ne '') {
 <font color="$fontcolor">$lt{'name'}:</font><font color="$vlinkcolor"> $env{'form.username'}</font><br />              if ($item eq 'description') {
 <font color="$fontcolor">$lt{'email'}: </font><font color="$vlinkcolor">$env{'form.email'}</font><br />                  my $descrip = $env{'form.description'};
 <font color="$fontcolor">$lt{'unme'}: </font><font color="$vlinkcolor">$env{'form.uname'} - $env{'form.udom'}</font><br />                  $descrip =  &Apache::loncommon::cleanup_html($descrip);
 <font color="$fontcolor">$lt{'tel'}: </font><font color="$vlinkcolor">$env{'form.phone'}</font><br />                  $descrip =~ s|[\n\r\f]|<br />|g;
 <font color="$fontcolor">$lt{'crsi'}: </font><font color="$vlinkcolor">$env{'form.title'} - $coursecode - $lt{'sect'}: $env{'form.section'}</font><br />                  $displaymsg .= 
 <font color="$fontcolor">$lt{'subj'}: </font><font color="$vlinkcolor">$env{'form.subject'}</font><br />                      '<span class="LC_helpform_receipt_cat">'.
 <font color="$fontcolor">$lt{'desc'}: </font><font color="$vlinkcolor">$descrip</font><br />                      "$lt{$item}</span>: $descrip<br />\n";
 <font color="$fontcolor">URL: </font><font color="$vlinkcolor">$env{'form.sourceurl'}</font><br />              } elsif ($item eq 'sourceurl') {
 <font color="$fontcolor">$lt{'date'}: </font><font color="$vlinkcolor">$reporttime</font><br />                  my $showurl = $env{'form.sourceurl'};
     |;                  $showurl =~ s/\?.*$//;
                   $showurl =  &Apache::loncommon::cleanup_html($showurl);
                   $displaymsg .= 
                       '<span class="LC_helpform_receipt_cat">'.
                       "$lt{$item}</span>: $showurl<br />\n";
               } elsif ($item eq 'cc') {
                   if ($okcclist) {
                       my $showcclist = &Apache::loncommon::cleanup_html($okcclist);
                       $displaymsg .=
                           '<span class="LC_helpform_receipt_cat">'.
                           "$lt{$item}</span>: $showcclist<br />\n";
                   }
               } else {
                   my $showitem = $env{'form.'.$item};
                   $showitem = &Apache::loncommon::cleanup_html($showitem);
                   $displaymsg .= 
                       '<span class="LC_helpform_receipt_cat">'.
                       "$lt{$item}</span>: $showitem<br />\n";
               }
           }
       }
       $displaymsg .= '<span class="LC_helpform_receipt_cat">'.
                      $lt{'date'}.'</span>: '.$reporttime.'<br />'."\n";
   
     my $start_page =       my $start_page = 
  &Apache::loncommon::start_page('Support request recorded',undef,   &Apache::loncommon::start_page('Support request recorded',undef,
Line 773  $lt{'date'}: $reporttime Line 754  $lt{'date'}: $reporttime
   
     $r->print(<<"END");      $r->print(<<"END");
 $start_page  $start_page
 <form name="logproblem">  <form name="logproblem" action="">
 <input type="hidden" name="action" value="result" />  <input type="hidden" name="command" value="result" />
 </form>  </form>
 END  END
     if ($r->uri eq '/adm/helpdesk') {      if ($r->uri eq '/adm/helpdesk') {
         &print_header($r,$url,'process');          &print_header($r,$url,'process');
     }      }
     if ($to =~ m/^[^\@]+\@[^\@]+$/) {      my $bad_email = 0;
         $r->print('<h3>'.$lt{'asup'}.' '.$to.'</h3>');      if ($to =~ /,/) {
     } else {          my @ok_email; 
         $to = $admin;          foreach my $email (split(/,/,$to)) {
         if ($to =~ m/^[^\@]+\@[^\@]+$/) {              if ($email =~ m/^[^\@]+\@[^\@]+$/) {
             $r->print('<h3>'.$lt{'asup'}.' '.$to.'</h3>');                  if (!grep(/^\Q$email\E$/,@ok_email)) {
                       push(@ok_email,$email);
                   }
               }
           }
           if (@ok_email > 0) {
               $to = join(',',@ok_email);
           } elsif ($admin =~ m/^[^\@]+\@[^\@]+$/) {
               $to = $admin;
         } else {          } else {
             $r->print('              $bad_email = 1;
  <h3>'.$lt{'warn'}.'</h3>'.  
 &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 <b>not</b> been sent to the LON-CAPA support staff or administrator at your institution.',$to).' '.&mt('Instead a copy has been sent to the LON-CAPA support team at Michigan State University.'));   
             $to = 'helpdesk@lon-capa.org';  
         }          }
       } elsif ($to !~ m/^[^\@]+\@[^\@]+$/) {
           if ($admin =~ m/^[^\@]+\@[^\@]+$/) {
               $to = $admin;
           } else {
               $bad_email = 1;
           }
       }
   
       my $message;
       if (!$bad_email) {
           $message = &Apache::lonhtmlcommon::confirm_success(
               &mt('A support request has been sent to [_1]','<tt>'.$to.'</tt>'));
       } else {
           $message = &Apache::lonhtmlcommon::confirm_success(
               $lt{'warn'}.'<br />'
              .&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>')
              .' '.&mt('Instead a copy has been sent to the LON-CAPA support team at Michigan State University.'),1); 
           $to = 'helpdesk@lon-capa.org';
     }      }
       $r->print(&Apache::loncommon::confirmwrapper($message));
   
     if (defined($env{'form.email'})) {      if (defined($env{'form.email'})) {
           $env{'form.email'} =~ s/^\s+//;
           $env{'form.email'} =~ s/\s+$//;
         if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {          if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
             $from = $env{'form.email'};              $from = $env{'form.email'};
         }          }
     }      }
   
       if (defined($env{'form.cc'})) {
           if ($badccmsg) {
               $displaymsg .= $badccmsg;
           }
       }
   
     my $subject = $env{'form.subject'};      my $subject = $env{'form.subject'};
     $subject =~ s#(`)#'#g;      $subject =~ s/(`)/'/g;
     $subject =~ s#\$#\(\$\)#g;      $subject =~ s/\$/\(\$\)/g;
     $supportmsg =~ s#(`)#'#g;      $supportmsg =~ s/(`)/'/g;
     $supportmsg =~ s#\$#\(\$\)#g;      $supportmsg =~ s/\$/\(\$\)/g;
     $displaymsg =~ s#(`)#'#g;      $displaymsg =~ s/(`)/'/g;
     $displaymsg =~ s#\$#\(\$\)#g;      $displaymsg =~ s/\$/\(\$\)/g;
     my $fname;      my $fname;
   
     my $attachmentpath = '';      my $attachmentpath = '';
     my $attachmentsize = '';      my $attachmentsize = '';
     if (defined($env{'user.name'})) {      if ((defined($env{'user.name'})) && (!$public)) {
         if ($env{'form.screenshot.filename'}) {          if ($homeserver && $env{'form.screenshot.filename'}) {
             $attachmentsize = length($env{'form.screenshot'});              $attachmentsize = length($env{'form.screenshot'});
             if ($attachmentsize > 131072) {              if ($attachmentsize > 131072) {
                 $displaymsg .= '<br />'.&mt('The uploaded screenshot file ([_1] bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.',$attachmentsize);                  $displaymsg .= '<br />'.&mt('The uploaded screenshot file ([_1] bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.',$attachmentsize);
Line 829  END Line 843  END
   
     if ($attachmentpath =~ m-/([^/]+)$-) {      if ($attachmentpath =~ m-/([^/]+)$-) {
         $fname = $1;          $fname = $1;
         $displaymsg .= '<br />'.&mt('An uploaded screenshot file - [_1] ([_2] bytes) was included in the request sent by [_3] from LON-CAPA domain',$fname,$attachmentsize,$env{'user.name'}.': '.$env{'user.domain'});          $displaymsg .= '<br />'
                         .&mt('An uploaded screenshot file [_1] ([_2] bytes) was included in the request sent by [_3].'
                             ,'<span class="LC_filename">'.$fname.'</span>'
                             ,$attachmentsize
                             ,$env{'user.name'}.':'.$env{'user.domain'}
                          );
         $supportmsg .= "\n";          $supportmsg .= "\n";
         foreach my $var (@cookievars) {          foreach my $var (@cookievars) {
             $supportmsg .= "$var: $cookies{$var}\n";              $supportmsg .= "$var: $cookies{$var}\n";
Line 849  END Line 868  END
                  Type    =>'TEXT',                   Type    =>'TEXT',
                  Data    => $supportmsg,                   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 ($attachmentpath) {      if ($homeserver && $attachmentpath) {
         my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);          my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);
         $msg->attach(Type     => $type,          $msg->attach(Type     => $type,
                      Path     => $attachmentpath,                       Path     => $attachmentpath,
Line 878  END Line 908  END
 ### Send it:  ### Send it:
     $msg->send('sendmail');      $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(qq|      $r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n");
  <b>$lt{'your'}</b>:<br /><br />      $r->print('<div style="width:620px;">'.
  <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">                &Apache::lonhtmlcommon::start_pick_box().
   <tr>                &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n".
    <td>                &Apache::lonhtmlcommon::row_closure().
     <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">                &Apache::lonhtmlcommon::row_title($lt{'adin'},undef,'LC_evenrow_value'));
      <tr>      my $envmsg;
       <td>  
        <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">  
         <tr>  
          <td>  
           <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">  
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>$lt{'info'}</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>$displaymsg</td>  
               </tr>  
              </table>  
             </td>  
            </tr>  
            <tr>  
             <td width="100%" colspan="2" bgcolor="#000000">  
              <img src="/adm/lonMisc/blackdot.gif" /><br />  
             </td>  
            </tr>  
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>$lt{'adin'}</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
     |);  
     foreach my $var (@cookievars) {      foreach my $var (@cookievars) {
         unless($cookies{$var} eq '') {          if ($cookies{$var} ne '') {
             $r->print("$var:&nbsp;<font color='$vlinkcolor'>$cookies{$var}</font>, ");              $envmsg.= '<span class="LC_helpform_receipt_cat">'.
                         $var.'</span>:&nbsp;'.$cookies{$var}.', ';
         }          }
     }      }
     foreach my $var (@ENVvars) {      foreach my $var (@ENVvars) {
         unless($ENV{$var} eq '') {          if ($ENV{$var} ne '') {
             $r->print("$var:&nbsp;<font color='$vlinkcolor'>$ENV{$var}</font>, ");              $envmsg .= '<span class="LC_helpform_receipt_cat">'.
                          $var.'</span>:&nbsp;'.$ENV{$var}.', ';
         }          }
     }      }
     foreach my $var (@envvars) {      foreach my $var (@envvars) {
         unless($env{$var} eq '') {           if ($env{$var} ne '') { 
             $r->print("$var:&nbsp;<font color='$vlinkcolor'>$env{$var}</font>, ");              $envmsg .= '<span class="LC_helpform_receipt_cat">'.
                          $var.'</span>:&nbsp;'.$env{$var}.', ';
         }          }
     }      }
     $r->print("      $envmsg =~ s/, $//;
                </td>      $r->print($envmsg."\n".
               </tr>                &Apache::lonhtmlcommon::row_closure(1)."\n".
              </table>                &Apache::lonhtmlcommon::end_pick_box().
             </td>                "</div>\n".
            </tr>                &Apache::loncommon::end_page());
           </table>  
          </td>  
         </tr>  
        </table>  
       </td>  
      </tr>  
     </table>  
    </td>  
   </tr>  
  </table>  
     ");  
     $r->print(&Apache::loncommon::end_page());  
 }  }
   
 sub print_header {  sub print_header {
     my ($r,$origurl,$action) = @_;      my ($r,$origurl,$command) = @_;
     my $location=&Apache::loncommon::lonhttpdurl("/adm");      my $location=&Apache::loncommon::lonhttpdurl("/adm");
     my $tablecolor = '#EEEE99';  
     my ($component_url);      my ($component_url);
     my $helpdesk_link = '<a href="javascript:validate()">';      my $helpdesk_link = '<a href="javascript:validate()">';
     if ($action eq 'process') {      if ($command eq 'process') {
         $helpdesk_link = '<a href="/adm/helpdesk">';          $helpdesk_link = '<a href="/adm/helpdesk">';
     }      }
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                                            login => 'Log-in help',                                             login    => 'Log-in help',
                                            ask   => 'Ask helpdesk',                                             ask      => 'Ask helpdesk',
                                            getst => 'Getting started guide',                                             getst    => 'Getting started guide',
                                            back =>  'Back to last location'                                             back     =>  'Back to last location',
                                              headline => 'help/support',
                                              stud     => 'Students',
                                              ifyo     => 'If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk.',
                                              cont     => 'Contact your instructor instead.',
                                          );                                           );
     my ($getstartlink,$getstarttext);      my ($getstartlink,$reviewtext);
     if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') {      if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') {
         $getstartlink = qq|<td align="center">&nbsp;<b><a href="/adm/gettingstarted.html">$lt{'getst'}</a></td>|;          $getstartlink = qq|<td align="center">&nbsp;<b><a href="/adm/gettingstarted.html">$lt{'getst'}</a></td>|;
         $getstarttext = ' '.&mt('and the "Getting started" guide').' ';          $reviewtext = &mt('Please review the information in "Log-in help" and the "Getting started" guide if you are unable to log-in.');
       } else {
           $reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.');
     }      }
     $r->print(<<END);      my $linkback;
 <table width="620" border="0" cellspacing="0" cellpadding="0" height="55">   <tr height="50">    <td width='5'>&nbsp;</td>      if ($origurl eq '') {
    <td>          $linkback = 'javascript:history.go(-1)';
     <fieldset><legend><img src="$location/lonIcons/minilogo.gif" height='20' width='29' valign='bottom' />&nbsp;&nbsp;<b><font size="+1">LON-CAPA help/support</font></b></legend>      } else {
  <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">          $linkback = &HTML::Entities::encode($origurl,'"<>&');
   <tr>      }
    <td>      my $loginhelp = &Apache::lonauth::loginhelpdisplay();
     <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">      if ($loginhelp eq '') {
      <tr>          $loginhelp = '/adm/loginproblems.html';
       <td>      }
        <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">      $r->print(<<"END");
         <tr>  <table width="620" border="0" cellspacing="0" cellpadding="0" style="height: 55px;">
          <td>   <tr>
           <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">     <td width="5" height="50">&nbsp;</td>
            <tr bgcolor="$tablecolor">     <td height="50">
             <td align="center"><img src="$location/help/gif/smallHelp.gif" border="0" alt="($lt{'login'})" valign="middle" />&nbsp;<b><a href="/adm/loginproblems.html">$lt{'login'}</a></td>      <fieldset>
             <td align="center">&nbsp;<b>$helpdesk_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="($lt{'ask'})" valign="middle" />&nbsp;$lt{'ask'}</a></b>&nbsp;</td>$getstartlink        <legend>
             <td align="center">&nbsp;<b><a href="$origurl" target="_top"><img src="$location/lonIcons/move_up.gif" border="0" alt="($lt{'back'})" valign="middle" />&nbsp;$lt{'back'}</a></b>&nbsp;</td>          <img src="$location/lonIcons/minilogo.gif" height="20" width="29" alt="logo" style="vertical-align:bottom" />
            </tr>          LON-CAPA $lt{'headline'}
           </table>        </legend>
          </td>   <table id="LC_helpmenu_links">
         </tr>     <tr>
        </table>      <td align="center"><span class="LC_nobreak"><img src="$location/help/help.png" border="0" alt="($lt{'login'})" style="vertical-align:middle" />&nbsp;<b><a href="$loginhelp">$lt{'login'}</a></b>&nbsp;</span></td>
       </td>      <td align="center"><span class="LC_nobreak">&nbsp;<b>$helpdesk_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="($lt{'ask'})" style="vertical-align:middle" />&nbsp;$lt{'ask'}</a></b>&nbsp;</span></td>$getstartlink
      </tr>      <td align="center"><span class="LC_nobreak">&nbsp;<b><a href="$linkback" target="_top"><img src="$location/lonIcons/move_up.gif" border="0" alt="($lt{'back'})" style="vertical-align:middle" />&nbsp;$lt{'back'}</a></b>&nbsp;</span></td>
     </table>     </tr>
    </td>  
   </tr>  
  </table>   </table>
 </fieldset>  </fieldset>
   </td>    </td>
   <td width='5'>&nbsp;</td>    <td width="5">&nbsp;</td>
  </tr>   </tr>
  <tr height='5'>   <tr>
   <td colspan='3' height='5'>&nbsp;</td>    <td colspan="3" height="5">&nbsp;</td>
  </tr>   </tr>
 END  END
     unless ($action eq 'process') {      if  ($command ne 'process') {
         $r->print('          my $stuwarn = &mt('Do [_1]not[_2] use this form to ask about course content.',
                             '<b>','</b>');
           $r->print(<<"END");
  <tr>   <tr>
   <td colspan="3">'.&mt('    <td colspan="3">$reviewtext 
 Please review the information in "Log-in help"').$getstarttext.' '.&mt('if you are unable to log-in').'.  '.&mt('If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk').'.<br /><font size="-1"><b>'.&mt('Note').':</b> '.&mt('Student questions about course content should be directed to the course instructor').'.</font><br /><br />    $lt{'ifyo'}
   <p class="LC_info">
   <b>$lt{'stud'}:</b> 
   $stuwarn $lt{'cont'}
   </p><br />
   </td>    </td>
  </tr>');   </tr>
   END
     }      }
     $r->print('      $r->print('
 </table>');  </table>');
     return;      return;
 }  }
   
   sub get_domain {
       my $codedom;
       if (exists($env{'form.codedom'})) {
           if (&Apache::lonnet::domain($env{'form.codedom'}) ne '') {
               return $env{'form.codedom'};
           }
       }
       if ($env{'request.course.id'}) {
           $codedom = $env{'course.'.$env{'request.course.id'}.'.domain'};
       } elsif ($env{'request.role.domain'}) {
           $codedom = $env{'request.role.domain'};
       } else {
           $codedom = &Apache::lonnet::default_login_domain();
       }
       return $codedom;
   }
   
 1;  1;

Removed from v.1.41  
changed lines
  Added in v.1.77


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.