--- loncom/interface/lonviewcoauthors.pm 2023/11/03 01:12:15 1.1
+++ loncom/interface/lonviewcoauthors.pm 2023/11/04 01:56:04 1.3
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to display the coauthors
#
-# $Id: lonviewcoauthors.pm,v 1.1 2023/11/03 01:12:15 raeburn Exp $
+# $Id: lonviewcoauthors.pm,v 1.3 2023/11/04 01:56:04 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,7 +33,7 @@ package Apache::lonviewcoauthors;
use strict;
use Apache::loncommon();
use Apache::lonhtmlcommon();
-use Apache::Constants qw(:common :http REDIRECT);
+use Apache::Constants qw(:common :http);
use Apache::lonlocal;
use Apache::lonnet;
use LONCAPA qw(:DEFAULT :match);
@@ -214,7 +214,7 @@ sub edit_settings {
} else {
%viewsettings = &retrieve_view_settings($auname,$audom,$role);
}
- my %userenv = &Apache::lonnet::userenvironment($audom,$auname,'',
+ my %userenv = &Apache::lonnet::userenvironment($audom,$auname,
'coauthorlist','coauthoroptin');
my %titles = &Apache::lonlocal::texthash (
coauthorlist => 'List availability',
@@ -306,7 +306,7 @@ sub edit_settings {
}
my $forceedit;
if ($env{'form.forceedit'}) {
- $forceedit = 1;
+ $forceedit = 1;
}
my $hiddenaction;
if ($caller eq '/adm/createuser') {
@@ -317,7 +317,7 @@ sub edit_settings {
''."\n".
''."\n".
''."\n".
- $hiddenaction.
+ $hiddenaction.
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
'
'.$lt{'set'}.'
'.$lt{'val'}.'
'.
@@ -351,7 +351,7 @@ sub edit_settings {
sub print_coauthors {
my ($r,$auname,$audom,$role,$caller,$settingsref) = @_;
my %viewsettings;
- if (ref($settingsref) eq 'HASH') {
+ if (ref($settingsref) eq 'HASH') {
%viewsettings = %{$settingsref};
} else {
%viewsettings =
@@ -364,7 +364,7 @@ sub print_coauthors {
rol => 'Role(s)',
and => 'and',
utd => 'Unable to determine Authoring Space context',
- );
+ );
if (($auname ne '') && ($audom ne '')) {
my (%shownstatus,%coauthors);
$r->print("
$lt{'cvl'}
");
@@ -380,14 +380,18 @@ sub print_coauthors {
my $fullcount = 0;
my $viewablecount = 0;
my $displaycount = 0;
+ my $getmanagers = 1;
my ($output,$roletype);
my @showroles;
if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
- @showroles = ('ca','aa');
+ @showroles = ('ca','aa');
} elsif ($viewsettings{'show'} eq 'role') {
($roletype) = ($env{'request.role'} =~ m{^(ca|aa)\./$audom/$auname$});
if ($roletype ne '') {
@showroles = ($roletype);
+ if ($roletype eq 'aa') {
+ undef($getmanagers);
+ }
}
} else {
@showroles = ('ca','aa');
@@ -408,7 +412,7 @@ sub print_coauthors {
$userinfo{$username.':'.$domain}{roles} = [$userrole];
}
} else {
- $userinfo{$username.':'.$domain}{fullname} =
+ $userinfo{$username.':'.$domain}{fullname} =
&Apache::loncommon::plainname($username,$domain,'lastname');
$userinfo{$username.':'.$domain}{roles} = [$userrole];
}
@@ -436,7 +440,7 @@ sub print_coauthors {
&Apache::lonnet::plaintext($roletype));
} else {
$output = &mt('The one user with a [_1] or [_2] role has opted not to be listed.',
- $rolenames[0],$rolenames[1]);
+ $rolenames[0],$rolenames[1]);
}
} else {
if ($roletype) {
@@ -455,7 +459,7 @@ sub print_coauthors {
$fullcount,&Apache::lonnet::plaintext($roletype));
} else {
$output = &mt('All [_1] users with a [_2] or [_3] role have opted to be listed.',
- $fullcount,$rolenames[0],$rolenames[1]);
+ $fullcount,$rolenames[0],$rolenames[1]);
}
} elsif ($fullcount == 1) {
if ($roletype) {
@@ -515,16 +519,28 @@ sub print_coauthors {
}
$table .= &Apache::loncommon::end_data_table_header_row()."\n";
my $count = 0;
+ my %camanagers;
+ if ($getmanagers) {
+ my %userenv = &Apache::lonnet::userenvironment($audom,$auname,
+ 'authormanagers');
+ map { $camanagers{$_} = 1; } split(/,/,$userenv{'authormanagers'});
+ }
my @sorted = sort {
lc($showuser{$a}{fullname}) cmp lc($showuser{$b}{fullname})
} (keys(%showuser));
foreach my $user (@sorted) {
my ($username,$domain) = split(/:/,$user);
- $count ++;
+ $count ++;
$table .= &Apache::loncommon::start_data_table_row()."\n".
'