1: # The LearningOnline Network with CAPA
2: # Helpdesk request form
3: #
4: # $Id: lonsupportreq.pm,v 1.94 2019/06/16 05:33:45 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') {
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: }
436: $i = $num%2;
437: $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'urlp'}",undef,$css[$i]).
438: $server."\n".'<input type="hidden" name="sourceurl" value="'.
439: &HTML::Entities::encode($sourceurl,'"<>&').'" />'."\n".
440: &Apache::lonhtmlcommon::row_closure();
441: unless ($helpform{'phone'} eq 'no') {
442: my $reqd;
443: if ($helpform{'phone'} eq 'req') {
444: $reqd = '<span class="LC_info">*</span>';
445: }
446: $output .= &Apache::lonhtmlcommon::row_title($html_lt{'phon'}.$reqd,undef,'LC_evenrow_value').
447: '<input type="text" size="15" name="phone" /><br />'."\n".
448: &Apache::lonhtmlcommon::row_closure();
449: $num ++;
450: $i = $num%2;
451: }
452: unless ($helpform{'course'} eq 'no') {
453: $output .= &Apache::lonhtmlcommon::row_title("$html_lt{'crsd'}$details_title",undef,$css[$i]);
454: if ($totcodes > 0) {
455: my $numtitles = @codetitles;
456: if ($numtitles == 0) {
457: $output .= $html_lt{'enin'}.':
458: <input type="text" name="coursecode" size="15" value="" />'."\n";
459: } else {
460: my @standardnames = &Apache::loncommon::get_standard_codeitems();
461: my $lasttitle = $numtitles;
462: if ($numtitles > 4) {
463: $lasttitle = 4;
464: }
465: my $onchange;
466: if ($sectionlist) {
467: $onchange = 'toggleSecVis()';
468: }
469: $output .= '<table><tr><td>'.$codetitles[0].'<br />'."\n".
470: '<select name="'.$standardnames[0].'" onchange="courseSet('."'$codetitles[0]'".');'.$onchange.'">'."\n".
471: ' <option value="-1">'.$html_lt{'sele'}."</option>\n";
472: my @items = ();
473: my @longitems = ();
474: if ($idlist{$codetitles[0]} =~ /","/) {
475: @items = split(/","/,$idlist{$codetitles[0]});
476: } else {
477: $items[0] = $idlist{$codetitles[0]};
478: }
479: if (defined($idlist_titles{$codetitles[0]})) {
480: if ($idlist_titles{$codetitles[0]} =~ /","/) {
481: @longitems = split(/","/,$idlist_titles{$codetitles[0]});
482: } else {
483: $longitems[0] = $idlist_titles{$codetitles[0]};
484: }
485: for (my $i=0; $i<@longitems; $i++) {
486: if ($longitems[$i] eq '') {
487: $longitems[$i] = $items[$i];
488: }
489: }
490: } else {
491: @longitems = @items;
492: }
493: for (my $i=0; $i<@items; $i++) {
494: $output .= ' <option value="'.$items[$i].'">'.$longitems[$i].'</option>'."\n";
495: }
496: $output .= '</select></td>';
497: for (my $i=1; $i<$numtitles; $i++) {
498: $output .= '<td>'.$codetitles[$i].'<br />'."\n".
499: '<select name="'.$standardnames[$i].'" onchange="courseSet('."'$codetitles[$i]'".');'.$onchange.'">'."\n".
500: '<option value="-1"><-'.$html_lt{'pick'}.' '.$codetitles[$i-1].'</option>'."\n".
501: '</select>'."\n".
502: '</td>'."\n";
503: }
504: $output .= '</tr></table>';
505: if ($numtitles > 4) {
506: $output .= '<br /><br />'.$codetitles[$numtitles].'<br />'."\n".
507: '<select name="'.$standardnames[$numtitles].'" onchange="courseSet('."'$codetitles[$numtitles]'".');'.$onchange.'">'."\n".
508: '<option value="-1"><-'.$html_lt{'pick'}.' '.$codetitles[$numtitles-1].'</option>'."\n".
509: '</select>'."\n";
510: }
511: }
512: } else {
513: $output .= $html_lt{'enin'}.':
514: <input type="text" name="coursecode" size="15" value="" />'."\n";
515: }
516: my $reqd;
517: if ($helpform{'course'} eq 'req') {
518: $reqd = '<span class="LC_info">*</span>';
519: }
520: $output .= '<br />'.$html_lt{'enct'}.$reqd.':
521: <input type="text" name="title" size="25" value="'.
522: &HTML::Entities::encode($ctitle,'"<>&').'" />'."\n";
523: $output .= &Apache::lonhtmlcommon::row_closure();
524: $num ++;
525: $i = $num%2;
526: }
527: unless ($helpform{'section'} eq 'no') {
528: $output .= &Apache::lonhtmlcommon::row_title($html_lt{'secn'},undef,$css[$i]);
529: if ($sectionlist) {
530: $output .= "<div id=\"LC_helpdesk_sectionlist\"><select name=\"sectionsel\">\n".
531: " <option value=\"\" selected=\"selected\">$html_lt{'sele'}</option>\n";
532: foreach my $id (sort(keys(%groupid))) {
533: if ($id eq $groupid{$id} || $groupid{$id} eq '') {
534: $output .= " <option value=".
535: &HTML::Entities::encode($id,'"<>&').
536: " >$id</option>\n";
537: } else {
538: $output .= " <option value=".
539: &HTML::Entities::encode($id,'"<>&').
540: " >$id - ($html_lt{'lsec'}: $groupid{$id})</option>\n";
541: }
542: }
543: $output .= '</select></div>'."\n".
544: '<div id="LC_helpdesk_section" style="display:none">'.
545: '<input type="text" name="sectiontxt" size="10" /></div>'."\n";
546: } else {
547: $output .= '<input type="text" name="section" size="10" />'."\n";
548: }
549: $output .= &Apache::lonhtmlcommon::row_closure();
550: $num ++;
551: $i = $num%2;
552: }
553: $output .= &Apache::lonhtmlcommon::row_title(
554: '<span title="'.&mt('required').'">'.
555: $html_lt{'subj'}.' <span class="LC_info">*</span></span>'
556: ,undef,'LC_oddrow_value').
557: '<input type="text" size="40" name="subject" />'."\n".
558: &Apache::lonhtmlcommon::row_closure().
559: &Apache::lonhtmlcommon::row_title(
560: '<span title="'.&mt('required').'">'.
561: $html_lt{'detd'}.' <span class="LC_info">*</span></span>'
562: ,undef,'LC_evenrow_value').
563: '<textarea rows="10" cols="45" name="description" style="word-wrap:normal;">'.
564: '</textarea>'."\n".
565: &Apache::lonhtmlcommon::row_closure();
566: $num ++;
567: $i = $num%2;
568: if ($knownuser) {
569: if ($homeserver) {
570: unless ($helpform{'screenshot'} eq 'no') {
571: my $max = 1048576;
572: my $showmax = 1.00;
573: if ($helpform{'maxsize'} =~ /^\d+\.\d*$/) {
574: $max *= $helpform{'maxsize'};
575: $showmax = $helpform{'maxsize'};
576: }
577: $showmax = ' ('.sprintf("%.2f",$showmax).' '.&mt('MB max.').')';
578: $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i])
579: .' <input type="file" name="screenshot" class="flUpload" size="20" />'
580: .'<input type="hidden" id="free_space" value="'.$max.'" />'
581: .'<br />'."\n".$html_lt{'uplf'}.$showmax."\n"
582: .&Apache::lonhtmlcommon::row_closure();
583: $num ++;
584: $i = $num%2;
585: }
586: }
587: } else {
588: if ($captcha_form) {
589: $output .= &Apache::lonhtmlcommon::row_title(
590: '<span title="'.&mt('required').'">'.
591: &mt('Validation').
592: ' <span class="LC_info">*</span></span>'
593: ,undef,$css[$i]).
594: $captcha_form."\n".
595: &Apache::lonhtmlcommon::row_closure();
596: $num ++;
597: $i = $num%2;
598: }
599: }
600: $output .= &Apache::lonhtmlcommon::row_title($html_lt{'fini'},undef,$css[$i]);
601: $output .= <<END;
602: <table border="0" cellpadding="8" cellspacing="0">
603: <tr>
604: <td>
605: <input type="hidden" name="command" value="process" />
606: <input type="button" value="$html_lt{'subm'}" onclick="validate()" />
607: </td>
608: <td> </td>
609: <td>
610: <input type="reset" value="$html_lt{'clfm'}" />
611: </td>
612: </tr>
613: </table>
614: END
615: $output .= &Apache::lonhtmlcommon::row_closure(1);
616: $output .= &Apache::lonhtmlcommon::end_pick_box();
617: $r->print(<<END);
618: $output
619: </form>
620: <br />
621: END
622: $r->print(&Apache::loncommon::end_page());
623: return;
624: }
625:
626: sub print_request_receipt {
627: my ($r,$url,$function) = @_;
628: my $public;
629: if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
630: $public = 1;
631: }
632: my $lonhost = $r->dir_config('lonHostID');
633: unless (($env{'user.name'} =~ /^$match_username$/) && (!$public)) {
634: my ($captcha_chk,$captcha_error) =
635: &Apache::loncommon::captcha_response('login',$lonhost);
636: if ($captcha_chk != 1) {
637: $r->print(&Apache::loncommon::start_page('Support request failed',undef,
638: {'function' => $function,
639: 'add_entries' => {
640: topmargin => "0",
641: marginheight => "0",
642: },
643: 'only_body' => 1,}));
644: if ($r->uri eq '/adm/helpdesk') {
645: &print_header($r,$url,'process');
646: }
647: $r->print(
648: '<h2>'.&mt('Support request failed').'</h2>'.
649: &Apache::lonhtmlcommon::confirm_success(
650: &mt('Validation of the code you entered failed.'),1).
651: '<br /><br />'.
652: &Apache::lonhtmlcommon::actionbox([
653: &mt('[_1]Go back[_2] and try again',
654: '<a href="javascript:history.go(-1)">','</a>')]).
655: &Apache::loncommon::end_page());
656: return;
657: }
658: }
659: my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');
660: my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role');
661: my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
662: my @cookievars;
663: if ($ENV{'SERVER_PORT'} == 443) {
664: @cookievars = ('lonLinkID');
665: } else {
666: @cookievars = ('lonID');
667: }
668:
669: my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
670: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
671: my $defdom = &get_domain();
672: my $from = $admin;
673: my %helpform;
674: my %domconfig =
675: &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);
676: if (ref($domconfig{'contacts'}) eq 'HASH') {
677: if (ref($domconfig{'contacts'}{'helpform'}) eq 'HASH') {
678: %helpform = %{$domconfig{'contacts'}{'helpform'}};
679: }
680: }
681: my $reporttime = &Apache::lonlocal::locallocaltime(time);
682: my %formvars = (
683: email => 1,
684: sourceurl => 1,
685: subject => 1,
686: description => 1,
687: );
688: unless ($helpform{'username'} eq 'no') {
689: $formvars{'username'} = 1;
690: }
691: unless ($helpform{'user'} eq 'no') {
692: $formvars{'uname'} = 1;
693: $formvars{'udom'} = 1;
694: }
695: unless ($helpform{'phone'} eq 'no') {
696: $formvars{'phone'} = 1;
697: }
698: unless ($helpform{'section'} eq 'no') {
699: $formvars{'section'} = 1;
700: }
701: unless ($helpform{'course'} eq 'no') {
702: $formvars{'course'} = 1;
703: }
704: unless ($helpform{'cc'} eq 'no') {
705: $formvars{'cc'} = 1;
706: }
707: unless ($helpform{'screenshot'} eq 'no') {
708: $formvars{'screenshot'} = 1;
709: }
710: my $coursecode;
711: if ($formvars{'course'}) {
712: $coursecode = $env{'form.coursecode'};
713: if ($coursecode eq '') {
714: my $totcodes = 0;
715: my %coursecodes;
716: $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$defdom);
717: my @standardnames = &Apache::loncommon::get_standard_codeitems();
718: if ($totcodes > 0) {
719: my $noregexps = 1;
720: $coursecode =
721: &Apache::courseclassifier::instcode_from_selectors($defdom,$noregexps);
722: }
723: if ($coursecode eq '') {
724: foreach my $item (@standardnames) {
725: if ((defined($env{'form.'.$item})) && ($env{'form.'.$item} ne '-1')) {
726: $coursecode .= $env{'form.'.$item};
727: }
728: }
729: }
730: }
731: }
732: my %lt = &Apache::lonlocal::texthash (
733: username => 'Name',
734: email => 'E-mail',
735: cc => 'Cc',
736: user => 'Username/domain',
737: phone => 'Phone',
738: crsi => 'Course Information',
739: subject => 'Subject',
740: description => 'Description',
741: sourceurl => 'URL',
742: date => 'Date/Time',
743: secn => 'Section',
744: warn => 'Warning: Problem with support e-mail address',
745: your => 'Your support request contained the following information',
746: sect => 'section',
747: info => 'Information supplied',
748: adin => 'Additional information recorded',
749: );
750:
751: my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist,$homeserver);
752: unless ($public) {
753: if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
754: $homeserver = &Apache::lonnet::homeserver($env{'user.name'},
755: $env{'user.domain'});
756: }
757: }
758: my ($cid,$cdom,$cnum,$sectionlist,$ccode);
759: if ($homeserver) {
760: $cid = $env{'request.course.id'};
761: }
762: if ($cid) {
763: $cdom = $env{'course.'.$cid.'.domain'};
764: $cnum = $env{'course.'.$cid.'.num'};
765: }
766: if ($cdom && $cnum) {
767: my %csettings = &Apache::lonnet::get('environment',['description','internal.coursecode','internal.sectionnums'],$cdom,$cnum);
768: $ccode = $csettings{'internal.coursecode'};
769: $sectionlist = $csettings{'internal.sectionnums'};
770: }
771: if (($homeserver) && (defined($env{'form.cc'})) && ($formvars{'cc'})) {
772: my @ccs;
773: if ($env{'form.cc'} =~ /,/) {
774: @ccs = split(/,/,$env{'form.cc'});
775: } else {
776: $env{'form.cc'} =~ s/^\s+//;
777: $env{'form.cc'} =~ s/\s+$//;
778: @ccs = $env{'form.cc'};
779: }
780: foreach my $cc (@ccs) {
781: $cc =~ s/^\s+//g;
782: $cc =~ s/\s+$//g;
783: if ($cc =~ m/^[^\@]+\@[^\@]+$/) {
784: if (!(grep(/^\Q$cc\E$/,@ok_ccs))) {
785: push(@ok_ccs,$cc);
786: }
787: } elsif ($cc ne '') {
788: if (!(grep(/^\Q$cc\E$/,@bad_ccs))) {
789: push(@bad_ccs,$cc);
790: }
791: }
792: }
793: if (@ok_ccs > 0) {
794: $okcclist = join(', ',@ok_ccs);
795: }
796: if (@bad_ccs == 1) {
797: if ($bad_ccs[0] ne '') {
798: $badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').&Apache::loncommon::cleanup_html($bad_ccs[0]);
799: }
800: } elsif (@bad_ccs > 1) {
801: $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: '). &Apache::loncommon::cleanup_html(join(', ',@bad_ccs));
802: }
803: }
804: $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";
805: if ($formvars{'course'}) {
806: $env{'form.crsi'} = $env{'form.title'};
807: if ($coursecode ne '') {
808: $env{'form.crsi'} .= ' - '.$coursecode;
809: }
810: }
811: if ($formvars{'section'}) {
812: my $section;
813: if ($sectionlist) {
814: if ($coursecode eq $ccode) {
815: $section = $env{'form.sectionsel'}
816: } else {
817: $section = $env{'form.sectiontxt'};
818: }
819: } else {
820: $section = $env{'form.section'};
821: }
822: $env{'form.crsi'} .= ' - '.$lt{'sect'}.': '.$section;
823: }
824: my $supportmsg;
825: if ($formvars{'username'}) {
826: $supportmsg .= "$lt{'username'}: $env{'form.username'}\n";
827: }
828: $supportmsg .= "$lt{'email'}: $env{'form.email'}\n";
829: if (($homeserver) && (defined($env{'form.cc'})) && ($formvars{'cc'})) {
830: $supportmsg .= "$lt{'cc'}: $okcclist\n";
831: }
832: if ($formvars{'user'}) {
833: $supportmsg .= "$lt{'user'}: $env{'form.user'}\n";
834: }
835: if ($formvars{'phone'}) {
836: $supportmsg .= "$lt{'phone'}: $env{'form.phone'}\n";
837: }
838: if ($formvars{'course'}) {
839: $supportmsg .= "$lt{'crsi'}: $env{'form.crsi'}\n";
840: }
841: $supportmsg .= "$lt{'subject'}: $env{'form.subject'}
842: $lt{'description'}: $env{'form.description'}
843: $lt{'sourceurl'}: $env{'form.sourceurl'}
844: $lt{'date'}: $reporttime
845: ";
846:
847: my $displaymsg;
848: foreach my $item ('username','email','cc','user','phone','crsi','subject','description','sourceurl') {
849: if ($env{'form.'.$item} ne '') {
850: if ($item eq 'description') {
851: my $descrip = $env{'form.description'};
852: $descrip = &Apache::loncommon::cleanup_html($descrip);
853: $descrip =~ s|[\n\r\f]|<br />|g;
854: $displaymsg .=
855: '<span class="LC_helpform_receipt_cat">'.
856: "$lt{$item}</span>: $descrip<br />\n";
857: } elsif ($item eq 'sourceurl') {
858: my $showurl = $env{'form.sourceurl'};
859: $showurl =~ s/\?.*$//;
860: $showurl = &Apache::loncommon::cleanup_html($showurl);
861: $displaymsg .=
862: '<span class="LC_helpform_receipt_cat">'.
863: "$lt{$item}</span>: $showurl<br />\n";
864: } elsif ($item eq 'cc') {
865: next if ($helpform{'cc'} eq 'no');
866: if ($okcclist) {
867: my $showcclist = &Apache::loncommon::cleanup_html($okcclist);
868: $displaymsg .=
869: '<span class="LC_helpform_receipt_cat">'.
870: "$lt{$item}</span>: $showcclist<br />\n";
871: }
872: } else {
873: if (($item eq 'username') || ($item eq 'user') || ($item eq 'phone')) {
874: next if ($helpform{$item} eq 'no');
875: }
876: next if (($item eq 'crsi') && ($helpform{'course'} eq 'no'));
877: my $showitem = $env{'form.'.$item};
878: $showitem = &Apache::loncommon::cleanup_html($showitem);
879: $displaymsg .=
880: '<span class="LC_helpform_receipt_cat">'.
881: "$lt{$item}</span>: $showitem<br />\n";
882: }
883: }
884: }
885:
886: my ($requname,$requdom,$reqemail);
887: foreach my $field ('uname','udom','email') {
888: $env{'form.'.$field} =~ s/^\s+//;
889: $env{'form.'.$field} =~ s/\s+$//;
890: }
891: if ($env{'form.uname'} =~ /^$match_username$/) {
892: $requname = $env{'form.uname'};
893: }
894: if ($env{'form.udom'} =~ /^$match_domain$/) {
895: $requdom = $env{'form.udom'};
896: }
897: if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
898: $reqemail = $env{'form.email'};
899: }
900:
901: my $dom_in_effect;
902: unless ($env{'user.domain'} eq 'public') {
903: $dom_in_effect = $env{'user.domain'};
904: }
905: if ($dom_in_effect eq '') {
906: $dom_in_effect = $requdom;
907: }
908: if ($dom_in_effect eq '') {
909: $dom_in_effect = $defdom;
910: }
911:
912: $displaymsg .= '<span class="LC_helpform_receipt_cat">'.
913: $lt{'date'}.'</span>: '.$reporttime.'<br />'."\n";
914:
915: my $start_page =
916: &Apache::loncommon::start_page('Support request recorded',undef,
917: {'function' => $function,
918: 'add_entries' => {
919: topmargin => "0",
920: marginheight => "0",
921: },
922: 'only_body' => 1,});
923:
924: $r->print(<<"END");
925: $start_page
926: <form name="logproblem" action="">
927: <input type="hidden" name="command" value="result" />
928: </form>
929: END
930: if ($r->uri eq '/adm/helpdesk') {
931: &print_header($r,$url,'process');
932: }
933: my $bad_email = 0;
934: my ($to,$bcc,$addtext) =
935: &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
936: $dom_in_effect,$origmail,
937: $requname,$requdom,
938: $reqemail);
939: if ($to =~ /,/) {
940: my @ok_email;
941: foreach my $email (split(/,/,$to)) {
942: if ($email =~ m/^[^\@]+\@[^\@]+$/) {
943: if (!grep(/^\Q$email\E$/,@ok_email)) {
944: push(@ok_email,$email);
945: }
946: }
947: }
948: if (@ok_email > 0) {
949: $to = join(',',@ok_email);
950: } elsif ($admin =~ m/^[^\@]+\@[^\@]+$/) {
951: $to = $admin;
952: } else {
953: $bad_email = 1;
954: }
955: } elsif ($to !~ m/^[^\@]+\@[^\@]+$/) {
956: if ($admin =~ m/^[^\@]+\@[^\@]+$/) {
957: $to = $admin;
958: } else {
959: $bad_email = 1;
960: }
961: }
962:
963: my $message;
964: if (!$bad_email) {
965: $message = &Apache::lonhtmlcommon::confirm_success(
966: &mt('A support request has been sent to [_1]','<tt>'.$to.'</tt>'));
967: } else {
968: $message = &Apache::lonhtmlcommon::confirm_success(
969: $lt{'warn'}.'<br />'
970: .&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>')
971: .' '.&mt('Instead a copy has been sent to the LON-CAPA support team at Michigan State University.'),1);
972: $to = 'helpdesk@lon-capa.org';
973: }
974: $r->print(&Apache::loncommon::confirmwrapper($message));
975:
976: if ($reqemail ne '') {
977: $from = $reqemail;
978: }
979:
980: if (defined($env{'form.cc'})) {
981: if ($badccmsg) {
982: $displaymsg .= $badccmsg;
983: }
984: }
985:
986: my $subject = $env{'form.subject'};
987: $subject =~ s/(`)/'/g;
988: $subject =~ s/\$/\(\$\)/g;
989: $supportmsg =~ s/(`)/'/g;
990: $supportmsg =~ s/\$/\(\$\)/g;
991: $displaymsg =~ s/(`)/'/g;
992: $displaymsg =~ s/\$/\(\$\)/g;
993: my $fname;
994:
995: my $attachmentpath = '';
996: my $showsize = '';
997:
998: if ((defined($env{'user.name'})) && (!$public)) {
999: if ($homeserver && $env{'form.screenshot.filename'}) {
1000: unless ($helpform{'screenshot'} eq 'no') {
1001: my $attachmentsize = length($env{'form.screenshot'});
1002: my $max = 1048576;
1003: my $showmax = 1.00;
1004: if ($helpform{'maxsize'} =~ /^\d+\.\d*$/) {
1005: $max *= $helpform{'maxsize'};
1006: $showmax = $helpform{'maxsize'};
1007: }
1008: $showmax = '('.sprintf("%.2f",$showmax).' MB)';
1009: $showsize = $attachmentsize/1048576;
1010: $showsize = '('.sprintf("%.2f",$showsize).' MB)';
1011: if ($attachmentsize > $max) {
1012: $displaymsg .= '<br /><span class="LC_warning">'.
1013: &mt('The uploaded screenshot file [_1] included with your request exceeded the maximum allowed size [_2], and has therefore been discarded.',$showsize,$showmax).'</span>';
1014: } else {
1015: $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
1016: }
1017: }
1018: }
1019: }
1020:
1021: my %cookies;
1022: my $cookie=CGI::Cookie->parse($r->header_in('Cookie'));
1023: if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) {
1024: $cookies{'lonID'} = $1;
1025: }
1026: if ($$cookie{'lonLinkID'} =~ /lonLinkID=([a-f0-9]+_linked);/) {
1027: $cookies{'lonLinkID'} = $1;
1028: }
1029: if ($attachmentpath =~ m-/([^/]+)$-) {
1030: $fname = $1;
1031: $displaymsg .= '<br />'
1032: .&mt('An uploaded screenshot file [_1] was included in the request sent by [_2].'
1033: ,'<span class="LC_filename">'.$fname.'</span> '.$showsize,
1034: ,$env{'user.name'}.':'.$env{'user.domain'}
1035: );
1036: $supportmsg .= "\n";
1037: foreach my $var (@cookievars) {
1038: $supportmsg .= "$var: $cookies{$var}\n";
1039: }
1040: foreach my $var(@ENVvars) {
1041: $supportmsg .= "$var: $ENV{$var}\n";
1042: }
1043: foreach my $var (@envvars) {
1044: $supportmsg .= "$var: $env{$var}\n";
1045: }
1046: }
1047:
1048: my $cc_string;
1049: if ($homeserver) {
1050: if (@ok_ccs > 0) {
1051: $cc_string = join(', ',@ok_ccs);
1052: }
1053: }
1054:
1055: my $attachment_text = '';
1056: unless ($homeserver && $attachmentpath) {
1057: foreach my $var (@cookievars) {
1058: $attachment_text .= "$var: $cookies{$var}\n";
1059: }
1060: foreach my $var (@ENVvars) {
1061: $attachment_text .= "$var: $ENV{$var}\n";
1062: }
1063: foreach my $var (@envvars) {
1064: $attachment_text .= "$var: $env{$var}\n";
1065: }
1066: foreach my $var (@loncvars) {
1067: $attachment_text .= "$var: $env{$var}\n";
1068: }
1069: }
1070:
1071: if ($addtext) {
1072: my ($addloc,$addstr) = split(/:/,$addtext,2);
1073: $addstr = &unescape($addstr);
1074: if ($addloc eq 's') {
1075: $subject = $addstr.' '.$subject;
1076: } elsif ($addloc eq 'b') {
1077: $supportmsg = $addstr."\n".$supportmsg;
1078: }
1079: }
1080:
1081: # Compose and send a MIME email
1082: &Apache::loncommon::mime_email($from, $to, $subject, $supportmsg, $cc_string, $bcc,
1083: $attachmentpath, $fname, $attachment_text);
1084:
1085: if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) {
1086: unlink($attachmentpath);
1087: }
1088: $r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n");
1089: $r->print('<div style="width:620px;">'.
1090: &Apache::lonhtmlcommon::start_pick_box().
1091: &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n".
1092: &Apache::lonhtmlcommon::row_closure().
1093: &Apache::lonhtmlcommon::row_title($lt{'adin'},undef,'LC_evenrow_value'));
1094: my $envmsg;
1095: foreach my $var (@cookievars) {
1096: if ($cookies{$var} ne '') {
1097: $envmsg.= '<span class="LC_helpform_receipt_cat">'.
1098: $var.'</span>: '.$cookies{$var}.', ';
1099: }
1100: }
1101: foreach my $var (@ENVvars) {
1102: if ($ENV{$var} ne '') {
1103: $envmsg .= '<span class="LC_helpform_receipt_cat">'.
1104: $var.'</span>: '.$ENV{$var}.', ';
1105: }
1106: }
1107: foreach my $var (@envvars) {
1108: if ($env{$var} ne '') {
1109: $envmsg .= '<span class="LC_helpform_receipt_cat">'.
1110: $var.'</span>: '.$env{$var}.', ';
1111: }
1112: }
1113: $envmsg =~ s/, $//;
1114: $r->print($envmsg."\n".
1115: &Apache::lonhtmlcommon::row_closure(1)."\n".
1116: &Apache::lonhtmlcommon::end_pick_box().
1117: "</div>\n".
1118: &Apache::loncommon::end_page());
1119: }
1120:
1121: sub print_header {
1122: my ($r,$origurl,$command) = @_;
1123: my $location=&Apache::loncommon::lonhttpdurl("/adm");
1124: my ($component_url);
1125: my $helpdesk_link = '<a href="javascript:validate()">';
1126: if ($command eq 'process') {
1127: $helpdesk_link = '<a href="/adm/helpdesk">';
1128: }
1129: my %lt = &Apache::lonlocal::texthash (
1130: login => 'Log-in help',
1131: ask => 'Ask helpdesk',
1132: getst => 'Getting started guide',
1133: back => 'Back to last location',
1134: headline => 'help/support',
1135: stud => 'Students',
1136: ifyo => 'If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk.',
1137: cont => 'Contact your instructor instead.',
1138: );
1139: my ($getstartlink,$reviewtext);
1140: if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') {
1141: $getstartlink = qq|<td align="center"> <b><a href="/adm/gettingstarted.html">$lt{'getst'}</a></td>|;
1142: $reviewtext = &mt('Please review the information in "Log-in help" and the "Getting started" guide if you are unable to log-in.');
1143: } else {
1144: $reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.');
1145: }
1146: my $linkback;
1147: if ($origurl eq '') {
1148: $linkback = 'javascript:history.go(-1)';
1149: } else {
1150: $linkback = &HTML::Entities::encode($origurl,'"<>&');
1151: }
1152: my $loginhelp = &Apache::lonauth::loginhelpdisplay();
1153: if ($loginhelp eq '') {
1154: $loginhelp = '/adm/loginproblems.html';
1155: }
1156: $r->print(<<"END");
1157: <table width="620" border="0" cellspacing="0" cellpadding="0" style="height: 55px;">
1158: <tr>
1159: <td width="5" height="50"> </td>
1160: <td height="50">
1161: <fieldset>
1162: <legend>
1163: <img src="$location/lonIcons/minilogo.gif" height="20" width="29" alt="logo" style="vertical-align:bottom" />
1164: LON-CAPA $lt{'headline'}
1165: </legend>
1166: <table id="LC_helpmenu_links">
1167: <tr>
1168: <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>
1169: <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
1170: <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>
1171: </tr>
1172: </table>
1173: </fieldset>
1174: </td>
1175: <td width="5"> </td>
1176: </tr>
1177: <tr>
1178: <td colspan="3" height="5"> </td>
1179: </tr>
1180: END
1181: if ($command ne 'process') {
1182: my $stuwarn = &mt('Do [_1]not[_2] use this form to ask about course content.',
1183: '<b>','</b>');
1184: $r->print(<<"END");
1185: <tr>
1186: <td colspan="3">$reviewtext
1187: $lt{'ifyo'}
1188: <p class="LC_info">
1189: <b>$lt{'stud'}:</b>
1190: $stuwarn $lt{'cont'}
1191: </p><br />
1192: </td>
1193: </tr>
1194: END
1195: }
1196: $r->print('
1197: </table>');
1198: return;
1199: }
1200:
1201: sub get_domain {
1202: my $codedom;
1203: if (exists($env{'form.codedom'})) {
1204: if (&Apache::lonnet::domain($env{'form.codedom'}) ne '') {
1205: return $env{'form.codedom'};
1206: }
1207: }
1208: if ($env{'request.course.id'}) {
1209: $codedom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1210: } elsif ($env{'request.role.domain'}) {
1211: $codedom = $env{'request.role.domain'};
1212: } else {
1213: $codedom = &Apache::lonnet::default_login_domain();
1214: }
1215: return $codedom;
1216: }
1217:
1218: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>