Diff for /loncom/interface/lonsupportreq.pm between versions 1.70 and 1.108

version 1.70, 2013/01/04 16:57:38 version 1.108, 2025/02/25 05:35:26
Line 1 Line 1
   # The LearningOnline Network with CAPA
   # Helpdesk request form
 #  #
 # $Id$  # $Id$
 #  #
Line 27 Line 29
 package Apache::lonsupportreq;  package Apache::lonsupportreq;
   
 use strict;  use strict;
 use MIME::Types;  
 use MIME::Lite;  
 use CGI::Cookie();  use CGI::Cookie();
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::loncommon();  use Apache::loncommon();
Line 67  sub handler { Line 67  sub handler {
         }          }
     }      }
     my $origurl = $env{'form.origurl'};      my $origurl = $env{'form.origurl'};
     $origurl =~ s{^https?://}{};      if ($origurl =~ m{^https?://[^/]+(.*)$}) {
           $origurl = $1;
       }
     $origurl =~ s/(`)//g;      $origurl =~ s/(`)//g;
     $origurl =~ s/\$/\(\$\)/g;      $origurl =~ s/\$/\(\$\)/g;
     my $command = $env{'form.command'};      my $command = $env{'form.command'};
Line 79  sub handler { Line 81  sub handler {
     }      }
     return OK;      return OK;
 }  }
       
 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,      my ($os,$browser,$bversion,$uname,$udom,$uhome,$urole,$usec,$email,$cid,
         $cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,          $cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,
         $formname,$public,$homeserver);          $formname,$public,$homeserver,$knownuser,$captcha_form,$captcha_error,
           $captcha,$recaptcha_version,$extra_validations,%groupid);
     $function = &Apache::loncommon::get_users_function() if (!$function);      $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'};  
     if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {      if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
         $public = 1;          $public = 1;
     } else {      } else {
Line 105  sub print_request_form { Line 107  sub print_request_form {
             }              }
         }          }
     }      }
       if (($env{'user.name'} =~ /^$match_username$/) &&
           ($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
           $knownuser = 1;
       } else {
           my $lonhost = $r->dir_config('lonHostID');
           ($captcha_form,$captcha_error,$captcha,$recaptcha_version) =
               &Apache::loncommon::captcha_display('login',$lonhost);
       }
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom',
                                                    'useremail','useraccount']);
   
     if ($homeserver) {      if ($homeserver) {
         $uhome = $env{'user.home'};          $uhome = $env{'user.home'};
         $urole = $env{'request.role'};          $urole = $env{'request.role'};
         $usec = $env{'request.course.sec'};          $usec = $env{'request.course.sec'};
         $cid = $env{'request.course.id'};          $cid = $env{'request.course.id'};
     }      }
       if ($cid) {
           $cdom = $env{'course.'.$cid.'.domain'};
           $cnum = $env{'course.'.$cid.'.num'};
       }
       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'};
           my @sections = split(/,/,$sectionlist);
           foreach my $section (@sections) {
              my ($sec,$grp) = split(/:/,$section);
              $groupid{$sec} = $grp;
           }
       }
   
     $formname = 'logproblem';      $formname = 'logproblem';
       my $codedom = &get_domain();
       my %helpform;
       my %domconfig =
            &Apache::lonnet::get_dom('configuration',['contacts'],$codedom);
       if (ref($domconfig{'contacts'}) eq 'HASH') {
           if (ref($domconfig{'contacts'}{'helpform'}) eq 'HASH') {
               %helpform = %{$domconfig{'contacts'}{'helpform'}};
           }
       }
   
       my %codes;
       my @codetitles;
       my %cat_titles;
       my %cat_order;
       my %idlist;
       my %idnums;
       my %idlist_titles;
       my $totcodes = 0;
       my $jscript = '';
       my $loaditems = qq|
   function initialize_codes() {
       return;
   }
       |;
       unless ($helpform{'course'} eq 'no') {
           my $instcats = &Apache::lonnet::get_dom_instcats($codedom);
           if (ref($instcats) eq 'HASH') {
               if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH') &&
                   (ref($instcats->{'cat_titles'}) eq 'HASH') && (ref($instcats->{'cat_order'}) eq 'HASH')) {
                   %codes = %{$instcats->{'codes'}};
                   @codetitles = @{$instcats->{'codetitles'}};
                   %cat_titles = %{$instcats->{'cat_titles'}};
                   %cat_order = %{$instcats->{'cat_order'}};
                   $totcodes = scalar(keys(%codes));
               }
               if ($totcodes > 0) {
                   my $numtypes = @codetitles;
                   &Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
                   my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);
                   my $longtitles_str = join('","',@{$longtitles});
                   my $allidlist = $idlist{$codetitles[0]};
                   my $knowncodes;
                   if (($ccode ne '') && ($cnum ne '')) {
                       my (%singlecodes,@singlecodetitles,%singlecat_titles,%singlecat_order);
                       my $crscode_reply = &Apache::lonnet::auto_instcode_format($cnum,$codedom,{ $cnum => $ccode },\%singlecodes,
                                                                                 \@singlecodetitles,\%singlecat_titles,\%singlecat_order);
                       if (ref($singlecodes{$cnum}) eq 'HASH') {
                           $knowncodes = $singlecodes{$cnum};
                       }
                   }
                   $jscript .= &Apache::courseclassifier::courseset_js_start($formname,$longtitles_str,$allidlist);
                   $jscript .= $scripttext;
                   $jscript .= &Apache::courseclassifier::javascript_code_selections($formname,\@codetitles,$knowncodes,$sectionlist);
                   $loaditems = '';
               }
           }
       }
       my %missing = &Apache::lonlocal::texthash(
                            username   => 'You must include a name.',
                            phone      => 'You must include a phone.',
       );
       &js_escape(\%missing);
       if (keys(%helpform)) {
           foreach my $key (keys(%helpform)) {
               if (($helpform{$key} eq 'req') && ($missing{$key} ne '')) {
                   next if (($key eq 'username') && (($knownuser) ||
                                                     (($env{'user.name'} =~ /^$match_username$/) && (!$public))));
                   $extra_validations .= <<"END";
   
       if (document.$formname.$key.value == '') {
           alert("$missing{$key}");
           return;
       }
   
   END
               }
           }
       }
     my $machine = &Apache::lonnet::absolute_url();      my $machine = &Apache::lonnet::absolute_url();
     my $sourceurl = $machine.$origurl;      my $sourceurl = $machine.$origurl;
     $server = $machine.&cleanup_html($origurl);      $server = $machine.&Apache::loncommon::cleanup_html($origurl);
     $server =~ s/\?.*$//;      $server =~ s/\?.*$//;
     my %lt = &Apache::lonlocal::texthash (      my %js_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',
                   rsub => 'You must include a subject',                    rsub => 'You must include a subject',
                   rdes => 'You must include a description',                    rdes => 'You must include a description',
       );
       my %html_lt = &Apache::lonlocal::texthash (
                   name => 'Name',                    name => 'Name',
                   subm => 'Submit Request',                    subm => 'Submit Request',
                   emad => 'Your e-mail address',                    emad => 'Your e-mail address',
                   emac => 'Cc',                     emac => 'Cc',
                   unme => 'username',                    unme => 'username',
                   doma => 'domain',                    doma => 'domain',
                   entu => 'Enter the username you use to log-in to LON-CAPA',                    entu => 'Enter the username you use to log-in to LON-CAPA',
Line 143  sub print_request_form { Line 252  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 help request (128 KB max.)',                    uplf => 'Upload a file (e.g., a screenshot) relevant to your help request',
                   fini => 'Finish',                    fini => 'Finish',
                   clfm => 'Clear Form',                    clfm => 'Clear Form',
     );      );
       &js_escape(\%js_lt);
       &html_escape(\%html_lt);
     my $scripttag = (<<"END");      my $scripttag = (<<"END");
 function validate() {  function validate() {
     if (validmail(document.logproblem.email) == false) {      if (validmail(document.logproblem.email) == false) {
         alert("$lt{'email'}: "+document.logproblem.email.value+" $lt{'notv'}.");          alert("$js_lt{'email'}: "+document.logproblem.email.value+" $js_lt{'notv'}.");
         return;          return;
     }      }
     if (document.logproblem.subject.value == '') {      if (document.logproblem.subject.value == '') {
         alert("$lt{'rsub'}.");          alert("$js_lt{'rsub'}.");
         return;          return;
     }      }
     if (document.logproblem.description.value == '') {      if (document.logproblem.description.value == '') {
         alert("$lt{'rdes'}.");          alert("$js_lt{'rdes'}.");
         return;          return;
     }      }
       $extra_validations
     document.logproblem.submit();      document.logproblem.submit();
 }  }
   
 END  END
     $scripttag .= &Apache::lonhtmlcommon::javascript_valid_email();      $scripttag .= &Apache::lonhtmlcommon::javascript_valid_email();
     if ($cid) {  
         $cdom = $env{'course.'.$cid.'.domain'};  
         $cnum = $env{'course.'.$cid.'.num'};  
     }  
     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 ($homeserver) {      if ($homeserver) {
         if ($env{'environment.permanentemail'}) {          if ($env{'environment.permanentemail'}) {
Line 192  END Line 294  END
             $firstname = $env{'environment.firstname'};              $firstname = $env{'environment.firstname'};
         }          }
     }      }
     my @sections = split(/,/,$sectionlist);  
     my %groupid;  
     foreach my $section (@sections) {  
         my ($sec,$grp) = split(/:/,$section);  
         $groupid{$sec} = $grp;  
     }  
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom',  
                                                  'useremail','useraccount']);  
     if ($env{'form.origurl'} eq '/adm/createaccount') {      if ($env{'form.origurl'} eq '/adm/createaccount') {
         if ($email eq '') {          if ($email eq '') {
             if ($env{'form.useremail'} =~ /^[^\@]+\@[^\@]+$/) {              if ($env{'form.useremail'} =~ /^[^\@]+\@[^\@]+$/) {
Line 212  END Line 306  END
             }              }
         }          }
     }      }
     my $codedom = &get_domain();  
     my $details_title;      my $details_title;
     if ($codedom) {      if ($codedom) {
         $details_title = '<br />('.$codedom.')';          $details_title = '<br />('.$codedom.')';
     }      }
     my %coursecodes;  
     my %codes;  
     my @codetitles;  
     my %cat_titles;  
     my %cat_order;  
     my %idlist;  
     my %idnums;  
     my %idlist_titles;  
     my $caller = 'global';  
     my $totcodes = 0;  
     my $format_reply;  
     my $jscript = '';  
     my $loaditems = qq|  
 function initialize_codes() {  
     return;  
 }  
     |;  
     if ($cnum) {  
         $coursecodes{$cnum} = $ccode;  
         if ($ccode eq '') {  
             $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes);  
         } else {  
             $coursecodes{$cnum} = $ccode;  
             $caller = $cnum;  
             $totcodes ++;  
         }  
     } else {   
         $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes);  
     }  
     if ($totcodes > 0) {  
         if ($ccode eq '') {  
             $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);  
             if ($format_reply eq 'ok') {  
                 my $numtypes = @codetitles;  
                 &Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);  
                 my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);  
                 my $longtitles_str = join('","',@{$longtitles});  
                 my $allidlist = $idlist{$codetitles[0]};  
                 $jscript .= &Apache::courseclassifier::courseset_js_start($formname,$longtitles_str,$allidlist);  
                 $jscript .= $scripttext;  
                 $jscript .= &Apache::courseclassifier::javascript_code_selections($formname,@codetitles);  
                 $loaditems = '';  
             }  
         }  
     }  
   
     my $js = <<"ENDJS";      my $js = <<"ENDJS";
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  // <![CDATA[
Line 272  $loaditems Line 320  $loaditems
 // ]]>  // ]]>
 </script>  </script>
 ENDJS  ENDJS
       if ($knownuser) {
           $js .="\n".'<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>';
       } elsif ($recaptcha_version >=2) {
           $js.= "\n".'<script src="https://www.google.com/recaptcha/api.js"></script>'."\n";
       }
     my %add_entries = (      my %add_entries = (
                        style    => "margin-top:0px;margin-bottom:0px;",                         style    => "margin-top:0px;margin-bottom:0px;",
                        onload   => "initialize_codes();",                         onload   => "initialize_codes();",
                       );                        );
   
           my $args = { 'function'    => $function,
     $r->print(&Apache::loncommon::start_page('Support Request',$js,                   'add_entries' => \%add_entries,
        { 'function'    => $function,                   'only_body'   => 1,};
  'add_entries' => \%add_entries,      unless (($knownuser) || ($public)) {
  'only_body'   => 1,}));          (undef,undef,undef,my $clientmathml,my $clientunicode) =
               &Apache::loncommon::decode_user_agent();
           if ($clientunicode && !$clientmathml) {
               $args->{'browser.unicode'} = 1;
           }
       }
       $r->print(&Apache::loncommon::start_page('Support Request',$js,$args));
     if ($r->uri eq '/adm/helpdesk') {      if ($r->uri eq '/adm/helpdesk') {
         &print_header($r,$origurl);          &print_header($r,$origurl);
     }      }
