Diff for /loncom/interface/lonsupportreq.pm between versions 1.4 and 1.66.6.2

version 1.4, 2004/07/09 21:08:24 version 1.66.6.2, 2012/02/10 19:22:19
Line 1 Line 1
   #
   # $Id$
   #
   # Copyright Michigan State University Board of Trustees
   #
   # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   #
   # LON-CAPA is free software; you can redistribute it and/or modify
   # it under the terms of the GNU General Public License as published by
   # the Free Software Foundation; either version 2 of the License, or
   # (at your option) any later version.
   #
   # LON-CAPA is distributed in the hope that it will be useful,
   # but WITHOUT ANY WARRANTY; without even the implied warranty of
   # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   # GNU General Public License for more details.
   #
   # You should have received a copy of the GNU General Public License
   # along with LON-CAPA; if not, write to the Free Software
   # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   #
   # /home/httpd/html/adm/gpl.txt
   #
   # http://www.lon-capa.org/
   #
   
 package Apache::lonsupportreq;  package Apache::lonsupportreq;
   
 use strict;  use strict;
 use lib qw(/home/httpd/lib/perl);  use MIME::Types;
   use MIME::Lite;
   use CGI::Cookie();
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonnet();  use Apache::lonhtmlcommon;
 use localenroll;  use Apache::lonnet;
 use Apache::lonlocal;  use Apache::lonlocal;
   use Apache::lonacc();
 use Mail::Send;  use LONCAPA qw(:DEFAULT :match);
 # use MIME::Lite;   
 # use MIME::Types;  
   
 sub handler {  sub handler {
     my ($r) = @_;      my ($r) = @_;
Line 20  sub handler { Line 47  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'},['action','origurl','function']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']);
     my $action = $ENV{'form.action'};      if ($r->uri eq '/adm/helpdesk') {
     my $function = $ENV{'form.function'};          &Apache::lonacc::get_posted_cgi($r);
     my $origurl = &Apache::lonnet::unescape($ENV{'form.origurl'});      }
     if ($action eq 'process') {      my $function = $env{'form.function'};
       my $origurl = $env{'form.origurl'};
       my $command = $env{'form.command'};
   
       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 35  sub handler { Line 69  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);      my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$email,
     my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0",marginheight="0"',1);          $lastname,$firstname,$server,$formname,$public);
     my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');      $function = &Apache::loncommon::get_users_function() if (!$function);
     $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'};      } else {
     $urole = $ENV{'request.role'};          $uname = $env{'user.name'};
     $usec = $ENV{'request.course.sec'};          $udom = $env{'user.domain'};
     $cid = $ENV{'request.course.id'};  
     $server = $ENV{'SERVER_NAME'};  
     my $scripttag;  
     if ($cid =~ m/_/) {  
         ($cdom,$cnum) = split/_/,$cid;  
     }  
     if ($cdom && $cnum) {  
         my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);  
         $ctitle = $csettings{'description'};  
         $ccode = $csettings{'internal.coursecode'};  
         $sectionlist = $csettings{'internal.sectionnums'};  
     }  
     if ($ENV{'environment.critnotification'}) {  
         $email = $ENV{'environment.critnotification'};  
     }  
     if (!$email && $ENV{'environment.notification'}) {  
         $email = $ENV{'environment.notification'};  
     }  
     if ($ENV{'environment.lastname'}) {  
         $lastname = $ENV{'environment.lastname'};  
     }  
     if ($ENV{'environment.firstname'}) {  
         $firstname = $ENV{'environment.firstname'};  
     }  
     my @sections = split/,/,$sectionlist;  
     my %groupid = ();  
     foreach (@sections) {  
         my ($sec,$grp) = split/:/,$_;  
         $groupid{$sec} = $grp;  
     }      }
     $r->print(<<END);      $uhome = $env{'user.home'};
 <html>      $formname = 'logproblem';
  <head>      my $machine = &Apache::lonnet::absolute_url();
   <title>LON-CAPA support request</title>      if ($origurl =~ m-^https?://-) {
           $server = $origurl;
       } else {
           $server = $machine.$origurl;
       }
       my $showserver = $server;
       $showserver =~ s/\?.*$//;
       my %lt = &Apache::lonlocal::texthash (
                     email => 'The e-mail address you entered',
                     notv => 'is not a valid e-mail address',
                     rsub => 'You must include a subject',
                     rdes => 'You must include a description',
                     name => 'Name',
                     subm => 'Submit Request',
                     emad => 'Your e-mail address',
                     emac => 'Cc', 
                     unme => 'username',
                     doma => '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',
                     phon => 'Phone',
                     pick => 'Pick',
                     subj => 'Subject',
                     detd => 'Detailed Description',
                     opfi => 'Optional file upload',
                     uplf => 'Upload a file (e.g., a screenshot) relevant to your help request (128 KB max.)',
                     fini => 'Finish',
                     clfm => 'Clear Form',
       );
       my $scripttag = (<<"END");
   function validate() {
       if (validmail(document.logproblem.email) == false) {
           alert("$lt{'email'}: "+document.logproblem.email.value+" $lt{'notv'}.");
           return;
       }
       if (document.logproblem.subject.value == '') {
           alert("$lt{'rsub'}.");
           return;
       }
       if (document.logproblem.description.value == '') {
           alert("$lt{'rdes'}.");
           return;
       }
       document.logproblem.submit();
   }
   
 END  END
     my $defdom = $Apache::lonnet::perlvar{'lonDefDomain'};      $scripttag .= &Apache::lonhtmlcommon::javascript_valid_email();
     my $codedom = $defdom;  
     my %coursecodes = ();      if ($env{'environment.permanentemail'}) {
     my %codes = ();          $email = $env{'environment.permanentemail'};
     my @codetitles = ();      } elsif ($env{'environment.critnotification'}) {
     my %cat_titles = ();          $email = $env{'environment.critnotification'};
     my %cat_order = ();      } elsif ($env{'environment.notification'}) {
           $email = $env{'environment.notification'};
       }
       if ($env{'environment.lastname'}) {
           $lastname = $env{'environment.lastname'};
       }
       if ($env{'environment.firstname'}) {
           $firstname = $env{'environment.firstname'};
       }
   
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom',
                                                    'useremail','useraccount']);
       if ($env{'form.origurl'} eq '/adm/createaccount') {
           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 $caller = 'global';      my $caller = 'global';
     my $totcodes = 0;  
     my $format_reply;      my $format_reply;
       my $jscript = '';
       my $js = '<script type="text/javascript">'."\n$scripttag\n$jscript\n".
        '</script>';
       my %add_entries = (topmargin    => "0",
          marginheight => "0",
         );
           
     if ($cdom) {      $r->print(&Apache::loncommon::start_page('Support Request',$js,
         $codedom = $cdom;         { 'function'    => $function,
     }   'add_entries' => \%add_entries,
     if ($cnum) {   'only_body'   => 1,}));
         $coursecodes{$cnum} = $ccode;      if ($r->uri eq '/adm/helpdesk') {
         if ($ccode eq '') {          &print_header($r,$origurl);
             $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes);      }
         } else {      my @css = ('LC_evenrow_value','LC_oddrow_value');
             $coursecodes{$cnum} = $ccode;      my $num = 1;
             $caller = $cnum;      my $i = $num%2;
             $totcodes ++;      $r->print('<form method="post" name="logproblem" enctype="multipart/form-data">'."\n");
         }      my $output = &Apache::lonhtmlcommon::start_pick_box().
     } else {                    &Apache::lonhtmlcommon::row_title($lt{'name'},undef,$css[$num])."\n";
         $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes);  
     }  
     if ($totcodes > 0) {  
         $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);  
     }  
     $r->print(<<END);  
 <html>  
 <head>  
  <title>LON-CAPA support request</title>  
 $scripttag  
 </head>  
 $bodytag  
  <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">  
   <tr>  
    <td>  
     <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">  
      <tr>  
       <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">  
            <form method="post" name="logproblem" onSubmit="return validate()">  
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>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,'"<>&').'" />';
     } 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.'" /><br />');          $output .= '<input type="text" size="20" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />';
     }      }
     $r->print(<<END);      $output .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="'.$lt{'subm'}.'" onclick="validate()" />&nbsp;'.
                </td>                  &Apache::lonhtmlcommon::row_closure()."\n";
               </tr>      $num ++;
              </table>      $i = $num%2;
             </td>      $output .= &Apache::lonhtmlcommon::row_title($lt{'emad'},undef,$css[$i]).
            </tr>                 '<input type="text" size="20" name="email" value="'.
            <tr>                 &HTML::Entities::encode($email,'"<>&').'" /><br />'."\n".
             <td width="100%" colspan="2" bgcolor="#000000">                 &Apache::lonhtmlcommon::row_closure();
              <img src="/adm/lonMisc/blackdot.gif" /><br />      $num ++;
             </td>      $i = $num%2;
            </tr>      if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
            <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>E-mail address:</b>          $i = $num%2;
                </td>      }
               </tr>      $output .= &Apache::lonhtmlcommon::row_title("$lt{'unme'}/$lt{'doma'}",undef,$css[$i]);
              </table>      my $udom_input = '<input type="hidden" name="udom" value="'.
             </td>                       &HTML::Entities::encode($udom,'"<>&').'" />';
             <td width="100%" valign="top">      my $uname_input = '<input type="hidden" name="uname" value="'.
              <table width="100%" border="0" cellpadding="8" cellspacing="0">                        &HTML::Entities::encode($uname,'"<>&').'" />'; 
               <tr>      if (($env{'user.name'} =~ /^$match_username$/) && 
                <td>          ($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
                 <input type="text" size="20" name="email" value="$email" /><br />          $output .= '<i>'.$lt{'unme'}.'</i>:&nbsp;'.$uname.'&nbsp;&nbsp;<i>'.$lt{'doma'}.'</i>:&nbsp;'.$udom.$udom_input.$uname_input;
                </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>username/domain:</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>username</i>:&nbsp;'.$uname.'&nbsp;&nbsp;<i>domain</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>domain</i>:&nbsp;'.$udom.$udom_input;              $output .= $lt{'entu'};
         } elsif (defined($uname)) {          } elsif (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { 
             $unameform = '<i>username</i>:&nbsp;'.$uname.'&nbsp;&nbsp;'.$uname_input;              $output .= $lt{'chdo'};
           } else {
               $output .= $lt{'entr'};
           }
           $output .= '<br />';
           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>domain</i>:&nbsp;';              $udomform = '<i>'.$lt{'doma'}.'</i>:&nbsp;';
             $udomform .= &Apache::loncommon::select_dom_form('','udom');              $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom');
         }          }
         if ($unameform eq '') {          if ($unameform eq '') {
             $unameform= '<i>username</i>:&nbsp;<input type="text" size="20" name="loncname" 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 />Enter the username you use to log-in to your LON-CAPA system, and choose your domain.');          $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>                 $showserver.'<input type="hidden" name="sourceurl" value="'.
            </tr>                 &HTML::Entities::encode($server,'"<>&').'" />'.
            <tr>                 &Apache::lonhtmlcommon::row_closure();
             <td width="100%" colspan="2" bgcolor="#000000">      $num ++;
              <img src="/adm/lonMisc/blackdot.gif" /><br />      $i = $num%2;
             </td>      $output .= &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,
            </tr>                                                   'LC_evenrow_value').
            <tr>                 '<input type="text" size="15" name="phone" /><br />'.
             <td width="140" bgcolor="$tablecolor">                 &Apache::lonhtmlcommon::row_closure();
              <table width="140" border="0" cellpadding="8" cellspacing="0">      $num ++;
               <tr>      $i = $num%2;
                <td align="right"><b>URL of page:</b>      $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().
              </table>                 &Apache::lonhtmlcommon::row_title($lt{'detd'},undef,'LC_evenrow_value').
             </td>                 '  <textarea rows="10" cols="45" name="description" wrap="virtual"></textarea>'.
             <td width="100%" valign="top">                 &Apache::lonhtmlcommon::row_closure();
              <table width="100%" border="0" cellpadding="8" cellspacing="0">      $num ++;
       $i = $num%2; 
       if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
           $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]).
                      ' <input type="file" name="screenshot" size="20" /><br />'.$lt{'uplf'}."\n".
           &Apache::lonhtmlcommon::row_closure();
           $num ++;
           $i = $num%2; 
       }
       $output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$css[$i]);
       $output .= <<END;
                <table border="0" cellpadding="8" cellspacing="0">
               <tr>                <tr>
                <td>                 <td>
                 $server$origurl<input type="hidden" name="origurl" value="$server$origurl" />                  <input type="hidden" name="command" value="process" />
                </td>                  <input type="button" value="$lt{'subm'}" onclick="validate()" /> &nbsp;
               </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>Phone #:</b>  
                </td>                 </td>
               </tr>                 <td>&nbsp;</td>
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>                 <td>
                 <input type="text" size="15" name="phone"><br>                  <input type="reset" value="$lt{'clfm'}" />
                </td>                 </td>
               </tr>                </tr>
              </table>               </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>Course Details:</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table border="0" cellpadding="3" cellspacing="3">  
               <tr>  
                <td>  
 END  END
     if ($coursecodes{$cnum}) {      $output .= &Apache::lonhtmlcommon::row_closure(1);
         foreach (@codetitles) {      $output .= &Apache::lonhtmlcommon::end_pick_box();
             $r->print('<i>'.$_.'</i>:&nbsp;'.$codes{$cnum}{$_});      $r->print(<<END);
   $output
   </form>
   <br />
   END
       $r->print(&Apache::loncommon::end_page());
       return;
   }
   
   sub print_request_receipt {
       my ($r,$url,$function) = @_;
       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 @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
       my @cookievars = ('lonID');
   
       my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
       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 $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);
                       }
                   }
               }
         }          }
         $r->print('.&nbsp;<input type="hidden" name="coursecode" value="'.$coursecodes{$cnum}.'" />');  
     } else {  
         $r->print('Enter institutional course code:&nbsp;  
                   <input type="text" name="coursecode" size="15" value="" />');  
     }      }
     if ($ctitle) {      my $reporttime = &Apache::lonlocal::locallocaltime(time);
         $r->print('<br /><i>Title</i>:&nbsp;'.$ctitle.'<input type="hidden" name="title" value="'.$ctitle.'" />');      my @formvars = ('username','email','uname','udom','sourceurl','phone',
     } else {                      'subject','description','screenshot');
         $r->print('<br />Enter course title:&nbsp;      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);
                  <input type="text" name="title" size="15" value="" />');      my %lt = &Apache::lonlocal::texthash (
                    username    => 'Name',
                    email       => 'E-mail',
                    cc          => 'Cc',
                    user        => 'Username/domain',
                    phone       => 'Phone',
                    subject     => 'Subject',
                    description => 'Description',
                    sourceurl   => 'URL',
                    date        => 'Date/Time',
                    warn        => 'Warning: Problem with support e-mail address',
                    your        => 'Your support request contained the following information',
                    info        => 'Information supplied',
                    adin        => 'Additional information recorded',
       );
   
       my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist);
       if ((defined($env{'user.name'})) && (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) {
               $badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').$bad_ccs[0];
           } elsif (@bad_ccs > 1) {
               my $bad_cc_string = join(', ',@bad_ccs);
               $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: ').$bad_cc_string;
           }
     }      }
     $r->print(<<END);      $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";
                </td>      my $supportmsg = <<END;
               </tr>  $lt{'username'}: $env{'form.username'}
              </table>  $lt{'email'}: $env{'form.email'}
             </td>  $lt{'cc'}: $okcclist
            </tr>  $lt{'user'}: $env{'form.user'}
            <tr>  $lt{'phone'}: $env{'form.phone'}
             <td width="100%" colspan="2" bgcolor="#000000">  $lt{'subject'}: $env{'form.subject'}
              <img src="/adm/lonMisc/blackdot.gif" /><br />  $lt{'description'}: $env{'form.description'}
             </td>  $lt{'sourceurl'}: $env{'form.sourceurl'}
            </tr>  $lt{'date'}: $reporttime
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>Section Number: </b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
 END  END
     if ($sectionlist) {      my $displaymsg;
         $r->print("<select name=\"section\">");      foreach my $item ('username','email','cc','user','phone','subject',
         foreach (sort keys %groupid) {                        'description','sourceurl') {
             if ($_ eq $groupid{$_} || $groupid{$_} eq '') {          if ($env{'form.'.$item} ne '') {
                 $r->print("<option value=\"$_\" />$_");              if ($item eq 'description') {
                   my $descrip = $env{'form.description'};
                   $descrip =  &cleanup_html($descrip);
                   $descrip =~ s|[\n\r\f]|<br />|g;
                   $displaymsg .= 
                       '<span class="LC_helpform_receipt_cat">'.
                       "$lt{$item}</span>: $descrip<br />\n";
               } elsif ($item eq 'sourceurl') {
                   my $showurl = $env{'form.sourceurl'};
                   $showurl =~ s/\?.*$//;
                   $showurl =  &cleanup_html($showurl);
                   $displaymsg .= 
                       '<span class="LC_helpform_receipt_cat">'.
                       "$lt{$item}</span>: $showurl<br />\n";
               } elsif ($item eq 'cc') {
                   $displaymsg .=
                       '<span class="LC_helpform_receipt_cat">'.
                       "$lt{$item}</span>: $okcclist<br />\n";
             } else {              } else {
                 $r->print("<option value=\"$_\" />$_ - (LON-CAPA sec: $groupid{$_}");                  my $showitem = $env{'form.'.$item};
                   $showitem = &cleanup_html($showitem);
                   $displaymsg .= 
                       '<span class="LC_helpform_receipt_cat">'.
                       "$lt{$item}</span>: $showitem<br />\n";
             }              }
         }          }
         $r->print("</select>");  
     } else {  
         $r->print("<input type=\"text\" name=\"section\" size=\"10\"/>");  
     }      }
     $r->print(<<END);      $displaymsg .= '<span class="LC_helpform_receipt_cat">'.
                </td>                     $lt{'date'}.'</span>: '.$reporttime.'<br />'."\n";
               </tr>  
              </table>      my $start_page = 
             </td>   &Apache::loncommon::start_page('Support request recorded',undef,
            </tr>         {'function'    => $function,
            <tr>   'add_entries' => {
             <td width="100%" colspan="2" bgcolor="#000000">      topmargin    => "0",
              <img src="/adm/lonMisc/blackdot.gif" /><br />      marginheight => "0",
             </td>   },
            </tr>   'only_body'   => 1,});
            <tr>  
             <td width="140" bgcolor="$tablecolor">      $r->print(<<"END");
              <table width="140" border="0" cellpadding="8" cellspacing="0">  $start_page
               <tr>  <form name="logproblem">
                <td align="right"><b>Subject</b>  <input type="hidden" name="command" value="result" />
                </td>  </form>
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table width="100%" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
                 <input type="text" size="40" name="subject">  
                </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>Detailed description:</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>  
            <tr>  
             <td width="140" bgcolor="$tablecolor">  
              <table width="140" border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td align="right"><b>Finish:</b>  
                </td>  
               </tr>  
              </table>  
             </td>  
             <td width="100%" valign="top">  
              <table border="0" cellpadding="8" cellspacing="0">  
               <tr>  
                <td>  
                 <input type="hidden" name="action" value="process" />  
                 <input type="submit" value="Submit Request Form" /> &nbsp;  
                </td>  
                <td>&nbsp;</td>  
                <td>  
                 <input type="reset" value="Clear Form">  
                </td>  
               </tr>  
              </table>  
             </td>  
            </tr>  
           </table>  
          </td>  
         </tr>  
        </table>  
       </td>  
      </tr>  
     </table>  
    </td>  
   </tr>  
  </table>  
 END  END
       if ($r->uri eq '/adm/helpdesk') {
           &print_header($r,$url,'process');
       }
       my $bad_email = 0;
       if ($to =~ /,/) {
           my @ok_email; 
           foreach my $email (split(/,/,$to)) {
               if ($email =~ m/^[^\@]+\@[^\@]+$/) {
                   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 {
               $bad_email = 1;
           }
       } 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));
   
 # What do we know about this user?      if (defined($env{'form.email'})) {
 #    foreach (sort keys %ENV) {          $env{'form.email'} =~ s/^\s+//;
 #        if ($_ =~ m/^browser/) {          $env{'form.email'} =~ s/\s+$//;
 #            $r->print("key is $_, value is $ENV{$_}");          if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
 #        } elsif ($_ =~ m/^environment/) {              $from = $env{'form.email'};
 #            $r->print("key is $_, value is $ENV{$_}");          }
 #        } elsif ($_ =~ m/^request/) {      }
 #            $r->print("key is $_, value is $ENV{$_}");  
 #        } elsif ($_ =~ m/^user\.(domain|home|name)/) {  
 #            $r->print("key is $_, value is $ENV{$_}");  
 #        } elsif ($_ =~ /^[A-Z]/) {  
 #            $r->print("key is $_, value is $ENV{$_}");  
 #        }  
 #    }  
     return  
 }  
   
 sub print_request_receipt {      if (defined($env{'form.cc'})) {
     my ($r,$url,$function) = @_;          if ($badccmsg) {
     my @envvars = ('lonID','HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME','browser.os','browser.type','browser.version','user.home','request.role');              $displaymsg .= $badccmsg;
     my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0"',1);          }
     my $to =  $Apache::lonnet::perlvar{'lonSupportEMail'};      }
     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','origurl','phone','section','coursecode','title','subject','description');  
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);  
   
 #    if ($ENV{'request.course.fn'}) {      my $subject = $env{'form.subject'};
 #        my $formdatafile = $ENV{'request.course.fn'}.'.formdata';      $subject =~ s/(`)/'/g;
 #        if (-e $formdatafile) {      $subject =~ s/\$/\(\$\)/g;
 #            open(FILE,"<$formdatafile");      $supportmsg =~ s/(`)/'/g;
 #            my @buffer =<FILE>;      $supportmsg =~ s/\$/\(\$\)/g;
 #            close(FILE);      $displaymsg =~ s/(`)/'/g;
 #            foreach (@buffer) {      $displaymsg =~ s/\$/\(\$\)/g;
 #                print STDERR $_;      my $fname;
 #            }   
 #        }      my $attachmentpath = '';
 #    }      my $attachmentsize = '';
       if ((defined($env{'user.name'})) && ($env{'user.name'} ne 'public')
     my $supportmsg = qq|          && ($env{'user.domain'} ne 'public')) {
 Name: $ENV{'form.username'}          if ($env{'form.screenshot.filename'}) {
 Email: $ENV{'form.email'}              $attachmentsize = length($env{'form.screenshot'});
 Username/domain: $ENV{'form.uname'} - $ENV{'form.udom'}              if ($attachmentsize > 131072) {
 Tel: $ENV{'form.phone'}                  $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);
 Course Information: $ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'}              } else {
 Subject: $ENV{'form.subject'}                  $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
 Description: $ENV{'form.description'}              }
 URL: $ENV{'form.origurl'}          }
 Date/Time: $reporttime      }
   
     |;      my %cookies;
     if ($to =~ m/^[^\@]+\@[^\@]+$/) {      my $cookie=CGI::Cookie->parse($r->header_in('Cookie'));
         $r->print(<<END);      if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) {
 <html>          $cookies{'lonID'} = $1;
 <head>      }
  <title>LON-CAPA support request recorded</title>  
 </head>      if ($attachmentpath =~ m-/([^/]+)$-) {
 $bodytag          $fname = $1;
  <h3>A support request has been sent to $to</h3>          $displaymsg .= '<br />'
 END                        .&mt('An uploaded screenshot file [_1] ([_2] bytes) was included in the request sent by [_3].'
     } else {                             ,'<span class="LC_filename">'.$fname.'</span>'
         $to = 'helpdesk@lon-capa.org';                            ,$attachmentsize
         $r->print(<<END);                            ,$env{'user.name'}.':'.$env{'user.domain'}
 <html>                         );
 <head>          $supportmsg .= "\n";
  <title>LON-CAPA support request recorded</title>          foreach my $var (@cookievars) {
 </head>              $supportmsg .= "$var: $cookies{$var}\n";
 $bodytag          }
  <h3>Warning: Problem with support e-mail address</h3>          foreach my $var(@ENVvars) {
 As the e-mail address provided for this LON-CAPA server ($to) does not appear to be a valid e-mail address, your support request has not been sent to the LON-CAPA support staff at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University.               $supportmsg .= "$var: $ENV{$var}\n";
 END          }
           foreach my $var (@envvars) {
               $supportmsg .= "$var: $env{$var}\n";
           }
       }
    
       my $msg = MIME::Lite->new(
                    From    => $from,
                    To      => $to,
                    Subject => $subject,
                    Type    =>'TEXT',
                    Data    => $supportmsg,
                    );
       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) {
           my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);
           $msg->attach(Type     => $type,
                        Path     => $attachmentpath,
                        Filename => $fname
                        );
   
       } else {
           my $envdata = '';
           foreach my $var (@cookievars) {
               $envdata .= "$var: $cookies{$var}\n";
           }
           foreach my $var (@ENVvars) {
               $envdata .= "$var: $ENV{$var}\n";
           }
           foreach my $var (@envvars) {
               $envdata .= "$var: $env{$var}\n";
           }
           foreach my $var (@loncvars) {
               $envdata .= "$var: $env{$var}\n";
           }
           $msg->attach(Type => 'TEXT',
                        Data => $envdata);
       }
   
   ### Send it:
       $msg->send('sendmail');
   
       if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) {
           unlink($attachmentpath);
       }
       $r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n");
       $r->print('<div style="width:620px;">'.
                 &Apache::lonhtmlcommon::start_pick_box().
                 &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n".
                 &Apache::lonhtmlcommon::row_closure().
                 &Apache::lonhtmlcommon::row_title($lt{'adin'},undef,'LC_evenrow_value'));
       my $envmsg;
       foreach my $var (@cookievars) {
           if ($cookies{$var} ne '') {
               $envmsg.= '<span class="LC_helpform_receipt_cat">'.
                         $var.'</span>:&nbsp;'.$cookies{$var}.', ';
           }
       }
       foreach my $var (@ENVvars) {
           if ($ENV{$var} ne '') {
               $envmsg .= '<span class="LC_helpform_receipt_cat">'.
                          $var.'</span>:&nbsp;'.$ENV{$var}.', ';
           }
       }
       foreach my $var (@envvars) {
           if ($env{$var} ne '') { 
               $envmsg .= '<span class="LC_helpform_receipt_cat">'.
                          $var.'</span>:&nbsp;'.$env{$var}.', ';
           }
       }
       $envmsg =~ s/, $//;
       $r->print($envmsg."\n".
                 &Apache::lonhtmlcommon::row_closure(1)."\n".
                 &Apache::lonhtmlcommon::end_pick_box().
                 "</div>\n".
                 &Apache::loncommon::end_page());
   }
   
   sub print_header {
       my ($r,$origurl,$command) = @_;
       my $location=&Apache::loncommon::lonhttpdurl("/adm");
       my ($component_url);
       my $helpdesk_link = '<a href="javascript:validate()">';
       if ($command eq 'process') {
           $helpdesk_link = '<a href="/adm/helpdesk">';
       }
       my %lt = &Apache::lonlocal::texthash (
                                              login => 'Log-in help',
                                              ask   => 'Ask helpdesk',
                                              getst => 'Getting started guide',
                                              back =>  'Back to last location',
                                              headline => 'help/support',
                                            );
       my ($getstartlink,$reviewtext);
       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>|;
           $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.');
     }      }
     my $msg = new Mail::Send;      if ($origurl eq '') {
     $msg->to($to);          $origurl = 'javascript:history.go(-1)';
 #    if (defined($ENV{'form.email'})) {  
 #        if ($ENV{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {  
 #            $msg->from($ENV{'form.email'});  
 #        }  
 #    }  
     $msg->subject('[LON-CAPA] - support request');  
     # ->open can cause an sh launch which can pass all of %ENV allong  
     # which can be to large for /bin/sh's little mind  
     my %oldENV=%ENV;  
     undef(%ENV);  
     if (my $fh = $msg->open()) {  
  print $fh $supportmsg;  
         $fh->close;  
     }      }
     %ENV=%oldENV;  
     undef(%oldENV);  
     $r->print(<<END);      $r->print(<<END);
  <b>Your support request contained the following information</b>:<br /><br />  <table width="620" border="0" cellspacing="0" cellpadding="0" height="55">   <tr height="50">    <td width='5'>&nbsp;</td>
  <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">  
   <tr>  
    <td>     <td>
     <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">      <fieldset>
      <tr>        <legend>
       <td>          <img src="$location/lonIcons/minilogo.gif" height="20" width="29" valign="bottom" />
        <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">          LON-CAPA $lt{'headline'}
         <tr>        </legend>
          <td>   <table id="LC_helpmenu_links">
           <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">     <tr>
            <tr>      <td align="center"><span class="LC_nobreak"><img src="$location/help/help.png" border="0" alt="($lt{'login'})" valign="middle" />&nbsp;<b><a href="/adm/loginproblems.html">$lt{'login'}</a></b>&nbsp;</span></td>
             <td width="140" bgcolor="$tablecolor">      <td align="center"><span class="LC_nobreak">&nbsp;<b>$helpdesk_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="($lt{'ask'})" valign="middle" />&nbsp;$lt{'ask'}</a></b>&nbsp;</span></td>$getstartlink
              <table width="140" border="0" cellpadding="8" cellspacing="0">      <td align="center"><span class="LC_nobreak">&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;</span></td>
               <tr>     </tr>
                <td align="right"><b>Information supplied</b>   </table>
                </td>  </fieldset>
               </tr>    </td>
              </table>    <td width='5'>&nbsp;</td>
             </td>   </tr>
             <td width="100%" valign="top">   <tr height='5'>
              <table width="100%" border="0" cellpadding="8" cellspacing="0">    <td colspan='3' height='5'>&nbsp;</td>
               <tr>   </tr>
                <td>  
 END  END
     my @textmsg = split/\n/,$supportmsg;      if  ($command ne 'process') {
     foreach my $line (@textmsg) {          $r->print('
         $line =~ s|^|<font color="$fontcolor">|;   <tr>
         $line =~ s|:|:</font><font color="$vlinkcolor">|;    <td colspan="3">'.$reviewtext.' '
         $r->print("$line</font><br />");  .&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('Students').'</b>: '.&mt('Do <b>not</b> use this form to ask questions about course content.').' '
     $r->print('</td>  .&mt('Contact your instructor instead.')
               </tr>  .'</font><br /><br />
              </table>    </td>
             </td>   </tr>');
            </tr>      }
            <tr>      $r->print('
             <td width="130" bgcolor="'.$tablecolor.'">  </table>');
              <table width="130" border="0" cellpadding="8" cellspacing="0">      return;
               <tr>  }
                <td align="right"><b>Additional information recorded</b>  
                </td>  sub get_domain {
               </tr>      my $codedom;
              </table>      if (exists($env{'form.codedom'})) {
             </td>          $codedom = $env{'form.codedom'};
             <td width="100%" valign="top">      } elsif ($env{'request.course.id'}) {
              <table width="100%" border="0" cellpadding="8" cellspacing="0">          $codedom = $env{'course.'.$env{'request.course.id'}.'.domain'};
               <tr>      } elsif ($env{'request.role.domain'}) {
                <td>          $codedom = $env{'request.role.domain'};
     ');      } else {
     foreach (@envvars) {          $codedom = &Apache::lonnet::default_login_domain();
         $r->print("$_:&nbsp;<font color='$vlinkcolor>$ENV{$_}</font>, ");  
         $supportmsg .= "$_: $ENV{$_}\n";  
     }      }
     $r->print("      return $codedom;
                </td>  
               </tr>  
              </table>  
             </td>  
            </tr>  
           </table>  
          </td>  
         </tr>  
        </table>  
       </td>  
      </tr>  
     </table>  
    </td>  
   </tr>  
  </table>  
     ");  
 }  }
   
 sub retrieve_instcodes {  sub cleanup_html {
     my ($coursecodes,$codedom,$totcodes) = @_;      my ($incoming) = @_;
     my %courses = &Apache::lonnet::courseiddump($codedom,'.',1);      my $outgoing;
     foreach my $course (keys %courses) {      if ($incoming ne '') {
         if ($courses{$course} =~ m/^[^:]*:([^:]+)$/) {          $outgoing = $incoming;
             $$coursecodes{$course} = &Apache::lonnet::unescape($1);          $outgoing =~ s/\#/&#035;/g;
             $totcodes ++;          $outgoing =~ s/\&/&#038;/g;
         }          $outgoing =~ s/</&#060;/g;
           $outgoing =~ s/>/&#062;/g;
           $outgoing =~ s/\(/&#040/g;
           $outgoing =~ s/\)/&#041;/g;
           $outgoing =~ s/"/&#034;/g;
           $outgoing =~ s/'/&#039;/g;
           $outgoing =~ s/\$/&#036;/g;
     }      }
     return $totcodes;      return $outgoing;
 }  }
   
 1;  1;

Removed from v.1.4  
changed lines
  Added in v.1.66.6.2


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