version 1.1, 2023/11/03 01:12:15
|
version 1.6, 2024/08/31 21:00:44
|
Line 33 package Apache::lonviewcoauthors;
|
Line 33 package Apache::lonviewcoauthors;
|
use strict; |
use strict; |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::Constants qw(:common :http REDIRECT); |
use Apache::Constants qw(:common :http); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
Line 96 sub handler {
|
Line 96 sub handler {
|
|
|
# Print page header |
# Print page header |
my $args = { 'bread_crumbs' => $brcrum }; |
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)); |
$args)); |
|
|
if (($canedit) && ($env{'form.forceedit'})) { |
if (($canedit) && ($env{'form.forceedit'})) { |
Line 214 sub edit_settings {
|
Line 214 sub edit_settings {
|
} else { |
} else { |
%viewsettings = &retrieve_view_settings($auname,$audom,$role); |
%viewsettings = &retrieve_view_settings($auname,$audom,$role); |
} |
} |
my %userenv = &Apache::lonnet::userenvironment($audom,$auname,'', |
my %userenv = &Apache::lonnet::userenvironment($audom,$auname, |
'coauthorlist','coauthoroptin'); |
'coauthorlist','coauthoroptin'); |
my %titles = &Apache::lonlocal::texthash ( |
my %titles = &Apache::lonlocal::texthash ( |
coauthorlist => 'List availability', |
coauthorlist => 'List availability', |
coauthoroptin => 'User agreement needed for listing', |
coauthoroptin => "Co-author's agreement needed for listing", |
); |
); |
my %options = &Apache::lonlocal::texthash ( |
my %options = &Apache::lonlocal::texthash ( |
role => "List only same type of co-author role as viewer", |
role => "List only same type of co-author role as viewer", |
Line 306 sub edit_settings {
|
Line 306 sub edit_settings {
|
} |
} |
my $forceedit; |
my $forceedit; |
if ($env{'form.forceedit'}) { |
if ($env{'form.forceedit'}) { |
$forceedit = 1; |
$forceedit = 1; |
} |
} |
my $hiddenaction; |
my $hiddenaction; |
if ($caller eq '/adm/createuser') { |
if ($caller eq '/adm/createuser') { |
Line 317 sub edit_settings {
|
Line 317 sub edit_settings {
|
'<input type="hidden" name="caller" value="'.$caller.'" />'."\n". |
'<input type="hidden" name="caller" value="'.$caller.'" />'."\n". |
'<input type="hidden" name="state" value="setconfig" />'."\n". |
'<input type="hidden" name="state" value="setconfig" />'."\n". |
'<input type="hidden" name="forceedit" value="'.$forceedit.'" />'."\n". |
'<input type="hidden" name="forceedit" value="'.$forceedit.'" />'."\n". |
$hiddenaction. |
$hiddenaction. |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
'<th>'.$lt{'set'}.'</th><th>'.$lt{'val'}.'</th>'. |
'<th>'.$lt{'set'}.'</th><th>'.$lt{'val'}.'</th>'. |
Line 351 sub edit_settings {
|
Line 351 sub edit_settings {
|
sub print_coauthors { |
sub print_coauthors { |
my ($r,$auname,$audom,$role,$caller,$settingsref) = @_; |
my ($r,$auname,$audom,$role,$caller,$settingsref) = @_; |
my %viewsettings; |
my %viewsettings; |
if (ref($settingsref) eq 'HASH') { |
if (ref($settingsref) eq 'HASH') { |
%viewsettings = %{$settingsref}; |
%viewsettings = %{$settingsref}; |
} else { |
} else { |
%viewsettings = |
%viewsettings = |
Line 364 sub print_coauthors {
|
Line 364 sub print_coauthors {
|
rol => 'Role(s)', |
rol => 'Role(s)', |
and => 'and', |
and => 'and', |
utd => 'Unable to determine Authoring Space context', |
utd => 'Unable to determine Authoring Space context', |
); |
); |
if (($auname ne '') && ($audom ne '')) { |
if (($auname ne '') && ($audom ne '')) { |
my (%shownstatus,%coauthors); |
my (%shownstatus,%coauthors); |
$r->print("<h3>$lt{'cvl'}</h3>"); |
$r->print("<h3>$lt{'cvl'}</h3>"); |
Line 380 sub print_coauthors {
|
Line 380 sub print_coauthors {
|
my $fullcount = 0; |
my $fullcount = 0; |
my $viewablecount = 0; |
my $viewablecount = 0; |
my $displaycount = 0; |
my $displaycount = 0; |
|
my $getmanagers = 1; |
my ($output,$roletype); |
my ($output,$roletype); |
my @showroles; |
my @showroles; |
if ($env{'request.role'} eq "au./$env{'user.domain'}/") { |
if ($env{'request.role'} eq "au./$env{'user.domain'}/") { |
@showroles = ('ca','aa'); |
@showroles = ('ca','aa'); |
} elsif ($viewsettings{'show'} eq 'role') { |
} elsif ($viewsettings{'show'} eq 'role') { |
($roletype) = ($env{'request.role'} =~ m{^(ca|aa)\./$audom/$auname$}); |
($roletype) = ($env{'request.role'} =~ m{^(ca|aa)\./$audom/$auname$}); |
if ($roletype ne '') { |
if ($roletype ne '') { |
@showroles = ($roletype); |
@showroles = ($roletype); |
|
if ($roletype eq 'aa') { |
|
undef($getmanagers); |
|
} |
} |
} |
} else { |
} else { |
@showroles = ('ca','aa'); |
@showroles = ('ca','aa'); |
} |
} |
my %coauthors = &Apache::lonnet::get_my_roles($auname,$audom,undef,undef, |
my %coauthors = &Apache::lonnet::get_my_roles($auname,$audom,undef,undef, |
\@showroles,[$audom]); |
\@showroles); |
my (%userinfo,%showuser); |
my (%userinfo,%showuser); |
foreach my $item (keys(%coauthors)) { |
foreach my $item (keys(%coauthors)) { |
my ($username,$domain,$userrole) = split(/:/,$item); |
my ($username,$domain,$userrole) = split(/:/,$item); |
|
next if (($username eq '') && ($domain eq'')); |
my ($start,$end) = split(/:/,$coauthors{$item}); |
my ($start,$end) = split(/:/,$coauthors{$item}); |
next if ($start eq '-1' && $end eq '-1'); |
next if ($start eq '-1' && $end eq '-1'); |
if (ref($userinfo{$username.':'.$domain}) eq 'HASH') { |
if (ref($userinfo{$username.':'.$domain}) eq 'HASH') { |
Line 408 sub print_coauthors {
|
Line 413 sub print_coauthors {
|
$userinfo{$username.':'.$domain}{roles} = [$userrole]; |
$userinfo{$username.':'.$domain}{roles} = [$userrole]; |
} |
} |
} else { |
} else { |
$userinfo{$username.':'.$domain}{fullname} = |
$userinfo{$username.':'.$domain}{fullname} = |
&Apache::loncommon::plainname($username,$domain,'lastname'); |
&Apache::loncommon::plainname($username,$domain,'lastname'); |
$userinfo{$username.':'.$domain}{roles} = [$userrole]; |
$userinfo{$username.':'.$domain}{roles} = [$userrole]; |
} |
} |
Line 436 sub print_coauthors {
|
Line 441 sub print_coauthors {
|
&Apache::lonnet::plaintext($roletype)); |
&Apache::lonnet::plaintext($roletype)); |
} else { |
} else { |
$output = &mt('The one user with a [_1] or [_2] role has opted not to be listed.', |
$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 { |
} else { |
if ($roletype) { |
if ($roletype) { |
Line 455 sub print_coauthors {
|
Line 460 sub print_coauthors {
|
$fullcount,&Apache::lonnet::plaintext($roletype)); |
$fullcount,&Apache::lonnet::plaintext($roletype)); |
} else { |
} else { |
$output = &mt('All [_1] users with a [_2] or [_3] role have opted to be listed.', |
$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) { |
} elsif ($fullcount == 1) { |
if ($roletype) { |
if ($roletype) { |
Line 515 sub print_coauthors {
|
Line 520 sub print_coauthors {
|
} |
} |
$table .= &Apache::loncommon::end_data_table_header_row()."\n"; |
$table .= &Apache::loncommon::end_data_table_header_row()."\n"; |
my $count = 0; |
my $count = 0; |
|
my %camanagers; |
|
if ($getmanagers) { |
|
my %userenv = &Apache::lonnet::userenvironment($audom,$auname, |
|
'authormanagers'); |
|
map { $camanagers{$_} = 1; } split(/,/,$userenv{'authormanagers'}); |
|
} |
my @sorted = sort { |
my @sorted = sort { |
lc($showuser{$a}{fullname}) cmp lc($showuser{$b}{fullname}) |
lc($showuser{$a}{fullname}) cmp lc($showuser{$b}{fullname}) |
} (keys(%showuser)); |
} (keys(%showuser)); |
foreach my $user (@sorted) { |
foreach my $user (@sorted) { |
my ($username,$domain) = split(/:/,$user); |
my ($username,$domain) = split(/:/,$user); |
$count ++; |
$count ++; |
$table .= &Apache::loncommon::start_data_table_row()."\n". |
$table .= &Apache::loncommon::start_data_table_row()."\n". |
'<td>'.$count.'</td>'. |
'<td>'.$count.'</td>'. |
'<td>'.&Apache::loncommon::aboutmewrapper($showuser{$user}{fullname}, |
'<td>'; |
$username,$domain). |
if ($camanagers{$user}) { |
|
$table .= '<span style="font-face:bold;">*</span>'; |
|
} else { |
|
$table .= ' 'x2; |
|
} |
|
$table .= &Apache::loncommon::aboutmewrapper($showuser{$user}{fullname}, |
|
$username,$domain). |
'</td>'. |
'</td>'. |
'<td>'.&Apache::loncommon::messagewrapper |
'<td>'.&Apache::loncommon::messagewrapper |
('<img src="/adm/lonIcons/mailto.gif" border="0" /> '. |
('<img src="/adm/lonIcons/mailto.gif" border="0" /> '. |
Line 532 sub print_coauthors {
|
Line 549 sub print_coauthors {
|
'</td>'; |
'</td>'; |
unless ($roletype) { |
unless ($roletype) { |
$table .= '<td>'. |
$table .= '<td>'. |
join(" $lt{'and'} ", map { &Apache::lonnet::plaintext($_); } |
join(" $lt{'and'} ", map { &Apache::lonnet::plaintext($_); } |
@{$showuser{$user}{roles}}). |
@{$showuser{$user}{roles}}). |
'</td>'; |
'</td>'; |
} |
} |
Line 540 sub print_coauthors {
|
Line 557 sub print_coauthors {
|
} |
} |
$table .= &Apache::loncommon::end_data_table()."\n"; |
$table .= &Apache::loncommon::end_data_table()."\n"; |
$r->print($table); |
$r->print($table); |
|
if (keys(%camanagers)) { |
|
$r->print('<br /><span class="LC_fontsize_medium">'. |
|
&mt('[_1]*[_2] indicates co-author can add/revoke co-author roles', |
|
'<span style="font-face:bold;">','</span>'). |
|
'</span>'); |
|
} |
} else { |
} else { |
$r->print('<div class="LC_info">'.$output.'</div>'); |
$r->print('<div class="LC_info">'.$output.'</div>'); |
} |
} |