Line 292  ENDJS Line 351  ENDJS
     if ($homeserver) {      if ($homeserver) {
         $formtype = ' enctype="multipart/form-data"';          $formtype = ' enctype="multipart/form-data"';
     }      }
     $r->print('<form method="post" action="" name="logproblem"'.$formtype.'>'."\n");      my $topsubmit = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="'.$html_lt{'subm'}.'" onclick="validate()" />&nbsp;';
       my $shownsubmit;
       $r->print('<div class="LC_landmark" role="main">'."\n".
                 '<form method="post" action="" name="logproblem"'.$formtype.'>'."\n");
     my $output = &Apache::lonhtmlcommon::start_pick_box().      my $output = &Apache::lonhtmlcommon::start_pick_box().
                  &Apache::lonhtmlcommon::row_title($lt{'name'},undef,$css[$num])."\n";                   &Apache::lonhtmlcommon::row_headline().
     my $fullname = '';                   '<span class="LC_info">'.
     if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) {                   &mt('(All fields marked with [_1]*[_2] are required.)',
         $fullname = "$firstname $lastname";                        '<span class="LC_parm_part">','</span>').
         $output .= $fullname.'<input type="hidden" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n";                   '</span>'.
     } else {                   &Apache::lonhtmlcommon::row_closure();
         if (defined($firstname) && $firstname ne '') {      unless ($helpform{'username'} eq 'no') {
             $fullname = $firstname;          my ($reqd,$aria_reqd,$namefield,$fullname);
         } elsif (defined($lastname) && $lastname ne '') {          if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) {
             $fullname = " $lastname";              $fullname = "$firstname $lastname";
         }              $namefield = $fullname.'<input type="hidden" name="username" id="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n";
         $output .= '<input type="text" size="20" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n";  
     }  
     $output .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="'.$lt{'subm'}.'" onclick="validate()" />&nbsp;'.  
                 &Apache::lonhtmlcommon::row_closure()."\n";  
     $num ++;  
     $i = $num%2;  
     $output .= &Apache::lonhtmlcommon::row_title($lt{'emad'},undef,$css[$i]).  
                '<input type="text" size="20" name="email" value="'.  
                &HTML::Entities::encode($email,'"<>&').'" /><br />'."\n".  
                &Apache::lonhtmlcommon::row_closure();  
     $num ++;  
     $i = $num%2;  
     if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {  
         if ($homeserver) {   
             $output .= &Apache::lonhtmlcommon::row_title($lt{'emac'},undef,$css[$i]).  
                        '<input type="text" size="50" name="cc" value="" /><br />'."\n".  
                        &Apache::lonhtmlcommon::row_closure();  
             $num ++;  
             $i = $num%2;  
         }  
     }  
     $output .= &Apache::lonhtmlcommon::row_title("$lt{'unme'}/$lt{'doma'}",undef,$css[$i]);  
     my $udom_input = '<input type="hidden" name="udom" value="'.  
                      &HTML::Entities::encode($udom,'"<>&').'" />'."\n";  
     my $uname_input = '<input type="hidden" name="uname" value="'.  
                       &HTML::Entities::encode($uname,'"<>&').'" />'."\n";   
     if (($env{'user.name'} =~ /^$match_username$/) &&   
         ($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {  
         $output .= '<i>'.$lt{'unme'}.'</i>:&nbsp;'.$uname.'&nbsp;&nbsp;<i>'.$lt{'doma'}.'</i>:&nbsp;'.$udom.$udom_input.$uname_input;  
     } else {  
         my $udomform = '';  
         my $unameform = '';  
         if (($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {  
             $output .= $lt{'entu'};  
         } elsif (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {   
             $output .= $lt{'chdo'};  
         } else {          } else {
             $output .= $lt{'entr'};              if (defined($firstname) && $firstname ne '') {
         }                  $fullname = $firstname;
         $output .= '<br />'."\n";              } elsif (defined($lastname) && $lastname ne '') {
         if (!$public) {                  $fullname = " $lastname";
             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 ($helpform{'username'} eq 'req') {
                   $reqd = '<span class="LC_parm_part">*</span>';
                   $aria_reqd = 'aria-required="true" ';
               }
               $namefield = '<input type="text" size="20" name="username" id="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" '.$aria_reqd.'/>'."\n";
         }          }
         if ($udomform eq '') {          my $title = '<label for="username">'.$html_lt{'name'}.'</label>';
             $udomform = '<i>'.$lt{'doma'}.'</i>:&nbsp;';          $output .= &Apache::lonhtmlcommon::row_title($title.$reqd,undef,$css[$num])."\n".$namefield.
             $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom')."\n";                     $topsubmit.
         }                     &Apache::lonhtmlcommon::row_closure()."\n";
         if ($unameform eq '') {          $shownsubmit = 1;
             $unameform= '<i>'.$lt{'unme'}.'</i>:&nbsp;<input type="text" size="20" name="uname" value="'.$uname.'" />&nbsp;&nbsp;';          $num ++;
         }          $i = $num%2;
         $output .= $unameform.$udomform;      }
       $output .= &Apache::lonhtmlcommon::row_title(
                      '<span title="'.&mt('required').'">'.
                      '<label for="email">'.$html_lt{'emad'}.
                      '</label><span class="LC_parm_part">*</span></span>'
                     ,undef,$css[$i]).
                  '<input type="text" size="20" name="email" id="email" value="'.
                  &HTML::Entities::encode($email,'"<>&').'" aria-required="true" />'."\n";
       unless ($shownsubmit) {
           $output .= $topsubmit;
     }      }
     $output .= &Apache::lonhtmlcommon::row_closure();      $output .= &Apache::lonhtmlcommon::row_closure();
     $num ++;      $num ++;
     $i = $num%2;      $i = $num%2;
     $output .= &Apache::lonhtmlcommon::row_title("$lt{'urlp'}",undef,$css[$i]).      if ($knownuser) {
                $server."\n".'<input type="hidden" name="sourceurl" value="'.          if ($homeserver) {
                &HTML::Entities::encode($sourceurl,'"<>&').'" />'."\n".              my $ip = &Apache::lonnet::get_requestor_ip($r);
                &Apache::lonhtmlcommon::row_closure().              my %setters;
                &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_evenrow_value').              my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
                '<input type="text" size="15" name="phone" /><br />'."\n".                  &Apache::loncommon::blockcheck(\%setters,'com',$ip);
                &Apache::lonhtmlcommon::row_closure();              unless (($helpform{'cc'} eq 'no') || ($by_ip)) {
     $num ++;                  $output .= &Apache::lonhtmlcommon::row_title('<label for="cc">'.$html_lt{'emac'}.'</label>',
     $i = $num%2;                                                                undef,$css[$i]).
     $output .= &Apache::lonhtmlcommon::row_title("$lt{'crsd'}$details_title",undef,$css[$i]);                             '<input type="text" size="50" name="cc" id="cc" value="" /><br />'."\n".
     if ($cnum) {                             &Apache::lonhtmlcommon::row_closure();
         if ($coursecodes{$cnum}) {                  $num ++;
             foreach my $item (@codetitles) {                  $i = $num%2;
                 $output .= '<i>'.$item.'</i>:&nbsp;'.$codes{$cnum}{$item}.';&nbsp;';  
             }              }
             $output .= '&nbsp;<input type="hidden" name="coursecode" value="'.&HTML::Entities::encode($coursecodes{$cnum},'"<>&').'" />'."\n";          }
       }
       unless (($helpform{'user'} eq 'no') || ($env{'request.lti.login'})) {
           $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'unme'}/$html_lt{'doma'}",undef,$css[$i]);
           my $udom_input = '<input type="hidden" name="udom" value="'.
                            &HTML::Entities::encode($udom,'"<>&').'" />'."\n";
           my $uname_input = '<input type="hidden" name="uname" value="'.
                            &HTML::Entities::encode($uname,'"<>&').'" />'."\n";
           if ($knownuser) {
               $output .= '<span class="LC_nobreak"><span class="LC_cusr_emph">'.$html_lt{'unme'}
                         .'</span>:&nbsp;'.$uname.'&nbsp;&nbsp;<span class="LC_cusr_emph">'
                         .$html_lt{'doma'}.'</span>:&nbsp;'.$udom.$udom_input.$uname_input.'</span>';
         } else {          } else {
             $output .= $lt{'enin'}.':&nbsp;              my $udomform = '';
                   <input type="text" name="coursecode" size="15" value="" />'."\n";              my $unameform = '';
               if (($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
                   $output .= $html_lt{'entu'};
               } elsif (($env{'user.name'} =~ /^$match_username$/) && (!$public)) { 
                   $output .= $html_lt{'chdo'};
               } else {
                   $output .= $html_lt{'entr'};
               }
               $output .= '<br />'."\n";
               if (!$public) {
                   if ($env{'user.domain'} =~ /^$match_domain$/) {
                       $udomform = '<span class="LC_cusr_emph">'.$html_lt{'doma'}.'</span>:&nbsp;'.$udom.$udom_input;
                   } elsif ($env{'user.name'} =~ /^$match_username$/) {
                       $unameform = '<span class="LC_cusr_emph">'.$html_lt{'unme'}.'</span>:&nbsp;'.$uname.'&nbsp;&nbsp;'.$uname_input;
                   }
               }
               if ($udomform eq '') {
                   $udomform = '<span class="LC_nobreak"><span class="LC_cusr_emph"><label for="udom">'
                              .$html_lt{'doma'}.'</label></span>:&nbsp;'
                              .&Apache::loncommon::select_dom_form($codedom,'udom','','','','','','','udom')."</span>\n";
               }
               if ($unameform eq '') {
                   $unameform= '<span class="LC_nobreak"><span class="LC_cusr_emph"><label for="uname">'
                              .$html_lt{'unme'}.'</label></span>:&nbsp;'
                              .'<input type="text" size="20" name="uname" id="uname" value="'.$uname.'" />'
                              .'&nbsp;&nbsp;</span>';
               }
               $output .= $unameform.$udomform;
         }          }
     } else {          $output .= &Apache::lonhtmlcommon::row_closure();
           $num ++;
           $i = $num%2;
       }
       unless ($env{'request.lti.login'}) {
           $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'urlp'}",undef,$css[$i]).
                      $server."\n".'<input type="hidden" name="sourceurl" value="'.
                      &HTML::Entities::encode($sourceurl,'"<>&').'" />'."\n".
                      &Apache::lonhtmlcommon::row_closure();
       }
       unless ($helpform{'phone'} eq 'no') {
           my ($reqd,$aria_reqd);
           if ($helpform{'phone'} eq 'req') {
               $reqd = '<span class="LC_parm_part">*</span>';
               $aria_reqd = 'aria-required="true" ';
           }
           $output .= &Apache::lonhtmlcommon::row_title('<label for="phone">'.$html_lt{'phon'}.'</label>'.$reqd,undef,'LC_evenrow_value').
                      '<input type="text" size="15" name="phone" id="phone" '.$aria_reqd.'/><br />'."\n".
                      &Apache::lonhtmlcommon::row_closure();
           $num ++;
           $i = $num%2;
       }
       unless (($helpform{'course'} eq 'no') || ($env{'request.lti.login'})) {
           $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'crsd'}$details_title",undef,$css[$i]);
         if ($totcodes > 0) {          if ($totcodes > 0) {
             my $numtitles = @codetitles;              my $numtitles = @codetitles;
             if ($numtitles == 0) {              if ($numtitles == 0) {
                 $output .= $lt{'enin'}.':&nbsp;                  $output .= '<label>'.$html_lt{'enin'}.':&nbsp;
                   <input type="text" name="coursecode" size="15" value="" />'."\n";                    <input type="text" name="coursecode" size="15" value="'.&HTML::Entities::encode($ccode,'\'"&<>').'" /></label>'."\n";
             } else {              } else {
                 my @standardnames = &Apache::loncommon::get_standard_codeitems();                  my @standardnames = &Apache::loncommon::get_standard_codeitems();
                 my $lasttitle = $numtitles;                  my $lasttitle = $numtitles;
                 if ($numtitles > 4) {                  if ($numtitles > 4) {
                     $lasttitle = 4;                      $lasttitle = 4;
                 }                   }
                 $output .= '<table><tr><td>'.$codetitles[0].'<br />'."\n".                  my $onchange;
                       '<select name="'.$standardnames[0].'" onchange="courseSet('."'$codetitles[0]'".')">'."\n".                  if ($sectionlist) {
                       ' <option value="-1">'.$lt{'sele'}."</option>\n";                      $onchange = 'toggleSecVis()';
                   }
                   $output .= '<table><tr>';
                   for (my $i=0; $i<$lasttitle; $i++) {
                       $output .= '<th><label for="'.$standardnames[$i].'_'.$i.'">'.$codetitles[0].'</label></th>';
                   }
                   $output .= '</tr>';
                   $output .= '<tr><td>'.
                         '<select name="'.$standardnames[0].'" id="'.$standardnames[0].'_0" onchange="courseSet('."'$codetitles[0]'".');'.$onchange.'">'."\n".
                         ' <option value="-1">'.$html_lt{'sele'}."</option>\n";
                 my @items = ();                  my @items = ();
                 my @longitems = ();                  my @longitems = ();
                 if ($idlist{$codetitles[0]} =~ /","/) {                  if ($idlist{$codetitles[0]} =~ /","/) {
Line 424  ENDJS Line 529  ENDJS
                     $output .= ' <option value="'.$items[$i].'">'.$longitems[$i].'</option>'."\n";                      $output .= ' <option value="'.$items[$i].'">'.$longitems[$i].'</option>'."\n";
                 }                  }
                 $output .= '</select></td>';                  $output .= '</select></td>';
                 for (my $i=1; $i<$numtitles; $i++) {                  for (my $i=1; $i<$lasttitle; $i++) {
                     $output .= '<td>'.$codetitles[$i].'<br />'."\n".                      $output .= '<td>'."\n".
                      '<select name="'.$standardnames[$i].'" onchange="courseSet('."'$codetitles[$i]'".')">'."\n".                       '<select name="'.$standardnames[$i].'" id="'.$standardnames[$i].'_'.$i.'" onchange="courseSet('."'$codetitles[$i]'".');'.$onchange.'">'."\n".
                      '<option value="-1">&lt;-'.$lt{'pick'}.' '.$codetitles[$i-1].'</option>'."\n".                       '<option value="-1">&lt;-'.$html_lt{'pick'}.' '.$codetitles[$i-1].'</option>'."\n".
                      '</select>'."\n".                       '</select>'."\n".
                      '</td>'."\n";                       '</td>'."\n";
                 }                  }
                 $output .= '</tr></table>';                  $output .= '</tr></table>';
                 if ($numtitles > 4) {                  if ($numtitles > 4) {
                     $output .= '<br /><br />'.$codetitles[$numtitles].'<br />'."\n".                      $output .= '<br /><br /><label>'.$codetitles[$numtitles].'<br />'."\n".
                           '<select name="'.$standardnames[$numtitles].'" onchange="courseSet('."'$codetitles[$numtitles]'".')">'."\n".                            '<select name="'.$standardnames[$numtitles].'" onchange="courseSet('."'$codetitles[$numtitles]'".');'.$onchange.'">'."\n".
                           '<option value="-1">&lt;-'.$lt{'pick'}.' '.$codetitles[$numtitles-1].'</option>'."\n".                            '<option value="-1">&lt;-'.$html_lt{'pick'}.' '.$codetitles[$numtitles-1].'</option>'."\n".
                           '</select>'."\n";                            '</select></label>'."\n";
                 }                  }
             }              }
         } else {          } else {
             $output .= $lt{'enin'}.':&nbsp;              $output .= '<label>'.$html_lt{'enin'}.':&nbsp;
                   <input type="text" name="coursecode" size="15" value="" />'."\n";                    <input type="text" name="coursecode" size="15" value="" /></label>'."\n";
         }          }
     }          my ($reqd,$aria_reqd);
     if ($ctitle) {          if ($helpform{'course'} eq 'req') {
         $output .= '<br /><i>'.$lt{'titl'}.'</i>:&nbsp;'.$ctitle.               $reqd = '<span class="LC_parm_part">*</span>';
                    '<input type="hidden" name="title" value="'.               $aria_reqd = 'aria-required="true" ';
                    &HTML::Entities::encode($ctitle,'"<>&').'" />'."\n";          }
     } else {          $output .= '<br /><div><label>'.$html_lt{'enct'}.$reqd.':&nbsp;
         $output .= '<br />'.$lt{'enct'}.':&nbsp;                     <input type="text" name="title" size="25" value="'.
                  <input type="text" name="title" size="25" value="" />'."\n";                     &HTML::Entities::encode($ctitle,'"<>&').'" '.$aria_reqd.'/></label></div>'."\n";
     }          $output .= &Apache::lonhtmlcommon::row_closure();
     $output .= &Apache::lonhtmlcommon::row_closure();          $num ++;
     $num ++;          $i = $num%2;
     $i = $num%2;      }
     $output .= &Apache::lonhtmlcommon::row_title($lt{'secn'},undef,$css[$i]);      unless (($helpform{'section'} eq 'no') || ($env{'request.lti.login'})) {
     if ($sectionlist) {          $output .= &Apache::lonhtmlcommon::row_title('<label for="section">'.$html_lt{'secn'}.'</label>',
         $output .= "<select name=\"section\"\n>".                                                       undef,$css[$i]);
                    "  <option value=\"\" selected=\"selected\">$lt{'sele'}</option>\n";          if ($sectionlist) {
         foreach my $id (sort(keys(%groupid))) {              $output .= "<div id=\"LC_helpdesk_sectionlist\">\n".
             if ($id eq $groupid{$id} || $groupid{$id} eq '') {                         "<select name=\"sectionsel\" id=\"section\">\n".
                 $output .= "  <option value=".                         "  <option value=\"\" selected=\"selected\">$html_lt{'sele'}</option>\n";
                            &HTML::Entities::encode($id,'"<>&').              foreach my $id (sort(keys(%groupid))) {
                            " >$id</option>\n";                  if ($id eq $groupid{$id} || $groupid{$id} eq '') {
             } else {                      $output .= "  <option value=".
                 $output .= "  <option value=".                                 &HTML::Entities::encode($id,'"<>&').
                            &HTML::Entities::encode($id,'"<>&').                                 " >$id</option>\n";
                            " >$id - ($lt{'lsec'}: $groupid{$id})</option>\n";                  } else {
                       $output .= "  <option value=".
                                  &HTML::Entities::encode($id,'"<>&').
                                  " >$id - ($html_lt{'lsec'}: $groupid{$id})</option>\n";
                   }
             }              }
               $output .= '</select></div>'."\n".
                          '<div id="LC_helpdesk_section" style="display:none">'.
                          '<input type="text" name="sectiontxt" id="notinuse" size="10" /></div>'."\n";
           } else {
               $output .= '<input type="text" name="section" id="section" size="10" />'."\n";
         }          }
         $output .= "</select>";          $output .= &Apache::lonhtmlcommon::row_closure();
     } else {          $num ++;
         $output .= '<input type="text" name="section" size="10" />'."\n";          $i = $num%2;
     }      }
     $output .= &Apache::lonhtmlcommon::row_closure();      $output .= &Apache::lonhtmlcommon::row_title(
     $num ++;                     '<span title="'.&mt('required').'">'.
     $i = $num%2;                      '<label for="subject">'.$html_lt{'subj'}.'</label>'.
     $output .= &Apache::lonhtmlcommon::row_title($lt{'subj'},undef,'LC_oddrow_value').                     '<span class="LC_parm_part">*</span></span>'
                '  <input type="text" size="40" name="subject" />'."\n".                    ,undef,'LC_oddrow_value').
                  '<input type="text" size="40" name="subject" id="subject" aria-required="true" />'."\n".
                &Apache::lonhtmlcommon::row_closure().                 &Apache::lonhtmlcommon::row_closure().
                &Apache::lonhtmlcommon::row_title($lt{'detd'},undef,'LC_evenrow_value').                 &Apache::lonhtmlcommon::row_title(
                '  <textarea rows="10" cols="45" name="description" style="word-wrap:normal;">'.                     '<span title="'.&mt('required').'">'.
                      '<label for="description">'.$html_lt{'detd'}.'</label>'.
                      '<span class="LC_parm_part">*</span></span>'
                     ,undef,'LC_evenrow_value').
                  '<textarea rows="10" cols="45" name="description" id="description" style="word-wrap:normal;" aria-required="true">'.
                '</textarea>'."\n".                 '</textarea>'."\n".
                &Apache::lonhtmlcommon::row_closure();                 &Apache::lonhtmlcommon::row_closure();
     $num ++;      $num ++;
     $i = $num%2;       $i = $num%2; 
     if (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {      if ($knownuser) {
         if ($homeserver) {          if ($homeserver) {
             $output .= &Apache::lonhtmlcommon::row_title($lt{'opfi'},undef,$css[$i]).              unless ($helpform{'screenshot'} eq 'no') {
                        ' <input type="file" name="screenshot" size="20" /><br />'.                  my $max = 1048576;
                        "\n".$lt{'uplf'}."\n".                  my $showmax = 1.00;
                        &Apache::lonhtmlcommon::row_closure();                  if ($helpform{'maxsize'} =~ /^\d+\.\d*$/) {
             $num ++;                      $max *= $helpform{'maxsize'};
             $i = $num%2;                      $showmax = $helpform{'maxsize'};
                   }
                   $showmax = ' ('.sprintf("%.2f",$showmax).' '.&mt('MB max.').')';
                   $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i])
                       .'<input type="file" name="screenshot" id="screenshot" class="LC_flUpload" size="20" />'
                       .'<input type="hidden" id="LC_free_space" value="'.$max.'" />'
                       .'<br />'."\n".'<label for="screenshot">'.$html_lt{'uplf'}.'</label>'.$showmax."\n"
                       .&Apache::lonhtmlcommon::row_closure();
                   $num ++;
                   $i = $num%2;
               }
         }          }
     } else {      } else {
         my $lonhost = $r->dir_config('lonHostID');          if ($captcha_form) {
         my ($captchaform,$error) =               $output .= &Apache::lonhtmlcommon::row_title(
             &Apache::loncommon::captcha_display('login',$lonhost);                             '<span title="'.&mt('required').'">'.
         if ($captchaform) {                             &mt('Validation').
             $output .= &Apache::lonhtmlcommon::row_title(&mt('Validation'),undef,                             '<span class="LC_parm_part">*</span></span>'
                                                          $css[$i])."\n".                        ,undef,$css[$i]).
                        $captchaform."\n".                         $captcha_form."\n".
                        &Apache::lonhtmlcommon::row_closure();                         &Apache::lonhtmlcommon::row_closure();
             $num ++;              $num ++;
             $i = $num%2;              $i = $num%2;
         }          }
     }      }
     $output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$css[$i]);      $output .= &Apache::lonhtmlcommon::row_title($html_lt{'fini'},undef,$css[$i]);
     $output .= <<END;      $output .= <<END;
              <table border="0" cellpadding="8" cellspacing="0">               <div>
               <tr>                 <div class="LC_floatleft" style="padding-top:0, padding-left:8px; padding-right:8px; padding-bottom:0; margin:0">
                <td>  
                 <input type="hidden" name="command" value="process" />                  <input type="hidden" name="command" value="process" />
                 <input type="button" value="$lt{'subm'}" onclick="validate()" /> &nbsp;                  <input type="button" value="$html_lt{'subm'}" onclick="validate()" /> &nbsp;
                </td>                 </div>
                <td>&nbsp;</td>                 <div class="LC_floatleft" style="padding-top:0, padding-left:8px; padding-right:8px; padding-bottom:0; margin:0">
                <td>                  <input type="reset" value="$html_lt{'clfm'}" />
                 <input type="reset" value="$lt{'clfm'}" />                 </div>
                </td>               </div>
               </tr>               <div style="padding:0;clear:both;margin:0;border:0"></div>
              </table>  
 END  END
     $output .= &Apache::lonhtmlcommon::row_closure(1);      $output .= &Apache::lonhtmlcommon::row_closure(1);
     $output .= &Apache::lonhtmlcommon::end_pick_box();      $output .= &Apache::lonhtmlcommon::end_pick_box();
Line 529  END Line 656  END
 $output  $output
 </form>  </form>
 <br />  <br />
   </div>
 END  END
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
     return;      return;
Line 537  END Line 665  END
 sub print_request_receipt {  sub print_request_receipt {
     my ($r,$url,$function) = @_;      my ($r,$url,$function) = @_;
     my $public;      my $public;
       my $args;
     if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {      if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
         $public = 1;          $public = 1;
     }      }
       my $lonhost = $r->dir_config('lonHostID');
     unless (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {      unless (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
         my $lonhost = $r->dir_config('lonHostID');  
         my ($captcha_chk,$captcha_error) =           my ($captcha_chk,$captcha_error) = 
             &Apache::loncommon::captcha_response('login',$lonhost);              &Apache::loncommon::captcha_response('login',$lonhost);
         if ($captcha_chk != 1) {          if ($captcha_chk != 1) {
             $r->print(&Apache::loncommon::start_page('Support request failed',undef,              $args = {
                                        {'function'    => $function,                       'function'    => $function,
                                         'add_entries' => {                       'add_entries' => {
                                             topmargin    => "0",                                           topmargin    => "0",
                                             marginheight => "0",                                           marginheight => "0",
                                         },                                        },
                                         'only_body'   => 1,}));                       'only_body'   => 1,};
               (undef,undef,undef,my $clientmathml,my $clientunicode) =
                   &Apache::loncommon::decode_user_agent();
               if ($clientunicode && !$clientmathml) {
                   $args->{'browser.unicode' => 1};
               }
               $r->print(&Apache::loncommon::start_page('Support request failed',undef,$args));
             if ($r->uri eq '/adm/helpdesk') {              if ($r->uri eq '/adm/helpdesk') {
                 &print_header($r,$url,'process');                  &print_header($r,$url,'process');
             }              }
             $r->print('<h3>'.&mt('Support request failed').'</h3>'.              $r->print(
                       '<span class="LC_error">'.                  '<div class="LC_landmark" role="main">'.
                       &mt('Validation of the code you entered failed.').                  '<h2 class="LC_heading_2">'.&mt('Support request failed').'</h2>'.
                       &Apache::loncommon::end_page());                        &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>')]).
                   '</div>'.
                   &Apache::loncommon::end_page());
             return;              return;
         }          }
     }      }
     my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');      my $ip = &Apache::lonnet::get_requestor_ip($r);
       my %setters;
       my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
           &Apache::loncommon::blockcheck(\%setters,'com',$ip);
       my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','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;
       if ($ENV{'SERVER_PORT'} == 443) {
           @cookievars = ('lonLinkID');
       } else {
           @cookievars = ('lonID');
       }
   
     my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};      my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
     my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};      my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
     my $defdom = &get_domain();      my $defdom = &get_domain();
     my $to = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',  
                                                       $defdom,$origmail);  
     my $from = $admin;      my $from = $admin;
     my $bcc;      my %helpform;
     my %domconfig =      my %domconfig =
          &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);           &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);
     if (ref($domconfig{'contacts'}) eq 'HASH') {      if (ref($domconfig{'contacts'}) eq 'HASH') {
         if (exists($domconfig{'contacts'}{'helpdeskmail'})) {          if (ref($domconfig{'contacts'}{'helpform'}) eq 'HASH') {
             if (ref($domconfig{'contacts'}{'helpdeskmail'}) eq 'HASH') {              %helpform = %{$domconfig{'contacts'}{'helpform'}};
                 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 @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot');      my %formvars = (
                        email       => 1,
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);                       sourceurl   => 1,
     my $coursecode = $env{'form.coursecode'};                       subject     => 1,
     if ($coursecode eq '') {                       description => 1,
         my $totcodes = 0;                     );
         my %coursecodes;      unless ($helpform{'username'} eq 'no') {
         $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$defdom,$totcodes);          $formvars{'username'} = 1;
         my @standardnames = &Apache::loncommon::get_standard_codeitems();      }
         if ($totcodes > 0) {      unless ($helpform{'user'} eq 'no') {
             my $noregexps = 1;          $formvars{'uname'} = 1;
             $coursecode =           $formvars{'udom'} = 1;
                 &Apache::courseclassifier::instcode_from_selectors($defdom,$noregexps);      }
         }       unless ($helpform{'phone'} eq 'no') {
           $formvars{'phone'} = 1;
       }
       unless (($helpform{'section'} eq 'no') || ($env{'request.lti.login'})) {
           $formvars{'section'} = 1;
       }
       unless (($helpform{'course'} eq 'no') || ($env{'request.lti.login'})) {
           $formvars{'course'} = 1;
       }
       unless (($helpform{'cc'} eq 'no') || ($by_ip)) {
           $formvars{'cc'} = 1;
       }
       unless ($helpform{'screenshot'} eq 'no') {
           $formvars{'screenshot'} = 1;
       }
       my ($coursecode,$sourceurl);
       if ($formvars{'course'}) {
           $coursecode = $env{'form.coursecode'};
         if ($coursecode eq '') {          if ($coursecode eq '') {
             foreach my $item (@standardnames) {              my $totcodes = 0;
                 if ((defined($env{'form.'.$item})) && ($env{'form.'.$item} ne '-1')) {              my $instcats = &Apache::lonnet::get_dom_instcats($defdom);
                     $coursecode .= $env{'form.'.$item};              if (ref($instcats) eq 'HASH') {
                   if (ref($instcats->{'codes'}) eq 'HASH') {
                       $totcodes = scalar(keys(%{$instcats->{'codes'}}));
                   }
               }
               my @standardnames = &Apache::loncommon::get_standard_codeitems();
               if ($totcodes > 0) {
                   my $noregexps = 1;
                   $coursecode = 
                       &Apache::courseclassifier::instcode_from_selectors($defdom,$noregexps);
               }
               if ($coursecode eq '') {
                   foreach my $item (@standardnames) {
                       if ((defined($env{'form.'.$item})) && ($env{'form.'.$item} ne '-1')) {
                           $coursecode .= $env{'form.'.$item};
                       }
                 }                  }
             }              }
         }          }
Line 636  sub print_request_receipt { Line 799  sub print_request_receipt {
                  secn        => 'Section',                   secn        => 'Section',
                  warn        => 'Warning: Problem with support e-mail address',                   warn        => 'Warning: Problem with support e-mail address',
                  your        => 'Your support request contained the following information',                   your        => 'Your support request contained the following information',
                    belo        => 'Below is your support request which could not be sent',
                    ifyk        => 'If you know an IT support address for your institution, you could copy this information and send it to that email address.',
                  sect        => 'section',                   sect        => 'section',
                  info        => 'Information supplied',                   info        => 'Information supplied',
                  adin        => 'Additional information recorded',                   adin        => 'Additional information recorded',
     );      );
   
     my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist,$public,$homeserver);      my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist,$homeserver);
     if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {      unless ($public) {
         $public = 1;  
     } else {  
         if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {          if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
             $homeserver = &Apache::lonnet::homeserver($env{'user.name'},              $homeserver = &Apache::lonnet::homeserver($env{'user.name'},
                                                       $env{'user.domain'});                                                        $env{'user.domain'});
         }          }
     }      }
       my ($cid,$cdom,$cnum,$sectionlist,$ccode);
     if (($homeserver) && (defined($env{'form.cc'}))) {      if ($homeserver) {
           $cid = $env{'request.course.id'};
       }
       if ($cid) {
           $cdom = $env{'course.'.$cid.'.domain'};
           $cnum = $env{'course.'.$cid.'.num'};
       }
       if ($cdom && $cnum) {
           my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);
           $ccode = $csettings{'internal.coursecode'};
           $sectionlist = $csettings{'internal.sectionnums'};
       }
       if (($homeserver) && (defined($env{'form.cc'})) && ($formvars{'cc'})) {
         my @ccs;          my @ccs;
         if ($env{'form.cc'} =~ /,/) {          if ($env{'form.cc'} =~ /,/) {
             @ccs = split(/,/,$env{'form.cc'});              @ccs = split(/,/,$env{'form.cc'});
Line 677  sub print_request_receipt { Line 852  sub print_request_receipt {
            $okcclist = join(', ',@ok_ccs);              $okcclist = join(', ',@ok_ccs); 
         }           } 
         if (@bad_ccs == 1) {          if (@bad_ccs == 1) {
             $badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').$bad_ccs[0];              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) {          } elsif (@bad_ccs > 1) {
             my $bad_cc_string = join(', ',@bad_ccs);              $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: '). &Apache::loncommon::cleanup_html(join(', ',@bad_ccs));
             $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: ').$bad_cc_string;          }
       }
       if ($env{'request.lti.login'}) {
           if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
               $env{'form.user'} = "'".$env{'user.name'}.':'.$env{'user.domain'}."'";
           }
           $sourceurl = &Apache::lonnet::absolute_url().$url;
       } else {
           $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";
           $sourceurl = $env{'form.sourceurl'};
       }
       if ($formvars{'course'}) {
           $env{'form.crsi'} = $env{'form.title'};
           if ($coursecode ne '') {
               $env{'form.crsi'} .= ' - '.$coursecode;
         }          }
     }      }
     $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";      if ($formvars{'section'}) {
     $env{'form.crsi'} = $env{'form.title'}.' - '.$coursecode.' - '.$lt{'sect'}.': '.$env{'form.section'};          my $section;
     my $supportmsg = <<END;          if ($sectionlist) {
 $lt{'username'}: $env{'form.username'}              if ($coursecode eq $ccode) {
 $lt{'email'}: $env{'form.email'}                  $section = $env{'form.sectionsel'}
 $lt{'cc'}: $okcclist              } else {
 $lt{'user'}: $env{'form.user'}                  $section = $env{'form.sectiontxt'};
 $lt{'phone'}: $env{'form.phone'}              }
 $lt{'crsi'}: $env{'form.crsi'}          } else {
 $lt{'subject'}: $env{'form.subject'}              $section = $env{'form.section'};
           }
           $env{'form.crsi'} .= ' - '.$lt{'sect'}.': '.$section;
       }
       my $supportmsg;
       if ($formvars{'username'}) {
           $supportmsg .= "$lt{'username'}: $env{'form.username'}\n";
       }
       $supportmsg .= "$lt{'email'}: $env{'form.email'}\n";
       if (($homeserver) && (defined($env{'form.cc'})) && ($formvars{'cc'})) {
           $supportmsg .= "$lt{'cc'}: $okcclist\n";
       }
       if ($formvars{'user'}) {
           $supportmsg .= "$lt{'user'}: $env{'form.user'}\n";
       }
       if ($formvars{'phone'}) {
           $supportmsg .= "$lt{'phone'}: $env{'form.phone'}\n";
       }
       if ($formvars{'course'}) {
           $supportmsg .= "$lt{'crsi'}: $env{'form.crsi'}\n";
       }
       $supportmsg .= "$lt{'subject'}: $env{'form.subject'}
 $lt{'description'}: $env{'form.description'}  $lt{'description'}: $env{'form.description'}
 $lt{'sourceurl'}: $env{'form.sourceurl'}  $lt{'sourceurl'}: $sourceurl
 $lt{'date'}: $reporttime  $lt{'date'}: $reporttime
   ";
   
 END  
     my $displaymsg;      my $displaymsg;
     foreach my $item ('username','email','cc','user','phone','crsi','subject','description','sourceurl') {      foreach my $item ('username','email','cc','user','phone','crsi','subject','description','sourceurl') {
         if ($env{'form.'.$item} ne '') {          if ($env{'form.'.$item} ne '') {
             if ($item eq 'description') {              if ($item eq 'description') {
                 my $descrip = $env{'form.description'};                  my $descrip = $env{'form.description'};
                 $descrip =  &cleanup_html($descrip);                  $descrip =  &Apache::loncommon::cleanup_html($descrip);
                 $descrip =~ s|[\n\r\f]|<br />|g;                  $descrip =~ s|[\n\r\f]|<br />|g;
                 $displaymsg .=                   $displaymsg .= 
                     '<span class="LC_helpform_receipt_cat">'.                      '<span class="LC_helpform_receipt_cat">'.
Line 711  END Line 923  END
             } elsif ($item eq 'sourceurl') {              } elsif ($item eq 'sourceurl') {
                 my $showurl = $env{'form.sourceurl'};                  my $showurl = $env{'form.sourceurl'};
                 $showurl =~ s/\?.*$//;                  $showurl =~ s/\?.*$//;
                 $showurl =  &cleanup_html($showurl);                  $showurl =  &Apache::loncommon::cleanup_html($showurl);
                 $displaymsg .=                   $displaymsg .= 
                     '<span class="LC_helpform_receipt_cat">'.                      '<span class="LC_helpform_receipt_cat">'.
                     "$lt{$item}</span>: $showurl<br />\n";                      "$lt{$item}</span>: $showurl<br />\n";
             } elsif ($item eq 'cc') {              } elsif ($item eq 'cc') {
                 $displaymsg .=                  next if ($helpform{'cc'} eq 'no');
                     '<span class="LC_helpform_receipt_cat">'.                  if ($okcclist) {
                     "$lt{$item}</span>: $okcclist<br />\n";                      my $showcclist = &Apache::loncommon::cleanup_html($okcclist);
                       $displaymsg .=
                           '<span class="LC_helpform_receipt_cat">'.
                           "$lt{$item}</span>: $showcclist<br />\n";
                   }
             } else {              } else {
                   if (($item eq 'username') || ($item eq 'user') || ($item eq 'phone')) {
                       next if ($helpform{$item} eq 'no');
                   }
                   next if (($item eq 'crsi') && ($helpform{'course'} eq 'no'));
                   next if (($item eq 'user') && ($env{'request.lti.login'}));
                 my $showitem = $env{'form.'.$item};                  my $showitem = $env{'form.'.$item};
                 $showitem = &cleanup_html($showitem);                  $showitem = &Apache::loncommon::cleanup_html($showitem);
                 $displaymsg .=                   $displaymsg .= 
                     '<span class="LC_helpform_receipt_cat">'.                      '<span class="LC_helpform_receipt_cat">'.
                     "$lt{$item}</span>: $showitem<br />\n";                      "$lt{$item}</span>: $showitem<br />\n";
             }              }
         }          }
     }      }
     $displaymsg .= '<span class="LC_helpform_receipt_cat">'.  
                    $lt{'date'}.'</span>: '.$reporttime.'<br />'."\n";  
   
     my $start_page =       my ($requname,$requdom,$reqemail);
  &Apache::loncommon::start_page('Support request recorded',undef,      foreach my $field ('uname','udom','email') {
        {'function'    => $function,          $env{'form.'.$field} =~ s/^\s+//;
  'add_entries' => {          $env{'form.'.$field} =~ s/\s+$//;
     topmargin    => "0",      }
     marginheight => "0",      if ($env{'form.uname'} =~ /^$match_username$/) {
  },          $requname = $env{'form.uname'};
  'only_body'   => 1,});      }
       if ($env{'form.udom'} =~ /^$match_domain$/) {
           $requdom = $env{'form.udom'};
       }
       if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
           $reqemail = $env{'form.email'};
       }
   
       my $dom_in_effect;
       unless ($env{'user.domain'} eq 'public') {
           $dom_in_effect = $env{'user.domain'};
       }
       if ($dom_in_effect eq '') {
           $dom_in_effect = $requdom;
       }
       if ($dom_in_effect eq '') {
           $dom_in_effect = $defdom;
       }
   
       $displaymsg .= '<span class="LC_helpform_receipt_cat">'.
                      $lt{'date'}.'</span>: '.$reporttime.'<br />'."\n";
       my $args = {'function'    => $function,
                   'add_entries' => {
                                       topmargin    => "0",
                                       marginheight => "0",
                                    },
                   'only_body'   => 1,};
       (undef,undef,undef,my $clientmathml,my $clientunicode) =
           &Apache::loncommon::decode_user_agent();
       if ($clientunicode && !$clientmathml) {
           $args->{'browser.unicode'} = 1;
       }
       $r->print(&Apache::loncommon::start_page('Support request recorded',undef,$args));
     $r->print(<<"END");      $r->print(<<"END");
 $start_page  <form name="logproblem" action="">
 <form name="logproblem">  
 <input type="hidden" name="command" value="result" />  <input type="hidden" name="command" value="result" />
 </form>  </form>
 END  END
