Annotation of loncom/interface/lonsupportreq.pm, revision 1.38
1.24 albertel 1: #
1.38 ! raeburn 2: # $Id: lonsupportreq.pm,v 1.37 2006/09/01 21:07:11 raeburn Exp $
1.24 albertel 3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
26:
1.1 raeburn 27: package Apache::lonsupportreq;
28:
29: use strict;
30: use lib qw(/home/httpd/lib/perl);
1.5 raeburn 31: use MIME::Types;
32: use MIME::Lite;
1.27 raeburn 33: use CGI::Cookie();
1.1 raeburn 34: use Apache::Constants qw(:common);
1.2 albertel 35: use Apache::loncommon();
1.24 albertel 36: use Apache::lonnet;
1.1 raeburn 37: use Apache::lonlocal;
1.34 albertel 38: use Apache::lonacc();
1.38 ! raeburn 39: use Apache::courseclassifier;
1.35 www 40: use lib '/home/httpd/lib/perl/';
41: use LONCAPA;
42:
1.1 raeburn 43:
44: sub handler {
1.2 albertel 45: my ($r) = @_;
46: &Apache::loncommon::content_type($r,'text/html');
1.1 raeburn 47: $r->send_http_header;
48:
49: if ($r->header_only) {
50: return OK;
51: }
1.12 raeburn 52: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']);
53: if ($r->uri eq '/adm/helpdesk') {
1.34 albertel 54: &Apache::lonacc::get_posted_cgi($r);
1.12 raeburn 55: }
1.25 albertel 56: my $function = $env{'form.function'};
1.35 www 57: my $origurl = &unescape($env{'form.origurl'});
1.25 albertel 58: my $action = $env{'form.action'};
1.12 raeburn 59:
1.1 raeburn 60: if ($action eq 'process') {
61: &print_request_receipt($r,$origurl,$function);
62: } else {
63: &print_request_form($r,$origurl,$function);
64: }
65: return OK;
66: }
67:
68: sub print_request_form {
69: my ($r,$origurl,$function) = @_;
1.29 raeburn 70: my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,$formname);
1.1 raeburn 71: my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
1.5 raeburn 72: if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {
1.14 raeburn 73: $tablecolor = '#EEEE99';
1.5 raeburn 74: }
1.10 raeburn 75: $ccode = '';
1.25 albertel 76: $os = $env{'browser.os'};
77: $browser = $env{'browser.type'};
78: $bversion = $env{'browser.version'};
79: $uhost = $env{'request.host'};
80: $uname = $env{'user.name'};
81: $udom = $env{'user.domain'};
82: $uhome = $env{'user.home'};
83: $urole = $env{'request.role'};
84: $usec = $env{'request.course.sec'};
85: $cid = $env{'request.course.id'};
1.29 raeburn 86: $formname = 'logproblem';
1.21 raeburn 87: if ($origurl =~ m-^http://-) {
88: $server = $origurl;
89: } else {
90: $server = 'http://'.$ENV{'SERVER_NAME'}.$origurl;
91: }
1.13 raeburn 92: my $scripttag = (<<'END');
1.5 raeburn 93: function validate() {
1.13 raeburn 94: if (validmail(document.logproblem.email) == false) {
95: alert("The e-mail address you entered: "+document.logproblem.email.value+" is not a valid e-mail address.");
96: return;
1.5 raeburn 97: }
98: document.logproblem.submit();
99: }
1.13 raeburn 100:
101: function validmail(field) {
102: var str = field.value;
103: if (window.RegExp) {
104: var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
1.31 albertel 105: var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"
1.13 raeburn 106: var reg1 = new RegExp(reg1str);
107: var reg2 = new RegExp(reg2str);
108: if (!reg1.test(str) && reg2.test(str)) {
109: return true;
110: }
111: return false;
112: }
113: else
114: {
115: if(str.indexOf("@") >= 0) {
116: return true;
117: }
118: return false;
119: }
120: }
1.5 raeburn 121: END
1.31 albertel 122:
1.1 raeburn 123: if ($cid =~ m/_/) {
124: ($cdom,$cnum) = split/_/,$cid;
125: }
126: if ($cdom && $cnum) {
127: my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);
128: $ctitle = $csettings{'description'};
129: $ccode = $csettings{'internal.coursecode'};
130: $sectionlist = $csettings{'internal.sectionnums'};
131: }
1.25 albertel 132: if ($env{'environment.critnotification'}) {
133: $email = $env{'environment.critnotification'};
1.1 raeburn 134: }
1.25 albertel 135: if (!$email && $env{'environment.notification'}) {
136: $email = $env{'environment.notification'};
1.1 raeburn 137: }
1.25 albertel 138: if ($env{'environment.lastname'}) {
139: $lastname = $env{'environment.lastname'};
1.1 raeburn 140: }
1.25 albertel 141: if ($env{'environment.firstname'}) {
142: $firstname = $env{'environment.firstname'};
1.1 raeburn 143: }
144: my @sections = split/,/,$sectionlist;
145: my %groupid = ();
146: foreach (@sections) {
147: my ($sec,$grp) = split/:/,$_;
148: $groupid{$sec} = $grp;
149: }
1.19 raeburn 150: my $codedom = $Apache::lonnet::perlvar{'lonDefDomain'};
151: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom']);
1.25 albertel 152: if (exists($env{'form.codedom'})) {
153: $codedom = $env{'form.codedom'};
1.19 raeburn 154: }
1.21 raeburn 155: my $details_title;
156: if ($codedom) {
157: $details_title = '<br />('.$codedom.')';
158: }
1.1 raeburn 159: my %coursecodes = ();
160: my %codes = ();
161: my @codetitles = ();
162: my %cat_titles = ();
163: my %cat_order = ();
1.6 raeburn 164: my %idlist = ();
165: my %idnums = ();
166: my %idlist_titles = ();
1.1 raeburn 167: my $caller = 'global';
168: my $totcodes = 0;
169: my $format_reply;
1.6 raeburn 170: my $jscript = '';
1.22 raeburn 171: my $loaditems = qq|
172: function initialize_codes() {
173: return;
174: }
175: |;
1.1 raeburn 176: if ($cdom) {
177: $codedom = $cdom;
178: }
179: if ($cnum) {
180: $coursecodes{$cnum} = $ccode;
181: if ($ccode eq '') {
1.38 ! raeburn 182: $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
1.1 raeburn 183: } else {
184: $coursecodes{$cnum} = $ccode;
185: $caller = $cnum;
186: $totcodes ++;
187: }
188: } else {
1.38 ! raeburn 189: $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
1.1 raeburn 190: }
191: if ($totcodes > 0) {
1.6 raeburn 192: if ($ccode eq '') {
1.22 raeburn 193: $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);
194: if ($format_reply eq 'ok') {
195: my $numtypes = @codetitles;
1.38 ! raeburn 196: &Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
! 197: my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);
! 198: my $longtitles_str = join('","',@{$longtitles});
! 199: my $allidlist = $idlist{$codetitles[0]};
! 200: $jscript .= &Apache::courseclassifier::courseset_js_start($formname,$longtitles_str,$allidlist);
! 201: $jscript .= $scripttext;
! 202: $jscript .= &Apache::courseclassifier::javascript_code_selections($formname,@codetitles);
1.22 raeburn 203: $loaditems = '';
204: }
1.6 raeburn 205: }
1.1 raeburn 206: }
1.30 albertel 207:
1.31 albertel 208: my $js = '<script type"text/javascript">'."\n$scripttag\n$jscript\n".
209: '</script>';
1.33 albertel 210: my %add_entries = (topmargin => "0",
211: marginheight => "0",
212: onLoad =>"initialize_codes()",);
213:
1.31 albertel 214: my $start_page =
215: &Apache::loncommon::start_page('Support Request',$js,
216: { 'function' => $function,
1.33 albertel 217: 'add_entries' => \%add_entries,
1.31 albertel 218: 'only_body' => 1,});
219: $r->print($start_page);
220:
1.15 raeburn 221: if ($r->uri eq '/adm/helpdesk') {
1.14 raeburn 222: &print_header($r,$origurl);
223: }
224: $r->print(<<"END");
1.15 raeburn 225: <form method="post" name="logproblem" enctype="multipart/form-data">
1.1 raeburn 226: <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
227: <tr>
228: <td>
229: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
230: <tr>
231: <td>
232: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
233: <tr>
234: <td>
235: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
236: <tr>
237: <td width="140" bgcolor="$tablecolor">
238: <table width="140" border="0" cellpadding="8" cellspacing="0">
239: <tr>
240: <td align="right"><b>Name:</b>
241: </td>
242: </tr>
243: </table>
244: </td>
245: <td width="100%" valign="top">
246: <table width="100%" border="0" cellpadding="8" cellspacing="0">
247: <tr>
248: <td>
249: END
250: my $fullname = '';
251: if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) {
252: $fullname = "$firstname $lastname";
253: $r->print("$fullname<input type=\"hidden\" name=\"username\" value=\"$fullname\" />");
254: } else {
255: if (defined($firstname) && $firstname ne '') {
256: $fullname = $firstname;
257: } elsif (defined($lastname) && $lastname ne '') {
258: $fullname= " $lastname";
259: }
1.17 raeburn 260: $r->print('<input type="text" size="20" name="username" value="'.$fullname.'" />');
1.1 raeburn 261: }
262: $r->print(<<END);
1.18 raeburn 263: <input type="button" value="Submit Request" onClick="validate()" />
1.1 raeburn 264: </td>
265: </tr>
266: </table>
267: </td>
268: </tr>
269: <tr>
270: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 271: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 272: </td>
273: </tr>
274: <tr>
275: <td width="140" bgcolor="$tablecolor">
276: <table width="140" border="0" cellpadding="8" cellspacing="0">
277: <tr>
278: <td align="right"><b>E-mail address:</b>
279: </td>
280: </tr>
281: </table>
282: </td>
283: <td width="100%" valign="top">
284: <table width="100%" border="0" cellpadding="8" cellspacing="0">
285: <tr>
286: <td>
287: <input type="text" size="20" name="email" value="$email" /><br />
288: </td>
289: </tr>
290: </table>
291: </td>
292: </tr>
293: <tr>
294: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 295: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 296: </td>
297: </tr>
298: <tr>
299: <td width="140" bgcolor="$tablecolor">
300: <table width="140" border="0" cellpadding="8" cellspacing="0">
301: <tr>
302: <td align="right"><b>username/domain:</b>
303: </td>
304: </tr>
305: </table>
306: </td>
307: <td width="100%" valign="top">
308: <table width="100%" border="0" cellpadding="8" cellspacing="0">
309: <tr>
310: <td>
311: END
312: my $udom_input = '<input type="hidden" name="udom" value="'.$udom.'" />';
313: my $uname_input = '<input type="hidden" name="uname" value="'.$uname.'" />';
314: if (defined($uname) && defined($udom)) {
315: $r->print('<i>username</i>: '.$uname.' <i>domain</i>: '.$udom.$udom_input.$uname_input);
316: } else {
317: my $udomform = '';
318: my $unameform = '';
319: if (defined($udom)) {
320: $udomform = '<i>domain</i>: '.$udom.$udom_input;
321: } elsif (defined($uname)) {
322: $unameform = '<i>username</i>: '.$uname.' '.$uname_input;
323: }
324: if ($udomform eq '') {
325: $udomform = '<i>domain</i>: ';
1.19 raeburn 326: $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom');
1.1 raeburn 327: }
328: if ($unameform eq '') {
1.19 raeburn 329: $unameform= '<i>username</i>: <input type="text" size="12" name="uname" value="'.$uname.'" /> ';
1.1 raeburn 330: }
331: $r->print($unameform.$udomform.'<br />Enter the username you use to log-in to your LON-CAPA system, and choose your domain.');
332: }
333: $r->print(<<END);
334: </td>
335: </tr>
336: </table>
337: </td>
338: </tr>
339: <tr>
340: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 341: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 342: </td>
343: </tr>
344: <tr>
345: <td width="140" bgcolor="$tablecolor">
346: <table width="140" border="0" cellpadding="8" cellspacing="0">
347: <tr>
348: <td align="right"><b>URL of page:</b>
349: </td>
350: </tr>
351: </table>
352: </td>
353: <td width="100%" valign="top">
354: <table width="100%" border="0" cellpadding="8" cellspacing="0">
355: <tr>
356: <td>
1.21 raeburn 357: $server<input type="hidden" name="sourceurl" value="$server" />
1.1 raeburn 358: </td>
359: </tr>
360: </table>
361: </td>
362: </tr>
363: <tr>
364: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 365: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 366: </td>
367: </tr>
368: <tr>
369: <td width="140" bgcolor="$tablecolor">
370: <table width="140" border="0" cellpadding="8" cellspacing="0">
371: <tr>
372: <td align="right"><b>Phone #:</b>
373: </td>
374: </tr>
375: </table>
376: </td>
377: <td width="100%" valign="top">
378: <table width="100%" border="0" cellpadding="8" cellspacing="0">
379: <tr>
380: <td>
381: <input type="text" size="15" name="phone"><br>
382: </td>
383: </tr>
384: </table>
385: </td>
386: </tr>
387: <tr>
388: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 389: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 390: </td>
391: </tr>
392: <tr>
393: <td width="140" bgcolor="$tablecolor">
394: <table width="140" border="0" cellpadding="8" cellspacing="0">
395: <tr>
1.21 raeburn 396: <td align="right"><b>Course Details:</b>$details_title
1.1 raeburn 397: </td>
398: </tr>
399: </table>
400: </td>
401: <td width="100%" valign="top">
402: <table border="0" cellpadding="3" cellspacing="3">
403: <tr>
404: <td>
405: END
1.10 raeburn 406: if ($cnum) {
407: if ($coursecodes{$cnum}) {
408: foreach (@codetitles) {
409: $r->print('<i>'.$_.'</i>: '.$codes{$cnum}{$_}.'; ');
410: }
411: $r->print(' <input type="hidden" name="coursecode" value="'.$coursecodes{$cnum}.'" />');
412: } else {
413: $r->print('Enter institutional course code:
414: <input type="text" name="coursecode" size="15" value="" />');
1.1 raeburn 415: }
416: } else {
1.10 raeburn 417: if ($totcodes > 0) {
418: my $numtitles = @codetitles;
419: if ($numtitles == 0) {
420: $r->print('Enter institutional course code:
1.1 raeburn 421: <input type="text" name="coursecode" size="15" value="" />');
1.10 raeburn 422: } else {
423: my $lasttitle = $numtitles;
424: if ($numtitles > 4) {
425: $lasttitle = 4;
426: }
427: $r->print('<table><tr><td>'.$codetitles[0].'<br />'."\n".
428: '<select name="'.$codetitles[0].'" onChange="courseSet('."'$codetitles[0]'".')">'."\n".
429: ' <option value="-1" />Select'."\n");
430: my @items = ();
1.20 raeburn 431: my @longitems = ();
1.10 raeburn 432: if ($idlist{$codetitles[0]} =~ /","/) {
433: @items = split/","/,$idlist{$codetitles[0]};
434: } else {
435: $items[0] = $idlist{$codetitles[0]};
436: }
1.20 raeburn 437: if (defined($idlist_titles{$codetitles[0]})) {
438: if ($idlist_titles{$codetitles[0]} =~ /","/) {
439: @longitems = split/","/,$idlist_titles{$codetitles[0]};
440: } else {
441: $longitems[0] = $idlist_titles{$codetitles[0]};
442: }
1.22 raeburn 443: for (my $i=0; $i<@longitems; $i++) {
444: if ($longitems[$i] eq '') {
445: $longitems[$i] = $items[$i];
446: }
447: }
1.20 raeburn 448: } else {
449: @longitems = @items;
450: }
451: for (my $i=0; $i<@items; $i++) {
452: $r->print(' <option value="'.$items[$i].'">'.$longitems[$i].'</option>');
1.10 raeburn 453: }
454: $r->print('</select></td>');
455: for (my $i=1; $i<$numtitles; $i++) {
456: $r->print('<td>'.$codetitles[$i].'<br />'."\n".
457: '<select name="'.$codetitles[$i].'" onChange="courseSet('."'$codetitles[$i]'".')">'."\n".
458: '<option value="-1"><-Pick '.$codetitles[$i-1].'</option>'."\n".
459: '</select>'."\n".
460: '</td>'
461: );
462: }
463: $r->print('</tr></table>');
464: if ($numtitles > 4) {
465: $r->print('<br /><br />'.$codetitles[$numtitles].'<br />'."\n".
466: '<select name="'.$codetitles[$numtitles].'" onChange="courseSet('."'$codetitles[$numtitles]'".')">'."\n".
467: '<option value="-1"><-Pick '.$codetitles[$numtitles-1].'</option>'."\n".
468: '</select>'."\n");
469: }
470: }
471: } else {
472: $r->print('Enter institutional course code:
473: <input type="text" name="coursecode" size="15" value="" />');
474: }
1.1 raeburn 475: }
476: if ($ctitle) {
477: $r->print('<br /><i>Title</i>: '.$ctitle.'<input type="hidden" name="title" value="'.$ctitle.'" />');
478: } else {
479: $r->print('<br />Enter course title:
1.10 raeburn 480: <input type="text" name="title" size="25" value="" />');
1.1 raeburn 481: }
482: $r->print(<<END);
483: </td>
484: </tr>
485: </table>
486: </td>
487: </tr>
488: <tr>
489: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 490: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 491: </td>
492: </tr>
493: <tr>
494: <td width="140" bgcolor="$tablecolor">
495: <table width="140" border="0" cellpadding="8" cellspacing="0">
496: <tr>
497: <td align="right"><b>Section Number: </b>
498: </td>
499: </tr>
500: </table>
501: </td>
502: <td width="100%" valign="top">
503: <table width="100%" border="0" cellpadding="8" cellspacing="0">
504: <tr>
505: <td>
506: END
507: if ($sectionlist) {
1.22 raeburn 508: $r->print("<select name=\"section\"\n>".
509: " <option value=\"\" selected=\"selected\">Select</option>\n");
1.1 raeburn 510: foreach (sort keys %groupid) {
511: if ($_ eq $groupid{$_} || $groupid{$_} eq '') {
1.22 raeburn 512: $r->print(" <option value=\"$_\" >$_</option>\n");
1.1 raeburn 513: } else {
1.22 raeburn 514: $r->print(" <option value=\"$_\" >$_ - (LON-CAPA sec: $groupid{$_})</option>\n");
1.1 raeburn 515: }
516: }
517: $r->print("</select>");
518: } else {
519: $r->print("<input type=\"text\" name=\"section\" size=\"10\"/>");
520: }
521: $r->print(<<END);
522: </td>
523: </tr>
524: </table>
525: </td>
526: </tr>
527: <tr>
528: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 529: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 530: </td>
531: </tr>
532: <tr>
533: <td width="140" bgcolor="$tablecolor">
534: <table width="140" border="0" cellpadding="8" cellspacing="0">
535: <tr>
536: <td align="right"><b>Subject</b>
537: </td>
538: </tr>
539: </table>
540: </td>
541: <td width="100%" valign="top">
542: <table width="100%" border="0" cellpadding="8" cellspacing="0">
543: <tr>
544: <td>
545: <input type="text" size="40" name="subject">
546: </td>
547: </tr>
548: </table>
549: </td>
550: </tr>
551: <tr>
552: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 553: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 554: </td>
555: </tr>
556: <tr>
557: <td width="140" bgcolor="$tablecolor">
558: <table width="140" border="0" cellpadding="8" cellspacing="0">
559: <tr>
560: <td align="right"><b>Detailed description:</b>
561: </td>
562: </tr>
563: </table>
564: </td>
565: <td width="100%" valign="top">
566: <table width="100%" border="0" cellpadding="8" cellspacing="0">
567: <tr>
568: <td>
569: <textarea rows="10" cols="45" name="description" wrap="virtual"></textarea>
570: </td>
571: </tr>
572: </table>
573: </td>
574: </tr>
575: <tr>
576: <td width="100%" colspan="2" bgcolor="#000000">
1.3 albertel 577: <img src="/adm/lonMisc/blackdot.gif" /><br />
1.1 raeburn 578: </td>
579: </tr>
1.5 raeburn 580: END
1.25 albertel 581: if (defined($env{'user.name'})) {
1.5 raeburn 582: $r->print(<<END);
583: <tr>
584: <td width="140" bgcolor="$tablecolor">
585: <table width="140" border="0" cellpadding="8" cellspacing="0">
586: <tr>
587: <td align="right"><b>Optional file upload:</b>
588: </td>
589: </tr>
590: </table>
591: </td>
592: <td width="100%" valign="top">
593: <table width="100%" border="0" cellpadding="8" cellspacing="0">
594: <tr>
595: <td>
596: <input type="file" name="screenshot" size="20" /><br />Upload a file (e.g., a screenshot) relevant to your support request (128 KB max. size).
597: </td>
598: </tr>
599: </table>
600: </td>
601: </tr>
602: <tr>
603: <td width="100%" colspan="2" bgcolor="#000000">
604: <img src="/adm/lonMisc/blackdot.gif" /><br />
605: </td>
606: </tr>
607: END
608: }
1.30 albertel 609:
1.5 raeburn 610: $r->print(<<END);
1.1 raeburn 611: <tr>
612: <td width="140" bgcolor="$tablecolor">
613: <table width="140" border="0" cellpadding="8" cellspacing="0">
614: <tr>
615: <td align="right"><b>Finish:</b>
616: </td>
617: </tr>
618: </table>
619: </td>
620: <td width="100%" valign="top">
621: <table border="0" cellpadding="8" cellspacing="0">
622: <tr>
623: <td>
624: <input type="hidden" name="action" value="process" />
1.15 raeburn 625: <input type="button" value="Submit Request" onClick="validate()"/>
1.1 raeburn 626: </td>
627: <td> </td>
628: <td>
629: <input type="reset" value="Clear Form">
630: </td>
631: </tr>
632: </table>
633: </td>
634: </tr>
635: </table>
636: </td>
637: </tr>
638: </table>
639: </td>
640: </tr>
641: </table>
642: </td>
643: </tr>
644: </table>
1.14 raeburn 645: </form>
1.1 raeburn 646: END
1.30 albertel 647: $r->print(&Apache::loncommon::end_page());
1.5 raeburn 648: return;
1.1 raeburn 649: }
650:
651: sub print_request_receipt {
652: my ($r,$url,$function) = @_;
1.26 raeburn 653: my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');
654: my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role');
1.5 raeburn 655: my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
1.27 raeburn 656: my @cookievars = ('lonID');
1.5 raeburn 657:
658: my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
1.1 raeburn 659: my $to = $Apache::lonnet::perlvar{'lonSupportEMail'};
1.5 raeburn 660: my $from = $admin;
1.1 raeburn 661: my $reporttime = &Apache::lonlocal::locallocaltime(time);
662: my $fontcolor = &Apache::loncommon::designparm($function.'.font');
663: my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink');
664: my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
1.14 raeburn 665: my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot');
1.20 raeburn 666:
1.1 raeburn 667: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);
1.25 albertel 668: my $coursecode = $env{'form.coursecode'};
1.19 raeburn 669: if ($coursecode eq '') {
1.25 albertel 670: if (defined($env{'form.Year'})) {
671: $coursecode .= $env{'form.Year'};
1.19 raeburn 672: }
1.25 albertel 673: if (defined($env{'form.Semester'})) {
674: $coursecode .= $env{'form.Semester'};
1.19 raeburn 675: }
1.25 albertel 676: if (defined($env{'form.Department'})) {
677: $coursecode .= $env{'form.Department'};
1.19 raeburn 678: }
1.25 albertel 679: if (defined($env{'form.Number'})) {
680: $coursecode .= $env{'form.Number'};
1.19 raeburn 681: }
682: }
1.1 raeburn 683: my $supportmsg = qq|
1.25 albertel 684: Name: $env{'form.username'}
685: Email: $env{'form.email'}
686: Username/domain: $env{'form.uname'} - $env{'form.udom'}
687: Tel: $env{'form.phone'}
688: Course Information: $env{'form.title'} - $coursecode - section: $env{'form.section'}
689: Subject: $env{'form.subject'}
690: Description: $env{'form.description'}
691: URL: $env{'form.sourceurl'}
1.1 raeburn 692: Date/Time: $reporttime
693:
694: |;
1.25 albertel 695: my $descrip = $env{'form.description'};
1.5 raeburn 696: $descrip =~ s#\n#<br />#g;
697: my $displaymsg = qq|
1.25 albertel 698: <font color="$fontcolor">Name:</font><font color="$vlinkcolor"> $env{'form.username'}</font><br />
699: <font color="$fontcolor">Email: </font><font color="$vlinkcolor">$env{'form.email'}</font><br />
700: <font color="$fontcolor">Username/domain: </font><font color="$vlinkcolor">$env{'form.uname'} - $env{'form.udom'}</font><br />
701: <font color="$fontcolor">Tel: </font><font color="$vlinkcolor">$env{'form.phone'}</font><br />
702: <font color="$fontcolor">Course Information: </font><font color="$vlinkcolor">$env{'form.title'} - $coursecode - section: $env{'form.section'}</font><br />
703: <font color="$fontcolor">Subject: </font><font color="$vlinkcolor">$env{'form.subject'}</font><br />
1.5 raeburn 704: <font color="$fontcolor">Description: </font><font color="$vlinkcolor">$descrip</font><br />
1.25 albertel 705: <font color="$fontcolor">URL: </font><font color="$vlinkcolor">$env{'form.sourceurl'}</font><br />
1.5 raeburn 706: <font color="$fontcolor">Date/Time: </font><font color="$vlinkcolor">$reporttime</font><br />
707: |;
1.32 albertel 708:
709: my $start_page =
710: &Apache::loncommon::start_page('Support request recorded',undef,
1.33 albertel 711: {'function' => $function,
712: 'add_entries' => {
713: topmargin => "0",
714: marginheight => "0",
715: },
716: 'only_body' => 1,});
1.32 albertel 717:
1.14 raeburn 718: $r->print(<<"END");
1.32 albertel 719: $start_page
1.16 raeburn 720: <form name="logproblem">
1.18 raeburn 721: <input type="hidden" name="action" value="result" />
1.16 raeburn 722: </form>
1.1 raeburn 723: END
1.14 raeburn 724: if ($r->uri eq '/adm/helpdesk') {
725: &print_header($r,$url,'process');
726: }
727: if ($to =~ m/^[^\@]+\@[^\@]+$/) {
728: $r->print("<h3>A support request has been sent to $to</h3>");
1.9 raeburn 729: } else {
730: $to = $admin;
731: if ($to =~ m/^[^\@]+\@[^\@]+$/) {
1.14 raeburn 732: $r->print("<h3>A support request has been sent to $to</h3>");
1.9 raeburn 733: END
734: } else {
735: $r->print(<<END);
1.1 raeburn 736: <h3>Warning: Problem with support e-mail address</h3>
1.9 raeburn 737: As the e-mail address provided for this LON-CAPA server ($to) does not appear to be a valid e-mail address, your support request has <b>not</b> been sent to the LON-CAPA support staff or administrator at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University.
1.1 raeburn 738: END
1.9 raeburn 739: $to = 'helpdesk@lon-capa.org';
740: }
1.1 raeburn 741: }
1.25 albertel 742: if (defined($env{'form.email'})) {
743: if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
744: $from = $env{'form.email'};
1.5 raeburn 745: }
746: }
747:
1.25 albertel 748: my $subject = $env{'form.subject'};
1.5 raeburn 749: $subject =~ s#(`)#'#g;
750: $subject =~ s#\$#\(\$\)#g;
751: $supportmsg =~ s#(`)#'#g;
752: $supportmsg =~ s#\$#\(\$\)#g;
753: $displaymsg =~ s#(`)#'#g;
754: $displaymsg =~ s#\$#\(\$\)#g;
755: my $fname;
756:
757: my $attachmentpath = '';
758: my $attachmentsize = '';
1.25 albertel 759: if (defined($env{'user.name'})) {
760: if ($env{'form.screenshot.filename'}) {
761: $attachmentsize = length($env{'form.screenshot'});
1.5 raeburn 762: if ($attachmentsize > 131072) {
763: $displaymsg .= "<br />The uploaded screenshot file ($attachmentsize bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.";
764: } else {
765: $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
766: }
767: }
768: }
769:
1.27 raeburn 770: my %cookies = ();
771: my $cookie=CGI::Cookie->parse($r->header_in('Cookie'));
772: if ($$cookie{'lonID'} =~ /lonID=(\w+);/) {
773: $cookies{'lonID'} = $1;
774: }
775:
1.5 raeburn 776: if ($attachmentpath =~ m-/([^/]+)$-) {
777: $fname = $1;
1.25 albertel 778: $displaymsg .= "<br />An uploaded screenshot file - $fname ($attachmentsize bytes) was included in the request sent by $env{'user.name'} from LON-CAPA domain: $env{'user.domain'}";
1.5 raeburn 779: $supportmsg .= "\n";
1.27 raeburn 780: foreach (@cookievars) {
781: $supportmsg .= "$_: $cookies{$_}\n";
782: }
1.26 raeburn 783: foreach (@ENVvars) {
784: $supportmsg .= "$_: $ENV{$_}\n";
785: }
1.5 raeburn 786: foreach (@envvars) {
1.25 albertel 787: $supportmsg .= "$_: $env{$_}\n";
1.5 raeburn 788: }
789: }
790:
791: my $msg = MIME::Lite->new(
792: From => $from,
793: To => $to,
794: Subject => $subject,
795: Type =>'TEXT',
796: Data => $supportmsg,
797: );
798:
799: if ($attachmentpath) {
800: my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);
801: $msg->attach(Type => $type,
802: Path => $attachmentpath,
803: Filename => $fname
804: );
805:
806: } else {
807: my $envdata = '';
1.27 raeburn 808: foreach (@cookievars) {
809: $envdata .= "$_: $cookies{$_}\n";
810: }
1.26 raeburn 811: foreach (@ENVvars) {
812: $envdata .= "$_: $ENV{$_}\n";
813: }
1.5 raeburn 814: foreach (@envvars) {
1.25 albertel 815: $envdata .= "$_: $env{$_}\n";
1.5 raeburn 816: }
817: foreach (@loncvars) {
1.25 albertel 818: $envdata .= "$_: $env{$_}\n";
1.5 raeburn 819: }
820: $msg->attach(Type => 'TEXT',
821: Data => $envdata);
822: }
823:
824: ### Send it:
825: $msg->send('sendmail');
826:
827: if ($attachmentpath =~ m#$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+#) {
828: unlink($attachmentpath);
829: }
830: $r->print(qq|
1.1 raeburn 831: <b>Your support request contained the following information</b>:<br /><br />
832: <table width="580" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
833: <tr>
834: <td>
835: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
836: <tr>
837: <td>
838: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
839: <tr>
840: <td>
841: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
842: <tr>
843: <td width="140" bgcolor="$tablecolor">
844: <table width="140" border="0" cellpadding="8" cellspacing="0">
845: <tr>
846: <td align="right"><b>Information supplied</b>
847: </td>
848: </tr>
849: </table>
850: </td>
851: <td width="100%" valign="top">
852: <table width="100%" border="0" cellpadding="8" cellspacing="0">
853: <tr>
1.5 raeburn 854: <td>$displaymsg</td>
1.1 raeburn 855: </tr>
856: </table>
857: </td>
858: </tr>
859: <tr>
1.5 raeburn 860: <td width="100%" colspan="2" bgcolor="#000000">
861: <img src="/adm/lonMisc/blackdot.gif" /><br />
862: </td>
863: </tr>
864: <tr>
865: <td width="140" bgcolor="$tablecolor">
866: <table width="140" border="0" cellpadding="8" cellspacing="0">
1.1 raeburn 867: <tr>
868: <td align="right"><b>Additional information recorded</b>
869: </td>
870: </tr>
871: </table>
872: </td>
873: <td width="100%" valign="top">
874: <table width="100%" border="0" cellpadding="8" cellspacing="0">
875: <tr>
876: <td>
1.5 raeburn 877: |);
1.27 raeburn 878: foreach (@cookievars) {
879: unless($cookies{$_} eq '') {
880: $r->print("$_: <font color='$vlinkcolor'>$cookies{$_}</font>, ");
881: }
882: }
1.26 raeburn 883: foreach (@ENVvars) {
884: unless($ENV{$_} eq '') {
885: $r->print("$_: <font color='$vlinkcolor'>$ENV{$_}</font>, ");
886: }
887: }
1.1 raeburn 888: foreach (@envvars) {
1.25 albertel 889: unless($env{$_} eq '') {
890: $r->print("$_: <font color='$vlinkcolor'>$env{$_}</font>, ");
1.5 raeburn 891: }
1.1 raeburn 892: }
893: $r->print("
894: </td>
895: </tr>
896: </table>
897: </td>
898: </tr>
899: </table>
900: </td>
901: </tr>
902: </table>
903: </td>
904: </tr>
905: </table>
906: </td>
907: </tr>
908: </table>
909: ");
1.30 albertel 910: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 911: }
912:
1.14 raeburn 913: sub print_header {
914: my ($r,$origurl,$action) = @_;
915: my $location=&Apache::loncommon::lonhttpdurl("/adm");
916: my $tablecolor = '#EEEE99';
917: my ($component_url);
918: my $helpdesk_link = '<a href="javascript:validate()">';
919: if ($action eq 'process') {
920: $helpdesk_link = '<a href="/adm/helpdesk">';
921: }
922: my %lt = &Apache::lonlocal::texthash (
923: login => 'Log-in help',
924: ask => 'Ask helpdesk',
925: getst => 'Getting started guide',
926: back => 'Back to last location'
1.21 raeburn 927: );
928: my ($getstartlink,$getstarttext);
929: if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') {
930: $getstartlink = qq|<td align="center"> <b><a href="/adm/gettingstarted.html">$lt{'getst'}</a></td>|;
931: $getstarttext = ' '.&mt('and the "Getting started" guide').' ';
932: }
1.14 raeburn 933: $r->print(<<END);
934: <table width="620" border="0" cellspacing="0" cellpadding="0" height="55"> <tr height="50"> <td width='5'> </td>
935: <td>
936: <fieldset><legend><img src="$location/lonIcons/minilogo.gif" height='20' width='29' valign='bottom' /> <b><font size="+1">LON-CAPA help/support</font></b></legend>
937: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
938: <tr>
939: <td>
940: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
941: <tr>
942: <td>
943: <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
944: <tr>
945: <td>
946: <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
947: <tr bgcolor="$tablecolor">
948: <td align="center"><img src="$location/help/gif/smallHelp.gif" border="0" alt="(Login help)" valign="middle" /> <b><a href="/adm/loginproblems.html">$lt{'login'}</a></td>
1.21 raeburn 949: <td align="center"> <b>$helpdesk_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="(Ask helpdesk)" valign="middle" /> $lt{'ask'}</a></b> </td>$getstartlink
1.14 raeburn 950: <td align="center"> <b><a href="$origurl" target="_top"><img src="$location/lonIcons/move_up.gif" border="0" alt="(Back to last location)" valign="middle" /> $lt{'back'}</a></b> </td>
951: </tr>
952: </table>
953: </td>
954: </tr>
955: </table>
956: </td>
957: </tr>
958: </table>
959: </td>
960: </tr>
961: </table>
962: </fieldset>
963: </td>
964: <td width='5'> </td>
965: </tr>
966: <tr height='5'>
967: <td colspan='3' height='5'> </td>
968: </tr>
969: END
970: unless ($action eq 'process') {
971: $r->print('
972: <tr>
973: <td colspan="3">'.&mt('
1.21 raeburn 974: Please review the information in "Log-in help"').$getstarttext.' '.&mt('if you are unable to log-in').'. '.&mt('If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk').'.<br /><font size="-1"><b>'.&mt('Note').':</b> '.&mt('Student questions about course content should be directed to the course instructor').'.</font><br /><br />
1.14 raeburn 975: </td>
976: </tr>');
977: }
978: $r->print('
979: </table>');
980: return;
981: }
982:
1.1 raeburn 983: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>