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