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