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