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