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