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