--- loncom/interface/loncreateuser.pm 2022/11/14 22:33:28 1.462 +++ loncom/interface/loncreateuser.pm 2023/08/01 15:56:32 1.469 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.462 2022/11/14 22:33:28 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.469 2023/08/01 15:56:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -296,7 +296,7 @@ sub build_tools_display { $currdisp,$custdisp,$custradio); $cust_off = 'checked="checked" '; $tool_on = 'checked="checked" '; - $curr_access = + $curr_access = &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, $context,\%userenv,'', {'is_adv' => $isadv}); @@ -3427,6 +3427,10 @@ sub update_user_data { &Apache::lonnet::appenv(\%newenvhash); } } + if ($changed{'aboutme'}) { + &Apache::loncommon::devalidate_aboutme_cache($env{'form.ccuname'}, + $env{'form.ccdomain'}); + } } } if (keys(%namechanged) > 0) { @@ -3973,7 +3977,13 @@ sub update_roles { my ($r,$context,$showcredits) = @_; my $now=time; my @rolechanges; - my %disallowed; + my (%disallowed,%got_role_approvals,%got_instdoms,%process_by,%instdoms, + %pending,%reject,%notifydc,%status,%unauthorized,%currqueued); + $got_role_approvals{$context} = ''; + $process_by{$context} = {}; + my @domroles = &Apache::lonuserutils::domain_roles(); + my @cstrroles = &Apache::lonuserutils::construction_space_roles(); + my @courseroles = &Apache::lonuserutils::roles_by_context('course',1); $r->print('

'.&mt('Modifying Roles').'

'); foreach my $key (keys(%env)) { next if (! $env{$key}); @@ -4075,6 +4085,7 @@ sub update_roles { if ($key=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) { my $url = $1; my $role = $2; + my $id = $url.'_'.$role; my $logmsg; my $output; if ($role eq 'st') { @@ -4082,10 +4093,17 @@ sub update_roles { my ($cdom,$cnum,$csec) = ($1,$2,$3); my $credits; if ($showcredits) { - my $defaultcredits = + my $defaultcredits = &Apache::lonuserutils::get_defaultcredits($cdom,$cnum); $credits = &get_user_credits($defaultcredits,$cdom,$cnum); } + unless ($udom eq $cdom) { + next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom, + $uname,$role,$now,0,$cdom,$cnum,$csec,$credits, + \%process_by,\%instdoms,\%got_role_approvals, + \%got_instdoms,\%reject,\%pending,\%notifydc, + \%status,\%unauthorized,\%currqueued)); + } my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context,$credits); if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) { if ($result eq 'refused' && $logmsg) { @@ -4101,6 +4119,22 @@ sub update_roles { } } } else { + my ($cdom,$cnum,$csec); + if (grep(/^\Q$role\E$/,@cstrroles)) { + ($cdom,$cnum) = ($url =~ m{^/($match_domain)/($match_username)$}); + } elsif (grep(/^\Q$role\E$/,@domroles)) { + ($cdom) = ($url =~ m{^/($match_domain)/$}); + } elsif ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) { + ($cdom,$cnum,$csec) = ($1,$2,$3); + } + if ($cdom ne '') { + unless ($udom eq $cdom) { + next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom, + $uname,$role,$now,0,$cdom,$cnum,$csec,'',\%process_by, + \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject, + \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued)); + } + } my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'}, $env{'form.ccuname'},$url,$role,0,$now,'','', $context); @@ -4119,6 +4153,17 @@ sub update_roles { # Re-enable custom role if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); + my $id = $url.'_cr'."/$rdom/$rnam/$rolename"; + my $role = "cr/$rdom/$rnam/$rolename"; + if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) { + my ($cdom,$cnum,$csec) = ($1,$2,$3); + unless ($udom eq $cdom) { + next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom, + $uname,$role,$now,0,$cdom,$cnum,$csec,'',\%process_by, + \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject, + \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued)); + } + } my $result = &Apache::lonnet::assigncustomrole( $env{'form.ccdomain'}, $env{'form.ccuname'}, $url,$rdom,$rnam,$rolename,0,$now,undef,$context); @@ -4140,6 +4185,8 @@ sub update_roles { # Activate a custom role my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5); my $url='/'.$one.'/'.$two; + my $id = $url.'_cr/'."$three/$four/$five"; + my $role = "cr/$three/$four/$five"; my $full=$one.'_'.$two.'_cr_cr_'.$three.'_'.$four.'_'.$five; my $start = ( $env{'form.start_'.$full} ? @@ -4148,15 +4195,22 @@ sub update_roles { my $end = ( $env{'form.end_'.$full} ? $env{'form.end_'.$full} : 0 ); - + # split multiple sections my %sections = (); my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$five); if ($num_sections == 0) { + unless ($udom eq $one) { + next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom, + $uname,$role,$start,$end,$one,$two,'','',\%process_by, + \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject, + \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued)); + } $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end,$context)); } else { my %curr_groups = &Apache::longroup::coursegroups($one,$two); + my ($restricted,$numchanges); foreach my $sec (sort {$a cmp $b} keys(%sections)) { if (($sec eq 'none') || ($sec eq 'all') || exists($curr_groups{$sec})) { @@ -4164,8 +4218,18 @@ sub update_roles { next; } my $securl = $url.'/'.$sec; + my $secid = $securl.'_cr'."/$three/$four/$five"; + undef($restricted); + unless ($udom eq $one) { + next if (&Apache::lonuserutils::restricted_dom($context,$secid,$udom, + $uname,$role,$start,$end,$one,$two,$sec,'',\%process_by, + \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject, + \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued)); + } + $numchanges ++; $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end,$context)); } + next unless ($numchanges); } if (!grep(/^cr$/,@rolechanges)) { push(@rolechanges,'cr'); @@ -4181,11 +4245,11 @@ sub update_roles { $env{'form.end_'.$one.'_'.$two.'_'.$three} : 0 ); my $url='/'.$one.'/'.$two; - my $type = 'three'; + my $id = $url.'_'.$three; # split multiple sections my %sections = (); my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three); - my $credits; + my ($credits,$numchanges); if ($three eq 'st') { if ($showcredits) { my $defaultcredits = @@ -4198,11 +4262,19 @@ sub update_roles { } } if ($num_sections == 0) { + unless ($udom eq $one) { + next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom, + $uname,$three,$start,$end,$one,$two,'',$credits,\%process_by, + \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject, + \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued)); + } + $numchanges ++; $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits)); } else { my %curr_groups = &Apache::longroup::coursegroups($one,$two); my $emptysec = 0; + my $restricted; foreach my $sec (sort {$a cmp $b} keys(%sections)) { $sec =~ s/\W//g; if ($sec ne '') { @@ -4212,14 +4284,34 @@ sub update_roles { next; } my $securl = $url.'/'.$sec; + my $secid = $securl.'_'.$three; + unless ($udom eq $one) { + undef($restricted); + $restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom, + $uname,$three,$start,$end,$one,$two,$sec,$credits,\%process_by, + \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject, + \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued); + next if ($restricted); + } + $numchanges ++; $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context,$credits)); } else { $emptysec = 1; } } if ($emptysec) { + unless ($udom eq $one) { + undef($restricted); + $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom, + $uname,$three,$start,$end,$one,$two,'',$credits,\%process_by, + \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject, + \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued); + next if ($restricted); + } + $numchanges ++; $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits)); } + next unless ($numchanges); } if (!grep(/^\Q$three\E$/,@rolechanges)) { push(@rolechanges,$three); @@ -4236,24 +4328,55 @@ sub update_roles { my $one = $1; my $two = $2; my $url='/'.$one.'/'; + my $id = $url.'_'.$two; + my ($cdom,$cnum) = split(/\//,$one); # split multiple sections my %sections = (); + my ($restricted,$numchanges); my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two},\%sections,$two); if ($num_sections == 0) { + unless ($udom eq $one) { + $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom, + $uname,$two,$start,$end,$cdom,$cnum,'','',\%process_by, + \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject, + \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued); + next if ($restricted); + } + $numchanges ++; $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context)); } else { my $emptysec = 0; foreach my $sec (sort {$a cmp $b} keys(%sections)) { if ($sec ne '') { my $securl = $url.'/'.$sec; + my $secid = $securl.'_'.$two; + unless ($udom eq $one) { + undef($restricted); + $restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom, + $uname,$two,$start,$end,$cdom,$cnum,$sec,'',\%process_by, + \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject, + \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued); + next if ($restricted); + } + $numchanges ++; $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context)); } else { $emptysec = 1; } } if ($emptysec) { + unless ($udom eq $one) { + undef($restricted); + $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom, + $uname,$two,$start,$end,$cdom,$cnum,'','',\%process_by, + \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject, + \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued); + next if ($restricted); + } + $numchanges ++; $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context)); } + next unless ($numchanges); } if (!grep(/^\Q$two\E$/,@rolechanges)) { push(@rolechanges,$two); @@ -4277,6 +4400,12 @@ sub update_roles { } } } # End of foreach (keys(%env)) + if ((keys(%reject)) || (keys(%unauthorized))) { + $r->print(&Apache::lonuserutils::print_roles_rejected($context,\%reject,\%unauthorized)); + } + if ((keys(%pending)) || (keys(%currqueued))) { + $r->print(&Apache::lonuserutils::print_roles_queued($context,\%pending,\%notifydc,\%currqueued)); + } # Flush the course logs so reverse user roles immediately updated $r->register_cleanup(\&Apache::lonnet::flushcourselogs); if (@rolechanges == 0) { @@ -4331,11 +4460,35 @@ sub enroll_single_student { } } } + my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form(); + my (%got_role_approvals,%got_instdoms,%process_by,%instdoms,%pending,%reject,%notifydc, + %status,%unauthorized,%currqueued); + unless ($env{'form.ccdomain'} eq $env{'course.'.$env{'request.course.id'}.'.domain'}) { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $csec = $env{'form.sections'}; + my $id = "/$cdom/$cnum"; + if ($csec ne '') { + $id .= "/$csec"; + } + $id .= '_st'; + if (&Apache::lonuserutils::restricted_dom($context,$id,$env{'form.ccdomain'},$env{'form.ccuname'}, + 'st',$startdate,$enddate,$cdom,$cnum,$csec,$credits, + \%process_by,\%instdoms,\%got_role_approvals,\%got_instdoms, + \%reject,\%pending,\%notifydc,\%status,\%unauthorized,\%currqueued)) { + if ((keys(%reject)) || (keys(%unauthorized))) { + $r->print(&Apache::lonuserutils::print_roles_rejected($context,\%reject,\%unauthorized)); + } + if ((keys(%pending)) || (keys(%currqueued))) { + $r->print(&Apache::lonuserutils::print_roles_queued($context,\%pending,\%notifydc,\%currqueued)); + } + return; + } + } # Clean out any old student roles the user has in this class. &Apache::lonuserutils::modifystudent($env{'form.ccdomain'}, $env{'form.ccuname'},$env{'request.course.id'},undef,$uhome); - my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form(); my $enroll_result = &Apache::lonnet::modify_student_enrollment($env{'form.ccdomain'}, $env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'}, @@ -4697,6 +4850,31 @@ sub set_custom_role { ); } +sub show_role_requests { + my ($caller,$dom) = @_; + my $showrolereqs; + my %domconfig = &Apache::lonnet::get_dom('configuration',['privacy'],$dom); + if (ref($domconfig{'privacy'}) eq 'HASH') { + if (ref($domconfig{'privacy'}{'approval'}) eq 'HASH') { + my %approvalconf = %{$domconfig{'privacy'}{'approval'}}; + foreach my $key ('instdom','extdom') { + if (ref($approvalconf{$key}) eq 'HASH') { + if (keys(%{$approvalconf{$key}})) { + foreach my $context ('domain','author','course','community') { + if ($approvalconf{$key}{$context} eq $caller) { + $showrolereqs = 1; + last if ($showrolereqs); + } + } + } + } + last if ($showrolereqs); + } + } + } + return $showrolereqs; +} + # ================================================================ Main Handler sub handler { my $r = shift; @@ -4742,7 +4920,7 @@ sub handler { if (&Apache::lonnet::auto_run($cnum,$cdom) && (($permission->{'cusr'}) || ($permission->{'view'}))) { push(@allhelp,'Course_Automated_Enrollment'); } - if ($permission->{'selfenrolladmin'}) { + if (($permission->{'selfenrolladmin'}) || ($permission->{'selfenrollview'})) { push(@allhelp,'Course_Approve_Selfenroll'); } } @@ -5282,8 +5460,9 @@ sub handler { ''.&mt('You do not have permission to modify dates or sections for users').''); } } elsif ($env{'form.action'} eq 'selfenroll') { - if ($permission->{selfenrolladmin}) { - my %currsettings = ( + my %currsettings; + if ($permission->{selfenrolladmin} || $permission->{selfenrollview}) { + %currsettings = ( selfenroll_types => $env{'course.'.$cid.'.internal.selfenroll_types'}, selfenroll_registered => $env{'course.'.$cid.'.internal.selfenroll_registered'}, selfenroll_section => $env{'course.'.$cid.'.internal.selfenroll_section'}, @@ -5299,6 +5478,8 @@ sub handler { default_enrollment_end_date => $env{'course.'.$cid.'.default_enrollment_end_date'}, uniquecode => $env{'course.'.$cid.'.internal.uniquecode'}, ); + } + if ($permission->{selfenrolladmin}) { push(@{$brcrum}, {href => '/adm/createuser?action=selfenroll', text => "Configure Self-enrollment", @@ -5319,6 +5500,16 @@ sub handler { $r->print('

'.&mt('Self-enrollment with a student role').'

'."\n"); &update_selfenroll_config($r,$cid,$cdom,$cnum,$context,$crstype,\%currsettings); } + } elsif ($permission->{selfenrollview}) { + push(@{$brcrum}, + {href => '/adm/createuser?action=selfenroll', + text => "View Self-enrollment configuration", + help => 'Course_Self_Enrollment'}); + $args = { bread_crumbs => $brcrum, + bread_crumbs_component => 'Self-enrollment Settings'}; + $r->print(&header(undef,$args)); + $r->print('

'.&mt('Self-enrollment with a student role').'

'."\n"); + &print_selfenroll_menu($r,'course',$cid,$cdom,$cnum,\%currsettings,'',1); } else { $r->print(&header(undef,{'no_nav_bar' => 1}). ''.&mt('You do not have permission to configure self-enrollment').''); @@ -5362,7 +5553,8 @@ sub handler { ''.&mt('You do not have permission to view change logs').''); } } elsif ($env{'form.action'} eq 'helpdesk') { - if (($permission->{'owner'}) || ($permission->{'co-owner'})) { + if (($permission->{'owner'} || $permission->{'co-owner'}) && + ($permission->{'cusr'} || $permission->{'view'})) { if ($env{'form.state'} eq 'process') { if ($permission->{'owner'}) { &update_helpdeskaccess($r,$permission,$brcrum); @@ -5376,6 +5568,26 @@ sub handler { $r->print(&header(undef,{'no_nav_bar' => 1}). ''.&mt('You do not have permission to view helpdesk access').''); } + } elsif ($env{'form.action'} eq 'rolerequests') { + if ($permission->{cusr} || $permission->{view}) { + &print_queued_roles($r,$context,$permission,$brcrum); + } + } elsif ($env{'form.action'} eq 'queuedroles') { + if (($permission->{cusr}) && ($context eq 'domain')) { + if (&show_role_requests($context,$env{'request.role.domain'})) { + if ($env{'form.state'} eq 'done') { + &process_pendingroles($r,$context,$permission,$brcrum); + } else { + &print_pendingroles($r,$context,$permission,$brcrum); + } + } else { + $r->print(&header(undef,{'no_nav_bar' => 1}). + ''.&mt('Domain coordinator approval of requests from other domains for assignment of roles to users from this domain not in use.').''); + } + } else { + $r->print(&header(undef,{'no_nav_bar' => 1}). + ''.&mt('You do not have permission to view queued requests from other domains for assignment of roles to users from this domain.').''); + } } else { $bread_crumbs_component = 'User Management'; $args = { bread_crumbs => $brcrum, @@ -5627,6 +5839,7 @@ sub print_main_menu { listusers => 'Show and manage users in this community.', }, ); + if ($linkcontext eq 'domain') { unless ($permission->{'cusr'}) { $links{'domain'}{'singleuser'} = 'View a User'; @@ -5792,7 +6005,8 @@ sub print_main_menu { icon => 'helpdesk-access.png', #help => 'Course_Helpdesk_Access', url => '/adm/createuser?action=helpdesk', - permission => ($permission->{'owner'} || $permission->{'co-owner'}), + permission => (($permission->{'owner'} || $permission->{'co-owner'}) && + ($permission->{'view'} || $permission->{'cusr'})), linktitle => 'Helpdesk access options', }, { @@ -5827,7 +6041,7 @@ sub print_main_menu { icon => 'selfenrl-queue.png', #help => 'Course_Approve_Selfenroll', url => '/adm/createuser?action=selfenrollqueue', - permission => $permission->{'selfenrolladmin'}, + permission => $permission->{'selfenrolladmin'} || $permission->{'selfenrollview'}, linktitle =>'Approve or reject enrollment requests.', }, ); @@ -5854,7 +6068,7 @@ sub print_main_menu { icon => 'self_enroll.png', #help => 'Course_Self_Enrollment', url => '/adm/createuser?action=selfenroll', - permission => $permission->{'selfenrolladmin'}, + permission => $permission->{'selfenrolladmin'} || $permission->{'selfenrollview'}, linktitle => 'Configure user self-enrollment.', }, ); @@ -5871,6 +6085,28 @@ sub print_main_menu { }, ); } + push(@{ $menu[2]->{items} }, + { + linktext => 'Role Requests (other domains)', + icon => 'edit-find.png', + #help => 'Role_Requests', + url => '/adm/createuser?action=rolerequests', + permission => $permission->{'cusr'}, + linktitle => 'Role requests for users in other domains', + }, + ); + if (&show_role_requests($context,$env{'request.role.domain'})) { + push(@{ $menu[2]->{items} }, + { + linktext => 'Queued Role Assignments (this domain)', + icon => 'edit-find.png', + #help => 'Role_Approvals', + url => '/adm/createuser?action=queuedroles', + permission => $permission->{'cusr'}, + linktitle => "Role requests for this domain's users", + }, + ); + } return Apache::lonhtmlcommon::generate_menu(@menu); # { text => 'View Log-in History', # help => 'Course_User_Logins', @@ -6103,8 +6339,7 @@ ENDSCRIPT '// ]]>'."\n". ''."\n". '

'.$lt->{'selfenroll'}.'

'."\n"; - - my $visactions = &cat_visibility(); + my $visactions = &cat_visibility($cdom); my ($cathash,%cattype); my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom); if (ref($domconfig{'coursecategories'}) eq 'HASH') { @@ -6650,6 +6885,7 @@ sub visible_in_stdcat { } sub cat_visibility { + my ($cdom) = @_; my %visactions = &Apache::lonlocal::texthash( vis => 'This course/community currently appears in the Course/Community Catalog for this domain.', gen => 'Courses can be both self-cataloging, based on an institutional code (e.g., fs08phy231), or can be assigned categories from a hierarchy defined for the domain.', @@ -6662,13 +6898,24 @@ sub cat_visibility { dc_chgconf => 'Ask a domain coordinator to change the Catalog type for this domain.', dc_setcode => 'Ask a domain coordinator to assign a six character code to the course', dc_unhide => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.', - dc_addinst => 'Ask a domain coordinator to enable display the catalog of "Official courses (with institutional codes)".', + dc_addinst => 'Ask a domain coordinator to enable catalog display of "Official courses (with institutional codes)".', dc_instcode => 'Ask a domain coordinator to assign an institutional code (if this is an official course).', dc_catalog => 'Ask a domain coordinator to enable or create at least one course category in the domain.', dc_categories => 'Ask a domain coordinator to create a hierarchy of categories and sub categories for courses in the domain.', dc_chgcat => 'Ask a domain coordinator to change the category assigned to the course, as the one currently assigned is no longer used in the domain', dc_addcat => 'Ask a domain coordinator to assign a category to the course.', ); + if ($env{'request.role'} eq "dc./$cdom/") { + $visactions{'dc_chgconf'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to change the Catalog type for this domain.','»'); + $visactions{'dc_setcode'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to assign a six character code to the course.','»'); + $visactions{'dc_unhide'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to change the "Exclude from course catalog" setting.','»'); + $visactions{'dc_addinst'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to enable catalog display of "Official courses (with institutional codes)".','»'); + $visactions{'dc_instcode'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify course owner, institutional code ... " to assign an institutional code (if this is an official course).','»'); + $visactions{'dc_catalog'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to enable or create at least one course category in the domain.','»'); + $visactions{'dc_categories'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to create a hierarchy of categories and sub categories for courses in the domain.','»'); + $visactions{'dc_chgcat'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify catalog settings for course" to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','»'); + $visactions{'dc_addcat'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify catalog settings for course" to assign a category to the course.','»'); + } $visactions{'unhide'} = &mt('Use [_1]Categorize course[_2] to change the "Exclude from course catalog" setting.','','"'); $visactions{'chgcat'} = &mt('Use [_1]Categorize course[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"','"'); $visactions{'addcat'} = &mt('Use [_1]Categorize course[_2] to assign a category to the course.','"','"'); @@ -6847,12 +7094,13 @@ ENDSCRIPT chgcontext => 'any', rolelog_start_date => $defstart, rolelog_end_date => $now, + approvals => 'any', ); my $more_records = 0; # set current my %curr; - foreach my $item ('show','page','role','chgcontext') { + foreach my $item ('show','page','role','chgcontext','approvals') { $curr{$item} = $env{'form.'.$item}; } my ($startdate,$enddate) = @@ -6926,6 +7174,11 @@ ENDSCRIPT if (($context eq 'course') && ($viewablesec ne '')) { next if ($roleslog{$id}{'logentry'}{'section'} ne $viewablesec); } + if ($curr{'approvals'} eq 'none') { + next if ($roleslog{$id}{'logentry'}{'approval'}); + } elsif ($curr{'approvals'} ne 'any') { + next if ($roleslog{$id}{'logentry'}{'approval'} ne $curr{'approvals'}); + } $count ++; next if ($count < $minshown); unless ($showntableheader) { @@ -6972,11 +7225,30 @@ ENDSCRIPT if ($chgcontext ne '' && $lt{$chgcontext} ne '') { $chgcontext = $lt{$chgcontext}; } + my ($showreqby,%reqby); + if (($roleslog{$id}{'logentry'}{'approval'}) && + ($roleslog{$id}{'logentry'}{'requester'})) { + if ($reqby{$roleslog{$id}{'logentry'}{'requester'}} eq '') { + my ($requname,$requdom) = split(/:/,$roleslog{$id}{'logentry'}{'requester'}); + $reqby{$roleslog{$id}{'logentry'}{'requester'}} = + &Apache::loncommon::plainname($requname,$requdom); + } + $showreqby = &mt('Requester').': '.$reqby{$roleslog{$id}{'logentry'}{'requester'}}.'
'; + if ($roleslog{$id}{'logentry'}{'approval'} eq 'domain') { + $showreqby .= &mt('Adjudicator').': '. + $whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}}. + ''; + } else { + $showreqby .= ''.&mt('User approved').''; + } + } else { + $showreqby = $whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}}; + } $r->print( &Apache::loncommon::start_data_table_row() .''.$count.'' .''.&Apache::lonlocal::locallocaltime($roleslog{$id}{'exe_time'}).'' - .''.$whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}}.'' + .''.$showreqby.'' .''.$changed{$roleslog{$id}{'uname'}.':'.$roleslog{$id}{'udom'}}.'' .''.&Apache::lonnet::plaintext($roleslog{$id}{'logentry'}{'role'},$crstype).''); if ($context eq 'course') { @@ -7330,7 +7602,7 @@ sub activity_display_filter { my $nolink = 1; my $output = ''; my $startform = @@ -7417,14 +7689,10 @@ sub userlogdisplay_navlinks { sub role_display_filter { my ($context,$formname,$cdom,$cnum,$curr,$version,$crstype) = @_; - my $lctype; - if ($context eq 'course') { - $lctype = lc($crstype); - } my $nolink = 1; my $output = '
'. ''.&mt('Actions/page:').'
'. - &Apache::lonmeta::selectbox('show',$curr->{'show'},undef, + &Apache::lonmeta::selectbox('show',$curr->{'show'},'',undef, (&mt('all'),5,10,20,50,100,1000,10000)). '
  
