--- loncom/interface/loncreateuser.pm 2023/11/03 21:40:22 1.471
+++ loncom/interface/loncreateuser.pm 2025/01/13 01:00:58 1.483
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.471 2023/11/03 21:40:22 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.483 2025/01/13 01:00:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -245,10 +245,15 @@ function toggleCustom(form,item,name) {
if (radioname) {
if (radioname.length > 0) {
var setvis;
+ var RegExp = /^customtext_(aboutme|blog|portfolio|portaccess|timezone|webdav|archive)\$/;
for (var i=0; i
'.&Apache::lonuserutils::forceid_change($context);
}
} else {
- $row .= $userenv{$item};
+ if ($env{'request.role.domain'} ne $ccdomain) {
+ if ($shownfields{$item}) {
+ $row .= $userenv{$item};
+ } else {
+ $row .= &mt('not shown');
+ }
+ } else {
+ $row .= $userenv{$item};
+ }
}
}
$row .= &Apache::lonhtmlcommon::row_closure(1);
@@ -3230,7 +3279,7 @@ sub update_user_data {
my @usertools = ('aboutme','blog','portfolio','portaccess','timezone');
my @requestcourses = ('official','unofficial','community','textbook','placement','lti');
my @requestauthor = ('requestauthor');
- my @authordefaults = ('webdav','editors');
+ my @authordefaults = ('webdav','editors','archive');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
my %canmodify_status =
@@ -3360,7 +3409,13 @@ sub update_user_data {
if ($env{'form.customwebdav'} == 1) {
$newcustom{'webdav'} = $env{'form.authordefaults_webdav'};
$changed{'webdav'} = &tool_admin('webdav',$newcustom{'webdav'},
- \%changeHash,'authordefaults');
+ \%changeHash,'authordefaults');
+ }
+ if ($env{'form.customarchive'} == 1) {
+ $newcustom{'archive'} = $env{'form.authordefaults_archive'};
+ $changed{'archive'} = &tool_admin('archive',$newcustom{'archive'},
+ \%changeHash,'authordefaults');
+
}
}
if ($canmodify_status{'inststatus'}) {
@@ -3429,7 +3484,7 @@ sub update_user_data {
'id','permanentemail','portfolioquota','authorquota','inststatus',
'tools.aboutme','tools.blog','tools.webdav',
'tools.portfolio','tools.timezone','tools.portaccess',
- 'authormanagers','authoreditors','requestauthor',
+ 'authormanagers','authoreditors','authorarchive','requestauthor',
'requestcourses.official','requestcourses.unofficial',
'requestcourses.community','requestcourses.textbook',
'requestcourses.placement','requestcourses.lti',
@@ -3781,7 +3836,10 @@ sub update_user_data {
}
if (($env{'user.name'} eq $env{'form.ccuname'}) &&
($env{'user.domain'} eq $env{'form.ccdomain'})) {
- my %newenvhash;
+ my (%newenvhash,$got_domdefs,%domdefaults,$got_userenv,
+ %userenv);
+ my @fromenv = keys(%changed);
+ push(@fromenv,'inststatus');
foreach my $key (keys(%changed)) {
if (($key eq 'official') || ($key eq 'unofficial') ||
($key eq 'community') || ($key eq 'textbook') ||
@@ -3791,29 +3849,71 @@ sub update_user_data {
if ($changeHash{'requestcourses.'.$key}) {
$newenvhash{'environment.canrequest.'.$key} = 1;
} else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ unless ($got_userenv) {
+ %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'},@fromenv);
+ $got_userenv = 1;
+ }
$newenvhash{'environment.canrequest.'.$key} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
- $key,'reload','requestcourses');
+ $key,'reload','requestcourses',\%userenv,\%domdefaults);
}
} elsif ($key eq 'requestauthor') {
$newenvhash{'environment.'.$key} = $changeHash{$key};
if ($changeHash{$key}) {
$newenvhash{'environment.canrequest.author'} = 1;
} else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ unless ($got_userenv) {
+ %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'},@fromenv);
+ $got_userenv = 1;
+ }
$newenvhash{'environment.canrequest.author'} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
- $key,'reload','requestauthor');
+ $key,'reload','requestauthor',\%userenv,\%domdefaults);
}
} elsif ($key eq 'editors') {
$newenvhash{'environment.author'.$key} = $changeHash{'author'.$key};
- if ($key eq 'editors') {
- if ($env{'form.customeditors'}) {
- $newenvhash{'environment.editors'} = $changeHash{'author'.$key};
+ if ($env{'form.customeditors'}) {
+ $newenvhash{'environment.editors'} = $changeHash{'author'.$key};
+ } else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ if ($domdefaults{'editors'} ne '') {
+ $newenvhash{'environment.editors'} = $domdefaults{'editors'};
} else {
- $newenvhash{'environment.editors'} =
- &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
- $key,'reload','authordefaults');
+ $newenvhash{'environment.editors'} = 'edit,xml';
+ }
+ }
+ } elsif ($key eq 'archive') {
+ $newenvhash{'environment.author.'.$key} =
+ $changeHash{'author.'.$key};
+ if ($changeHash{'author.'.$key} ne '') {
+ $newenvhash{'environment.canarchive'} =
+ $changeHash{'author.'.$key};
+ } else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
}
+ $newenvhash{'environment.canarchive'} =
+ $domdefaults{'archive'};
}
} elsif ($key ne 'quota') {
$newenvhash{'environment.tools.'.$key} =
@@ -3822,9 +3922,20 @@ sub update_user_data {
$newenvhash{'environment.availabletools.'.$key} =
$changeHash{'tools.'.$key};
} else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ unless ($got_userenv) {
+ %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'},@fromenv);
+ $got_userenv = 1;
+ }
$newenvhash{'environment.availabletools.'.$key} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
- $key,'reload','tools');
+ $key,'reload','tools',\%userenv,\%domdefaults);
}
}
}
@@ -4025,7 +4136,8 @@ sub display_userinfo {
'prvs' => 'Previous Value:',
'chto' => 'Changed To:',
'editors' => "Available Editors in Authoring Space",
- 'managers' => "Co-authors who can add/revoke co-authors",
+ 'managers' => "Co-authors who can add/revoke roles",
+ 'archive' => "Managers can download tar.gz file of Authoring Space",
'edit' => 'Standard editor (Edit)',
'xml' => 'Text editor (EditXML)',
'daxe' => 'Daxe editor (Daxe)',
@@ -4059,7 +4171,7 @@ sub display_userinfo {
if ($entry eq 'requestauthor') {
@items = ($entry);
} elsif ($entry eq 'authordefaults') {
- @items = ('webdav','managers','editors');
+ @items = ('webdav','managers','editors','archive');
} else {
@items = @{$requestcourses};
}
@@ -4310,6 +4422,9 @@ sub tool_changes {
} elsif ($tool eq 'webdav') {
$envkey = 'tools.webdav';
$newval = $env{'form.'.$context.'_'.$tool};
+ } elsif ($tool eq 'archive') {
+ $envkey = 'authorarchive';
+ $newval = $env{'form.'.$context.'_'.$tool};
}
} else {
$newval = $env{'form.'.$context.'_'.$tool};
@@ -4341,7 +4456,7 @@ sub tool_changes {
} elsif ($tool eq 'editors') {
$oldaccesstext->{$tool} = &mt('can use: [_1]',
join(', ', map { $tooldesc{$_} } split(/,/,$userenv->{$envkey})));
- } elsif ($tool eq 'webdav') {
+ } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {
if ($userenv->{$envkey}) {
$oldaccesstext->{$tool} = &mt("availability set to 'on'");
} else {
@@ -4387,7 +4502,7 @@ sub tool_changes {
$managers =~ s/,/, /g;
$newaccesstext->{$tool} = $managers;
}
- } elsif ($tool eq 'webdav') {
+ } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {
if ($newval) {
$newaccesstext->{$tool} = &mt("availability set to 'on'");
} else {
@@ -4427,7 +4542,7 @@ sub tool_changes {
$managers =~ s/,/, /g;
$newaccesstext->{$tool} = $managers;
}
- } elsif ($tool eq 'webdav') {
+ } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {
if ($userenv->{$envkey}) {
$newaccesstext->{$tool} = &mt("availability set to 'on'");
} else {
@@ -4476,7 +4591,7 @@ sub tool_changes {
$managers =~ s/,/, /g;
$newaccesstext->{$tool} = $managers;
}
- } elsif ($tool eq 'webdav') {
+ } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {
if ($userenv->{$envkey}) {
$newaccesstext->{$tool} = &mt("availability set to 'on'");
} else {
@@ -4524,7 +4639,7 @@ sub tool_changes {
} elsif ($tool eq 'editors') {
$newaccesstext->{$tool} = &mt('can use: [_1]',
join(', ', map { $tooldesc{$_} } split(/,/,$newval)));
- } elsif ($tool eq 'webdav') {
+ } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {
if ($newval) {
$newaccesstext->{$tool} = &mt("availability set to 'on'");
} else {
@@ -5188,7 +5303,7 @@ sub tool_admin {
$toolchanged = 1;
if ($tool eq 'requestauthor') {
$changeHash->{$context} = $settool;
- } elsif (($tool eq 'managers') || ($tool eq 'editors')) {
+ } elsif (($tool eq 'managers') || ($tool eq 'editors') || ($tool eq 'archive')) {
$changeHash->{'author'.$tool} = $settool;
} elsif ($tool eq 'webdav') {
$changeHash->{'tools.'.$tool} = $settool;
@@ -5506,7 +5621,7 @@ sub display_coauthor_managers {
}
$output .= "
'.&mt('Select manager(s)').': '; + $output .= '
'.&mt('If checked, can manage').': '; foreach my $user (@possmanagers) { my $checked; if (grep(/^\Q$user\E$/,@custommanagers)) { @@ -6350,7 +6465,7 @@ sub handler { if (($permission->{cusr}) && ($context eq 'author')) { push(@{$brcrum}, {href => '/adm/createuser?action=camanagers', - text => 'Co-authors who manage', + text => 'Co-author Managers', help => 'Author_Manage_Coauthors'}); if ($env{'form.state'} eq 'process') { push(@{$brcrum}, @@ -6404,6 +6519,27 @@ sub handler { $r->internal_redirect('/adm/viewcoauthors'); return OK; } + } elsif (($env{'form.action'} eq 'setenv') && ($context eq 'author')) { + my ($role,$audom,$auname,$canview,$canedit) = + &Apache::lonviewcoauthors::get_allowable(); + push(@{$brcrum}, + {href => '/adm/createuser?action=calist', + text => 'Coauthor-viewable list', + help => 'Author_List_Coauthors'}); + my $args = { 'bread_crumbs' => $brcrum }; + $r->print(&Apache::loncommon::start_page('Coauthor-viewable list',undef, + $args)); + my %viewsettings = + &Apache::lonviewcoauthors::retrieve_view_settings($auname,$audom,$role); + if ($viewsettings{'show'} eq 'none') { + $r->print('
'. + &mt('Listing of co-authors not enabled for this Authoring Space'). + '
'); + } else { + &Apache::lonviewcoauthors::print_coauthors($r,$auname,$audom,$role, + '/adm/createuser',\%viewsettings); + } } else { $bread_crumbs_component = 'User Management'; $args = { bread_crumbs => $brcrum, @@ -6510,6 +6646,15 @@ function updateCols(caller) { document.getElementById('showcolstart').checked = false; document.getElementById('showcolend').checked = false; } + if (context == 'author') { + if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Expired') { + document.getElementById('showcolmanager').checked = false; + document.getElementById('showcolmanager').disabled = 'disabled'; + } else if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value != 'aa') { + document.getElementById('showcolmanager').checked = true; + document.getElementById('showcolmanager').disabled = ''; + } + } } } if (caller == 'output') { @@ -6595,6 +6740,15 @@ function updateCols(caller) { } } } + if (context == 'author') { + if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'aa') { + document.getElementById('showcolmanager').checked = false; + document.getElementById('showcolmanager').disabled = 'disabled'; + } else if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value != 'Expired') { + document.getElementById('showcolmanager').checked = true; + document.getElementById('showcolmanager').disabled = ''; + } + } } return; } @@ -6890,6 +7044,27 @@ sub print_main_menu { ); } } elsif ($context eq 'author') { + my $coauthorlist; + if ($env{'request.role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) { + if ($env{'environment.internal.coauthorlist./'.$1.'/'.$2}) { + $coauthorlist = 1; + } + } elsif ($env{'request.role'} eq "au./$env{'user.domain'}/") { + if ($env{'environment.coauthorlist'}) { + $coauthorlist = 1; + } + } + if ($coauthorlist) { + push(@{ $menu[1]->{items} }, + { + linktext => 'Co-author-viewable list', + icon => 'clst.png', + #help => 'Coauthor_Listing', + url => '/adm/createuser?action=calist&forceedit=0', + permission => $permission->{'cusr'}, + linktitle => 'Co-author-viewable listing', + }); + } push(@{ $menu[2]->{items} }, #Category: Administration { linktext => 'Change Log', @@ -6900,16 +7075,16 @@ sub print_main_menu { linktitle => 'View change log.', }, { - linktext => 'Co-authors who can add/revoke co-author roles', - icon => 'helpdesk-access.png', + linktext => 'Co-author Managers', + icon => 'camanager.png', #help => 'Coauthor_Management', url => '/adm/createuser?action=camanagers', permission => $permission->{'author'}, linktitle => 'Assign/Revoke right to manage co-author roles', }, { - linktext => 'Configure coauthor-viewable listing', - icon => 'helpdesk-access.png', + linktext => 'Configure Co-author Listing', + icon => 'coauthors.png', #help => 'Coauthor_Settings', url => '/adm/createuser?action=calist&forceedit=1', permission => ($permission->{'cusr'}),