Diff for /loncom/interface/lonsupportreq.pm between versions 1.68 and 1.74

version 1.68, 2012/08/27 02:02:57 version 1.74, 2013/11/26 03:17:06
Line 39  use Apache::lonacc(); Line 39  use Apache::lonacc();
 use Apache::lonauth();  use Apache::lonauth();
 use Apache::courseclassifier;  use Apache::courseclassifier;
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
    use HTML::Entities;
   
 sub handler {  sub handler {
     my ($r) = @_;      my ($r) = @_;
Line 57  sub handler { Line 57  sub handler {
     if ($r->uri eq '/adm/helpdesk') {      if ($r->uri eq '/adm/helpdesk') {
         &Apache::lonacc::get_posted_cgi($r);          &Apache::lonacc::get_posted_cgi($r);
     }      }
     my $function = $env{'form.function'};      my $function;
       if ($env{'form.function'}) {
           if (($env{'form.function'} eq 'norole')  ||
               ($env{'form.function'} eq 'student') ||
               ($env{'form.function'} eq 'admin')   ||
               ($env{'form.function'} eq 'author')) {
               $function = $env{'form.function'};
           }
       }
     my $origurl = $env{'form.origurl'};      my $origurl = $env{'form.origurl'};
       $origurl =~ s{^https?://}{};
       $origurl =~ s/(`)//g;
       $origurl =~ s/\$/\(\$\)/g;
     my $command = $env{'form.command'};      my $command = $env{'form.command'};
   
     if ($command eq 'process') {      if ($command eq 'process') {
Line 102  sub print_request_form { Line 113  sub print_request_form {
     }      }
     $formname = 'logproblem';      $formname = 'logproblem';
     my $machine = &Apache::lonnet::absolute_url();      my $machine = &Apache::lonnet::absolute_url();
     if ($origurl =~ m-^https?://-) {      my $sourceurl = $machine.$origurl;
         $server = $origurl;      $server = $machine.&Apache::loncommon::cleanup_html($origurl);
     } else {      $server =~ s/\?.*$//;
         $server = $machine.$origurl;  
     }  
     my $showserver = $server;  
     $showserver =~ s/\?.*$//;  
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                   email => 'The e-mail address you entered',                    email => 'The e-mail address you entered',
                   notv => 'is not a valid e-mail address',                    notv => 'is not a valid e-mail address',
Line 358  ENDJS Line 365  ENDJS
     $num ++;      $num ++;
     $i = $num%2;      $i = $num%2;
     $output .= &Apache::lonhtmlcommon::row_title("$lt{'urlp'}",undef,$css[$i]).      $output .= &Apache::lonhtmlcommon::row_title("$lt{'urlp'}",undef,$css[$i]).
                $showserver."\n".'<input type="hidden" name="sourceurl" value="'.                 $server."\n".'<input type="hidden" name="sourceurl" value="'.
                &HTML::Entities::encode($server,'"<>&').'" />'."\n".                 &HTML::Entities::encode($sourceurl,'"<>&').'" />'."\n".
                &Apache::lonhtmlcommon::row_closure().                 &Apache::lonhtmlcommon::row_closure().
                &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_evenrow_value').                 &Apache::lonhtmlcommon::row_title("$lt{'phon'}",undef,'LC_evenrow_value').
                '<input type="text" size="15" name="phone" /><br />'."\n".                 '<input type="text" size="15" name="phone" /><br />'."\n".
Line 488  ENDJS Line 495  ENDJS
             $num ++;              $num ++;
             $i = $num%2;              $i = $num%2;
         }          }
       } else {
           my $lonhost = $r->dir_config('lonHostID');
           my ($captchaform,$error) = 
               &Apache::loncommon::captcha_display('login',$lonhost);
           if ($captchaform) {
               $output .= &Apache::lonhtmlcommon::row_title(&mt('Validation'),undef,
                                                            $css[$i])."\n".
                          $captchaform."\n".
                          &Apache::lonhtmlcommon::row_closure();
               $num ++;
               $i = $num%2;
           }
     }      }
     $output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$css[$i]);      $output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$css[$i]);
     $output .= <<END;      $output .= <<END;
Line 517  END Line 536  END
   
 sub print_request_receipt {  sub print_request_receipt {
     my ($r,$url,$function) = @_;      my ($r,$url,$function) = @_;
       my $public;
       if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
           $public = 1;
       }
       unless (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
           my $lonhost = $r->dir_config('lonHostID');
           my ($captcha_chk,$captcha_error) = 
               &Apache::loncommon::captcha_response('login',$lonhost);
           if ($captcha_chk != 1) {
               $r->print(&Apache::loncommon::start_page('Support request failed',undef,
                                          {'function'    => $function,
                                           'add_entries' => {
                                               topmargin    => "0",
                                               marginheight => "0",
                                           },
                                           'only_body'   => 1,}));
               if ($r->uri eq '/adm/helpdesk') {
                   &print_header($r,$url,'process');
               }
               $r->print('<h3>'.&mt('Support request failed').'</h3>'.
                         '<span class="LC_error">'.
                         &mt('Validation of the code you entered failed.').
                         &Apache::loncommon::end_page());
               return;
           }
       }
     my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');      my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');
     my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role');      my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role');
     my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');      my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
Line 596  sub print_request_receipt { Line 641  sub print_request_receipt {
                  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'});
Line 632  sub print_request_receipt { Line 675  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;  
         }          }
     }      }
     $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";      $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";
Line 658  END Line 702  END
         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 666  END Line 710  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 .=                  if ($okcclist) {
                     '<span class="LC_helpform_receipt_cat">'.                      my $showcclist = &Apache::loncommon::cleanup_html($okcclist);
                     "$lt{$item}</span>: $okcclist<br />\n";                      $displaymsg .=
                           '<span class="LC_helpform_receipt_cat">'.
                           "$lt{$item}</span>: $showcclist<br />\n";
                   }
             } else {              } else {
                 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";
Line 697  END Line 744  END
   
     $r->print(<<"END");      $r->print(<<"END");
 $start_page  $start_page
 <form name="logproblem">  <form name="logproblem" action="">
 <input type="hidden" name="command" value="result" />  <input type="hidden" name="command" value="result" />
 </form>  </form>
 END  END
Line 767  END Line 814  END
   
     my $attachmentpath = '';      my $attachmentpath = '';
     my $attachmentsize = '';      my $attachmentsize = '';
     if ((defined($env{'user.name'})) && ($env{'user.name'} ne 'public')      if ((defined($env{'user.name'})) && (!$public)) {
         && ($env{'user.domain'} ne 'public')) {  
         if ($homeserver && $env{'form.screenshot.filename'}) {          if ($homeserver && $env{'form.screenshot.filename'}) {
             $attachmentsize = length($env{'form.screenshot'});              $attachmentsize = length($env{'form.screenshot'});
             if ($attachmentsize > 131072) {              if ($attachmentsize > 131072) {
Line 913  sub print_header { Line 959  sub print_header {
     } 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.');
     }      }
       my $linkback;
     if ($origurl eq '') {      if ($origurl eq '') {
         $origurl = 'javascript:history.go(-1)';          $linkback = 'javascript:history.go(-1)';
       } else {
           $linkback = &HTML::Entities::encode($origurl,'"<>&');
     }      }
     my $loginhelp = &Apache::lonauth::loginhelpdisplay();      my $loginhelp = &Apache::lonauth::loginhelpdisplay();
     if ($loginhelp eq '') {      if ($loginhelp eq '') {
Line 934  sub print_header { Line 983  sub print_header {
    <tr>     <tr>
     <td align="center"><span class="LC_nobreak"><img src="$location/help/help.png" border="0" alt="($lt{'login'})" style="vertical-align:middle" />&nbsp;<b><a href="$loginhelp">$lt{'login'}</a></b>&nbsp;</span></td>      <td align="center"><span class="LC_nobreak"><img src="$location/help/help.png" border="0" alt="($lt{'login'})" style="vertical-align:middle" />&nbsp;<b><a href="$loginhelp">$lt{'login'}</a></b>&nbsp;</span></td>
     <td 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      <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
     <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'})" style="vertical-align:middle" />&nbsp;$lt{'back'}</a></b>&nbsp;</span></td>      <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>     </tr>
  </table>   </table>
 </fieldset>  </fieldset>
Line 967  END Line 1016  END
 sub get_domain {  sub get_domain {
     my $codedom;      my $codedom;
     if (exists($env{'form.codedom'})) {      if (exists($env{'form.codedom'})) {
         $codedom = $env{'form.codedom'};          if (&Apache::lonnet::domain($env{'form.codedom'}) ne '') {
     } elsif ($env{'request.course.id'}) {              return $env{'form.codedom'};
           }
       }
       if ($env{'request.course.id'}) {
         $codedom = $env{'course.'.$env{'request.course.id'}.'.domain'};          $codedom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     } elsif ($env{'request.role.domain'}) {      } elsif ($env{'request.role.domain'}) {
         $codedom = $env{'request.role.domain'};          $codedom = $env{'request.role.domain'};
Line 978  sub get_domain { Line 1030  sub get_domain {
     return $codedom;      return $codedom;
 }  }
   
 sub cleanup_html {  
     my ($incoming) = @_;  
     my $outgoing;  
     if ($incoming ne '') {  
         $outgoing = $incoming;  
         $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;  
     }  
     return $outgoing;  
 }  
   
 1;  1;

Removed from v.1.68  
changed lines
  Added in v.1.74


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