'; my $startform = @@ -7448,7 +7716,7 @@ sub role_display_filter { if ($curr->{'role'} eq 'any') { $output .= ' selected="selected"'; } - $output .= '>'.&mt('Any').''."\n"; + $output .= '>'.&mt('Any').''."\n"; my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype); foreach my $role (@roles) { my $plrole; @@ -7469,7 +7737,7 @@ sub role_display_filter { &mt('Context:').'
' - .'
'. ''.&mt('Changes/page:').'
'. - &Apache::lonmeta::selectbox('show',$curr->{'show'},undef, + &Apache::lonmeta::selectbox('show',$curr->{'show'},'',undef, (&mt('all'),5,10,20,50,100,1000,10000)). '
  
'; + my @possapprovals = ('any','none','domain','user'); + my %apptxt = &approval_types(); + $output .= ''. + '  '. + ''. + &mt('Approvals:').'
'; # Update Display button $output .= '

' @@ -7525,6 +7805,7 @@ sub rolechg_contexts { domain => 'User Management in domain', selfenroll => 'Self-enrolled', requestcourses => 'Course Request', + ltienroll => 'Enrollment via LTI', ); if ($crstype eq 'Community') { $lt{'createcourse'} = &mt('Community Creation'); @@ -7549,6 +7830,15 @@ sub rolechg_contexts { return %lt; } +sub approval_types { + return &Apache::lonlocal::texthash ( + any => 'Any', + none => 'No approval needed', + user => 'Role recipient approval', + domain => 'Domain coordinator approval', + ); +} + sub print_helpdeskaccess_display { my ($r,$permission,$brcrum) = @_; my $formname = 'helpdeskaccess'; @@ -7955,6 +8245,67 @@ ENDJS return; } +sub print_queued_roles { + my ($r,$context,$permission,$brcrum) = @_; + push (@{$brcrum}, + {href => '/adm/createuser?action=rolerequests', + text => 'Role Requests (other domains)', + help => ''}); + my $bread_crumbs_component = 'Role Requests'; + my $args = { bread_crumbs => $brcrum, + bread_crumbs_component => $bread_crumbs_component}; + # print page header + $r->print(&header('',$args)); + my ($dom,$cnum); + $dom = $env{'request.role.domain'}; + if ($context eq 'course') { + if ($env{'request.course.id'}) { + if (&Apache::loncommon::course_type() eq 'Community') { + $context = 'community'; + } + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + } + } elsif ($context eq 'author') { + $cnum = $env{'user.name'}; + } + $r->print(&Apache::loncoursequeueadmin::display_queued_requests('othdomqueue',$dom,$cnum,$context)); + return; +} + +sub print_pendingroles { + my ($r,$context,$permission,$brcrum) = @_; + push (@{$brcrum}, + {href => '/adm/createuser?action=queuedroles', + text => 'Queued Role Assignments (users in this domain)', + help => ''}); + my $bread_crumbs_component = 'Queued Role Assignments'; + my $args = { bread_crumbs => $brcrum, + bread_crumbs_component => $bread_crumbs_component}; + # print page header + $r->print(&header('',$args)); + $r->print(&Apache::loncoursequeueadmin::display_queued_requests('othdomaction',$env{'request.role.domain'},'','domain')); + return; +} + +sub process_pendingroles { + my ($r,$context,$permission,$brcrum) = @_; + push (@{$brcrum}, + {href => '/adm/createuser?action=queuedroles', + text => 'Queued Role Assignments (users in this domain)', + help => ''}, + {href => '/adm/createuser?action=processrolereq', + text => 'Process Queue', + help => ''}); + my $bread_crumbs_component = 'Queued Role Assignments'; + my $args = { bread_crumbs => $brcrum, + bread_crumbs_component => $bread_crumbs_component}; + # print page header + $r->print(&header('',$args)); + $r->print(&Apache::loncoursequeueadmin::update_request_queue('othdombydc', + $env{'request.role.domain'})); + return; +} + sub domain_adhoc_access { my ($roles,$domcurrent,$accesstypes,$usertypes,$othertitle) = @_; my %domusage; @@ -9624,7 +9975,7 @@ sub update_selfenroll_config { } else { $r->print(&mt('No changes were made to the existing self-enrollment settings in this course.')); } - my $visactions = &cat_visibility(); + my $visactions = &cat_visibility($cdom); my ($cathash,%cattype); my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom); if (ref($domconfig{'coursecategories'}) eq 'HASH') {