--- loncom/interface/loncreateuser.pm 2019/04/29 22:19:24 1.451
+++ loncom/interface/loncreateuser.pm 2022/12/01 01:28:26 1.466
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.451 2019/04/29 22:19:24 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.466 2022/12/01 01:28:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -71,6 +71,7 @@ use Apache::longroup;
use Apache::lonuserutils;
use Apache::loncoursequeueadmin;
use LONCAPA qw(:DEFAULT :match);
+use HTML::Entities;
my $loginscript; # piece of javascript used in two separate instances
my $authformnop;
@@ -246,6 +247,7 @@ sub build_tools_display {
'aboutme' => "Personal Information Page",
'webdav' => "WebDAV access to Authoring Spaces (if SSL and author/co-author)",
'portfolio' => "Personal User Portfolio",
+ 'timezone' => "Can set Time Zone",
'avai' => "Available",
'cusa' => "availability",
'chse' => "Change setting",
@@ -259,6 +261,7 @@ sub build_tools_display {
'lti' => 'Can request creation of LTI courses',
'requestauthor' => 'Can request author space',
);
+ $isadv = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname);
if ($context eq 'requestcourses') {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'requestcourses.official','requestcourses.unofficial',
@@ -272,7 +275,6 @@ sub build_tools_display {
$colspan = ' colspan="2"';
%domconfig =
&Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain);
- $isadv = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname);
} elsif ($context eq 'requestauthor') {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'requestauthor');
@@ -286,17 +288,18 @@ sub build_tools_display {
} else {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'tools.aboutme','tools.portfolio','tools.blog',
- 'tools.webdav');
- @usertools = ('aboutme','blog','webdav','portfolio');
+ 'tools.webdav','tools.timezone');
+ @usertools = ('aboutme','blog','webdav','portfolio','timezone');
}
foreach my $item (@usertools) {
my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off,
$currdisp,$custdisp,$custradio);
$cust_off = 'checked="checked" ';
$tool_on = 'checked="checked" ';
- $curr_access =
+ $curr_access =
&Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,
- $context);
+ $context,\%userenv,'',
+ {'is_adv' => $isadv});
if ($context eq 'requestauthor') {
if ($userenv{$context} ne '') {
$cust_on = ' checked="checked" ';
@@ -1616,7 +1619,7 @@ ENDNOTOOLSPRIV
if ($newuser) {
$r->print(' onclick="auth_check()" \>'."\n");
} else {
- $r->print('onclick="this.form.submit()" \>'."\n");
+ $r->print(' onclick="this.form.submit()" \>'."\n");
}
} else {
$r->print(''.
@@ -2441,8 +2444,8 @@ sub modify_login_block {
}
sub personal_data_display {
- my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray,
- $now,$captchaform,$emailusername,$usertype,$usernameset,$condition,$excluded) = @_;
+ my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray,$now,
+ $captchaform,$emailusername,$usertype,$usernameset,$condition,$excluded,$showsubmit) = @_;
my ($output,%userenv,%canmodify,%canmodify_status);
my @userinfo = ('firstname','middlename','lastname','generation',
'permanentemail','id');
@@ -2552,8 +2555,8 @@ sub personal_data_display {
}
$rowcount ++;
$output .= &Apache::lonhtmlcommon::row_closure(1);
- my $upassone = '';
- my $upasstwo = '';
+ my $upassone = '';
+ my $upasstwo = '';
$output .= &Apache::lonhtmlcommon::row_title(&mt('Password').'*',
'LC_pick_box_title',
'LC_oddrow_value')."\n".
@@ -2567,10 +2570,11 @@ sub personal_data_display {
if ($usernameset eq 'free') {
my $onclick = "toggleUsernameDisp(this,'selfcreateusername');";
$output .= &Apache::lonhtmlcommon::row_title($lt{'username'},undef,'LC_oddrow_value')."\n".
- &mt('Use e-mail address: ').
- ''."\n".
- (' 'x2).
- ''."\n".
+ ''.&mt('Use e-mail address: ').
+ ''.(' 'x2).
+ ''."\n".
'
'.
'
'.&mt('Preferred username').
' '.
@@ -2678,12 +2682,17 @@ sub personal_data_display {
&Apache::lonhtmlcommon::row_closure(1);
$rowcount ++;
}
- my $submit_text = &mt('Create account');
- $output .= &Apache::lonhtmlcommon::row_title()."\n".
- '
'.
- ''.
- &Apache::lonhtmlcommon::row_closure(1);
+ if ($showsubmit) {
+ my $submit_text = &mt('Create account');
+ $output .= &Apache::lonhtmlcommon::row_title()."\n".
+ '
';
+ if ($usertype ne '') {
+ $output .= '';
+ }
+ $output .= &Apache::lonhtmlcommon::row_closure(1);
+ }
}
$output .= &Apache::lonhtmlcommon::end_pick_box();
if (wantarray) {
@@ -2906,7 +2915,7 @@ sub update_user_data {
my (%alerts,%rulematch,%inst_results,%curr_rules);
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
- my @usertools = ('aboutme','blog','webdav','portfolio');
+ my @usertools = ('aboutme','blog','webdav','portfolio','timezone');
my @requestcourses = ('official','unofficial','community','textbook','placement','lti');
my @requestauthor = ('requestauthor');
my ($othertitle,$usertypes,$types) =
@@ -3036,7 +3045,7 @@ sub update_user_data {
$env{'form.ccdomain'},$env{'form.ccuname'});
}
}
- $r->print('
'.&mt('Home server').': '.$uhome.' '.
+ $r->print('
'.&mt('Home Server').': '.$uhome.' '.
&Apache::lonnet::hostname($uhome));
} elsif (($env{'form.login'} ne 'nochange') &&
($env{'form.login'} ne '' )) {
@@ -3051,11 +3060,11 @@ sub update_user_data {
&Apache::lonnet::modifyuserauth(
$env{'form.ccdomain'},$env{'form.ccuname'},
$amode,$genpwd));
- $r->print('
'.&mt('Home server').': '.&Apache::lonnet::homeserver
+ $r->print('
'.&mt('Home Server').': '.&Apache::lonnet::homeserver
($env{'form.ccuname'},$env{'form.ccdomain'}));
} else {
# Okay, this is a non-fatal error.
- $r->print($error.&mt('You do not have the authority to modify this users authentication information.').$end);
+ $r->print($error.&mt('You do not have privileges to modify the authentication configuration for this user.').$end);
}
} elsif (($env{'form.intarg'} ne '') &&
(&Apache::lonnet::queryauthenticate($env{'form.ccuname'},$env{'form.ccdomain'}) =~ /^internal:/) &&
@@ -3082,12 +3091,14 @@ sub update_user_data {
my %userenv = &Apache::lonnet::get
('environment',['firstname','middlename','lastname','generation',
'id','permanentemail','portfolioquota','authorquota','inststatus',
- 'tools.aboutme','tools.blog','tools.webdav','tools.portfolio',
+ 'tools.aboutme','tools.blog','tools.webdav',
+ 'tools.portfolio','tools.timezone',
'requestcourses.official','requestcourses.unofficial',
'requestcourses.community','requestcourses.textbook',
+ 'requestcourses.lti','requestauthor',
'reqcrsotherdom.official','reqcrsotherdom.unofficial',
'reqcrsotherdom.community','reqcrsotherdom.textbook',
- 'reqcrsotherdom.placement','requestauthor'],
+ 'reqcrsotherdom.placement'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -3117,7 +3128,7 @@ sub update_user_data {
}
} elsif ($context eq 'author') {
if ($rolenum eq $auname && $roledom eq $audom) {
- if (!grep(/^\Q$role\E$/,@userroles)) {
+ if (!grep(/^\Q$role\E$/,@userroles)) {
push(@userroles,$role);
}
}
@@ -3416,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) {
@@ -3585,6 +3600,7 @@ sub display_userinfo {
'webdav' => 'WebDAV Availability',
'aboutme' => 'Personal Information Page Availability',
'portfolio' => 'Portfolio Availability',
+ 'timezone' => 'Can set own Time Zone',
'official' => 'Can Request Official Courses',
'unofficial' => 'Can Request Unofficial Courses',
'community' => 'Can Request Communities',
@@ -3961,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});
@@ -4063,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') {
@@ -4070,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) {
@@ -4089,12 +4119,28 @@ 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);
- $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
- &Apache::lonnet::plaintext($role),
- &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'
';
+ $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'
';
if ($result ne "ok") {
$output .= &mt('Error: [_1]',$result).'
';
}
@@ -4107,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);
@@ -4128,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} ?
@@ -4136,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,$5);
+ 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})) {
@@ -4152,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');
@@ -4162,20 +4238,21 @@ sub update_roles {
# Activate roles for sections with 3 id numbers
# set start, end times, and the url for the class
my ($one,$two,$three)=($1,$2,$3);
- my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ?
- $env{'form.start_'.$one.'_'.$two.'_'.$three} :
+ my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ?
+ $env{'form.start_'.$one.'_'.$two.'_'.$three} :
$now );
- my $end = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ?
+ my $end = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ?
$env{'form.end_'.$one.'_'.$two.'_'.$three} :
0 );
my $url='/'.$one.'/'.$two;
+ my $id = $url.'_'.$three;
my $type = '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) {
+ if ($showcredits) {
my $defaultcredits =
&Apache::lonuserutils::get_defaultcredits($one,$two);
$credits = $env{'form.credits_'.$one.'_'.$two.'_'.$three};
@@ -4186,11 +4263,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 '') {
@@ -4200,14 +4285,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);
@@ -4215,33 +4320,63 @@ sub update_roles {
} elsif ($key=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
# Activate roles for sections with two id numbers
# set start, end times, and the url for the class
- my $start = ( $env{'form.start_'.$1.'_'.$2} ?
- $env{'form.start_'.$1.'_'.$2} :
+ my $start = ( $env{'form.start_'.$1.'_'.$2} ?
+ $env{'form.start_'.$1.'_'.$2} :
$now );
- my $end = ( $env{'form.end_'.$1.'_'.$2} ?
+ my $end = ( $env{'form.end_'.$1.'_'.$2} ?
$env{'form.end_'.$1.'_'.$2} :
0 );
my $one = $1;
my $two = $2;
my $url='/'.$one.'/';
+ my $id = $url.'_'.$two;
# 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,$one,$two,'','',\%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,$one,$two,$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,$one,$two,'','',\%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);
@@ -4265,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) {
@@ -4319,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'},
@@ -4685,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;
@@ -5350,7 +5540,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);
@@ -5364,6 +5555,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,
@@ -5615,6 +5826,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';
@@ -5780,7 +5992,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',
},
{
@@ -5859,6 +6072,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',
@@ -7147,9 +7382,10 @@ ENDSCRIPT
my ($nav_script,$nav_links);
# table header
- my $tableheader = ''.
+ my $heading = ''.
&mt('User access logs for: [_1]',
- &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom)).'
'
+ &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom)).'
';
+ my $tableheader = $heading
.&Apache::loncommon::start_data_table_header_row()
.' | '
.'
'.&mt('When').' | '
@@ -7267,7 +7503,7 @@ ENDSCRIPT
$r->print(&Apache::loncommon::end_data_table().
&userlogdisplay_navlinks(\%curr,$more_records));
} else { # No content displayed above
- $r->print('
'
+ $r->print($heading.'
'
.&mt('There are no records to display.')
.'
');
}
@@ -7404,10 +7640,6 @@ 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('Changes/page:').' '.
@@ -7435,7 +7667,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;
@@ -7456,12 +7688,12 @@ sub role_display_filter {
&mt('Context:').'
|