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