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