--- loncom/interface/lonviewcoauthors.pm 2023/11/03 01:12:15 1.1
+++ loncom/interface/lonviewcoauthors.pm 2024/08/31 21:00:44 1.6
@@ -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.6 2024/08/31 21:00:44 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);
@@ -96,7 +96,7 @@ sub handler {
# Print page header
my $args = { 'bread_crumbs' => $brcrum };
- $r->print(&Apache::loncommon::start_page('Co-authors listing',undef,
+ $r->print(&Apache::loncommon::start_page('Co-author listing',undef,
$args));
if (($canedit) && ($env{'form.forceedit'})) {
@@ -214,11 +214,11 @@ 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',
- coauthoroptin => 'User agreement needed for listing',
+ coauthoroptin => "Co-author's agreement needed for listing",
);
my %options = &Apache::lonlocal::texthash (
role => "List only same type of co-author role as viewer",
@@ -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,23 +380,28 @@ 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');
}
my %coauthors = &Apache::lonnet::get_my_roles($auname,$audom,undef,undef,
- \@showroles,[$audom]);
+ \@showroles);
my (%userinfo,%showuser);
foreach my $item (keys(%coauthors)) {
my ($username,$domain,$userrole) = split(/:/,$item);
+ next if (($username eq '') && ($domain eq''));
my ($start,$end) = split(/:/,$coauthors{$item});
next if ($start eq '-1' && $end eq '-1');
if (ref($userinfo{$username.':'.$domain}) eq 'HASH') {
@@ -408,7 +413,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 +441,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 +460,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 +520,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".
'