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