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