1: # The LearningOnline Network with CAPA
2: # Helpdesk request form
3: #
4: # $Id: lonsupportreq.pm,v 1.79.2.12 2024/07/15 17:13:06 raeburn Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::lonsupportreq;
30:
31: use strict;
32: use MIME::Types;
33: use MIME::Lite;
34: use CGI::Cookie();
35: use Apache::Constants qw(:common);
36: use Apache::loncommon();
37: use Apache::lonhtmlcommon;
38: use Apache::lonnet;
39: use Apache::lonlocal;
40: use Apache::lonacc();
41: use Apache::lonauth();
42: use Apache::courseclassifier;
43: use LONCAPA qw(:DEFAULT :match);
44: use HTML::Entities;
45:
46: sub handler {
47: my ($r) = @_;
48: &Apache::loncommon::content_type($r,'text/html');
49: $r->send_http_header;
50:
51: if ($r->header_only) {
52: return OK;
53: }
54: if ($r->uri eq '/adm/helpdesk') {
55: &Apache::lonlocal::get_language_handle($r);
56: }
57:
58: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']);
59: if ($r->uri eq '/adm/helpdesk') {
60: &Apache::lonacc::get_posted_cgi($r);
61: }
62: my $function;
63: if ($env{'form.function'}) {
64: if (($env{'form.function'} eq 'norole') ||
65: ($env{'form.function'} eq 'student') ||
66: ($env{'form.function'} eq 'admin') ||
67: ($env{'form.function'} eq 'author')) {
68: $function = $env{'form.function'};
69: }
70: }
71: my $origurl = $env{'form.origurl'};
72: if ($origurl =~ m{^https?://[^/]+(.*)$}) {
73: $origurl = $1;
74: }
75: $origurl =~ s/(`)//g;
76: $origurl =~ s/\$/\(\$\)/g;
77: my $command = $env{'form.command'};
78:
79: if ($command eq 'process') {
80: &print_request_receipt($r,$origurl,$function);
81: } else {
82: &print_request_form($r,$origurl,$function);
83: }
84: return OK;
85: }
86:
87: sub print_request_form {
88: my ($r,$origurl,$function) = @_;
89: my ($os,$browser,$bversion,$uname,$udom,$uhome,$urole,$usec,$email,$cid,
90: $cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,
91: $formname,$public,$homeserver,$knownuser,$captcha_form,$captcha_error,
92: $captcha,$recaptcha_version,$extra_validations,%groupid);
93: $function = &Apache::loncommon::get_users_function() if (!$function);
94: $ccode = '';
95: $os = $env{'browser.os'};
96: $browser = $env{'browser.type'};
97: $bversion = $env{'browser.version'};
98: if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
99: $public = 1;
100: } else {
101: if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
102: $homeserver = &Apache::lonnet::homeserver($env{'user.name'},
103: $env{'user.domain'});
104: if ($homeserver eq 'no_host') {
105: undef($homeserver);
106: } else {
107: $uname = $env{'user.name'};
108: $udom = $env{'user.domain'};
109: }
110: }
111: }
112: if (($env{'user.name'} =~ /^$match_username$/) &&
113: ($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
114: $knownuser = 1;
115: } else {
116: my $lonhost = $r->dir_config('lonHostID');
117: ($captcha_form,$captcha_error,$captcha,$recaptcha_version) =
118: &Apache::loncommon::captcha_display('login',$lonhost);
119: }
120: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom',
121: 'useremail','useraccount']);
122:
123: if ($homeserver) {
124: $uhome = $env{'user.home'};
125: $urole = $env{'request.role'};
126: $usec = $env{'request.course.sec'};
127: $cid = $env{'request.course.id'};
128: }
129: if ($cid) {
130: $cdom = $env{'course.'.$cid.'.domain'};
131: $cnum = $env{'course.'.$cid.'.num'};
132: }
133: if ($cdom && $cnum) {
134: my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);
135: $ctitle = $csettings{'description'};
136: $ccode = $csettings{'internal.coursecode'};
137: $sectionlist = $csettings{'internal.sectionnums'};
138: my @sections = split(/,/,$sectionlist);
139: foreach my $section (@sections) {
140: my ($sec,$grp) = split(/:/,$section);
141: $groupid{$sec} = $grp;
142: }
143: }
144:
145: $formname = 'logproblem';
146: my $codedom = &get_domain();
147: my %helpform;
148: my %domconfig =
149: &Apache::lonnet::get_dom('configuration',['contacts'],$codedom);
150: if (ref($domconfig{'contacts'}) eq 'HASH') {
151: if (ref($domconfig{'contacts'}{'helpform'}) eq 'HASH') {
152: %helpform = %{$domconfig{'contacts'}{'helpform'}};
153: }
154: }
155:
156: my %codes;
157: my @codetitles;
158: my %cat_titles;
159: my %cat_order;
160: my %idlist;
161: my %idnums;
162: my %idlist_titles;
163: my $totcodes = 0;
164: my $jscript = '';
165: my $loaditems = qq|
166: function initialize_codes() {
167: return;
168: }
169: |;
170: unless ($helpform{'course'} eq 'no') {
171: my $instcats = &Apache::lonnet::get_dom_instcats($codedom);
172: if (ref($instcats) eq 'HASH') {
173: if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH') &&
174: (ref($instcats->{'cat_titles'}) eq 'HASH') && (ref($instcats->{'cat_order'}) eq 'HASH')) {
175: %codes = %{$instcats->{'codes'}};
176: @codetitles = @{$instcats->{'codetitles'}};
177: %cat_titles = %{$instcats->{'cat_titles'}};
178: %cat_order = %{$instcats->{'cat_order'}};
179: $totcodes = scalar(keys(%codes));
180: }
181: if ($totcodes > 0) {
182: my $numtypes = @codetitles;
183: &Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
184: my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);
185: my $longtitles_str = join('","',@{$longtitles});
186: my $allidlist = $idlist{$codetitles[0]};
187: my $knowncodes;
188: if (($ccode ne '') && ($cnum ne '')) {
189: my (%singlecodes,@singlecodetitles,%singlecat_titles,%singlecat_order);
190: my $crscode_reply = &Apache::lonnet::auto_instcode_format($cnum,$codedom,{ $cnum => $ccode },\%singlecodes,
191: \@singlecodetitles,\%singlecat_titles,\%singlecat_order);
192: if (ref($singlecodes{$cnum}) eq 'HASH') {
193: $knowncodes = $singlecodes{$cnum};
194: }
195: }
196: $jscript .= &Apache::courseclassifier::courseset_js_start($formname,$longtitles_str,$allidlist);
197: $jscript .= $scripttext;
198: $jscript .= &Apache::courseclassifier::javascript_code_selections($formname,\@codetitles,$knowncodes,$sectionlist);
199: $loaditems = '';
200: }
201: }
202: }
203: my %missing = &Apache::lonlocal::texthash(
204: username => 'You must include a name.',
205: phone => 'You must include a phone.',
206: );
207: &js_escape(\%missing);
208: if (keys(%helpform)) {
209: foreach my $key (keys(%helpform)) {
210: if (($helpform{$key} eq 'req') && ($missing{$key} ne '')) {
211: next if (($key eq 'username') && (($knownuser) ||
212: (($env{'user.name'} =~ /^$match_username$/) && (!$public))));
213: $extra_validations .= <<"END";
214:
215: if (document.$formname.$key.value == '') {
216: alert("$missing{$key}");
217: return;
218: }
219:
220: END
221: }
222: }
223: }
224: my $machine = &Apache::lonnet::absolute_url();
225: my $sourceurl = $machine.$origurl;
226: $server = $machine.&Apache::loncommon::cleanup_html($origurl);
227: $server =~ s/\?.*$//;
228: my %js_lt = &Apache::lonlocal::texthash (
229: email => 'The e-mail address you entered',
230: notv => 'is not a valid e-mail address',
231: rsub => 'You must include a subject',
232: rdes => 'You must include a description',
233: );
234: my %html_lt = &Apache::lonlocal::texthash (
235: name => 'Name',
236: subm => 'Submit Request',
237: emad => 'Your e-mail address',
238: emac => 'Cc',
239: unme => 'username',
240: doma => 'domain',
241: entu => 'Enter the username you use to log-in to LON-CAPA',
242: chdo => 'Choose your LON-CAPA domain',
243: entr => 'Enter the username you use to log-in to LON-CAPA, and your domain.',
244: urlp => 'URL of page',
245: phon => 'Phone',
246: crsd => 'Course Details',
247: enin => 'Enter institutional course code',
248: pick => 'Pick',
249: enct => 'Enter course title',
250: secn => 'Section Number',
251: sele => 'Select',
252: titl => 'Title',
253: lsec => 'LON-CAPA sec',
254: subj => 'Subject',
255: detd => 'Detailed Description',
256: opfi => 'Optional file upload',
257: uplf => 'Upload a file (e.g., a screenshot) relevant to your help request',
258: fini => 'Finish',
259: clfm => 'Clear Form',
260: );
261: &js_escape(\%js_lt);
262: &html_escape(\%html_lt);
263: my $scripttag = (<<"END");
264: function validate() {
265: if (validmail(document.logproblem.email) == false) {
266: alert("$js_lt{'email'}: "+document.logproblem.email.value+" $js_lt{'notv'}.");
267: return;
268: }
269: if (document.logproblem.subject.value == '') {
270: alert("$js_lt{'rsub'}.");
271: return;
272: }
273: if (document.logproblem.description.value == '') {
274: alert("$js_lt{'rdes'}.");
275: return;
276: }
277: $extra_validations
278: document.logproblem.submit();
279: }
280:
281: END
282: $scripttag .= &Apache::lonhtmlcommon::javascript_valid_email();
283:
284: if ($homeserver) {
285: if ($env{'environment.permanentemail'}) {
286: $email = $env{'environment.permanentemail'};
287: } elsif ($env{'environment.critnotification'}) {
288: $email = $env{'environment.critnotification'};
289: } elsif ($env{'environment.notification'}) {
290: $email = $env{'environment.notification'};
291: }
292: if ($env{'environment.lastname'}) {
293: $lastname = $env{'environment.lastname'};
294: }
295: if ($env{'environment.firstname'}) {
296: $firstname = $env{'environment.firstname'};
297: }
298: }
299: if ($env{'form.origurl'} eq '/adm/createaccount') {
300: if ($email eq '') {
301: if ($env{'form.useremail'} =~ /^[^\@]+\@[^\@]+$/) {
302: $email = &HTML::Entities::encode($env{'form.useremail'},'"<>&');
303: }
304: }
305: if ($uname eq '') {
306: if ($env{'form.useraccount'} =~ /^$match_username$/) {
307: $uname = &HTML::Entities::encode($env{'form.useraccount'},'"<>&');
308: }
309: }
310: }
311: my $details_title;
312: if ($codedom) {
313: $details_title = '<br />('.$codedom.')';
314: }
315:
316: my $js = <<"ENDJS";
317: <script type="text/javascript">
318: // <![CDATA[
319: $scripttag
320: $jscript
321: $loaditems
322: // ]]>
323: </script>
324: ENDJS
325: if ($knownuser) {
326: $js .="\n".'<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>';
327: } elsif ($recaptcha_version >=2) {
328: $js.= "\n".'<script src="https://www.google.com/recaptcha/api.js"></script>'."\n";
329: }
330: my %add_entries = (
331: style => "margin-top:0px;margin-bottom:0px;",
332: onload => "initialize_codes();",
333: );
334:
335:
336: $r->print(&Apache::loncommon::start_page('Support Request',$js,
337: { 'function' => $function,
338: 'add_entries' => \%add_entries,
339: 'only_body' => 1,}));
340: if ($r->uri eq '/adm/helpdesk') {
341: &print_header($r,$origurl);
342: }
343: my @css = ('LC_evenrow_value','LC_oddrow_value');
344: my $num = 1;
345: my $i = $num%2;
346: my $formtype;
347: if ($homeserver) {
348: $formtype = ' enctype="multipart/form-data"';
349: }
350: my $topsubmit = ' <input type="button" value="'.$html_lt{'subm'}.'" onclick="validate()" /> ';
351: my $shownsubmit;
352: $r->print('<form method="post" action="" name="logproblem"'.$formtype.'>'."\n");
353: my $output = &Apache::lonhtmlcommon::start_pick_box().
354: &Apache::lonhtmlcommon::row_headline().
355: '<span class="LC_info">'.
356: &mt('(All fields marked with * are required.)').
357: '</span>'.
358: &Apache::lonhtmlcommon::row_closure();
359: unless ($helpform{'username'} eq 'no') {
360: my ($reqd,$namefield,$fullname);
361: if ((defined($lastname) && $lastname ne '') && (defined($firstname) && $firstname ne '')) {
362: $fullname = "$firstname $lastname";
363: $namefield = $fullname.'<input type="hidden" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n";
364: } else {
365: if (defined($firstname) && $firstname ne '') {
366: $fullname = $firstname;
367: } elsif (defined($lastname) && $lastname ne '') {
368: $fullname = " $lastname";
369: }
370: $namefield = '<input type="text" size="20" name="username" value="'.&HTML::Entities::encode($fullname,'"<>&').'" />'."\n";
371: if ($helpform{'username'} eq 'req') {
372: $reqd = '<span class="LC_info">*</span>';
373: }
374: }
375: $output .= &Apache::lonhtmlcommon::row_title($html_lt{'name'}.$reqd,undef,$css[$num])."\n".$namefield.
376: $topsubmit.
377: &Apache::lonhtmlcommon::row_closure()."\n";
378: $shownsubmit = 1;
379: $num ++;
380: $i = $num%2;
381: }
382: $output .= &Apache::lonhtmlcommon::row_title(
383: '<span title="'.&mt('required').'">'.
384: $html_lt{'emad'}.' <span class="LC_info">*</span></span>'
385: ,undef,$css[$i]).
386: '<input type="text" size="20" name="email" value="'.
387: &HTML::Entities::encode($email,'"<>&').'" />'."\n";
388: unless ($shownsubmit) {
389: $output .= $topsubmit;
390: }
391: $output .= &Apache::lonhtmlcommon::row_closure();
392: $num ++;
393: $i = $num%2;
394: if ($knownuser) {
395: if ($homeserver) {
396: my $ip = &Apache::lonnet::get_requestor_ip($r);
397: my %setters;
398: my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
399: &Apache::loncommon::blockcheck(\%setters,'com',$ip);
400: unless (($helpform{'cc'} eq 'no') || ($by_ip)) {
401: $output .= &Apache::lonhtmlcommon::row_title($html_lt{'emac'},undef,$css[$i]).
402: '<input type="text" size="50" name="cc" value="" /><br />'."\n".
403: &Apache::lonhtmlcommon::row_closure();
404: $num ++;
405: $i = $num%2;
406: }
407: }
408: }
409: unless ($helpform{'user'} eq 'no') {
410: $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'unme'}/$html_lt{'doma'}",undef,$css[$i]);
411: my $udom_input = '<input type="hidden" name="udom" value="'.
412: &HTML::Entities::encode($udom,'"<>&').'" />'."\n";
413: my $uname_input = '<input type="hidden" name="uname" value="'.
414: &HTML::Entities::encode($uname,'"<>&').'" />'."\n";
415: if ($knownuser) {
416: $output .= '<i>'.$html_lt{'unme'}.'</i>: '.$uname.' <i>'.$html_lt{'doma'}.'</i>: '.$udom.$udom_input.$uname_input;
417: } else {
418: my $udomform = '';
419: my $unameform = '';
420: if (($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) {
421: $output .= $html_lt{'entu'};
422: } elsif (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
423: $output .= $html_lt{'chdo'};
424: } else {
425: $output .= $html_lt{'entr'};
426: }
427: $output .= '<br />'."\n";
428: if (!$public) {
429: if ($env{'user.domain'} =~ /^$match_domain$/) {
430: $udomform = '<i>'.$html_lt{'doma'}.'</i>: '.$udom.$udom_input;
431: } elsif ($env{'user.name'} =~ /^$match_username$/) {
432: $unameform = '<i>'.$html_lt{'unme'}.'</i>: '.$uname.' '.$uname_input;
433: }
434: }
435: if ($udomform eq '') {
436: $udomform = '<i>'.$html_lt{'doma'}.'</i>: ';
437: $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom')."\n";
438: }
439: if ($unameform eq '') {
440: $unameform= '<i>'.$html_lt{'unme'}.'</i>: <input type="text" size="20" name="uname" value="'.$uname.'" /> ';
441: }
442: $output .= $unameform.$udomform;
443: }
444: $output .= &Apache::lonhtmlcommon::row_closure();
445: $num ++;
446: }
447: $i = $num%2;
448: $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'urlp'}",undef,$css[$i]).
449: $server."\n".'<input type="hidden" name="sourceurl" value="'.
450: &HTML::Entities::encode($sourceurl,'"<>&').'" />'."\n".
451: &Apache::lonhtmlcommon::row_closure();
452: unless ($helpform{'phone'} eq 'no') {
453: my $reqd;
454: if ($helpform{'phone'} eq 'req') {
455: $reqd = '<span class="LC_info">*</span>';
456: }
457: $output .= &Apache::lonhtmlcommon::row_title($html_lt{'phon'}.$reqd,undef,'LC_evenrow_value').
458: '<input type="text" size="15" name="phone" /><br />'."\n".
459: &Apache::lonhtmlcommon::row_closure();
460: $num ++;
461: $i = $num%2;
462: }
463: unless ($helpform{'course'} eq 'no') {
464: $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'crsd'}$details_title",undef,$css[$i]);
465: if ($totcodes > 0) {
466: my $numtitles = @codetitles;
467: if ($numtitles == 0) {
468: $output .= $html_lt{'enin'}.':
469: <input type="text" name="coursecode" size="15" value="'.&HTML::Entities::encode($ccode,'\'"&<>').'" />'."\n";
470: } else {
471: my @standardnames = &Apache::loncommon::get_standard_codeitems();
472: my $lasttitle = $numtitles;
473: if ($numtitles > 4) {
474: $lasttitle = 4;
475: }
476: my $onchange;
477: if ($sectionlist) {
478: $onchange = 'toggleSecVis()';
479: }
480: $output .= '<table><tr><td>'.$codetitles[0].'<br />'."\n".
481: '<select name="'.$standardnames[0].'" onchange="courseSet('."'$codetitles[0]'".');'.$onchange.'">'."\n".
482: ' <option value="-1">'.$html_lt{'sele'}."</option>\n";
483: my @items = ();
484: my @longitems = ();
485: if ($idlist{$codetitles[0]} =~ /","/) {
486: @items = split(/","/,$idlist{$codetitles[0]});
487: } else {
488: $items[0] = $idlist{$codetitles[0]};
489: }
490: if (defined($idlist_titles{$codetitles[0]})) {
491: if ($idlist_titles{$codetitles[0]} =~ /","/) {
492: @longitems = split(/","/,$idlist_titles{$codetitles[0]});
493: } else {
494: $longitems[0] = $idlist_titles{$codetitles[0]};
495: }
496: for (my $i=0; $i<@longitems; $i++) {
497: if ($longitems[$i] eq '') {
498: $longitems[$i] = $items[$i];
499: }
500: }
501: } else {
502: @longitems = @items;
503: }
504: for (my $i=0; $i<@items; $i++) {
505: $output .= ' <option value="'.$items[$i].'">'.$longitems[$i].'</option>'."\n";
506: }
507: $output .= '</select></td>';
508: for (my $i=1; $i<$numtitles; $i++) {
509: $output .= '<td>'.$codetitles[$i].'<br />'."\n".
510: '<select name="'.$standardnames[$i].'" onchange="courseSet('."'$codetitles[$i]'".');'.$onchange.'">'."\n".
511: '<option value="-1"><-'.$html_lt{'pick'}.' '.$codetitles[$i-1].'</option>'."\n".
512: '</select>'."\n".
513: '</td>'."\n";
514: }
515: $output .= '</tr></table>';
516: if ($numtitles > 4) {
517: $output .= '<br /><br />'.$codetitles[$numtitles].'<br />'."\n".
518: '<select name="'.$standardnames[$numtitles].'" onchange="courseSet('."'$codetitles[$numtitles]'".');'.$onchange.'">'."\n".
519: '<option value="-1"><-'.$html_lt{'pick'}.' '.$codetitles[$numtitles-1].'</option>'."\n".
520: '</select>'."\n";
521: }
522: }
523: } else {
524: $output .= $html_lt{'enin'}.':
525: <input type="text" name="coursecode" size="15" value="" />'."\n";
526: }
527: my $reqd;
528: if ($helpform{'course'} eq 'req') {
529: $reqd = '<span class="LC_info">*</span>';
530: }
531: $output .= '<br />'.$html_lt{'enct'}.$reqd.':
532: <input type="text" name="title" size="25" value="'.
533: &HTML::Entities::encode($ctitle,'"<>&').'" />'."\n";
534: $output .= &Apache::lonhtmlcommon::row_closure();
535: $num ++;
536: $i = $num%2;
537: }
538: unless ($helpform{'section'} eq 'no') {
539: $output .= &Apache::lonhtmlcommon::row_title($html_lt{'secn'},undef,$css[$i]);
540: if ($sectionlist) {
541: $output .= "<div id=\"LC_helpdesk_sectionlist\"><select name=\"sectionsel\">\n".
542: " <option value=\"\" selected=\"selected\">$html_lt{'sele'}</option>\n";
543: foreach my $id (sort(keys(%groupid))) {
544: if ($id eq $groupid{$id} || $groupid{$id} eq '') {
545: $output .= " <option value=".
546: &HTML::Entities::encode($id,'"<>&').
547: " >$id</option>\n";
548: } else {
549: $output .= " <option value=".
550: &HTML::Entities::encode($id,'"<>&').
551: " >$id - ($html_lt{'lsec'}: $groupid{$id})</option>\n";
552: }
553: }
554: $output .= '</select></div>'."\n".
555: '<div id="LC_helpdesk_section" style="display:none">'.
556: '<input type="text" name="sectiontxt" size="10" /></div>'."\n";
557: } else {
558: $output .= '<input type="text" name="section" size="10" />'."\n";
559: }
560: $output .= &Apache::lonhtmlcommon::row_closure();
561: $num ++;
562: $i = $num%2;
563: }
564: $output .= &Apache::lonhtmlcommon::row_title(
565: '<span title="'.&mt('required').'">'.
566: $html_lt{'subj'}.' <span class="LC_info">*</span></span>'
567: ,undef,'LC_oddrow_value').
568: '<input type="text" size="40" name="subject" />'."\n".
569: &Apache::lonhtmlcommon::row_closure().
570: &Apache::lonhtmlcommon::row_title(
571: '<span title="'.&mt('required').'">'.
572: $html_lt{'detd'}.' <span class="LC_info">*</span></span>'
573: ,undef,'LC_evenrow_value').
574: '<textarea rows="10" cols="45" name="description" style="word-wrap:normal;">'.
575: '</textarea>'."\n".
576: &Apache::lonhtmlcommon::row_closure();
577: $num ++;
578: $i = $num%2;
579: if ($knownuser) {
580: if ($homeserver) {
581: unless ($helpform{'screenshot'} eq 'no') {
582: my $max = 1048576;
583: my $showmax = 1.00;
584: if ($helpform{'maxsize'} =~ /^\d+\.\d*$/) {
585: $max *= $helpform{'maxsize'};
586: $showmax = $helpform{'maxsize'};
587: }
588: $showmax = ' ('.sprintf("%.2f",$showmax).' '.&mt('MB max.').')';
589: $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i])
590: .' <input type="file" name="screenshot" class="LC_flUpload" size="20" />'
591: .'<input type="hidden" id="LC_free_space" value="'.$max.'" />'
592: .'<br />'."\n".$html_lt{'uplf'}.$showmax."\n"
593: .&Apache::lonhtmlcommon::row_closure();
594: $num ++;
595: $i = $num%2;
596: }
597: }
598: } else {
599: if ($captcha_form) {
600: $output .= &Apache::lonhtmlcommon::row_title(
601: '<span title="'.&mt('required').'">'.
602: &mt('Validation').
603: ' <span class="LC_info">*</span></span>'
604: ,undef,$css[$i]).
605: $captcha_form."\n".
606: &Apache::lonhtmlcommon::row_closure();
607: $num ++;
608: $i = $num%2;
609: }
610: }
611: $output .= &Apache::lonhtmlcommon::row_title($html_lt{'fini'},undef,$css[$i]);
612: $output .= <<END;
613: <table border="0" cellpadding="8" cellspacing="0">
614: <tr>
615: <td>
616: <input type="hidden" name="command" value="process" />
617: <input type="button" value="$html_lt{'subm'}" onclick="validate()" />
618: </td>
619: <td> </td>
620: <td>
621: <input type="reset" value="$html_lt{'clfm'}" />
622: </td>
623: </tr>
624: </table>
625: END
626: $output .= &Apache::lonhtmlcommon::row_closure(1);
627: $output .= &Apache::lonhtmlcommon::end_pick_box();
628: $r->print(<<END);
629: $output
630: </form>
631: <br />
632: END
633: $r->print(&Apache::loncommon::end_page());
634: return;
635: }
636:
637: sub print_request_receipt {
638: my ($r,$url,$function) = @_;
639: my $public;
640: if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
641: $public = 1;
642: }
643: my $lonhost = $r->dir_config('lonHostID');
644: unless (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
645: my ($captcha_chk,$captcha_error) =
646: &Apache::loncommon::captcha_response('login',$lonhost);
647: if ($captcha_chk != 1) {
648: $r->print(&Apache::loncommon::start_page('Support request failed',undef,
649: {'function' => $function,
650: 'add_entries' => {
651: topmargin => "0",
652: marginheight => "0",
653: },
654: 'only_body' => 1,}));
655: if ($r->uri eq '/adm/helpdesk') {
656: &print_header($r,$url,'process');
657: }
658: $r->print(
659: '<h2>'.&mt('Support request failed').'</h2>'.
660: &Apache::lonhtmlcommon::confirm_success(
661: &mt('Validation of the code you entered failed.'),1).
662: '<br /><br />'.
663: &Apache::lonhtmlcommon::actionbox([
664: &mt('[_1]Go back[_2] and try again',
665: '<a href="javascript:history.go(-1)">','</a>')]).
666: &Apache::loncommon::end_page());
667: return;
668: }
669: }
670: my $ip = &Apache::lonnet::get_requestor_ip($r);
671: my %setters;
672: my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
673: &Apache::loncommon::blockcheck(\%setters,'com',$ip);
674: my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','SERVER_ADDR','SERVER_NAME');
675: my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role');
676: my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
677: my @cookievars;
678: if ($ENV{'SERVER_PORT'} == 443) {
679: @cookievars = ('lonLinkID');
680: } else {
681: @cookievars = ('lonID');
682: }
683:
684: my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
685: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
686: my $defdom = &get_domain();
687: my $from = $admin;
688: my %helpform;
689: my %domconfig =
690: &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);
691: if (ref($domconfig{'contacts'}) eq 'HASH') {
692: if (ref($domconfig{'contacts'}{'helpform'}) eq 'HASH') {
693: %helpform = %{$domconfig{'contacts'}{'helpform'}};
694: }
695: }
696: my $reporttime = &Apache::lonlocal::locallocaltime(time);
697: my %formvars = (
698: email => 1,
699: sourceurl => 1,
700: subject => 1,
701: description => 1,
702: );
703: unless ($helpform{'username'} eq 'no') {
704: $formvars{'username'} = 1;
705: }
706: unless ($helpform{'user'} eq 'no') {
707: $formvars{'uname'} = 1;
708: $formvars{'udom'} = 1;
709: }
710: unless ($helpform{'phone'} eq 'no') {
711: $formvars{'phone'} = 1;
712: }
713: unless ($helpform{'section'} eq 'no') {
714: $formvars{'section'} = 1;
715: }
716: unless ($helpform{'course'} eq 'no') {
717: $formvars{'course'} = 1;
718: }
719: unless (($helpform{'cc'} eq 'no') || ($by_ip)) {
720: $formvars{'cc'} = 1;
721: }
722: unless ($helpform{'screenshot'} eq 'no') {
723: $formvars{'screenshot'} = 1;
724: }
725: my $coursecode;
726: if ($formvars{'course'}) {
727: $coursecode = $env{'form.coursecode'};
728: if ($coursecode eq '') {
729: my $totcodes = 0;
730: my $instcats = &Apache::lonnet::get_dom_instcats($defdom);
731: if (ref($instcats) eq 'HASH') {
732: if (ref($instcats->{'codes'}) eq 'HASH') {
733: $totcodes = scalar(keys(%{$instcats->{'codes'}}));
734: }
735: }
736: my @standardnames = &Apache::loncommon::get_standard_codeitems();
737: if ($totcodes > 0) {
738: my $noregexps = 1;
739: $coursecode =
740: &Apache::courseclassifier::instcode_from_selectors($defdom,$noregexps);
741: }
742: if ($coursecode eq '') {
743: foreach my $item (@standardnames) {
744: if ((defined($env{'form.'.$item})) && ($env{'form.'.$item} ne '-1')) {
745: $coursecode .= $env{'form.'.$item};
746: }
747: }
748: }
749: }
750: }
751: my %lt = &Apache::lonlocal::texthash (
752: username => 'Name',
753: email => 'E-mail',
754: cc => 'Cc',
755: user => 'Username/domain',
756: phone => 'Phone',
757: crsi => 'Course Information',
758: subject => 'Subject',
759: description => 'Description',
760: sourceurl => 'URL',
761: date => 'Date/Time',
762: secn => 'Section',
763: warn => 'Warning: Problem with support e-mail address',
764: your => 'Your support request contained the following information',
765: belo => 'Below is your support request which could not be sent',
766: ifyk => 'If you know an IT support address for your institution, you could copy this information and send it to that email address.',
767: sect => 'section',
768: info => 'Information supplied',
769: adin => 'Additional information recorded',
770: );
771:
772: my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist,$homeserver);
773: unless ($public) {
774: if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
775: $homeserver = &Apache::lonnet::homeserver($env{'user.name'},
776: $env{'user.domain'});
777: }
778: }
779: my ($cid,$cdom,$cnum,$sectionlist,$ccode);
780: if ($homeserver) {
781: $cid = $env{'request.course.id'};
782: }
783: if ($cid) {
784: $cdom = $env{'course.'.$cid.'.domain'};
785: $cnum = $env{'course.'.$cid.'.num'};
786: }
787: if ($cdom && $cnum) {
788: my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);
789: $ccode = $csettings{'internal.coursecode'};
790: $sectionlist = $csettings{'internal.sectionnums'};
791: }
792: if (($homeserver) && (defined($env{'form.cc'})) && ($formvars{'cc'})) {
793: my @ccs;
794: if ($env{'form.cc'} =~ /,/) {
795: @ccs = split(/,/,$env{'form.cc'});
796: } else {
797: $env{'form.cc'} =~ s/^\s+//;
798: $env{'form.cc'} =~ s/\s+$//;
799: @ccs = $env{'form.cc'};
800: }
801: foreach my $cc (@ccs) {
802: $cc =~ s/^\s+//g;
803: $cc =~ s/\s+$//g;
804: if ($cc =~ m/^[^\@]+\@[^\@]+$/) {
805: if (!(grep(/^\Q$cc\E$/,@ok_ccs))) {
806: push(@ok_ccs,$cc);
807: }
808: } elsif ($cc ne '') {
809: if (!(grep(/^\Q$cc\E$/,@bad_ccs))) {
810: push(@bad_ccs,$cc);
811: }
812: }
813: }
814: if (@ok_ccs > 0) {
815: $okcclist = join(', ',@ok_ccs);
816: }
817: if (@bad_ccs == 1) {
818: if ($bad_ccs[0] ne '') {
819: $badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').&Apache::loncommon::cleanup_html($bad_ccs[0]);
820: }
821: } elsif (@bad_ccs > 1) {
822: $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: '). &Apache::loncommon::cleanup_html(join(', ',@bad_ccs));
823: }
824: }
825: $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";
826: if ($formvars{'course'}) {
827: $env{'form.crsi'} = $env{'form.title'};
828: if ($coursecode ne '') {
829: $env{'form.crsi'} .= ' - '.$coursecode;
830: }
831: }
832: if ($formvars{'section'}) {
833: my $section;
834: if ($sectionlist) {
835: if ($coursecode eq $ccode) {
836: $section = $env{'form.sectionsel'}
837: } else {
838: $section = $env{'form.sectiontxt'};
839: }
840: } else {
841: $section = $env{'form.section'};
842: }
843: $env{'form.crsi'} .= ' - '.$lt{'sect'}.': '.$section;
844: }
845: my $supportmsg;
846: if ($formvars{'username'}) {
847: $supportmsg .= "$lt{'username'}: $env{'form.username'}\n";
848: }
849: $supportmsg .= "$lt{'email'}: $env{'form.email'}\n";
850: if (($homeserver) && (defined($env{'form.cc'})) && ($formvars{'cc'})) {
851: $supportmsg .= "$lt{'cc'}: $okcclist\n";
852: }
853: if ($formvars{'user'}) {
854: $supportmsg .= "$lt{'user'}: $env{'form.user'}\n";
855: }
856: if ($formvars{'phone'}) {
857: $supportmsg .= "$lt{'phone'}: $env{'form.phone'}\n";
858: }
859: if ($formvars{'course'}) {
860: $supportmsg .= "$lt{'crsi'}: $env{'form.crsi'}\n";
861: }
862: $supportmsg .= "$lt{'subject'}: $env{'form.subject'}
863: $lt{'description'}: $env{'form.description'}
864: $lt{'sourceurl'}: $env{'form.sourceurl'}
865: $lt{'date'}: $reporttime
866: ";
867:
868: my $displaymsg;
869: foreach my $item ('username','email','cc','user','phone','crsi','subject','description','sourceurl') {
870: if ($env{'form.'.$item} ne '') {
871: if ($item eq 'description') {
872: my $descrip = $env{'form.description'};
873: $descrip = &Apache::loncommon::cleanup_html($descrip);
874: $descrip =~ s|[\n\r\f]|<br />|g;
875: $displaymsg .=
876: '<span class="LC_helpform_receipt_cat">'.
877: "$lt{$item}</span>: $descrip<br />\n";
878: } elsif ($item eq 'sourceurl') {
879: my $showurl = $env{'form.sourceurl'};
880: $showurl =~ s/\?.*$//;
881: $showurl = &Apache::loncommon::cleanup_html($showurl);
882: $displaymsg .=
883: '<span class="LC_helpform_receipt_cat">'.
884: "$lt{$item}</span>: $showurl<br />\n";
885: } elsif ($item eq 'cc') {
886: next if ($helpform{'cc'} eq 'no');
887: if ($okcclist) {
888: my $showcclist = &Apache::loncommon::cleanup_html($okcclist);
889: $displaymsg .=
890: '<span class="LC_helpform_receipt_cat">'.
891: "$lt{$item}</span>: $showcclist<br />\n";
892: }
893: } else {
894: if (($item eq 'username') || ($item eq 'user') || ($item eq 'phone')) {
895: next if ($helpform{$item} eq 'no');
896: }
897: next if (($item eq 'crsi') && ($helpform{'course'} eq 'no'));
898: my $showitem = $env{'form.'.$item};
899: $showitem = &Apache::loncommon::cleanup_html($showitem);
900: $displaymsg .=
901: '<span class="LC_helpform_receipt_cat">'.
902: "$lt{$item}</span>: $showitem<br />\n";
903: }
904: }
905: }
906:
907: my ($requname,$requdom,$reqemail);
908: foreach my $field ('uname','udom','email') {
909: $env{'form.'.$field} =~ s/^\s+//;
910: $env{'form.'.$field} =~ s/\s+$//;
911: }
912: if ($env{'form.uname'} =~ /^$match_username$/) {
913: $requname = $env{'form.uname'};
914: }
915: if ($env{'form.udom'} =~ /^$match_domain$/) {
916: $requdom = $env{'form.udom'};
917: }
918: if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
919: $reqemail = $env{'form.email'};
920: }
921:
922: my $dom_in_effect;
923: unless ($env{'user.domain'} eq 'public') {
924: $dom_in_effect = $env{'user.domain'};
925: }
926: if ($dom_in_effect eq '') {
927: $dom_in_effect = $requdom;
928: }
929: if ($dom_in_effect eq '') {
930: $dom_in_effect = $defdom;
931: }
932:
933: $displaymsg .= '<span class="LC_helpform_receipt_cat">'.
934: $lt{'date'}.'</span>: '.$reporttime.'<br />'."\n";
935:
936: my $start_page =
937: &Apache::loncommon::start_page('Support request recorded',undef,
938: {'function' => $function,
939: 'add_entries' => {
940: topmargin => "0",
941: marginheight => "0",
942: },
943: 'only_body' => 1,});
944:
945: $r->print(<<"END");
946: $start_page
947: <form name="logproblem" action="">
948: <input type="hidden" name="command" value="result" />
949: </form>
950: END
951: if ($r->uri eq '/adm/helpdesk') {
952: &print_header($r,$url,'process');
953: }
954: my $bad_email = 0;
955: my ($to,$bcc,$addtext) =
956: &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
957: $dom_in_effect,$origmail,
958: $requname,$requdom,
959: $reqemail);
960: if ($to =~ /,/) {
961: my @ok_email;
962: foreach my $email (split(/,/,$to)) {
963: if ($email =~ m/^[^\@]+\@[^\@]+$/) {
964: if (!grep(/^\Q$email\E$/,@ok_email)) {
965: push(@ok_email,$email);
966: }
967: }
968: }
969: if (@ok_email > 0) {
970: $to = join(',',@ok_email);
971: } elsif ($admin =~ m/^[^\@]+\@[^\@]+$/) {
972: $to = $admin;
973: } else {
974: $bad_email = 1;
975: }
976: } elsif ($to !~ m/^[^\@]+\@[^\@]+$/) {
977: if ($admin =~ m/^[^\@]+\@[^\@]+$/) {
978: $to = $admin;
979: } else {
980: $bad_email = 1;
981: }
982: }
983:
984: my $message;
985: if (!$bad_email) {
986: $message = &mt('A support request has been sent to [_1]','<tt>'.$to.'</tt>');
987: } else {
988: $message = $lt{'warn'}.'<br />';
989: if ($to eq '') {
990: $message .= &mt('For this LON-CAPA server no e-mail address has been configured to receive support requests, so your support request has [_1]not[_2] been sent to the LON-CAPA support staff or administrator at your institution.','<b>','</b>');
991: } else {
992: $message .= &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 [_2]not[_3] been sent to the LON-CAPA support staff or administrator at your institution.','<tt>'.$to.'</tt>','<b>','</b>');
993: }
994: }
995: $r->print(&Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($message,$bad_email)));
996:
997: if ($reqemail ne '') {
998: $from = $reqemail;
999: }
1000:
1001: if (defined($env{'form.cc'})) {
1002: if ($badccmsg) {
1003: $displaymsg .= $badccmsg;
1004: }
1005: }
1006:
1007: my $subject = $env{'form.subject'};
1008: $subject =~ s/(`)/'/g;
1009: $subject =~ s/\$/\(\$\)/g;
1010: $supportmsg =~ s/(`)/'/g;
1011: $supportmsg =~ s/\$/\(\$\)/g;
1012: $displaymsg =~ s/(`)/'/g;
1013: $displaymsg =~ s/\$/\(\$\)/g;
1014: my $fname;
1015:
1016: my $attachmentpath = '';
1017: my $showsize = '';
1018:
1019: if ((defined($env{'user.name'})) && (!$public)) {
1020: if ($homeserver && $env{'form.screenshot.filename'}) {
1021: unless ($helpform{'screenshot'} eq 'no') {
1022: my $attachmentsize = length($env{'form.screenshot'});
1023: my $max = 1048576;
1024: my $showmax = 1.00;
1025: if ($helpform{'maxsize'} =~ /^\d+\.\d*$/) {
1026: $max *= $helpform{'maxsize'};
1027: $showmax = $helpform{'maxsize'};
1028: }
1029: $showmax = '('.sprintf("%.2f",$showmax).' MB)';
1030: $showsize = $attachmentsize/1048576;
1031: $showsize = '('.sprintf("%.2f",$showsize).' MB)';
1032: if ($attachmentsize > $max) {
1033: $displaymsg .= '<br /><span class="LC_warning">'.
1034: &mt('The uploaded screenshot file [_1] included with your request exceeded the maximum allowed size [_2], and has therefore been discarded.',$showsize,$showmax).'</span>';
1035: } else {
1036: $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
1037: }
1038: }
1039: }
1040: }
1041:
1042: my %cookies;
1043: my $cookie=CGI::Cookie->parse($r->header_in('Cookie'));
1044: if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) {
1045: $cookies{'lonID'} = $1;
1046: }
1047: if ($$cookie{'lonLinkID'} =~ /lonLinkID=([a-f0-9]+_linked);/) {
1048: $cookies{'lonLinkID'} = $1;
1049: }
1050: if ($attachmentpath =~ m-/([^/]+)$-) {
1051: $fname = $1;
1052: $displaymsg .= '<br />'
1053: .&mt('An uploaded screenshot file [_1] was included in the request sent by [_2].'
1054: ,'<span class="LC_filename">'.$fname.'</span> '.$showsize,
1055: ,$env{'user.name'}.':'.$env{'user.domain'}
1056: );
1057: $supportmsg .= "\n";
1058: foreach my $var (@cookievars) {
1059: $supportmsg .= "$var: $cookies{$var}\n";
1060: }
1061: foreach my $var(@ENVvars) {
1062: $supportmsg .= "$var: $ENV{$var}\n";
1063: }
1064: $supportmsg .= "REMOTE_ADDR: $ip\n";
1065: foreach my $var (@envvars) {
1066: $supportmsg .= "$var: $env{$var}\n";
1067: }
1068: }
1069:
1070: my $cc_string;
1071: if ($homeserver) {
1072: if (@ok_ccs > 0) {
1073: $cc_string = join(', ',@ok_ccs);
1074: }
1075: }
1076:
1077: my $attachment_text = '';
1078: unless ($homeserver && $attachmentpath) {
1079: foreach my $var (@cookievars) {
1080: $attachment_text .= "$var: $cookies{$var}\n";
1081: }
1082: foreach my $var (@ENVvars) {
1083: $attachment_text .= "$var: $ENV{$var}\n";
1084: }
1085: $attachment_text .= "REMOTE_ADDR: $ip\n";
1086: foreach my $var (@envvars) {
1087: $attachment_text .= "$var: $env{$var}\n";
1088: }
1089: foreach my $var (@loncvars) {
1090: $attachment_text .= "$var: $env{$var}\n";
1091: }
1092: }
1093:
1094: if ($addtext) {
1095: my ($addloc,$addstr) = split(/:/,$addtext,2);
1096: $addstr = &unescape($addstr);
1097: if ($addloc eq 's') {
1098: $subject = $addstr.' '.$subject;
1099: } elsif ($addloc eq 'b') {
1100: $supportmsg = $addstr."\n".$supportmsg;
1101: }
1102: }
1103:
1104: unless ($bad_email) {
1105: my $msg = MIME::Lite->new(
1106: From => $from,
1107: To => $to,
1108: Subject => $subject,
1109: Type =>'TEXT',
1110: Data => $supportmsg,
1111: );
1112: if ($homeserver) {
1113: if (@ok_ccs > 0) {
1114: my $cc_string = join(', ',@ok_ccs);
1115: $msg->add("Cc" => $cc_string);
1116: }
1117: }
1118: if ($bcc ne '') {
1119: $msg->add("Bcc" => $bcc);
1120: }
1121: $msg->attr("content-type" => "text/plain");
1122: $msg->attr("content-type.charset" => "UTF-8");
1123:
1124: if ($homeserver && $attachmentpath) {
1125: my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);
1126: $msg->attach(Type => $type,
1127: Path => $attachmentpath,
1128: Filename => $fname
1129: );
1130:
1131: } elsif ($attachment_text ne '') {
1132: $msg->attach(Type => 'TEXT',
1133: Data => $attachment_text);
1134: }
1135:
1136: ### Send it:
1137: $msg->send('sendmail');
1138: }
1139:
1140: if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) {
1141: unlink($attachmentpath);
1142: }
1143: if ($bad_email) {
1144: $r->print('<b>'.$lt{'belo'}.'</b><br />'.
1145: $lt{'ifyk'}.'<br /><br />'."\n");
1146: } else {
1147: $r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n");
1148: }
1149: $r->print('<div style="width:620px;">'.
1150: &Apache::lonhtmlcommon::start_pick_box().
1151: &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n".
1152: &Apache::lonhtmlcommon::row_closure().
1153: &Apache::lonhtmlcommon::row_title($lt{'adin'},undef,'LC_evenrow_value'));
1154: my $envmsg;
1155: foreach my $var (@cookievars) {
1156: if ($cookies{$var} ne '') {
1157: $envmsg.= '<span class="LC_helpform_receipt_cat">'.
1158: $var.'</span>: '.$cookies{$var}.', ';
1159: }
1160: }
1161: foreach my $var (@ENVvars) {
1162: if ($ENV{$var} ne '') {
1163: $envmsg .= '<span class="LC_helpform_receipt_cat">'.
1164: $var.'</span>: '.$ENV{$var}.', ';
1165: }
1166: }
1167: if ($ip ne '') {
1168: $envmsg .= '<span class="LC_helpform_receipt_cat">'.
1169: 'REMOTE_ADDR</span>: '.$ip.', ';
1170: }
1171: foreach my $var (@envvars) {
1172: if ($env{$var} ne '') {
1173: $envmsg .= '<span class="LC_helpform_receipt_cat">'.
1174: $var.'</span>: '.$env{$var}.', ';
1175: }
1176: }
1177: $envmsg =~ s/, $//;
1178: $r->print($envmsg."\n".
1179: &Apache::lonhtmlcommon::row_closure(1)."\n".
1180: &Apache::lonhtmlcommon::end_pick_box().
1181: "</div>\n".
1182: &Apache::loncommon::end_page());
1183: }
1184:
1185: sub print_header {
1186: my ($r,$origurl,$command) = @_;
1187: my $location=&Apache::loncommon::lonhttpdurl("/adm");
1188: my ($component_url);
1189: my $helpdesk_link = '<a href="javascript:validate()">';
1190: if ($command eq 'process') {
1191: $helpdesk_link = '<a href="/adm/helpdesk">';
1192: }
1193: my %lt = &Apache::lonlocal::texthash (
1194: login => 'Log-in help',
1195: ask => 'Ask helpdesk',
1196: getst => 'Getting started guide',
1197: back => 'Back to last location',
1198: headline => 'help/support',
1199: stud => 'Students',
1200: ifyo => 'If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk.',
1201: cont => 'Contact your instructor instead.',
1202: );
1203: my ($getstartlink,$reviewtext);
1204: if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') {
1205: $getstartlink = qq|<td align="center"> <b><a href="/adm/gettingstarted.html">$lt{'getst'}</a></td>|;
1206: $reviewtext = &mt('Please review the information in "Log-in help" and the "Getting started" guide if you are unable to log-in.');
1207: } else {
1208: $reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.');
1209: }
1210: my $linkback;
1211: if ($origurl eq '') {
1212: $linkback = 'javascript:history.go(-1)';
1213: } else {
1214: $linkback = &HTML::Entities::encode($origurl,'"<>&');
1215: }
1216: my $loginhelp = &Apache::lonauth::loginhelpdisplay();
1217: if ($loginhelp eq '') {
1218: $loginhelp = '/adm/loginproblems.html';
1219: }
1220: $r->print(<<"END");
1221: <table width="620" border="0" cellspacing="0" cellpadding="0" style="height: 55px;">
1222: <tr>
1223: <td width="5" height="50"> </td>
1224: <td height="50">
1225: <fieldset>
1226: <legend>
1227: <img src="$location/lonIcons/minilogo.gif" height="20" width="29" alt="logo" style="vertical-align:bottom" />
1228: LON-CAPA $lt{'headline'}
1229: </legend>
1230: <table id="LC_helpmenu_links">
1231: <tr>
1232: <td align="center"><span class="LC_nobreak"><img src="$location/help/help.png" border="0" alt="($lt{'login'})" style="vertical-align:middle" /> <b><a href="$loginhelp">$lt{'login'}</a></b> </span></td>
1233: <td align="center"><span class="LC_nobreak"> <b>$helpdesk_link<img src="$location/lonIcons/helpdesk.gif" border="0" alt="($lt{'ask'})" style="vertical-align:middle" /> $lt{'ask'}</a></b> </span></td>$getstartlink
1234: <td align="center"><span class="LC_nobreak"> <b><a href="$linkback" target="_top"><img src="$location/lonIcons/move_up.gif" border="0" alt="($lt{'back'})" style="vertical-align:middle" /> $lt{'back'}</a></b> </span></td>
1235: </tr>
1236: </table>
1237: </fieldset>
1238: </td>
1239: <td width="5"> </td>
1240: </tr>
1241: <tr>
1242: <td colspan="3" height="5"> </td>
1243: </tr>
1244: END
1245: if ($command ne 'process') {
1246: my $stuwarn = &mt('Do [_1]not[_2] use this form to ask about course content.',
1247: '<b>','</b>');
1248: $r->print(<<"END");
1249: <tr>
1250: <td colspan="3">$reviewtext
1251: $lt{'ifyo'}
1252: <p class="LC_info">
1253: <b>$lt{'stud'}:</b>
1254: $stuwarn $lt{'cont'}
1255: </p><br />
1256: </td>
1257: </tr>
1258: END
1259: }
1260: $r->print('
1261: </table>');
1262: return;
1263: }
1264:
1265: sub get_domain {
1266: my $codedom;
1267: if (exists($env{'form.codedom'})) {
1268: if (&Apache::lonnet::domain($env{'form.codedom'}) ne '') {
1269: return $env{'form.codedom'};
1270: }
1271: }
1272: if ($env{'request.course.id'}) {
1273: $codedom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1274: } elsif ($env{'request.role.domain'}) {
1275: $codedom = $env{'request.role.domain'};
1276: } else {
1277: $codedom = &Apache::lonnet::default_login_domain();
1278: }
1279: return $codedom;
1280: }
1281:
1282: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>