--- loncom/interface/loncreateuser.pm 2024/02/29 16:28:35 1.476 +++ 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.476 2024/02/29 16:28:35 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.483 2025/01/13 01:00:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -245,7 +245,7 @@ function toggleCustom(form,item,name) { if (radioname) { if (radioname.length > 0) { var setvis; - var RegExp = /^customtext_(aboutme|blog|portfolio|portaccess|timezone|webdav)\$/; + var RegExp = /^customtext_(aboutme|blog|portfolio|portaccess|timezone|webdav|archive)\$/; for (var i=0; i "WebDAV access to Authoring Spaces (https)", 'editors' => "Available Editors", 'managers' => "Co-authors who can add/revoke roles", + 'archive' => "Managers can download tar.gz file of Authoring Space", 'portfolio' => "Personal User Portfolio", 'portaccess' => "Portfolio Shareable", 'timezone' => "Can set Time Zone", @@ -330,8 +331,8 @@ sub build_tools_display { &Apache::lonnet::get_dom('configuration',['quotas','authordefaults'],$ccdomain); %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,'tools.webdav', 'authoreditors','authormanagers', - 'domcoord.author'); - @usertools = ('webdav','editors','managers'); + 'authorarchive','domcoord.author'); + @usertools = ('webdav','editors','managers','archive'); $colspan = ' colspan="2"'; } else { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, @@ -345,7 +346,7 @@ sub build_tools_display { $currdisp,$custdisp,$custradio,$onclick,$customsty,$editorsty); $cust_off = 'checked="checked" '; $tool_on = 'checked="checked" '; - unless (($context eq 'authordefaults') && ($item ne 'webdav')) { + unless (($context eq 'authordefaults') || ($item eq 'webdav')) { $curr_access = &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, $context,\%userenv,'', @@ -357,15 +358,29 @@ sub build_tools_display { $cust_off = ''; } } elsif ($context eq 'authordefaults') { - if ($item eq 'editors') { + if (($item eq 'editors') || ($item eq 'archive')) { if ($userenv{'author'.$item} ne '') { $cust_on = ' checked="checked" '; $cust_off = ''; + if ($item eq 'archive') { + $curr_access = $userenv{'author'.$item}; + } + } elsif ($item eq 'archive') { + $curr_access = 0; + if (ref($domconfig{'authordefaults'}) eq 'HASH') { + $curr_access = $domconfig{'authordefaults'}{'archive'}; + } } } elsif ($item eq 'webdav') { if ($userenv{'tools.'.$item} ne '') { $cust_on = ' checked="checked" '; $cust_off = ''; + $curr_access = $userenv{'tools.'.$item}; + } else { + $curr_access = + &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,'reload', + undef,\%userenv,'', + {'is_adv' => $isadv}); } } } elsif ($userenv{$context.'.'.$item} ne '') { @@ -457,6 +472,8 @@ sub build_tools_display { my $current = $userenv{$context.'.'.$item}; if ($item eq 'webdav') { $current = $userenv{'tools.webdav'}; + } elsif ($item eq 'archive') { + $current = $userenv{'author'.$item}; } if ($current eq '') { $custom_access = @@ -1514,6 +1531,7 @@ sub print_user_modification_page { 'bread_crumbs_component' => 'User Management'}; if ($env{'form.popup'}) { $args->{'no_nav_bar'} = 1; + $args->{'add_modal'} = 1; } if (($context eq 'domain') && ($env{'request.role.domain'} eq $ccdomain)) { my @toggles; @@ -1523,7 +1541,7 @@ sub print_user_modification_page { unless ($isauthor) { push(@toggles,'requestauthor'); } - push(@toggles,('webdav','editors')); + push(@toggles,('webdav','editors','archive')); } if (&Apache::lonnet::allowed('mut',$ccdomain)) { push(@toggles,('aboutme','blog','portfolio','portaccess','timezone')); @@ -2899,6 +2917,24 @@ sub personal_data_display { $rowcount ++; } } + my %shownfields; + if ($env{'request.role.domain'} ne $ccdomain) { + my %shownfields_by_type = + &Apache::lonuserutils::get_othdom_shownfields($ccdomain,\@userinfo); + my @types = split(/:/,$userenv{'inststatus'}); + if (@types == 0) { + @types = ('default'); + } + foreach my $type (@types) { + if (ref($shownfields_by_type{$type}) eq 'HASH') { + foreach my $field (keys(%{$shownfields_by_type{$type}})) { + if ($shownfields_by_type{$type}{$field}) { + $shownfields{$field} = 1; + } + } + } + } + } foreach my $item (@userinfo) { my $rowtitle = $lt{$item}; my $hiderow = 0; @@ -2945,7 +2981,15 @@ sub personal_data_display { $row .= '
'.&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); @@ -3235,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 = @@ -3365,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'}) { @@ -3434,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', @@ -3850,6 +3900,21 @@ sub update_user_data { $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} = $changeHash{'tools.'.$key}; @@ -4072,6 +4137,7 @@ sub display_userinfo { 'chto' => 'Changed To:', 'editors' => "Available Editors in Authoring Space", '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)', @@ -4105,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}; } @@ -4356,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}; @@ -4387,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 { @@ -4433,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 { @@ -4473,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 { @@ -4522,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 { @@ -4570,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 { @@ -5234,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; @@ -6450,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('Coauthor-viewable listing').'

'. + '

'. + &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, @@ -6954,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',