Line 750  END Line 999  END
         &print_header($r,$url,'process');          &print_header($r,$url,'process');
     }      }
     my $bad_email = 0;      my $bad_email = 0;
       my ($to,$bcc,$addtext) =
           &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
                                                    $dom_in_effect,$origmail,
                                                    $requname,$requdom,
                                                    $reqemail);
     if ($to =~ /,/) {      if ($to =~ /,/) {
         my @ok_email;           my @ok_email; 
         foreach my $email (split(/,/,$to)) {          foreach my $email (split(/,/,$to)) {
Line 776  END Line 1030  END
   
     my $message;      my $message;
     if (!$bad_email) {      if (!$bad_email) {
         $message = &Apache::lonhtmlcommon::confirm_success(          $message = &mt('A support request has been sent to [_1]','<tt>'.$to.'</tt>');
             &mt('A support request has been sent to [_1]','<tt>'.$to.'</tt>'));  
     } else {      } else {
         $message = &Apache::lonhtmlcommon::confirm_success(          $message = $lt{'warn'}.'<br />';
             $lt{'warn'}.'<br />'          if ($to eq '') {
            .&mt('As the e-mail address provided for this LON-CAPA server ([_1]) does not appear to be a valid e-mail address, your support request has [_2]not[_3] been sent to the LON-CAPA support staff or administrator at your institution.','<tt>'.$to.'</tt>','<b>','</b>')              $message .= &mt('For this LON-CAPA server no e-mail address has been configured to receive support requests, so your support request has [_1]not[_2] been sent to the LON-CAPA support staff or administrator at your institution.','<b>','</b>');
            .' '.&mt('Instead a copy has been sent to the LON-CAPA support team at Michigan State University.'),1);           } else {
         $to = 'helpdesk@lon-capa.org';              $message .= &mt('As the e-mail address provided for this LON-CAPA server ([_1]) does not appear to be a valid e-mail address, your support request has [_2]not[_3] been sent to the LON-CAPA support staff or administrator at your institution.','<tt>'.$to.'</tt>','<b>','</b>');
     }  
     $r->print(&Apache::loncommon::confirmwrapper($message));  
   
     if (defined($env{'form.email'})) {  
         $env{'form.email'} =~ s/^\s+//;  
         $env{'form.email'} =~ s/\s+$//;  
         if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {  
             $from = $env{'form.email'};  
         }          }
     }      }
       $r->print('<div class="LC_landmark" role="main">');
       if ($bad_email) {
           $r->print(&Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($message,$bad_email)).'<br />');
       }
       if ($reqemail ne '') {
           $from = $reqemail;
       }
   
     if (defined($env{'form.cc'})) {      if (defined($env{'form.cc'})) {
         if ($badccmsg) {          if ($badccmsg) {
Line 811  END Line 1063  END
     my $fname;      my $fname;
   
     my $attachmentpath = '';      my $attachmentpath = '';
     my $attachmentsize = '';      my $showsize = '';
     if ((defined($env{'user.name'})) && ($env{'user.name'} ne 'public')  
         && ($env{'user.domain'} ne 'public')) {      if ((defined($env{'user.name'})) && (!$public)) {
         if ($homeserver && $env{'form.screenshot.filename'}) {          if ($homeserver && $env{'form.screenshot.filename'}) {
             $attachmentsize = length($env{'form.screenshot'});              unless ($helpform{'screenshot'} eq 'no') {
             if ($attachmentsize > 131072) {                  my $attachmentsize = length($env{'form.screenshot'});
                 $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);                  my $max = 1048576;
             } else {                  my $showmax = 1.00;
                 $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');                  if ($helpform{'maxsize'} =~ /^\d+\.\d*$/) {
                       $max *= $helpform{'maxsize'};
                       $showmax = $helpform{'maxsize'};
                   }
                   $showmax = '('.sprintf("%.2f",$showmax).' MB)';
                   $showsize = $attachmentsize/1048576;
                   $showsize = '('.sprintf("%.2f",$showsize).' MB)';
                   if ($attachmentsize > $max) {
                       $displaymsg .= '<br /><span class="LC_warning">'.
                                      &mt('The uploaded screenshot file [_1] included with your request exceeded the maximum allowed size [_2], and has therefore been discarded.',$showsize,$showmax).'</span>';
                   } else {
                       $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
                   }
             }              }
         }          }
     }      }
Line 829  END Line 1093  END
     if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) {      if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) {
         $cookies{'lonID'} = $1;          $cookies{'lonID'} = $1;
     }      }
       if ($$cookie{'lonLinkID'} =~ /lonLinkID=([a-f0-9]+_linked);/) {
           $cookies{'lonLinkID'} = $1;
       }
       my $lti_info;
       if (($env{'request.lti.login'}) && ($env{'request.course.id'})) {
           my $ltidom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           if ($ltidom) {
               my %lti = &Apache::lonnet::get_domain_lti($ltidom,'provider');
               if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
                   if ($lti{$env{'request.lti.login'}}{'consumer'}) {
                       $lti_info = "LTI consumer: ".$lti{$env{'request.lti.login'}}{'consumer'}."\n";
                   }
               }
           }
       }
     if ($attachmentpath =~ m-/([^/]+)$-) {      if ($attachmentpath =~ m-/([^/]+)$-) {
         $fname = $1;          $fname = $1;
         $displaymsg .= '<br />'          $displaymsg .= '<br />'
                       .&mt('An uploaded screenshot file [_1] ([_2] bytes) was included in the request sent by [_3].'                        .&mt('An uploaded screenshot file [_1] was included in the request sent by [_2].'
                           ,'<span class="LC_filename">'.$fname.'</span>'                            ,'<span class="LC_filename">'.$fname.'</span>&nbsp;'.$showsize,
                           ,$attachmentsize  
                           ,$env{'user.name'}.':'.$env{'user.domain'}                            ,$env{'user.name'}.':'.$env{'user.domain'}
                        );                         );
         $supportmsg .= "\n";          $supportmsg .= "\n";
Line 845  END Line 1122  END
         foreach my $var(@ENVvars) {          foreach my $var(@ENVvars) {
             $supportmsg .= "$var: $ENV{$var}\n";              $supportmsg .= "$var: $ENV{$var}\n";
         }          }
           $supportmsg .= "REMOTE_ADDR: $ip\n";
         foreach my $var (@envvars) {          foreach my $var (@envvars) {
             $supportmsg .= "$var: $env{$var}\n";              $supportmsg .= "$var: $env{$var}\n";
         }          }
           if ($lti_info) {
               $supportmsg .= $lti_info;
           }
     }      }
    
     my $msg = MIME::Lite->new(      my $cc_string;
                  From    => $from,  
                  To      => $to,  
                  Subject => $subject,  
                  Type    =>'TEXT',  
                  Data    => $supportmsg,  
                  );  
     if ($homeserver) {      if ($homeserver) {
         if (@ok_ccs > 0) {          if (@ok_ccs > 0) {
             my $cc_string = join(', ',@ok_ccs);              $cc_string = join(', ',@ok_ccs);
             $msg->add("Cc" => $cc_string);  
         }          }
     }      }
     if ($bcc ne '') {  
         $msg->add("Bcc" => $bcc);  
     }  
     $msg->attr("content-type"         => "text/plain");  
     $msg->attr("content-type.charset" => "UTF-8");  
   
     if ($homeserver && $attachmentpath) {  
         my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);  
         $msg->attach(Type     => $type,  
                      Path     => $attachmentpath,  
                      Filename => $fname  
                      );  
   
     } else {      my $attachment_text = '';
         my $envdata = '';      unless ($homeserver && $attachmentpath) {
         foreach my $var (@cookievars) {          foreach my $var (@cookievars) {
             $envdata .= "$var: $cookies{$var}\n";              $attachment_text .= "$var: $cookies{$var}\n";
         }          }
         foreach my $var (@ENVvars) {          foreach my $var (@ENVvars) {
             $envdata .= "$var: $ENV{$var}\n";              $attachment_text .= "$var: $ENV{$var}\n";
         }          }
           $attachment_text .= "REMOTE_ADDR: $ip\n";
         foreach my $var (@envvars) {          foreach my $var (@envvars) {
             $envdata .= "$var: $env{$var}\n";              $attachment_text .= "$var: $env{$var}\n";
         }          }
         foreach my $var (@loncvars) {          foreach my $var (@loncvars) {
             $envdata .= "$var: $env{$var}\n";              $attachment_text .= "$var: $env{$var}\n";
           }
           if ($lti_info) {
               $attachment_text .= $lti_info;
         }          }
         $msg->attach(Type => 'TEXT',  
                      Data => $envdata);  
     }      }
   
 ### Send it:      if ($addtext) {
     $msg->send('sendmail');          my ($addloc,$addstr) = split(/:/,$addtext,2);
           $addstr = &unescape($addstr);
           if ($addloc eq 's') {
               $subject = $addstr.' '.$subject;
           } elsif ($addloc eq 'b') {
               $supportmsg = $addstr."\n".$supportmsg;
           }
       }
   
       if ($bad_email) {
           $r->print('<b>'.$lt{'belo'}.'</b><br />'.
                     $lt{'ifyk'}."\n");
       } else {
           # Compose and send a MIME email
           &Apache::loncommon::mime_email($from,'',$to,$subject,$supportmsg,$cc_string,
                                          $bcc,$attachmentpath,$fname,$attachment_text);
           $r->print('<b>'.$lt{'your'}.'</b>:'."\n");
       }
     if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) {      if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) {
         unlink($attachmentpath);          unlink($attachmentpath);
     }      }
     $r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n");  
     $r->print('<div style="width:620px;">'.      $r->print('<div style="width:620px;">'.
               &Apache::lonhtmlcommon::start_pick_box().                &Apache::lonhtmlcommon::start_pick_box().
               &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n".                &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n".
Line 919  END Line 1198  END
                        $var.'</span>:&nbsp;'.$ENV{$var}.', ';                         $var.'</span>:&nbsp;'.$ENV{$var}.', ';
         }          }
     }      }
       if ($ip ne '') {
           $envmsg .= '<span class="LC_helpform_receipt_cat">'.
                      'REMOTE_ADDR</span>:&nbsp;'.$ip.', ';
       }
     foreach my $var (@envvars) {      foreach my $var (@envvars) {
         if ($env{$var} ne '') {           if ($env{$var} ne '') { 
             $envmsg .= '<span class="LC_helpform_receipt_cat">'.              $envmsg .= '<span class="LC_helpform_receipt_cat">'.
Line 929  END Line 1212  END
     $r->print($envmsg."\n".      $r->print($envmsg."\n".
               &Apache::lonhtmlcommon::row_closure(1)."\n".                &Apache::lonhtmlcommon::row_closure(1)."\n".
               &Apache::lonhtmlcommon::end_pick_box().                &Apache::lonhtmlcommon::end_pick_box().
               "</div>\n".                '</div>');
       unless ($bad_email) {
           $r->print('<p><br />'.&Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($message)).'</p>');
       }
       $r->print("</div>\n".
               &Apache::loncommon::end_page());                &Apache::loncommon::end_page());
 }  }
   
Line 937  sub print_header { Line 1224  sub print_header {
     my ($r,$origurl,$command) = @_;      my ($r,$origurl,$command) = @_;
     my $location=&Apache::loncommon::lonhttpdurl("/adm");      my $location=&Apache::loncommon::lonhttpdurl("/adm");
     my ($component_url);      my ($component_url);
     my $helpdesk_link = '<a href="javascript:validate()">';      my $helpicon_link = '<a href="javascript:validate();" tabindex="-1">';
       if ($command eq 'process') {
           $helpicon_link = '<a href="/adm/helpdesk" tabindex="-1">';
       }
       my $helpdesk_link = '<a href="javascript:validate();">';
     if ($command eq 'process') {      if ($command eq 'process') {
         $helpdesk_link = '<a href="/adm/helpdesk">';          $helpdesk_link = '<a href="/adm/helpdesk">';
     }      }
Line 945  sub print_header { Line 1236  sub print_header {
                                            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',                                             headline => 'help/support',
                                            stud     => 'Students',                                             stud     => 'Students',
                                            ifyo     => 'If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk.',                                             ifyo     => 'If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk.',
Line 953  sub print_header { Line 1244  sub print_header {
                                          );                                           );
     my ($getstartlink,$reviewtext);      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|<div class="LC_helpdesk_links LC_nobreak"><div class="LC_helpdesk_img" aria-hidden="true">&nbsp;</div><div class="LC_helpdesk_text"><a href="/adm/gettingstarted.html">$lt{'getst'}</a>&nbsp;</div></div>|;
         $reviewtext = &mt('Please review the information in "Log-in help" and the "Getting started" guide if you are unable to log-in.');          $reviewtext = &mt('Please review the information in "Log-in help" and the "Getting started" guide if you are unable to log-in.');
     } else {      } else {
         $reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.');          $reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.');
Line 969  sub print_header { Line 1260  sub print_header {
         $loginhelp = '/adm/loginproblems.html';          $loginhelp = '/adm/loginproblems.html';
     }      }
     $r->print(<<"END");      $r->print(<<"END");
 <table width="620" border="0" cellspacing="0" cellpadding="0" style="height: 55px;">  <div class="LC_landmark" style="display: inline-block;" role="navigation">
  <tr>    <div class="LC_helpdesk_headbox">
    <td width="5" height="50">&nbsp;</td>      <h1 class="LC_helpdesk_legend">
    <td height="50">        <img src="$location/lonIcons/minilogo.gif" height="20" width="29" alt="LONCAPA logo" style="vertical-align: middle" />
     <fieldset>        LON-CAPA $lt{'headline'}
       <legend>      </h1>
         <img src="$location/lonIcons/minilogo.gif" height="20" width="29" alt="logo" style="vertical-align:bottom" />      <div style="border:0; padding:0; margin: 1em 0 0.5em;">
         LON-CAPA $lt{'headline'}        <div class="LC_helpdesk_links LC_nobreak"><div class="LC_helpdesk_img" aria-hidden="true">&nbsp;<a href="$loginhelp" tabindex="-1"><img src="$location/help/help.png" border="0" alt="($lt{'login'})" style="vertical-align:middle" />&nbsp;</a></div><div class="LC_helpdesk_text"><a href="$loginhelp">$lt{'login'}</a>&nbsp;</div></div>
       </legend>        <div class="LC_helpdesk_links LC_nobreak"><div class="LC_helpdesk_img" aria-hidden="true">&nbsp;$helpicon_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="($lt{'ask'})" style="vertical-align:top" />&nbsp;</a></div><div class="LC_helpdesk_text">$helpdesk_link$lt{'ask'}</a>&nbsp;</div></div>$getstartlink
  <table id="LC_helpmenu_links">        <div class="LC_helpdesk_links LC_nobreak"><div class="LC_helpdesk_img" aria-hidden="true">&nbsp;<a href="$linkback" target="_top" tabindex="-1"><img src="$location/lonIcons/move_up.gif" border="0" alt="($lt{'back'})" style="vertical-align:middle" />&nbsp;</a></div><div class="LC_helpdesk_text"><a href="$linkback" target="_top">$lt{'back'}</a>&nbsp;</div></div>
    <tr>      </div>
     <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>    </div>
     <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  </div>
     <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>  
    </tr>  
  </table>  
 </fieldset>  
   </td>  
   <td width="5">&nbsp;</td>  
  </tr>  
  <tr>  
   <td colspan="3" height="5">&nbsp;</td>  
  </tr>  
 END  END
     if  ($command ne 'process') {      if  ($command ne 'process') {
         my $stuwarn = &mt('Do [_1]not[_2] use this form to ask about course content.',          my $stuwarn = &mt('Do [_1]not[_2] use this form to ask about course content.',
                           '<b>','</b>');                            '<b>','</b>');
         $r->print(<<"END");          $r->print(<<"END");
  <tr>   <div style="border:0; padding:0; margin: 0; max-width: 600px;" role="complementary">
   <td colspan="3">$reviewtext     $reviewtext
   $lt{'ifyo'}<br />    $lt{'ifyo'}
 <span style="font-size:90%;"><b>$lt{'stud'}</b>:     <p class="LC_info">
 $stuwarn $lt{'cont'}</span>      <b>$lt{'stud'}:</b> 
 <br /><br />      $stuwarn $lt{'cont'}
   </td>    </p>
  </tr>   </div>
 END  END
     }      }
     $r->print('  
 </table>');  
     return;      return;
 }  }
   
Line 1029  sub get_domain { Line 1308  sub get_domain {
     return $codedom;      return $codedom;
 }  }
   
 sub cleanup_html {  
     my ($incoming) = @_;  
     my $outgoing;  
     if ($incoming ne '') {  
         $outgoing = $incoming;  
         $outgoing =~ s/;/&#059;/g;  
         $outgoing =~ s/\#/&#035;/g;  
         $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;  
         $outgoing =~ s{/}{&#047;}g;  
         $outgoing =~ s/=/&#061;/g;  
         $outgoing =~ s/\\/&#092;/g  
     }  
     return $outgoing;  
 }  
   
 1;  1;

Removed from v.1.70  
changed lines
  Added in v.1.108


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