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