--- loncom/auth/lonroles.pm 2008/05/20 18:19:28 1.194
+++ loncom/auth/lonroles.pm 2008/07/14 10:21:52 1.201
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.194 2008/05/20 18:19:28 www Exp $
+# $Id: lonroles.pm,v 1.201 2008/07/14 10:21:52 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 {
@@ -501,13 +502,6 @@ ENDHEADER
$r->print('');
$r->print('');
}
- if ($env{'user.adv'}) {
- $r->print(
- ' ');
- }
-
my (%roletext,%sortrole,%roleclass);
my $countactive=0;
my $countfuture=0;
@@ -674,6 +668,19 @@ ENDHEADER
}
}
}
+ if ($env{'user.adv'}) {
+ $r->print(
+ ' ');
+ } else {
+ if ($countactive > 0) {
+ my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
+ 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.','','').'
');
+ }
+ }
+
# No active roles
if ($countactive==0) {
if ($inrole) {
@@ -786,9 +793,14 @@ ENDHEADER
}
$r->print(&Apache::lonnet::getannounce());
if ($advanced) {
- $r->print('
This is LON-CAPA '.
- $r->dir_config('lonVersion').' '.
- ''.&mt('Logout').'
');
+ my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
+ $r->print('
');
}
$r->print(&Apache::loncommon::end_page());
return OK;
@@ -858,7 +870,8 @@ sub print_rolerows {
sub findcourse_advice {
my ($r) = @_;
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
- if (&check_autoenroll($env{'user.domain'})) {
+ 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).'
'.&mt('The course has yet to be created.').'
@@ -870,7 +883,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;
}
@@ -1061,26 +1074,26 @@ 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.selectrole'}})) {
+ if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
$setprivs = 1;
} else {
- my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.selectrole'}});
+ my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}});
if (($start && ($start>$then || $start == -1)) ||
($end && $end<$then)) {
$setprivs = 1;
}
}
if ($setprivs) {
- if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E(/?\w*)$-) {
+ if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
my $role = $1;
my $custom_role = $2;
my $usec = $3;
if ($role eq 'cr') {
- if ($custom_role =~ m-^$match_domain/$match_courseid/\w+$-) {
+ if ($custom_role =~ m-^/$match_domain/$match_username/\w+$-) {
$role .= $custom_role;
} else {
return;
@@ -1280,24 +1293,6 @@ sub courseloadpage {
return $startpage;
}
-sub check_autoenroll {
- my ($dom) = @_;
- my $run_enroll = 0;
- my $settings;
- my %domconfig =
- &Apache::lonnet::get_dom('configuration',['autoenroll'],$dom);
- if (ref($domconfig{'autoenroll'}) eq 'HASH') {
- $settings = $domconfig{'autoenroll'};
- if ($settings->{'run'} eq '1') {
- $run_enroll = 1;
- }
- } else {
- $run_enroll = &localenroll::run($dom);
- }
- return $run_enroll;
-}
-
-
1;
__END__