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