--- loncom/auth/lonroles.pm 2008/07/08 20:16:16 1.200
+++ loncom/auth/lonroles.pm 2008/07/18 16:17:39 1.202
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.200 2008/07/08 20:16:16 raeburn Exp $
+# $Id: lonroles.pm,v 1.202 2008/07/18 16:17:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,6 +43,7 @@ use Apache::lonpageflip();
use Apache::lonnavdisplay();
use GDBM_File;
use LONCAPA qw(:DEFAULT :match);
+use HTML::Entities;
sub redirect_user {
@@ -675,7 +676,8 @@ ENDHEADER
} else {
if ($countactive > 0) {
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
- $r->print('
'.&mt('[_1]Visit the [_2]Course Catalog[_3] to view all [_4] LON-CAPA courses.','','','',$domdesc).' '.&mt('If a course is [_1]not[_2] in your list of current courses below, you may be able to enroll if self-enrollment is permitted.','','').'
');
+ my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
+ $r->print('
'.&mt('[_1]Visit the [_2]Course Catalog[_3] to view all [_4] LON-CAPA courses.','','','',$domdesc).' '.&mt('If a course is [_1]not[_2] in your list of current courses below, you may be able to enroll if self-enrollment is permitted.','','').'
');
}
}
@@ -712,19 +714,31 @@ ENDHEADER
$r->print(&Apache::loncommon::end_page());
return OK;
# Is there only one choice?
- } elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) {
- $r->print('
\n".
+ &mt('Construction Space access is only available from '.
+ 'the home server of the corresponding Author.').' '.
+ &mt("Click the 'Switch Server' link to go there.").' ');
+ }
}
# More than one possible role
# ----------------------------------------------------------------------- Table
- unless ((!&Apache::lonmenu::show_course()) || ($nochoose)) {
+ unless ((!&Apache::lonmenu::show_course()) || ($nochoose) || ($countactive==1)) {
$r->print("
".&mt('Select a Course to Enter')."
\n");
}
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose);
@@ -759,27 +773,28 @@ ENDHEADER
&Apache::loncommon::authorbrowser_javascript());
}
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext);
- my $tremark='';
- my $tfont='#003300';
- if ($env{'request.role'} eq 'cm') {
- $r->print('
');
}
$r->print(&Apache::loncommon::end_page());
@@ -866,6 +883,7 @@ sub print_rolerows {
sub findcourse_advice {
my ($r) = @_;
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
+ my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) {
$r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).'
@@ -878,7 +896,7 @@ sub findcourse_advice {
} else {
$r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').' ');
}
- $r->print('
'.&mt('The [_1]Course Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created.','','',$domdesc).' ');
+ $r->print('
'.&mt('The [_1]Course Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created.','','',$domdesc).' ');
$r->print(&mt('You can search the course catalog for courses which permit self-enrollment, if you would like to enroll in a course.').'
');
return;
}
@@ -1014,6 +1032,24 @@ sub build_roletext {
return $roletext;
}
+sub check_needs_switchserver {
+ my ($possiblerole) = @_;
+ my $needs_switchserver;
+ my ($role,$where) = split(/\./,$possiblerole,2);
+ my (undef,$tdom,$twho) = split(/\//,$where);
+ my ($server_status,$home);
+ if (($role eq 'ca') || ($role eq 'aa')) {
+ ($server_status,$home) = &check_author_homeserver($twho,$tdom);
+ } else {
+ ($server_status,$home) = &check_author_homeserver($env{'user.name'},
+ $env{'user.domain'});
+ }
+ if ($server_status eq 'switchserver') {
+ $needs_switchserver = 1;
+ }
+ return $needs_switchserver;
+}
+
sub check_author_homeserver {
my ($uname,$udom)=@_;
if (($uname eq '') || ($udom eq '')) {
@@ -1069,8 +1105,8 @@ sub check_fordc {
sub adhoc_course_role {
my ($then) = @_;
my ($cdom,$cnum);
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
if (&check_forcc($cdom,$cnum,$then)) {
my $setprivs;
if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {