--- loncom/interface/loncreateuser.pm 2024/05/01 21:22:09 1.478 +++ loncom/interface/loncreateuser.pm 2025/02/26 15:39:20 1.484 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.478 2024/05/01 21:22:09 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.484 2025/02/26 15:39:20 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -285,7 +285,7 @@ sub build_tools_display { 'webdav' => "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", + 'archive' => "Managers can download tar.gz file of Authoring Space", 'portfolio' => "Personal User Portfolio", 'portaccess' => "Portfolio Shareable", 'timezone' => "Can set Time Zone", @@ -375,6 +375,12 @@ sub build_tools_display { 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 '') { @@ -1525,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; @@ -2846,7 +2853,7 @@ sub personal_data_display { } my $genhelp=&Apache::loncommon::help_open_topic('Generation'); - $output = '

'.$lt{'pd'}.'

'. + $output = '

'.$lt{'pd'}.'

'. &Apache::lonhtmlcommon::start_pick_box(); if (($context eq 'selfcreate') && ($newuser eq 'email')) { my $size = 25; @@ -2862,9 +2869,9 @@ sub personal_data_display { undef($condition); } } - $output .= &Apache::lonhtmlcommon::row_title($lt{'email'}.'*',undef, + $output .= &Apache::lonhtmlcommon::row_title('*',undef, 'LC_oddrow_value')."\n". - ''; + ''; if ($condition) { $output .= $condition; } elsif ($excluded) { @@ -2883,14 +2890,14 @@ sub personal_data_display { } $rowcount ++; $output .= &Apache::lonhtmlcommon::row_closure(1); - my $upassone = ''; - my $upasstwo = ''; - $output .= &Apache::lonhtmlcommon::row_title(&mt('Password').'*', + my $upassone = ''; + my $upasstwo = ''; + $output .= &Apache::lonhtmlcommon::row_title('*', 'LC_pick_box_title', 'LC_oddrow_value')."\n". $upassone."\n". &Apache::lonhtmlcommon::row_closure(1)."\n". - &Apache::lonhtmlcommon::row_title(&mt('Confirm password').'*', + &Apache::lonhtmlcommon::row_title('*', 'LC_pick_box_title', 'LC_oddrow_value')."\n". $upasstwo. @@ -2904,59 +2911,85 @@ sub personal_data_display { ''."\n". ''."\n".&Apache::lonhtmlcommon::row_closure(1); + ''."\n".&Apache::lonhtmlcommon::row_closure(1); $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; if ($item eq 'generation') { $rowtitle = $genhelp.$rowtitle; } - my $row = &Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n"; + my $row = &Apache::lonhtmlcommon::row_title('',undef,'LC_oddrow_value')."\n"; if ($newuser) { if (ref($inst_results) eq 'HASH') { if ($inst_results->{$item} ne '') { - $row .= ''.$inst_results->{$item}; + $row .= ''.$inst_results->{$item}; } else { if ($context eq 'selfcreate') { if ($canmodify{$item}) { - $row .= ''; + $row .= ''; $editable ++; } else { $hiderow = 1; } } else { - $row .= ''; + $row .= ''; } } } else { if ($context eq 'selfcreate') { if ($canmodify{$item}) { if ($newuser eq 'email') { - $row .= ''; + $row .= ''; } else { - $row .= ''; + $row .= ''; } $editable ++; } else { $hiderow = 1; } } else { - $row .= ''; + $row .= ''; } } } else { if ($canmodify{$item}) { - $row .= ''; + $row .= ''; if (($item eq 'id') && (!$newuser)) { $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); @@ -3012,7 +3045,8 @@ sub personal_data_display { } if ($showsubmit) { my $submit_text = &mt('Create account'); - $output .= &Apache::lonhtmlcommon::row_title()."\n". + $output .= &Apache::lonhtmlcommon::row_title(''. + &mt('Submit').'','','','',1)."\n". '
'; if ($usertype ne '') { @@ -3376,12 +3410,12 @@ 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{'for.customarchive'} == 1) { + if ($env{'form.customarchive'} == 1) { $newcustom{'archive'} = $env{'form.authordefaults_archive'}; $changed{'archive'} = &tool_admin('archive',$newcustom{'archive'}, - \%changeHash,'authordefaults'); + \%changeHash,'authordefaults'); } } @@ -3867,6 +3901,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}; @@ -6471,6 +6520,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, @@ -6975,6 +7045,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',