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