Annotation of loncom/interface/lonsupportreq.pm, revision 1.108

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

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