File:  [LON-CAPA] / loncom / interface / lonsupportreq.pm
Revision 1.78: download - view: text, annotated - select for diffs
Mon Jan 20 17:25:41 2014 UTC (10 years, 3 months ago) by bisitz
Branches: MAIN
CVS tags: version_2_11_1, version_2_11_0_RC3, version_2_11_0, HEAD
- Help students to easily find out which fields are required and which not.
    - Add marker to all required fields and display info text to explain.
  (corresponding to lonevaluate.pm 1.30)

- Warning style for warning message about too big attachment size

- Additional info about rev. 1.76:
Standard style for note to students

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

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