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