Annotation of loncom/interface/lonsupportreq.pm, revision 1.68
1.24 albertel 1: #
1.68 ! raeburn 2: # $Id: lonsupportreq.pm,v 1.67 2012/04/18 17:30:24 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.5 raeburn 491: }
1.50 raeburn 492: $output .= &Apache::lonhtmlcommon::row_title($lt{'fini'},undef,$css[$i]);
1.44 raeburn 493: $output .= <<END;
1.1 raeburn 494: <table border="0" cellpadding="8" cellspacing="0">
495: <tr>
496: <td>
1.44 raeburn 497: <input type="hidden" name="command" value="process" />
498: <input type="button" value="$lt{'subm'}" onclick="validate()" />
1.1 raeburn 499: </td>
500: <td> </td>
501: <td>
1.44 raeburn 502: <input type="reset" value="$lt{'clfm'}" />
1.1 raeburn 503: </td>
504: </tr>
505: </table>
1.44 raeburn 506: END
507: $output .= &Apache::lonhtmlcommon::row_closure(1);
508: $output .= &Apache::lonhtmlcommon::end_pick_box();
509: $r->print(<<END);
510: $output
1.14 raeburn 511: </form>
1.44 raeburn 512: <br />
1.1 raeburn 513: END
1.30 albertel 514: $r->print(&Apache::loncommon::end_page());
1.5 raeburn 515: return;
1.1 raeburn 516: }
517:
518: sub print_request_receipt {
519: my ($r,$url,$function) = @_;
1.26 raeburn 520: my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME');
521: my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role');
1.5 raeburn 522: my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id');
1.27 raeburn 523: my @cookievars = ('lonID');
1.5 raeburn 524:
525: my $admin = $Apache::lonnet::perlvar{'lonAdminMail'};
1.45 raeburn 526: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
527: my $defdom = &get_domain();
528: my $to = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
529: $defdom,$origmail);
1.5 raeburn 530: my $from = $admin;
1.56 raeburn 531: my $bcc;
532: my %domconfig =
533: &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);
534: if (ref($domconfig{'contacts'}) eq 'HASH') {
535: if (exists($domconfig{'contacts'}{'helpdeskmail'})) {
536: if (ref($domconfig{'contacts'}{'helpdeskmail'}) eq 'HASH') {
537: my $bccmail = $domconfig{'contacts'}{'helpdeskmail'}{'bcc'};
538: if ($bccmail ne '') {
539: my @bccs = split(/,/,$bccmail);
540: my @ok_bccs;
541: foreach my $bcc (@bccs) {
542: $bcc =~ s/^\s+//g;
543: $bcc =~ s/\s+$//g;
544: if ($bcc =~ m/^[^\@]+\@[^\@]+$/) {
545: if (!(grep(/^\Q$bcc\E$/,@ok_bccs))) {
546: push(@ok_bccs,$bcc);
547: }
548: }
549: }
550: if (@ok_bccs > 0) {
551: $bcc = join(', ',@ok_bccs);
552: }
553: }
554: }
555: }
556: }
1.1 raeburn 557: my $reporttime = &Apache::lonlocal::locallocaltime(time);
1.14 raeburn 558: my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot');
1.20 raeburn 559:
1.1 raeburn 560: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars);
1.25 albertel 561: my $coursecode = $env{'form.coursecode'};
1.19 raeburn 562: if ($coursecode eq '') {
1.57 raeburn 563: my $totcodes = 0;
564: my %coursecodes;
565: $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$defdom,$totcodes);
566: my @standardnames = &Apache::loncommon::get_standard_codeitems();
567: if ($totcodes > 0) {
1.64 raeburn 568: my $noregexps = 1;
569: $coursecode =
570: &Apache::courseclassifier::instcode_from_selectors($defdom,$noregexps);
1.57 raeburn 571: }
572: if ($coursecode eq '') {
573: foreach my $item (@standardnames) {
574: if ((defined($env{'form.'.$item})) && ($env{'form.'.$item} ne '-1')) {
575: $coursecode .= $env{'form.'.$item};
576: }
577: }
1.19 raeburn 578: }
579: }
1.40 raeburn 580: my %lt = &Apache::lonlocal::texthash (
1.44 raeburn 581: username => 'Name',
1.52 schafran 582: email => 'E-mail',
1.46 raeburn 583: cc => 'Cc',
1.44 raeburn 584: user => 'Username/domain',
585: phone => 'Phone',
586: crsi => 'Course Information',
587: subject => 'Subject',
588: description => 'Description',
589: sourceurl => 'URL',
590: date => 'Date/Time',
591: secn => 'Section',
592: warn => 'Warning: Problem with support e-mail address',
593: your => 'Your support request contained the following information',
594: sect => 'section',
595: info => 'Information supplied',
596: adin => 'Additional information recorded',
1.40 raeburn 597: );
1.46 raeburn 598:
1.67 raeburn 599: my (@ok_ccs,@bad_ccs,$badccmsg,$okcclist,$public,$homeserver);
600: if (($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) {
601: $public = 1;
602: } else {
603: if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) {
604: $homeserver = &Apache::lonnet::homeserver($env{'user.name'},
605: $env{'user.domain'});
606: }
607: }
608:
609: if (($homeserver) && (defined($env{'form.cc'}))) {
1.46 raeburn 610: my @ccs;
611: if ($env{'form.cc'} =~ /,/) {
612: @ccs = split(/,/,$env{'form.cc'});
613: } else {
614: $env{'form.cc'} =~ s/^\s+//;
615: $env{'form.cc'} =~ s/\s+$//;
616: @ccs = $env{'form.cc'};
617: }
618: foreach my $cc (@ccs) {
619: $cc =~ s/^\s+//g;
620: $cc =~ s/\s+$//g;
621: if ($cc =~ m/^[^\@]+\@[^\@]+$/) {
622: if (!(grep(/^\Q$cc\E$/,@ok_ccs))) {
623: push(@ok_ccs,$cc);
624: }
1.57 raeburn 625: } elsif ($cc ne '') {
1.46 raeburn 626: if (!(grep(/^\Q$cc\E$/,@bad_ccs))) {
627: push(@bad_ccs,$cc);
628: }
629: }
630: }
631: if (@ok_ccs > 0) {
632: $okcclist = join(', ',@ok_ccs);
633: }
634: if (@bad_ccs == 1) {
635: $badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').$bad_ccs[0];
636: } elsif (@bad_ccs > 1) {
637: my $bad_cc_string = join(', ',@bad_ccs);
638: $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: ').$bad_cc_string;
639: }
640: }
1.44 raeburn 641: $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";
1.57 raeburn 642: $env{'form.crsi'} = $env{'form.title'}.' - '.$coursecode.' - '.$lt{'sect'}.': '.$env{'form.section'};
1.44 raeburn 643: my $supportmsg = <<END;
644: $lt{'username'}: $env{'form.username'}
1.40 raeburn 645: $lt{'email'}: $env{'form.email'}
1.46 raeburn 646: $lt{'cc'}: $okcclist
1.44 raeburn 647: $lt{'user'}: $env{'form.user'}
648: $lt{'phone'}: $env{'form.phone'}
1.57 raeburn 649: $lt{'crsi'}: $env{'form.crsi'}
1.44 raeburn 650: $lt{'subject'}: $env{'form.subject'}
651: $lt{'description'}: $env{'form.description'}
652: $lt{'sourceurl'}: $env{'form.sourceurl'}
1.40 raeburn 653: $lt{'date'}: $reporttime
1.1 raeburn 654:
1.44 raeburn 655: END
656: my $displaymsg;
1.46 raeburn 657: foreach my $item ('username','email','cc','user','phone','crsi','subject','description','sourceurl') {
1.44 raeburn 658: if ($env{'form.'.$item} ne '') {
659: if ($item eq 'description') {
660: my $descrip = $env{'form.description'};
1.54 raeburn 661: $descrip = &cleanup_html($descrip);
662: $descrip =~ s|[\n\r\f]|<br />|g;
1.44 raeburn 663: $displaymsg .=
664: '<span class="LC_helpform_receipt_cat">'.
665: "$lt{$item}</span>: $descrip<br />\n";
666: } elsif ($item eq 'sourceurl') {
667: my $showurl = $env{'form.sourceurl'};
668: $showurl =~ s/\?.*$//;
1.54 raeburn 669: $showurl = &cleanup_html($showurl);
1.44 raeburn 670: $displaymsg .=
671: '<span class="LC_helpform_receipt_cat">'.
672: "$lt{$item}</span>: $showurl<br />\n";
1.46 raeburn 673: } elsif ($item eq 'cc') {
674: $displaymsg .=
675: '<span class="LC_helpform_receipt_cat">'.
676: "$lt{$item}</span>: $okcclist<br />\n";
1.44 raeburn 677: } else {
1.54 raeburn 678: my $showitem = $env{'form.'.$item};
679: $showitem = &cleanup_html($showitem);
1.44 raeburn 680: $displaymsg .=
681: '<span class="LC_helpform_receipt_cat">'.
1.54 raeburn 682: "$lt{$item}</span>: $showitem<br />\n";
1.44 raeburn 683: }
684: }
685: }
686: $displaymsg .= '<span class="LC_helpform_receipt_cat">'.
687: $lt{'date'}.'</span>: '.$reporttime.'<br />'."\n";
1.32 albertel 688:
689: my $start_page =
690: &Apache::loncommon::start_page('Support request recorded',undef,
1.33 albertel 691: {'function' => $function,
692: 'add_entries' => {
693: topmargin => "0",
694: marginheight => "0",
695: },
696: 'only_body' => 1,});
1.32 albertel 697:
1.14 raeburn 698: $r->print(<<"END");
1.32 albertel 699: $start_page
1.16 raeburn 700: <form name="logproblem">
1.44 raeburn 701: <input type="hidden" name="command" value="result" />
1.16 raeburn 702: </form>
1.1 raeburn 703: END
1.14 raeburn 704: if ($r->uri eq '/adm/helpdesk') {
705: &print_header($r,$url,'process');
706: }
1.45 raeburn 707: my $bad_email = 0;
708: if ($to =~ /,/) {
709: my @ok_email;
710: foreach my $email (split(/,/,$to)) {
711: if ($email =~ m/^[^\@]+\@[^\@]+$/) {
1.46 raeburn 712: if (!grep(/^\Q$email\E$/,@ok_email)) {
713: push(@ok_email,$email);
714: }
1.45 raeburn 715: }
716: }
717: if (@ok_email > 0) {
718: $to = join(',',@ok_email);
719: } elsif ($admin =~ m/^[^\@]+\@[^\@]+$/) {
720: $to = $admin;
721: } else {
722: $bad_email = 1;
723: }
724: } elsif ($to !~ m/^[^\@]+\@[^\@]+$/) {
725: if ($admin =~ m/^[^\@]+\@[^\@]+$/) {
726: $to = $admin;
1.9 raeburn 727: } else {
1.45 raeburn 728: $bad_email = 1;
729: }
730: }
1.66 bisitz 731:
732: my $message;
733: if (!$bad_email) {
734: $message = &Apache::lonhtmlcommon::confirm_success(
735: &mt('A support request has been sent to [_1]','<tt>'.$to.'</tt>'));
736: } else {
737: $message = &Apache::lonhtmlcommon::confirm_success(
738: $lt{'warn'}.'<br />'
739: .&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>')
740: .' '.&mt('Instead a copy has been sent to the LON-CAPA support team at Michigan State University.'),1);
741: $to = 'helpdesk@lon-capa.org';
1.1 raeburn 742: }
1.66 bisitz 743: $r->print(&Apache::loncommon::confirmwrapper($message));
744:
1.25 albertel 745: if (defined($env{'form.email'})) {
1.46 raeburn 746: $env{'form.email'} =~ s/^\s+//;
747: $env{'form.email'} =~ s/\s+$//;
1.25 albertel 748: if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) {
749: $from = $env{'form.email'};
1.5 raeburn 750: }
751: }
752:
1.46 raeburn 753: if (defined($env{'form.cc'})) {
754: if ($badccmsg) {
755: $displaymsg .= $badccmsg;
756: }
757: }
758:
1.25 albertel 759: my $subject = $env{'form.subject'};
1.44 raeburn 760: $subject =~ s/(`)/'/g;
761: $subject =~ s/\$/\(\$\)/g;
762: $supportmsg =~ s/(`)/'/g;
763: $supportmsg =~ s/\$/\(\$\)/g;
764: $displaymsg =~ s/(`)/'/g;
765: $displaymsg =~ s/\$/\(\$\)/g;
1.5 raeburn 766: my $fname;
767:
768: my $attachmentpath = '';
769: my $attachmentsize = '';
1.56 raeburn 770: if ((defined($env{'user.name'})) && ($env{'user.name'} ne 'public')
771: && ($env{'user.domain'} ne 'public')) {
1.67 raeburn 772: if ($homeserver && $env{'form.screenshot.filename'}) {
1.25 albertel 773: $attachmentsize = length($env{'form.screenshot'});
1.5 raeburn 774: if ($attachmentsize > 131072) {
1.40 raeburn 775: $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 776: } else {
777: $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests');
778: }
779: }
780: }
781:
1.40 raeburn 782: my %cookies;
1.27 raeburn 783: my $cookie=CGI::Cookie->parse($r->header_in('Cookie'));
1.39 albertel 784: if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) {
1.27 raeburn 785: $cookies{'lonID'} = $1;
786: }
787:
1.5 raeburn 788: if ($attachmentpath =~ m-/([^/]+)$-) {
789: $fname = $1;
1.51 bisitz 790: $displaymsg .= '<br />'
791: .&mt('An uploaded screenshot file [_1] ([_2] bytes) was included in the request sent by [_3].'
1.66 bisitz 792: ,'<span class="LC_filename">'.$fname.'</span>'
1.51 bisitz 793: ,$attachmentsize
794: ,$env{'user.name'}.':'.$env{'user.domain'}
795: );
1.5 raeburn 796: $supportmsg .= "\n";
1.40 raeburn 797: foreach my $var (@cookievars) {
798: $supportmsg .= "$var: $cookies{$var}\n";
1.27 raeburn 799: }
1.40 raeburn 800: foreach my $var(@ENVvars) {
801: $supportmsg .= "$var: $ENV{$var}\n";
1.26 raeburn 802: }
1.40 raeburn 803: foreach my $var (@envvars) {
804: $supportmsg .= "$var: $env{$var}\n";
1.5 raeburn 805: }
806: }
807:
808: my $msg = MIME::Lite->new(
809: From => $from,
810: To => $to,
811: Subject => $subject,
812: Type =>'TEXT',
813: Data => $supportmsg,
814: );
1.67 raeburn 815: if ($homeserver) {
816: if (@ok_ccs > 0) {
817: my $cc_string = join(', ',@ok_ccs);
818: $msg->add("Cc" => $cc_string);
819: }
1.46 raeburn 820: }
1.56 raeburn 821: if ($bcc ne '') {
822: $msg->add("Bcc" => $bcc);
823: }
1.65 raeburn 824: $msg->attr("content-type" => "text/plain");
825: $msg->attr("content-type.charset" => "UTF-8");
1.5 raeburn 826:
1.67 raeburn 827: if ($homeserver && $attachmentpath) {
1.5 raeburn 828: my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath);
829: $msg->attach(Type => $type,
830: Path => $attachmentpath,
831: Filename => $fname
832: );
833:
834: } else {
835: my $envdata = '';
1.40 raeburn 836: foreach my $var (@cookievars) {
837: $envdata .= "$var: $cookies{$var}\n";
1.27 raeburn 838: }
1.40 raeburn 839: foreach my $var (@ENVvars) {
840: $envdata .= "$var: $ENV{$var}\n";
1.26 raeburn 841: }
1.40 raeburn 842: foreach my $var (@envvars) {
843: $envdata .= "$var: $env{$var}\n";
1.5 raeburn 844: }
1.40 raeburn 845: foreach my $var (@loncvars) {
846: $envdata .= "$var: $env{$var}\n";
1.5 raeburn 847: }
848: $msg->attach(Type => 'TEXT',
849: Data => $envdata);
850: }
851:
852: ### Send it:
853: $msg->send('sendmail');
854:
1.44 raeburn 855: if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) {
1.5 raeburn 856: unlink($attachmentpath);
857: }
1.44 raeburn 858: $r->print('<b>'.$lt{'your'}.'</b>:<br /><br />'."\n");
1.55 bisitz 859: $r->print('<div style="width:620px;">'.
860: &Apache::lonhtmlcommon::start_pick_box().
1.44 raeburn 861: &Apache::lonhtmlcommon::row_title($lt{'info'},undef,'LC_oddrow_value')."\n".$displaymsg."\n".
862: &Apache::lonhtmlcommon::row_closure().
863: &Apache::lonhtmlcommon::row_title($lt{'adin'},undef,'LC_evenrow_value'));
864: my $envmsg;
1.40 raeburn 865: foreach my $var (@cookievars) {
1.44 raeburn 866: if ($cookies{$var} ne '') {
867: $envmsg.= '<span class="LC_helpform_receipt_cat">'.
868: $var.'</span>: '.$cookies{$var}.', ';
1.27 raeburn 869: }
870: }
1.40 raeburn 871: foreach my $var (@ENVvars) {
1.44 raeburn 872: if ($ENV{$var} ne '') {
873: $envmsg .= '<span class="LC_helpform_receipt_cat">'.
874: $var.'</span>: '.$ENV{$var}.', ';
1.26 raeburn 875: }
876: }
1.40 raeburn 877: foreach my $var (@envvars) {
1.44 raeburn 878: if ($env{$var} ne '') {
879: $envmsg .= '<span class="LC_helpform_receipt_cat">'.
880: $var.'</span>: '.$env{$var}.', ';
1.5 raeburn 881: }
1.1 raeburn 882: }
1.44 raeburn 883: $envmsg =~ s/, $//;
884: $r->print($envmsg."\n".
885: &Apache::lonhtmlcommon::row_closure(1)."\n".
1.55 bisitz 886: &Apache::lonhtmlcommon::end_pick_box().
887: "</div>\n".
1.44 raeburn 888: &Apache::loncommon::end_page());
1.1 raeburn 889: }
890:
1.14 raeburn 891: sub print_header {
1.44 raeburn 892: my ($r,$origurl,$command) = @_;
1.14 raeburn 893: my $location=&Apache::loncommon::lonhttpdurl("/adm");
894: my ($component_url);
895: my $helpdesk_link = '<a href="javascript:validate()">';
1.44 raeburn 896: if ($command eq 'process') {
1.14 raeburn 897: $helpdesk_link = '<a href="/adm/helpdesk">';
898: }
899: my %lt = &Apache::lonlocal::texthash (
1.67 raeburn 900: login => 'Log-in help',
901: ask => 'Ask helpdesk',
902: getst => 'Getting started guide',
903: back => 'Back to last location',
1.47 bisitz 904: headline => 'help/support',
1.67 raeburn 905: stud => 'Students',
906: ifyo => 'If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk.',
907: cont => 'Contact your instructor instead.',
1.21 raeburn 908: );
1.47 bisitz 909: my ($getstartlink,$reviewtext);
1.21 raeburn 910: if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') {
911: $getstartlink = qq|<td align="center"> <b><a href="/adm/gettingstarted.html">$lt{'getst'}</a></td>|;
1.47 bisitz 912: $reviewtext = &mt('Please review the information in "Log-in help" and the "Getting started" guide if you are unable to log-in.');
913: } else {
914: $reviewtext = &mt('Please review the information in "Log-in help" if you are unable to log-in.');
1.21 raeburn 915: }
1.59 raeburn 916: if ($origurl eq '') {
917: $origurl = 'javascript:history.go(-1)';
918: }
1.68 ! raeburn 919: my $loginhelp = &Apache::lonauth::loginhelpdisplay();
! 920: if ($loginhelp eq '') {
! 921: $loginhelp = '/adm/loginproblems.html';
! 922: }
1.67 raeburn 923: $r->print(<<"END");
924: <table width="620" border="0" cellspacing="0" cellpadding="0" style="height: 55px;">
925: <tr>
926: <td width="5" height="50"> </td>
927: <td height="50">
1.53 bisitz 928: <fieldset>
929: <legend>
1.67 raeburn 930: <img src="$location/lonIcons/minilogo.gif" height="20" width="29" alt="logo" style="vertical-align:bottom" />
1.53 bisitz 931: LON-CAPA $lt{'headline'}
932: </legend>
1.44 raeburn 933: <table id="LC_helpmenu_links">
934: <tr>
1.68 ! raeburn 935: <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 936: <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
937: <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 938: </tr>
1.14 raeburn 939: </table>
940: </fieldset>
941: </td>
1.67 raeburn 942: <td width="5"> </td>
1.14 raeburn 943: </tr>
1.67 raeburn 944: <tr>
945: <td colspan="3" height="5"> </td>
1.14 raeburn 946: </tr>
947: END
1.44 raeburn 948: if ($command ne 'process') {
1.67 raeburn 949: my $stuwarn = &mt('Do [_1]not[_2] use this form to ask about course content.',
950: '<b>','</b>');
951: $r->print(<<"END");
1.14 raeburn 952: <tr>
1.67 raeburn 953: <td colspan="3">$reviewtext
954: $lt{'ifyo'}<br />
955: <span style="font-size:90%;"><b>$lt{'stud'}</b>:
956: $stuwarn $lt{'cont'}</span>
957: <br /><br />
1.14 raeburn 958: </td>
1.67 raeburn 959: </tr>
960: END
1.14 raeburn 961: }
962: $r->print('
963: </table>');
964: return;
965: }
966:
1.45 raeburn 967: sub get_domain {
968: my $codedom;
969: if (exists($env{'form.codedom'})) {
970: $codedom = $env{'form.codedom'};
971: } elsif ($env{'request.course.id'}) {
972: $codedom = $env{'course.'.$env{'request.course.id'}.'.domain'};
973: } elsif ($env{'request.role.domain'}) {
974: $codedom = $env{'request.role.domain'};
975: } else {
1.54 raeburn 976: $codedom = &Apache::lonnet::default_login_domain();
1.45 raeburn 977: }
978: return $codedom;
979: }
980:
1.54 raeburn 981: sub cleanup_html {
982: my ($incoming) = @_;
983: my $outgoing;
984: if ($incoming ne '') {
985: $outgoing = $incoming;
986: $outgoing =~ s/\#/#/g;
987: $outgoing =~ s/\&/&/g;
988: $outgoing =~ s/</</g;
989: $outgoing =~ s/>/>/g;
990: $outgoing =~ s/\(/(/g;
991: $outgoing =~ s/\)/)/g;
992: $outgoing =~ s/"/"/g;
993: $outgoing =~ s/'/'/g;
994: $outgoing =~ s/\$/$/g;
995: }
996: return $outgoing;
997: }
998:
1.1 raeburn 999: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>