--- loncom/auth/lonroles.pm 2005/11/11 18:47:09 1.134
+++ loncom/auth/lonroles.pm 2006/01/06 21:04:33 1.145
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.134 2005/11/11 18:47:09 www Exp $
+# $Id: lonroles.pm,v 1.145 2006/01/06 21:04:33 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -51,7 +51,7 @@ sub redirect_user {
my $navwindow;
if ($launch_nav eq 'on') {
$navwindow.=&Apache::lonnavmaps::launch_win('now',undef,undef,
- ($url eq '/adm/whatsnew'));
+ ($url =~ m-^/adm/whatsnew-));
} else {
$navwindow.=&Apache::lonnavmaps::close();
}
@@ -126,6 +126,11 @@ sub handler {
if ($tstatus eq 'is') {
$where=~s/^\///;
my ($cdom,$cnum,$csec)=split(/\//,$where);
+# check for course groups
+ my %coursegroups = &Apache::lonnet::get_active_groups(
+ $env{'user.domain'},$env{'user.name'},$cdom, $cnum);
+ my $cgrps = join(':',keys(%coursegroups));
+
# store role if recent_role list being kept
if ($env{'environment.recentroles'}) {
&Apache::lonhtmlcommon::store_recent('roles',
@@ -227,7 +232,8 @@ ENDENTERKEY
&Apache::lonnet::appenv(
'request.role' => $trolecode,
'request.role.domain' => $cdom,
- 'request.course.sec' => $csec);
+ 'request.course.sec' => $csec,
+ 'request.course.groups' => $cgrps);
my $tadv=0;
my $msg=&mt('Entering course ...');
@@ -265,13 +271,22 @@ ENDENTERKEY
'.course.helper.not.run'}) {
$furl = "/adm/helper/course.initialization.helper";
# Send the user to the course they selected
- } elsif (($env{'request.course.fn'})
- && ($role eq 'cc' && ($env{'environment.course_init_display'} ne 'firstres'))) {
- $msg = &mt('Entering course ....');
- &redirect_user($r,&mt('New in course'),
- '/adm/whatsnew',$msg,
- $env{'environment.remotenavmap'});
- return OK;
+ } elsif ($env{'request.course.id'}) {
+ if (&Apache::lonnet::allowed('whn',
+ $env{'request.course.id'})
+ || &Apache::lonnet::allowed('whn',
+ $env{'request.course.id'}.'/'
+ .$env{'request.course.sec'})
+ ) {
+ my $startpage = &courseloadpage($courseid);
+ unless ($startpage eq 'firstres') {
+ $msg = &mt('Entering course ....');
+ &redirect_user($r,&mt('New in course'),
+ '/adm/whatsnew?refpage=start',$msg,
+ $env{'environment.remotenavmap'});
+ return OK;
+ }
+ }
}
&redirect_user($r,&mt('Entering Course'),
$furl,$msg,
@@ -316,6 +331,7 @@ ENDENTERKEY
my $swinfo=&Apache::lonmenu::rawconfig();
my $bodytag=&Apache::loncommon::bodytag('User Roles');
my $standby=&mt('Role selected. Please stand by.');
+ $standby=~s/\n/\\n/g;
my $helptag='
'.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,undef,undef,undef,undef,,&mt("Click here for help")).' |
';
$r->print(<
@@ -435,7 +451,7 @@ ENDHEADER
if ($envkey=~/^user\.role\./) {
my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
&role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
- next if (!defined($role) || $role eq '');
+ next if (!defined($role) || $role eq '' || $role =~ /^gr/);
$tremark='';
$tpstart=' ';
$tpend=' ';
@@ -519,11 +535,7 @@ ENDHEADER
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
$button=0;
- $switchserver=&Apache::lonnet::escape('http://'.
- $Apache::lonnet::hostname{$home}.
- '/adm/login?domain='.$env{'user.domain'}.
- '&username='.$env{'user.name'}.
- '&firsturl=/priv/'.$env{'user.name'}.'/');
+ $switchserver='otherserver='.$home.'&role='.$trolecode;
}
#next if ($home eq 'no_host');
$home = $Apache::lonnet::hostname{$home};
@@ -629,7 +641,7 @@ ENDHEADER
if (defined($roletext{'user.role.'.$_})) {
$output.=$roletext{'user.role.'.$_};
if ($_ =~ m-dc\./(\w+)/- && $dcroles{$1}) {
- $output .= &allcourses_row($1);
+ $output .= &allcourses_row($1,'recent');
}
} elsif ($numdc > 0) {
unless ($_ =~/^error\:/) {
@@ -657,7 +669,7 @@ ENDHEADER
$output.=$roletext{$sortrole{$which}};
if ($sortrole{$which} =~ m-dc\./(\w+)/-) {
if ($dcroles{$1}) {
- $output .= &allcourses_row($1);
+ $output .= &allcourses_row($1,'');
}
}
}
@@ -869,13 +881,13 @@ sub check_fordc {
}
sub courselink {
- my ($dcdom) = @_;
+ my ($dcdom,$rowtype) = @_;
my $courseform=&Apache::loncommon::selectcourse_link
- ('rolechoice','dccourse_'.$dcdom,'dcdomain_'.$dcdom,'coursedesc_'.$dcdom,$dcdom);
- my $hiddenitems = ''.
- ''.
- ''.
- '';
+ ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.$dcdom,$dcdom);
+ my $hiddenitems = ''.
+ ''.
+ ''.
+ '';
return $courseform.$hiddenitems;
}
@@ -916,34 +928,26 @@ END
}
sub processpick {
- my $dcdom = shift;
my $process_pick = <<"END";
END
return $process_pick;
@@ -980,12 +984,10 @@ sub display_cc_role {
}
sub allcourses_row {
- my $dcdom = shift;
+ my ($dcdom,$rowtype) = @_;
my $ccrole = Apache::lonnet::plaintext('cc');
- my $selectlink = &courselink($dcdom);
+ my $selectlink = &courselink($dcdom,$rowtype);
my $output = ''.
- ''.
- ''.
''.
''.$ccrole.''.
' '.$selectlink.''.
@@ -1028,6 +1030,23 @@ sub set_privileges {
&Apache::lonnet::appenv('request.role.adv' => $tadv);
}
+sub courseloadpage {
+ my ($courseid) = @_;
+ my $startpage;
+ my %entry_settings = &Apache::lonnet::get('nohist_whatsnew',
+ [$courseid.':courseinit']);
+ my ($tmp) = %entry_settings;
+ unless ($tmp =~ /^error: 2 /) {
+ $startpage = $entry_settings{$courseid.':courseinit'};
+ }
+ if ($startpage eq '') {
+ if (exists($env{'environment.course_init_display'})) {
+ $startpage = $env{'environment.course_init_display'};
+ }
+ }
+ return $startpage;
+}
+
1;
__END__
|