File:  [LON-CAPA] / loncom / interface / lonsupportreq.pm
Revision 1.80: download - view: text, annotated - select for diffs
Thu Jun 18 20:19:06 2015 UTC (8 years, 11 months ago) by musolffc
Branches: MAIN
CVS tags: HEAD
File size checking for uploaded files

A new javascript file, file_upload.js, handles client side file size checking.
The function, checkUploadSize(), accepts an html file input element and a maximum
file size (in bytes) as input.  If the size of the file to be uploaded exceeds the
size allowed, a message is displayed the the element is cleared.  Server side
checking is still used if it passes this test.

Loading file_upload.js adds event handlers to file input elements with
class="flUpload".
    <input type="file" class="flUpload" />

It also looks for a hidden element with id="free_space" that contains the maximum
upload size.
    <input type="hidden" id="free_space" value="$free_space" />

The free space is usually calculated by subtracting a user's disk usage from their
quota allowance.  In some cases it is a fixed value.

I have implemented this for every upload instance I could find.  These include:
* Message attachments
* Authoring space
* Portfolio
* Course editor
* Essay response problems
* Helpdesk request forms
* RSS feed uploads

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

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