File:  [LON-CAPA] / loncom / interface / lontiny.pm
Revision 1.8.2.1: download - view: text, annotated - select for diffs
Sun Jan 2 17:21:37 2022 UTC (2 years, 5 months ago) by raeburn
Branches: version_2_11_4_msu
- For 2.11.4 (modified)
  Remove code dependent on $env{'request.lti.login'} - only used in 2.12

    1: # The LearningOnline Network with CAPA
    2: # Extract domain, courseID, and symb from a shortened URL,
    3: # and switch role to a role in designated course.
    4: #
    5: # $Id: lontiny.pm,v 1.8.2.1 2022/01/02 17:21:37 raeburn Exp $
    6: #
    7: # Copyright Michigan State University Board of Trustees
    8: #
    9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   10: #
   11: # LON-CAPA is free software; you can redistribute it and/or modify
   12: # it under the terms of the GNU General Public License as published by
   13: # the Free Software Foundation; either version 2 of the License, or
   14: # (at your option) any later version.
   15: #
   16: # LON-CAPA is distributed in the hope that it will be useful,
   17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19: # GNU General Public License for more details.
   20: #
   21: # You should have received a copy of the GNU General Public License
   22: # along with LON-CAPA; if not, write to the Free Software
   23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24: #
   25: # /home/httpd/html/adm/gpl.txt
   26: #
   27: # http://www.lon-capa.org/
   28: #
   29: 
   30: package Apache::lontiny;
   31: 
   32: use strict;
   33: use Apache::Constants qw(:common :http);
   34: use Apache::lonnet;
   35: use Apache::loncommon;
   36: use Apache::lonhtmlcommon;
   37: use Apache::lonroles;
   38: use Apache::lonuserstate;
   39: use Apache::lonnavmaps;
   40: use Apache::lonlocal;
   41: use LONCAPA qw(:DEFAULT :match);
   42: 
   43: sub handler {
   44:     my $r = shift;
   45:     my %user;
   46:     my $handle = &Apache::lonnet::check_for_valid_session($r,undef,\%user);
   47:     if ($handle ne '') {
   48:         my $lonidsdir=$r->dir_config('lonIDsDir');
   49:         &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
   50:         if ($r->uri =~ m{^/tiny/($match_domain)/(\w+)$}) {
   51:             my ($cdom,$key) = ($1,$2);
   52:             if (&Apache::lonnet::domain($cdom) ne '') {
   53:                 my $configuname = &Apache::lonnet::get_domainconfiguser($cdom);
   54:                 my $tinyurl;
   55:                 my ($result,$cached)=&Apache::lonnet::is_cached_new('tiny',$cdom."\0".$key);
   56:                 if (defined($cached)) {
   57:                     $tinyurl = $result;
   58:                 } else {
   59:                     my %currtiny = &Apache::lonnet::get('tiny',[$key],$cdom,$configuname);
   60:                     if ($currtiny{$key} ne '') {
   61:                         $tinyurl = $currtiny{$key};
   62:                         &Apache::lonnet::do_cache_new('tiny',$cdom."\0".$key,$currtiny{$key},600);
   63:                     }
   64:                 }
   65:                 if ($tinyurl) {
   66:                     my ($cnum,$symb) = split(/\&/,$tinyurl);
   67:                     if ($cnum =~ /^$match_courseid$/) {
   68:                         my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
   69:                         if ($chome ne 'no_host') {
   70:                             &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['ttoken']);
   71:                             if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {
   72:                                 # Check for ttoken
   73:                                 my $newlauncher = &launch_check($r->uri,$symb);
   74:                                 my ($map,$resid,$url) = &Apache::lonnet::decode_symb($symb);
   75:                                 if (&Apache::lonnet::is_on_map($url)) {
   76:                                     my $realuri;
   77:                                     if ((&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) &&
   78:                                         (!$env{'request.role.adv'})) {
   79:                                         $env{'user.error.msg'}=$r->uri.':bre:1:1:Access to resource denied';
   80:                                         return HTTP_NOT_ACCEPTABLE;
   81:                                     }
   82:                                     if ((&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i) &&
   83:                                         (!$env{'request.role.adv'})) {
   84:                                         $realuri = &Apache::lonenc::encrypted(&Apache::lonnet::clutter($url));
   85:                                         if (($url =~ /\.sequence$/) &&
   86:                                             ($env{'course.'.$env{'request.course.id'}.'.type'} ne 'Placement')) {
   87:                                             $realuri .= '?navmap=1';
   88:                                         } else {
   89:                                             $realuri .= '?symb='.&Apache::lonenc::encrypted($symb);
   90:                                         }
   91:                                     } else {
   92:                                         $realuri = &Apache::lonnet::clutter($url);
   93:                                         if (($url =~ /\.sequence$/) &&
   94:                                             ($env{'course.'.$env{'request.course.id'}.'.type'} ne 'Placement')) {
   95:                                             $realuri .= '?navmap=1';
   96:                                         } else {
   97:                                             $realuri .= '?symb='.$symb;
   98:                                         }
   99:                                     }
  100:                                     my $update;
  101:                                     # Check if course needs to be re-initialized
  102:                                     if ($newlauncher) {
  103:                                         $update = 1;
  104:                                     } else {
  105:                                         my $loncaparev = $r->dir_config('lonVersion');
  106:                                         my ($result,@reinit) = &Apache::loncommon::needs_coursereinit($loncaparev);
  107:                                         if ($result eq 'update') {
  108:                                             $update = 1;
  109:                                         } elsif (!-e $env{'request.course.fn'}.'.db') {
  110:                                             $update = 1;
  111:                                         } elsif (!$env{'request.role.adv'}) {
  112:                                             my $navmap = Apache::lonnavmaps::navmap->new();
  113:                                             if (ref($navmap)) {
  114:                                                 my $res = $navmap->getBySymb($symb);
  115:                                                 if (ref($res)) {
  116:                                                     my ($enc_in_bighash,$enc_in_parm);
  117:                                                     $enc_in_bighash = $res->encrypted();
  118:                                                     if (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i) {
  119:                                                         $enc_in_parm = 1;
  120:                                                     }
  121:                                                     if ($enc_in_bighash ne $enc_in_parm) {
  122:                                                         $update = 1;
  123:                                                     }
  124:                                                 }
  125:                                             }
  126:                                         }
  127:                                     }
  128:                                     if ($update) {
  129:                                         my ($furl,$ferr)=
  130:                                             &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
  131:                                         if ($ferr) {
  132:                                             $env{'user.error.msg'}=$r->uri.':bre:0:0:Course not initialized';
  133:                                             $env{'user.reinit'} = 1;
  134:                                             return HTTP_NOT_ACCEPTABLE;
  135:                                         }
  136:                                     }
  137:                                     my $host = $r->headers_in->get('Host');
  138:                                     if (!$host) {
  139:                                         $r->internal_redirect($realuri);
  140:                                         return OK;
  141:                                     } else {
  142:                                         my $protocol = 'http';
  143:                                         if ($r->get_server_port == 443) {
  144:                                             $protocol = 'https';
  145:                                         }
  146:                                         my $location = $protocol.'://'.$host.$realuri;
  147:                                         $r->headers_out->set(Location => $location);
  148:                                         return REDIRECT;
  149:                                     }
  150:                                 }
  151:                             } else {
  152:                                 my %crsenv = &Apache::lonnet::coursedescription("$cdom/$cnum");
  153:                                 my @possroles = ('in','ta','ep','st','cr','ad');
  154:                                 if ($crsenv{'type'} eq 'Community') {
  155:                                     unshift(@possroles,'co');
  156:                                 } else {
  157:                                     unshift(@possroles,'cc');
  158:                                 }
  159:                                 my %roleshash = &Apache::lonnet::get_my_roles($env{'user.uname'},
  160:                                                                               $env{'user.domain'},
  161:                                                                               'userroles',undef,
  162:                                                                               \@possroles,[$cdom],1);
  163:                                 my (%possroles,$hassection);
  164:                                 if (keys(%roleshash)) {
  165:                                     foreach my $entry (keys(%roleshash)) {
  166:                                         if ($entry =~ /^\Q$cnum:$cdom:\E([^:]+):([^:]*)$/) {
  167:                                             $possroles{$1} = $2;
  168:                                             if ($2 ne '') {
  169:                                                 $hassection = 1;
  170:                                             }
  171:                                         }
  172:                                     }
  173:                                 }
  174:                                 my @allposs = keys(%possroles);
  175:                                 if (@allposs == 0) {
  176:                                     &show_roles($r,\%crsenv,\%possroles);
  177:                                 } elsif (@allposs == 1) {
  178:                                     my $newrole = "$allposs[0]./$cdom/$cnum";
  179:                                     $newrole = "$allposs[0]./$cdom/$cnum";
  180:                                     if ($possroles{$allposs[0]} ne '') {
  181:                                         $newrole .= "/$possroles{$allposs[0]}"; 
  182:                                     }
  183:                                     my $destination .= '/adm/roles?selectrole=1&'.$newrole.'=1'.
  184:                                                        '&destinationurl='.&HTML::Entities::encode($r->uri);
  185:                                     if ($env{'form.ttoken'}) {
  186:                                         $destination .= '&ttoken='.$env{'form.ttoken'};
  187:                                     }
  188:                                     &do_redirect($r,$destination);
  189:                                 } elsif (keys(%possroles) > 1) {
  190:                                     if (grep(/^(cc|co)$/,@allposs)) {
  191:                                         my $newrole;
  192:                                         if (exists($possroles{'cc'})) {
  193:                                             $newrole = 'cc';
  194:                                         } else {
  195:                                             $newrole = 'co';
  196:                                         }
  197:                                         $newrole .= "./$cdom/$cnum";
  198:                                         my $destination .= '/adm/roles?selectrole=1&'.$newrole.'=1'.
  199:                                                            '&destinationurl='.&HTML::Entities::encode($r->uri);
  200:                                         if ($env{'form.ttoken'}) {
  201:                                             $destination .= '&ttoken='.$env{'form.ttoken'};
  202:                                         }
  203:                                         &do_redirect($r,$destination);
  204:                                     } else {
  205:                                         my $hascustom;
  206:                                         if (grep(/^cr\//,@allposs)) {
  207:                                             $hascustom = 1;
  208:                                         }
  209:                                         &show_roles($r,\%crsenv,\%possroles,$hassection,$hascustom);
  210:                                     }
  211:                                 }
  212:                                 return OK;
  213:                             }
  214:                         }
  215:                     }
  216:                 }
  217:             }
  218:         }
  219:         &generic_error($r);
  220:         return OK;
  221:     } else {
  222:         return FORBIDDEN;
  223:     }
  224: }
  225: 
  226: sub launch_check {
  227:     my ($linkuri,$symb) = @_;
  228:     my ($linkprotector,$linkproturi,$linkkey,$newlauncher);
  229:     if ($env{'form.ttoken'}) {
  230:         my %link_info = &Apache::lonnet::tmpget($env{'form.ttoken'});
  231:         &Apache::lonnet::tmpdel($env{'form.ttoken'});
  232:         delete($env{'form.ttoken'});
  233:         if ($link_info{'linkprot'}) {
  234:             ($linkprotector,$linkproturi) = split(/:/,$link_info{'linkprot'},2);
  235:             if ($env{'user.linkprotector'}) {
  236:                 my @protectors = split(/,/,$env{'user.linkprotector'});
  237:                 unless (grep(/^\Q$linkprotector\E$/,@protectors)) {
  238:                     push(@protectors,$linkprotector);
  239:                     @protectors = sort { $a <=> $b } @protectors;
  240:                     &Apache::lonnet::appenv({'user.linkprotector' => join(',',@protectors)});
  241:                 }
  242:             } else {
  243:                 &Apache::lonnet::appenv({'user.linkprotector' => $linkprotector });
  244:             }
  245:             if ($env{'user.linkproturi'}) {
  246:                 my @proturis = split(/,/,$env{'user.linkproturi'});
  247:                 unless(grep(/^\Q$linkproturi\E$/,@proturis)) {
  248:                     push(@proturis,$linkproturi);
  249:                     @proturis = sort(@proturis);
  250:                     &Apache::lonnet::appenv({'user.linkproturi' => join(',',@proturis)});
  251:                 }
  252:             } else {
  253:                 &Apache::lonnet::appenv({'user.linkproturi' => $linkproturi});
  254:             }
  255:         } elsif ($link_info{'linkkey'} ne '') {
  256:             $linkkey = $link_info{'linkkey'};
  257:             my $keyedlinkuri = $linkuri;
  258:             if ($env{'user.deeplinkkey'} ne '') {
  259:                 my @linkkeys = split(/,/,$env{'user.deeplinkkey'});
  260:                 unless (grep(/^\Q$linkkey\E$/,@linkkeys)) {
  261:                     push(@linkkeys,$linkkey);
  262:                     &Apache::lonnet::appenv({'user.deeplinkkey' => join(',',sort(@linkkeys))});
  263:                 }
  264:             } else {
  265:                 &Apache::lonnet::appenv({'user.deeplinkkey' => $linkkey});
  266:             }
  267:             if ($env{'user.keyedlinkuri'}) {
  268:                 my @keyeduris = split(/,/,$env{'user.keyedlinkuri'});
  269:                 unless (grep(/^\Q$keyedlinkuri\E$/,@keyeduris)) {
  270:                     push(@keyeduris,$keyedlinkuri);
  271:                     &Apache::lonnet::appenv({'user.keyedlinkuri' => join(',',sort(@keyeduris))});
  272:                 }
  273:             } else {
  274:                 &Apache::lonnet::appenv({'user.keyedlinkuri' => $keyedlinkuri});
  275:             }
  276:         }
  277:         if ($link_info{'checklaunch'}) {
  278:             $newlauncher = 1;
  279:         }
  280:     }
  281:     my $currdeeplinklogin = $env{'request.deeplink.login'};
  282:     my $deeplink;
  283:     if ($symb =~ /\.(page|sequence)$/) {
  284:         my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($symb))[2]);
  285:         my $navmap = Apache::lonnavmaps::navmap->new();
  286:         if (ref($navmap)) {
  287:             $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink');
  288:         }
  289:     } else {
  290:         $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$symb);
  291:     }
  292:     if ($deeplink ne '') {
  293:         my $disallow;
  294:         my ($state,$others,$listed,$scope,$protect) = split(/,/,$deeplink);
  295:         if (($protect ne 'none') && ($protect ne '')) {
  296:             my ($acctype,$item) = split(/:/,$protect);
  297:             if ($acctype =~ /lti(c|d)$/) {
  298:                 my $ltitype = $1;
  299:                 if ($linkprotector) {
  300:                     unless ($linkprotector.':'.$linkproturi eq $item.$ltitype.':'.$linkuri) {
  301:                         $disallow = 1;
  302:                     }
  303:                 } else {
  304:                     $disallow = 1;
  305:                 }
  306:             } elsif ($acctype eq 'key') {
  307:                 if ($linkkey ne '') {
  308:                     unless ($linkkey eq $item) {
  309:                         $disallow = 1;
  310:                     }
  311:                 } else {
  312:                     $disallow = 1;
  313:                 }
  314:             }
  315:         }
  316:         if ($disallow) {
  317:             if ($currdeeplinklogin eq $linkuri) {
  318:                 &Apache::lonnet::delenv('request.deeplink.login');
  319:             }
  320:         } else {
  321:             unless ($currdeeplinklogin eq $linkuri) {
  322:                 if (($linkprotector) || ($linkkey ne '')) {
  323:                     if ($linkprotector) {
  324:                         &Apache::lonnet::appenv({'request.linkprot' => $linkprotector.':'.$linkproturi});
  325:                     } elsif ($env{'request.linkprot'}) {
  326:                         &Apache::lonnet::delenv({'request.linkprot'});
  327:                     }
  328:                     if ($linkkey ne '') {
  329:                         &Apache::lonnet::appenv({'request.linkkey' => $linkkey});
  330:                     } elsif ($env{'request.linkkey'} ne '') {
  331:                         &Apache::lonnet::delenv({'request.linkkey'});
  332:                     }
  333:                     $newlauncher = 1;
  334:                 }
  335:             }
  336:             &Apache::lonnet::appenv({'request.deeplink.login' => $linkuri});
  337:         }
  338:     } else {
  339:         if ($linkprotector) {
  340:             &Apache::lonnet::appenv({'request.linkprot' => $linkprotector.':'.$linkproturi});
  341:         } elsif ($env{'request.linkprot'}) {
  342:             &Apache::lonnet::delenv({'request.linkprot'});
  343:         }
  344:         if ($linkkey ne '') {
  345:             &Apache::lonnet::appenv({'request.linkkey' => $linkkey});
  346:         } else {
  347:             &Apache::lonnet::delenv({'request.linkkey'});
  348:         }
  349:         &Apache::lonnet::appenv({'request.deeplink.login' => $linkuri});
  350:     }
  351:     return $newlauncher;
  352: }
  353: 
  354: sub do_redirect {
  355:     my ($r,$destination) = @_;
  356:     my $windowname = 'loncapaclient';
  357:     my $header = '<meta HTTP-EQUIV="Refresh" CONTENT="0; url='.$destination.'" />';
  358:     my $args = {'bread_crumbs' => [{'href' => '','text' => 'Role initialization'},],};
  359:     &Apache::loncommon::content_type($r,'text/html');
  360:     $r->send_http_header;
  361:     $r->print(&Apache::loncommon::start_page('Valid link',$header,$args).
  362:               &Apache::lonhtmlcommon::scripttag('self.name="'.$windowname.'";').
  363:               '<h1>'.&mt('Welcome').'</h1>'.
  364:               '<p>'.&mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>').'</p><p>'.
  365:               '<a href="'.$destination.'">'.&mt('Continue').'</a></p>'.
  366:               &Apache::loncommon::end_page());
  367:     return;
  368: }
  369: 
  370: sub show_roles {
  371:     my ($r,$crsenv,$possroles,$hassection,$hascustom) = @_;
  372:     &Apache::loncommon::content_type($r,'text/html');
  373:     $r->send_http_header;
  374:     my ($crsdesc,$crstype,$cdom,$cnum,$header,$title,$preamble,$datatable,$js,$args);
  375:     if (ref($crsenv) eq 'HASH') {
  376:         $crsdesc = $crsenv->{'description'};
  377:         $crstype = $crsenv->{'type'};
  378:         $cdom = $crsenv->{'domain'};
  379:         $cnum = $crsenv->{'num'};
  380:     }
  381:     if ($crstype eq '') {
  382:         $crstype = 'Course';
  383:     }
  384:     my $lc_crstype = lc($crstype);
  385:     if ($crsdesc ne '') {
  386:         $header = &mt("The page you requested belongs to the following $lc_crstype: [_1]",
  387:                       '<i>'.$crsdesc.'</i>');
  388:     }
  389:     if (ref($possroles) eq 'HASH') {
  390:         if (keys(%{$possroles}) > 0) {
  391:             $args = {'bread_crumbs' => [{'href' => '','text' => "Choose role in $lc_crstype"},],};
  392:             $title = 'Choose a role'; #Do not localize.
  393:             if ($crstype eq 'Community') {
  394:                 $preamble = &mt('You have the following active roles in this community:');
  395:             } else { 
  396:                 $preamble = &mt('You have the following active roles in this course:');
  397:             }
  398:             $datatable = '<form name="" action="/adm/roles">'.
  399:                          '<input type="hidden" name="newrole" value="" />'."\n".
  400:                          '<input type="hidden" name="selectrole" value="1" />'."\n".
  401:                          '<input type="hidden" name="destinationurl" value="'.$r->uri.'" />'."\n";
  402:             if ($env{'form.ttoken'}) {
  403:                 $datatable .= '<input type="hidden" name="ttoken" value="'.$env{'form.ttoken'}.'" />'."\n";
  404:             }
  405:             $datatable .= &Apache::loncommon::start_data_table().
  406:                           &Apache::loncommon::start_data_table_header_row().
  407:                           '<th></th><th>'.&mt('User role').'</th>';
  408:             if ($hassection) {
  409:                 $datatable .= '<th>'.&mt('Section').'</th>';
  410:             }
  411:             if ($hascustom) {
  412:                 $datatable .= '<th>'.&mt('Information').'</th>';
  413:             }
  414:             $datatable .= &Apache::loncommon::end_data_table_header_row();
  415:             my @available = sort(keys(%{$possroles}));
  416:             foreach my $role ('ad','in','ta','ep','st','cr') {
  417:                 foreach my $key (@available) {
  418:                     if ($key =~ m{^$role($|/)}) {
  419:                         my $trolecode = "$key./$cdom/$cnum";
  420:                         my $rolename = &Apache::lonnet::plaintext($key,$crstype,$cdom.'_'.$cnum);
  421:                         my $sec = $possroles->{$key};
  422:                         if ($sec ne '') {
  423:                             $trolecode .= '/'.$sec;
  424:                         }
  425:                         my $buttonname=$trolecode;
  426:                         $buttonname=~s/\W//g;
  427:                         $datatable .= &Apache::loncommon::start_data_table_row().
  428:                                       '<td><input name="'.$buttonname.'" type="button" value="'.
  429:                                       &mt('Select').'" onclick="javascript:enterrole(this.form,'.
  430:                                       "'$trolecode','$buttonname'".');" /></td>';
  431:                         if ($key =~ /^cr\//) {
  432:                             my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$key);
  433:                             $datatable .= '<td><span class="LC_nobreak">'.$rolename.'</span></td>';
  434:                             if ($hassection) {
  435:                                 $datatable .= '<td>'.$sec.'</td>';
  436:                             }
  437:                             $datatable.= '<td><span class="LC_fontsize_small LC_cusr_emph">'.
  438:                                           &mt('Custom role defined by [_1]',$rauthor.':'.$rdomain).
  439:                                           '</td>';
  440:                         } else {
  441:                             if ($hassection) {
  442:                                 $datatable .= '<td>'.$rolename.'</td>';
  443:                                 if ($hascustom) {
  444:                                     $datatable .= '<td colspan="2">'.$sec.'</td>';
  445:                                 } else {
  446:                                     $datatable .= '<td>'.$sec.'</td>';
  447:                                 }
  448:                             } elsif ($hascustom) {
  449:                                 $datatable .= '<td colspan="2">'.$rolename.'</td>';
  450:                             } else {
  451:                                 $datatable .= '<td>'.$rolename.'</td>';
  452:                             }
  453:                         }
  454:                         $datatable .= &Apache::loncommon::end_data_table_row();
  455:                     }
  456:                 }
  457:             }
  458:             $datatable .= &Apache::loncommon::end_data_table().
  459:                           '</form>';
  460:             my $standby = &mt('Role selected. Please stand by.');
  461:             $js = <<"ENDJS";
  462: <script type="text/javascript">
  463: // <![CDATA[
  464: 
  465: active=true;
  466: 
  467: function enterrole (thisform,rolecode,buttonname) {
  468:     if (active) {
  469:         active=false;
  470:         document.title='$standby';
  471:         window.status='$standby';
  472:         thisform.newrole.value=rolecode;
  473:         thisform.submit();
  474:     } else {
  475:        alert('$standby');
  476:     }
  477: }
  478: 
  479: // ]]>
  480: </script>
  481: ENDJS
  482:         } else {
  483:             $title = 'No active role';
  484:             $preamble = &mt("You have no active roles in this $lc_crstype so the page is currently unavailable to you.");
  485:             $args = {'bread_crumbs' => [{'href' => '','text' => 'Role status'},],};
  486:         }
  487:     }
  488:     &Apache::loncommon::content_type($r,'text/html');
  489:     $r->send_http_header;
  490:     $r->print(&Apache::loncommon::start_page($title,$js,$args).
  491:               '<h3>'.$header.'</h3>'.
  492:               '<div>'.$preamble.'</div>'.
  493:               $datatable.
  494:               &Apache::loncommon::end_page());
  495:     return;
  496: }
  497: 
  498: sub generic_error {
  499:     my ($r) = @_;
  500:     my $continuelink;
  501:     my $linktext;
  502:     if ($env{'user.adv'}) {
  503:         $linktext = &mt('Continue to your roles page');
  504:     } else {
  505:         $linktext = &mt('Continue to your courses page');
  506:     }
  507:     $continuelink='<a href="/adm/roles">'.$linktext.'</a>';
  508:     my $msg = &mt('The page you requested does not exist.');
  509:     &Apache::loncommon::content_type($r,'text/html');
  510:     $r->send_http_header;
  511:     my $args = {'bread_crumbs' => [{'href' => '','text' => 'Link status'},],};
  512:     $r->print(&Apache::loncommon::start_page('Invalid URL',undef,$args).
  513:               '<div class="LC_error">'.$msg.'</div>'.
  514:               '<p>'.$continuelink.'</p>'.
  515:               &Apache::loncommon::end_page());
  516:     return;
  517: }
  518: 
  519: 1;

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