--- loncom/interface/loncreateuser.pm 2019/04/29 22:19:24 1.451
+++ loncom/interface/loncreateuser.pm 2022/11/16 14:24:35 1.463
@@ -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.463 2022/11/16 14:24:35 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',
@@ -4092,9 +4108,9 @@ sub update_roles {
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).'
';
}
@@ -4139,7 +4155,7 @@ sub update_roles {
# 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) {
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end,$context));
} else {
@@ -4162,10 +4178,10 @@ 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;
@@ -4175,7 +4191,7 @@ sub update_roles {
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
my $credits;
if ($three eq 'st') {
- if ($showcredits) {
+ if ($showcredits) {
my $defaultcredits =
&Apache::lonuserutils::get_defaultcredits($one,$two);
$credits = $env{'form.credits_'.$one.'_'.$two.'_'.$three};
@@ -4215,10 +4231,10 @@ 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;
@@ -7147,9 +7163,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 +7284,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.')
.'
');
}
@@ -7456,12 +7473,12 @@ sub role_display_filter {
&mt('Context:').'