Annotation of loncom/interface/lontiny.pm, revision 1.10
1.1 raeburn 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: #
1.10 ! raeburn 5: # $Id: lontiny.pm,v 1.9 2022/05/24 16:23:04 raeburn Exp $
1.1 raeburn 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;
1.5 raeburn 38: use Apache::lonuserstate;
39: use Apache::lonnavmaps;
1.1 raeburn 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);
1.6 raeburn 47: if ($handle ne '') {
1.5 raeburn 48: my $lonidsdir=$r->dir_config('lonIDsDir');
49: &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
1.1 raeburn 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') {
1.8 raeburn 70: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['ttoken']);
1.5 raeburn 71: if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {
1.8 raeburn 72: # Check for ttoken
73: my $newlauncher = &launch_check($r->uri,$symb);
1.5 raeburn 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
1.7 raeburn 102: if ($newlauncher) {
1.5 raeburn 103: $update = 1;
1.7 raeburn 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: }
1.5 raeburn 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';
1.1 raeburn 145: }
1.5 raeburn 146: my $location = $protocol.'://'.$host.$realuri;
147: $r->headers_out->set(Location => $location);
148: return REDIRECT;
1.1 raeburn 149: }
150: }
1.5 raeburn 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: }
1.4 raeburn 172: }
173: }
1.5 raeburn 174: my @allposs = keys(%possroles);
175: if ($env{'request.lti.login'}) {
176: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
177: if ($env{'request.lti.target'} eq '') {
178: if ($env{'form.ltitarget'} eq 'iframe') {
179: &Apache::lonnet::appenv({'request.lti.target' => 'iframe'});
180: delete($env{'form.ltitarget'});
1.4 raeburn 181: }
1.5 raeburn 182: }
183: if ($env{'form.selectrole'}) {
184: foreach my $role (@allposs) {
185: my $newrole = "$role./$cdom/$cnum";
186: if ($possroles{$allposs[0]} ne '') {
187: $newrole .= "/$possroles{$role}";
188: }
189: if ($env{"form.$newrole"}) {
190: my $destination .= '/adm/roles?selectrole=1&'.$newrole.'=1'.
191: '&destinationurl='.&HTML::Entities::encode($r->uri);
192: if ($env{'form.ltitarget'} eq 'iframe') {
193: $destination .= '<itarget=iframe';
194: }
195: &do_redirect($r,$destination);
196: return OK;
1.4 raeburn 197: }
198: }
199: }
200: }
1.5 raeburn 201: if (@allposs == 0) {
202: &show_roles($r,\%crsenv,\%possroles);
203: } elsif (@allposs == 1) {
204: my $newrole = "$allposs[0]./$cdom/$cnum";
205: $newrole = "$allposs[0]./$cdom/$cnum";
206: if ($possroles{$allposs[0]} ne '') {
207: $newrole .= "/$possroles{$allposs[0]}";
1.1 raeburn 208: }
209: my $destination .= '/adm/roles?selectrole=1&'.$newrole.'=1'.
210: '&destinationurl='.&HTML::Entities::encode($r->uri);
1.8 raeburn 211: if ($env{'form.ttoken'}) {
212: $destination .= '&ttoken='.$env{'form.ttoken'};
213: }
1.1 raeburn 214: &do_redirect($r,$destination);
1.5 raeburn 215: } elsif (keys(%possroles) > 1) {
216: if (grep(/^(cc|co)$/,@allposs)) {
217: my $newrole;
218: if (exists($possroles{'cc'})) {
219: $newrole = 'cc';
220: } else {
221: $newrole = 'co';
222: }
223: $newrole .= "./$cdom/$cnum";
224: my $destination .= '/adm/roles?selectrole=1&'.$newrole.'=1'.
225: '&destinationurl='.&HTML::Entities::encode($r->uri);
1.8 raeburn 226: if ($env{'form.ttoken'}) {
227: $destination .= '&ttoken='.$env{'form.ttoken'};
228: }
1.5 raeburn 229: &do_redirect($r,$destination);
230: } else {
231: my $hascustom;
232: if (grep(/^cr\//,@allposs)) {
233: $hascustom = 1;
234: }
235: &show_roles($r,\%crsenv,\%possroles,$hassection,$hascustom);
1.1 raeburn 236: }
237: }
1.5 raeburn 238: return OK;
1.1 raeburn 239: }
240: }
241: }
242: }
243: }
244: }
245: &generic_error($r);
246: return OK;
247: } else {
248: return FORBIDDEN;
249: }
250: }
251:
1.7 raeburn 252: sub launch_check {
1.8 raeburn 253: my ($linkuri,$symb) = @_;
1.7 raeburn 254: my ($linkprotector,$linkproturi,$linkkey,$newlauncher);
1.8 raeburn 255: if ($env{'form.ttoken'}) {
256: my %link_info = &Apache::lonnet::tmpget($env{'form.ttoken'});
257: &Apache::lonnet::tmpdel($env{'form.ttoken'});
258: delete($env{'form.ttoken'});
1.10 ! raeburn 259: if ($link_info{'ltoken'}) {
! 260: unless (($link_info{'linkprot'}) || ($link_info{'linkkey'} ne '')) {
! 261: my %ltoken_info = &Apache::lonnet::tmpget($link_info{'ltoken'});
! 262: if ($ltoken_info{'linkprot'}) {
! 263: $link_info{'linkprot'} = $ltoken_info{'linkprot'};
! 264: } elsif ($ltoken_info{'linkkey'} ne '') {
! 265: $link_info{'linkkey'} = $ltoken_info{'linkkey'};
! 266: }
! 267: }
! 268: &Apache::lonnet::tmpdel($env{'form.ltoken'});
! 269: delete($env{'form.ltoken'});
! 270: }
1.7 raeburn 271: if ($link_info{'linkprot'}) {
272: ($linkprotector,$linkproturi) = split(/:/,$link_info{'linkprot'},2);
273: if ($env{'user.linkprotector'}) {
274: my @protectors = split(/,/,$env{'user.linkprotector'});
275: unless (grep(/^\Q$linkprotector\E$/,@protectors)) {
276: push(@protectors,$linkprotector);
277: @protectors = sort { $a <=> $b } @protectors;
278: &Apache::lonnet::appenv({'user.linkprotector' => join(',',@protectors)});
279: }
280: } else {
281: &Apache::lonnet::appenv({'user.linkprotector' => $linkprotector });
282: }
283: if ($env{'user.linkproturi'}) {
284: my @proturis = split(/,/,$env{'user.linkproturi'});
285: unless(grep(/^\Q$linkproturi\E$/,@proturis)) {
286: push(@proturis,$linkproturi);
287: @proturis = sort(@proturis);
288: &Apache::lonnet::appenv({'user.linkproturi' => join(',',@proturis)});
289: }
290: } else {
291: &Apache::lonnet::appenv({'user.linkproturi' => $linkproturi});
292: }
1.8 raeburn 293: } elsif ($link_info{'linkkey'} ne '') {
294: $linkkey = $link_info{'linkkey'};
295: my $keyedlinkuri = $linkuri;
296: if ($env{'user.deeplinkkey'} ne '') {
297: my @linkkeys = split(/,/,$env{'user.deeplinkkey'});
298: unless (grep(/^\Q$linkkey\E$/,@linkkeys)) {
299: push(@linkkeys,$linkkey);
300: &Apache::lonnet::appenv({'user.deeplinkkey' => join(',',sort(@linkkeys))});
301: }
302: } else {
303: &Apache::lonnet::appenv({'user.deeplinkkey' => $linkkey});
304: }
305: if ($env{'user.keyedlinkuri'}) {
306: my @keyeduris = split(/,/,$env{'user.keyedlinkuri'});
307: unless (grep(/^\Q$keyedlinkuri\E$/,@keyeduris)) {
308: push(@keyeduris,$keyedlinkuri);
309: &Apache::lonnet::appenv({'user.keyedlinkuri' => join(',',sort(@keyeduris))});
310: }
311: } else {
312: &Apache::lonnet::appenv({'user.keyedlinkuri' => $keyedlinkuri});
313: }
1.7 raeburn 314: }
1.8 raeburn 315: if ($link_info{'checklaunch'}) {
316: $newlauncher = 1;
1.7 raeburn 317: }
1.8 raeburn 318: }
319: my $currdeeplinklogin = $env{'request.deeplink.login'};
320: my $deeplink;
321: if ($symb =~ /\.(page|sequence)$/) {
322: my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($symb))[2]);
323: my $navmap = Apache::lonnavmaps::navmap->new();
324: if (ref($navmap)) {
325: $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink');
1.7 raeburn 326: }
1.8 raeburn 327: } else {
328: $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$symb);
1.7 raeburn 329: }
1.8 raeburn 330: if ($deeplink ne '') {
331: my $disallow;
1.9 raeburn 332: my ($state,$others,$listed,$scope,$protect,$display,$target) = split(/,/,$deeplink);
1.8 raeburn 333: if (($protect ne 'none') && ($protect ne '')) {
334: my ($acctype,$item) = split(/:/,$protect);
335: if ($acctype =~ /lti(c|d)$/) {
336: my $ltitype = $1;
337: if ($linkprotector) {
338: unless ($linkprotector.':'.$linkproturi eq $item.$ltitype.':'.$linkuri) {
339: $disallow = 1;
340: }
341: } else {
342: $disallow = 1;
1.7 raeburn 343: }
1.8 raeburn 344: } elsif ($acctype eq 'key') {
345: if ($linkkey ne '') {
346: unless ($linkkey eq $item) {
347: $disallow = 1;
1.7 raeburn 348: }
1.8 raeburn 349: } else {
350: $disallow = 1;
1.7 raeburn 351: }
1.8 raeburn 352: }
353: }
354: if ($disallow) {
355: if ($currdeeplinklogin eq $linkuri) {
356: &Apache::lonnet::delenv('request.deeplink.login');
1.10 ! raeburn 357: if ($env{'request.deeplink.target'} ne '') {
! 358: &Apache::lonnet::delenv('request.deeplink.target');
! 359: }
1.8 raeburn 360: }
361: } else {
362: unless ($currdeeplinklogin eq $linkuri) {
363: if (($linkprotector) || ($linkkey ne '')) {
364: if ($linkprotector) {
365: &Apache::lonnet::appenv({'request.linkprot' => $linkprotector.':'.$linkproturi});
366: } elsif ($env{'request.linkprot'}) {
367: &Apache::lonnet::delenv({'request.linkprot'});
1.7 raeburn 368: }
1.8 raeburn 369: if ($linkkey ne '') {
370: &Apache::lonnet::appenv({'request.linkkey' => $linkkey});
371: } elsif ($env{'request.linkkey'} ne '') {
372: &Apache::lonnet::delenv({'request.linkkey'});
1.7 raeburn 373: }
1.8 raeburn 374: $newlauncher = 1;
1.7 raeburn 375: }
376: }
377: &Apache::lonnet::appenv({'request.deeplink.login' => $linkuri});
1.9 raeburn 378: if ($target ne '') {
379: &Apache::lonnet::appenv({'request.deeplink.target' => $target});
1.10 ! raeburn 380: } elsif ($env{'request.deeplink.target'} ne '') {
! 381: &Apache::lonnet::delenv('request.deeplink.target');
1.9 raeburn 382: }
1.7 raeburn 383: }
384: } else {
385: if ($linkprotector) {
386: &Apache::lonnet::appenv({'request.linkprot' => $linkprotector.':'.$linkproturi});
1.8 raeburn 387: } elsif ($env{'request.linkprot'}) {
388: &Apache::lonnet::delenv({'request.linkprot'});
389: }
390: if ($linkkey ne '') {
1.7 raeburn 391: &Apache::lonnet::appenv({'request.linkkey' => $linkkey});
1.8 raeburn 392: } else {
393: &Apache::lonnet::delenv({'request.linkkey'});
1.7 raeburn 394: }
1.8 raeburn 395: &Apache::lonnet::appenv({'request.deeplink.login' => $linkuri});
1.10 ! raeburn 396: if ($env{'request.deeplink.target'} ne '') {
! 397: &Apache::lonnet::delenv('request.deeplink.target');
! 398: }
1.7 raeburn 399: }
400: return $newlauncher;
401: }
402:
1.1 raeburn 403: sub do_redirect {
404: my ($r,$destination) = @_;
1.2 raeburn 405: my $windowname = 'loncapaclient';
406: if ($env{'request.lti.login'}) {
407: $windowname .= 'lti';
408: }
1.1 raeburn 409: my $header = '<meta HTTP-EQUIV="Refresh" CONTENT="0; url='.$destination.'" />';
410: my $args = {'bread_crumbs' => [{'href' => '','text' => 'Role initialization'},],};
411: &Apache::loncommon::content_type($r,'text/html');
412: $r->send_http_header;
413: $r->print(&Apache::loncommon::start_page('Valid link',$header,$args).
1.2 raeburn 414: &Apache::lonhtmlcommon::scripttag('self.name="'.$windowname.'";').
1.1 raeburn 415: '<h1>'.&mt('Welcome').'</h1>'.
416: '<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>'.
417: '<a href="'.$destination.'">'.&mt('Continue').'</a></p>'.
418: &Apache::loncommon::end_page());
419: return;
420: }
421:
422: sub show_roles {
423: my ($r,$crsenv,$possroles,$hassection,$hascustom) = @_;
424: &Apache::loncommon::content_type($r,'text/html');
425: $r->send_http_header;
426: my ($crsdesc,$crstype,$cdom,$cnum,$header,$title,$preamble,$datatable,$js,$args);
427: if (ref($crsenv) eq 'HASH') {
428: $crsdesc = $crsenv->{'description'};
429: $crstype = $crsenv->{'type'};
430: $cdom = $crsenv->{'domain'};
431: $cnum = $crsenv->{'num'};
432: }
433: if ($crstype eq '') {
434: $crstype = 'Course';
435: }
436: my $lc_crstype = lc($crstype);
437: if ($crsdesc ne '') {
438: $header = &mt("The page you requested belongs to the following $lc_crstype: [_1]",
439: '<i>'.$crsdesc.'</i>');
440: }
441: if (ref($possroles) eq 'HASH') {
442: if (keys(%{$possroles}) > 0) {
443: $args = {'bread_crumbs' => [{'href' => '','text' => "Choose role in $lc_crstype"},],};
444: $title = 'Choose a role'; #Do not localize.
445: if ($crstype eq 'Community') {
446: $preamble = &mt('You have the following active roles in this community:');
447: } else {
448: $preamble = &mt('You have the following active roles in this course:');
449: }
450: $datatable = '<form name="" action="/adm/roles">'.
1.8 raeburn 451: '<input type="hidden" name="newrole" value="" />'."\n".
452: '<input type="hidden" name="selectrole" value="1" />'."\n".
453: '<input type="hidden" name="destinationurl" value="'.$r->uri.'" />'."\n";
454: if ($env{'form.ttoken'}) {
455: $datatable .= '<input type="hidden" name="ttoken" value="'.$env{'form.ttoken'}.'" />'."\n";
456: }
457: $datatable .= &Apache::loncommon::start_data_table().
458: &Apache::loncommon::start_data_table_header_row().
459: '<th></th><th>'.&mt('User role').'</th>';
1.1 raeburn 460: if ($hassection) {
461: $datatable .= '<th>'.&mt('Section').'</th>';
462: }
463: if ($hascustom) {
464: $datatable .= '<th>'.&mt('Information').'</th>';
465: }
466: $datatable .= &Apache::loncommon::end_data_table_header_row();
467: my @available = sort(keys(%{$possroles}));
468: foreach my $role ('ad','in','ta','ep','st','cr') {
469: foreach my $key (@available) {
470: if ($key =~ m{^$role($|/)}) {
471: my $trolecode = "$key./$cdom/$cnum";
472: my $rolename = &Apache::lonnet::plaintext($key,$crstype,$cdom.'_'.$cnum);
473: my $sec = $possroles->{$key};
474: if ($sec ne '') {
475: $trolecode .= '/'.$sec;
476: }
477: my $buttonname=$trolecode;
478: $buttonname=~s/\W//g;
479: $datatable .= &Apache::loncommon::start_data_table_row().
480: '<td><input name="'.$buttonname.'" type="button" value="'.
481: &mt('Select').'" onclick="javascript:enterrole(this.form,'.
482: "'$trolecode','$buttonname'".');" /></td>';
483: if ($key =~ /^cr\//) {
484: my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$key);
485: $datatable .= '<td><span class="LC_nobreak">'.$rolename.'</span></td>';
486: if ($hassection) {
487: $datatable .= '<td>'.$sec.'</td>';
488: }
489: $datatable.= '<td><span class="LC_fontsize_small LC_cusr_emph">'.
490: &mt('Custom role defined by [_1]',$rauthor.':'.$rdomain).
491: '</td>';
492: } else {
493: if ($hassection) {
494: $datatable .= '<td>'.$rolename.'</td>';
495: if ($hascustom) {
496: $datatable .= '<td colspan="2">'.$sec.'</td>';
497: } else {
498: $datatable .= '<td>'.$sec.'</td>';
499: }
500: } elsif ($hascustom) {
501: $datatable .= '<td colspan="2">'.$rolename.'</td>';
502: } else {
503: $datatable .= '<td>'.$rolename.'</td>';
504: }
505: }
506: $datatable .= &Apache::loncommon::end_data_table_row();
507: }
508: }
509: }
510: $datatable .= &Apache::loncommon::end_data_table().
511: '</form>';
512: my $standby = &mt('Role selected. Please stand by.');
513: $js = <<"ENDJS";
514: <script type="text/javascript">
515: // <![CDATA[
516:
517: active=true;
518:
519: function enterrole (thisform,rolecode,buttonname) {
520: if (active) {
521: active=false;
522: document.title='$standby';
523: window.status='$standby';
524: thisform.newrole.value=rolecode;
525: thisform.submit();
526: } else {
527: alert('$standby');
528: }
529: }
530:
531: // ]]>
532: </script>
533: ENDJS
534: } else {
535: $title = 'No active role';
536: $preamble = &mt("You have no active roles in this $lc_crstype so the page is currently unavailable to you.");
537: $args = {'bread_crumbs' => [{'href' => '','text' => 'Role status'},],};
538: }
539: }
540: &Apache::loncommon::content_type($r,'text/html');
541: $r->send_http_header;
542: $r->print(&Apache::loncommon::start_page($title,$js,$args).
543: '<h3>'.$header.'</h3>'.
544: '<div>'.$preamble.'</div>'.
545: $datatable.
546: &Apache::loncommon::end_page());
547: return;
548: }
549:
550: sub generic_error {
551: my ($r) = @_;
1.3 raeburn 552: my $continuelink;
553: unless ($env{'request.lti.login'}) {
554: my $linktext;
555: if ($env{'user.adv'}) {
556: $linktext = &mt('Continue to your roles page');
557: } else {
558: $linktext = &mt('Continue to your courses page');
559: }
560: $continuelink='<a href="/adm/roles">'.$linktext.'</a>';
1.1 raeburn 561: }
562: my $msg = &mt('The page you requested does not exist.');
563: &Apache::loncommon::content_type($r,'text/html');
564: $r->send_http_header;
565: my $args = {'bread_crumbs' => [{'href' => '','text' => 'Link status'},],};
566: $r->print(&Apache::loncommon::start_page('Invalid URL',undef,$args).
567: '<div class="LC_error">'.$msg.'</div>'.
568: '<p>'.$continuelink.'</p>'.
569: &Apache::loncommon::end_page());
570: return;
571: }
572:
573: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>