File:  [LON-CAPA] / loncom / interface / lonsupportreq.pm
Revision 1.82: download - view: text, annotated - select for diffs
Fri Feb 19 02:39:07 2016 UTC (8 years, 3 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Support version 2 of Google reCAPTCHA.

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>