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