--- loncom/interface/lonsupportreq.pm 2005/04/07 06:56:23 1.25 +++ loncom/interface/lonsupportreq.pm 2006/04/10 21:40:09 1.33 @@ -1,5 +1,5 @@ # -# $Id: lonsupportreq.pm,v 1.25 2005/04/07 06:56:23 albertel Exp $ +# $Id: lonsupportreq.pm,v 1.33 2006/04/10 21:40:09 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,6 +30,7 @@ use strict; use lib qw(/home/httpd/lib/perl); use MIME::Types; use MIME::Lite; +use CGI::Cookie(); use Apache::Constants qw(:common); use Apache::loncommon(); use Apache::lonnet; @@ -61,8 +62,7 @@ sub handler { sub print_request_form { my ($r,$origurl,$function) = @_; - my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server); - my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0" onLoad="initialize_codes()"',1); + my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,$formname); my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) { $tablecolor = '#EEEE99'; @@ -78,6 +78,7 @@ sub print_request_form { $urole = $env{'request.role'}; $usec = $env{'request.course.sec'}; $cid = $env{'request.course.id'}; + $formname = 'logproblem'; if ($origurl =~ m-^http://-) { $server = $origurl; } else { @@ -96,7 +97,7 @@ function validmail(field) { var str = field.value; if (window.RegExp) { var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)"; - var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; + var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //" var reg1 = new RegExp(reg1str); var reg2 = new RegExp(reg2str); if (!reg1.test(str) && reg2.test(str)) { @@ -113,7 +114,7 @@ function validmail(field) { } } END - #" stupid emacs + if ($cid =~ m/_/) { ($cdom,$cnum) = split/_/,$cid; } @@ -188,23 +189,25 @@ function initialize_codes() { if ($format_reply eq 'ok') { my $numtypes = @codetitles; &build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles); - &javascript_code_selections($numtypes,\%cat_titles,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles); + &javascript_code_selections($formname,$numtypes,\%cat_titles,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles); $loaditems = ''; } } } - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< - LON-CAPA support request - - -$bodytag -ENDHEAD + + my $js = ''; + my %add_entries = (topmargin => "0", + marginheight => "0", + onLoad =>"initialize_codes()",); + + my $start_page = + &Apache::loncommon::start_page('Support Request',$js, + { 'function' => $function, + 'add_entries' => \%add_entries, + 'only_body' => 1,}); + $r->print($start_page); + if ($r->uri eq '/adm/helpdesk') { &print_header($r,$origurl); } @@ -593,6 +596,7 @@ END END } + $r->print(< @@ -629,18 +633,18 @@ END - - END + $r->print(&Apache::loncommon::end_page()); return; } sub print_request_receipt { my ($r,$url,$function) = @_; - my @envvars = ('lonID','HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME','browser.os','browser.type','browser.version','user.home','request.role'); + my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME'); + my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role'); my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id'); + my @cookievars = ('lonID'); - my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0"',1); my $admin = $Apache::lonnet::perlvar{'lonAdminMail'}; my $to = $Apache::lonnet::perlvar{'lonSupportEMail'}; my $from = $admin; @@ -691,13 +695,18 @@ Date/Time: $reporttime URL: $env{'form.sourceurl'}
Date/Time: $reporttime
|; - my $html=&Apache::lonxml::xmlbegin(); + + my $start_page = + &Apache::loncommon::start_page('Support request recorded',undef, + {'function' => $function, + 'add_entries' => { + topmargin => "0", + marginheight => "0", + }, + 'only_body' => 1,}); + $r->print(<<"END"); -$html - - LON-CAPA support request recorded - -$bodytag +$start_page
@@ -748,10 +757,22 @@ END } } + my %cookies = (); + my $cookie=CGI::Cookie->parse($r->header_in('Cookie')); + if ($$cookie{'lonID'} =~ /lonID=(\w+);/) { + $cookies{'lonID'} = $1; + } + if ($attachmentpath =~ m-/([^/]+)$-) { $fname = $1; $displaymsg .= "
An uploaded screenshot file - $fname ($attachmentsize bytes) was included in the request sent by $env{'user.name'} from LON-CAPA domain: $env{'user.domain'}"; $supportmsg .= "\n"; + foreach (@cookievars) { + $supportmsg .= "$_: $cookies{$_}\n"; + } + foreach (@ENVvars) { + $supportmsg .= "$_: $ENV{$_}\n"; + } foreach (@envvars) { $supportmsg .= "$_: $env{$_}\n"; } @@ -774,6 +795,12 @@ END } else { my $envdata = ''; + foreach (@cookievars) { + $envdata .= "$_: $cookies{$_}\n"; + } + foreach (@ENVvars) { + $envdata .= "$_: $ENV{$_}\n"; + } foreach (@envvars) { $envdata .= "$_: $env{$_}\n"; } @@ -785,8 +812,6 @@ END } ### Send it: - # ->send can cause an sh launch which can pass all of %env along - # which can be to large for /bin/sh's little mind $msg->send('sendmail'); if ($attachmentpath =~ m#$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+#) { @@ -840,6 +865,16 @@ END |); + foreach (@cookievars) { + unless($cookies{$_} eq '') { + $r->print("$_: $cookies{$_}, "); + } + } + foreach (@ENVvars) { + unless($ENV{$_} eq '') { + $r->print("$_: $ENV{$_}, "); + } + } foreach (@envvars) { unless($env{$_} eq '') { $r->print("$_: $env{$_}, "); @@ -861,9 +896,8 @@ END - - "); + $r->print(&Apache::loncommon::end_page()); } sub print_header { @@ -938,7 +972,7 @@ Please review the information in "Log-in sub retrieve_instcodes { my ($coursecodes,$codedom,$totcodes) = @_; - my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.'); + my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.','.'); foreach my $course (keys %courses) { if ($courses{$course} =~ m/^[^:]*:([^:]+)/) { $$coursecodes{$course} = &Apache::lonnet::unescape($1); @@ -1157,7 +1191,7 @@ sub recurse_list { } sub javascript_code_selections { - my ($numcats,$cat_titles,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_; + my ($formname,$numcats,$cat_titles,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_; my $numtitles = @{$codetitles}; my @seltitles = (); for (my $j=0; $j<$numtitles; $j++) { @@ -1178,10 +1212,10 @@ function courseSet(caller) { var ids = new Array ("$seltitle_str"); var formitems = new Array ($numtitles); var longtitles = new Array ("$longtitles_str"); - var idyr = document.logproblem.Year.selectedIndex - var idsem = document.logproblem.Semester.selectedIndex - var iddept = document.logproblem.Department.selectedIndex - var idclass = document.logproblem.Number.selectedIndex + var idyr = document.$formname.Year.selectedIndex + var idsem = document.$formname.Semester.selectedIndex + var iddept = document.$formname.Department.selectedIndex + var idclass = document.$formname.Number.selectedIndex var idyears = new Array("$$idlist{$$codetitles[0]}"); END if ($longtitles[0]) { @@ -1245,55 +1279,59 @@ END } $$script_tag .= (<