--- loncom/auth/lonroles.pm 2013/05/10 15:02:45 1.285
+++ loncom/auth/lonroles.pm 2013/06/02 02:21:43 1.287
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.285 2013/05/10 15:02:45 raeburn Exp $
+# $Id: lonroles.pm,v 1.287 2013/06/02 02:21:43 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -723,11 +723,13 @@ ENDENTERKEY
my $crumbtext = 'User Roles';
my $pagetitle = 'My Roles';
my $recent = &mt('Recent Roles');
+ my $standby = &mt('Role selected. Please stand by.');
my $show_course=&Apache::loncommon::show_course();
if ($show_course) {
$crumbtext = 'Courses';
$pagetitle = 'My Courses';
$recent = &mt('Recent Courses');
+ $standby = &mt('Course selected. Please stand by.');
}
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}];
@@ -737,7 +739,6 @@ ENDENTERKEY
my $swinfo=&Apache::lonmenu::rawconfig();
my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
my $funcs = &get_roles_functions($showcount);
- my $standby=&mt('Role selected. Please stand by.');
$standby=~s/\n/\\n/g;
my $noscript='
'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'
'.&mt('As this is not the case, most functionality in the system will be unavailable.').'
';
@@ -2440,9 +2441,11 @@ sub update_session_roles {
&unescape($groupinfo{'description'});
}
$groupdesc = $groupdescs{$cdom.'_'.$cnum}{$group};
- $groupmsg .= '
'.
- &mt('[_1] with status: [_2].',
- ''.$groupdesc.'',$newgroup{$item}).'';
+ if ($groupdesc) {
+ $groupmsg .= ''.
+ &mt('[_1] with status: [_2].',
+ ''.$groupdesc.'',$newgroup{$item}).'';
+ }
}
}
if ($groupmsg) {
@@ -2456,47 +2459,67 @@ sub update_session_roles {
}
}
if (keys(%newrole) > 0) {
- $changemsg .= ''.&mt('New roles').
- '';
+ my $newmsg;
foreach my $item (sort(keys(%newrole))) {
my $desc = &role_desc($item,$update,$refresh,$now);
- $changemsg .= '- '.
- &mt('[_1] with status: [_2].',
- $desc,$newrole{$item}).'
';
+ if ($desc) {
+ $newmsg .= '- '.
+ &mt('[_1] with status: [_2].',
+ $desc,$newrole{$item}).'
';
+ }
+ }
+ if ($newmsg) {
+ $changemsg .= '- '.&mt('New roles').
+ ''.
+ '
';
}
- $changemsg .= '
';
}
if (keys(%customprivchg) > 0) {
- $changemsg .= ''.
- &mt('Custom roles with privilege changes').
- '';
+ my $privmsg;
foreach my $item (sort(keys(%customprivchg))) {
my $desc = &role_desc($item,$update,$refresh,$now);
- $changemsg .= '- '.$desc.'
';
+ if ($desc) {
+ $privmsg .= '- '.$desc.'
';
+ }
}
- $changemsg .= '
';
+ if ($privmsg) {
+ $changemsg .= ''.
+ &mt('Custom roles with privilege changes').
+ ''.
+ '';
+ }
}
if (keys(%rolechange) > 0) {
- $changemsg .= ''.
- &mt('Existing roles with status changes').''.
- '';
+ my $rolemsg;
foreach my $item (sort(keys(%rolechange))) {
my $desc = &role_desc($item,$update,$refresh,$now);
+ if ($desc) {
+ $rolemsg .= '- '.
+ &mt('[_1] status now: [_2].',$desc,
+ $rolechange{$item}).'
';
+ }
+ }
+ if ($rolemsg) {
$changemsg .= '- '.
- &mt('[_1] status now: [_2].',$desc,
- $rolechange{$item}).'
';
+ &mt('Existing roles with status changes').''.
+ ''.
+ '';
}
- $changemsg .= '
';
}
if (keys(%deletedroles) > 0) {
- $changemsg .= ''.
- &mt('Existing roles now expired').''.
- '';
+ my $delmsg;
foreach my $item (sort(keys(%deletedroles))) {
my $desc = &role_desc($item,$update,$refresh,$now);
- $changemsg .= '- '.$desc.'
';
+ if ($desc) {
+ $delmsg .= '- '.$desc.'
';
+ }
+ }
+ if ($delmsg) {
+ $changemsg .= '- '.
+ &mt('Existing roles now expired').'
'.
+ ''.
+ '';
}
- $changemsg .= '
';
}
}
if ((keys(%changed_groups) > 0) || (keys(%groupchange) > 0)) {
@@ -2556,6 +2579,12 @@ sub update_session_roles {
}
if ($changemsg) {
$msg .= '';
+ } else {
+ if (&Apache::loncommon::show_course()) {
+ $msg = &mt('No new courses or communities');
+ } else {
+ $msg = &mt('No role changes');
+ }
}
return $msg;
}
@@ -2567,6 +2596,7 @@ sub role_desc {
&Apache::lonnet::role_status('user.role.'.$item,$update,$refresh,
$now,\$role,\$where,\$trolecode,
\$tstatus,\$tstart,\$tend);
+ return unless ($role);
if ($role =~ /^cr\//) {
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
$tremark = &mt('Customrole defined by [_1].',$rauthor.':'.$rdomain);
@@ -2608,9 +2638,15 @@ sub role_desc {
} elsif ($tdom) {
$twhere = &mt('Domain').': '.$tdom;
}
- my $output = "$trole -- $twhere";
- if ($tremark) {
- $output .= '
'.$tremark;
+ my $output;
+ if ($trole) {
+ $output = $trole;
+ if ($twhere) {
+ $output .= " -- $twhere";
+ }
+ if ($tremark) {
+ $output .= '
'.$tremark;
+ }
}
return $output;
}