[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonuserutils.pm
raeburn
raeburn at source.lon-capa.org
Fri Sep 14 16:52:35 EDT 2018
raeburn Fri Sep 14 20:52:35 2018 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface lonuserutils.pm
Log:
- For 2.11
Backport 1.189, 1.191, 1.192 (part), 1.193 (part).
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.184 loncom/interface/lonuserutils.pm:1.184.4.1
--- loncom/interface/lonuserutils.pm:1.184 Fri Jul 7 02:50:41 2017
+++ loncom/interface/lonuserutils.pm Fri Sep 14 20:52:35 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.184 2017/07/07 02:50:41 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.184.4.1 2018/09/14 20:52:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1121,8 +1121,15 @@
if (!$env{'form.datatoken'}) {
$datatoken=&Apache::loncommon::upfile_store($r);
} else {
- $datatoken=$env{'form.datatoken'};
- &Apache::loncommon::load_tmp_file($r);
+ $datatoken=&Apache::loncommon::valid_datatoken($env{'form.datatoken'});
+ if ($datatoken ne '') {
+ &Apache::loncommon::load_tmp_file($r,$datatoken);
+ }
+ }
+ if ($datatoken eq '') {
+ $r->print('<p class="LC_error">'.&mt('Error').': '.
+ &mt('Invalid datatoken').'</p>');
+ return 'missingdata';
}
my @records=&Apache::loncommon::upfile_record_sep();
if($env{'form.noFirstLine'}){
@@ -1206,6 +1213,7 @@
}
&print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear,
$context,$permission,$crstype,$showcredits);
+ return 'ok';
}
sub setup_date_selectors {
@@ -4107,7 +4115,10 @@
# ================================================= Drop/Add from uploaded file
sub upfile_drop_add {
my ($r,$context,$permission,$showcredits) = @_;
- &Apache::loncommon::load_tmp_file($r);
+ my $datatoken = &Apache::loncommon::valid_datatoken($env{'form.datatoken'});
+ if ($datatoken ne '') {
+ &Apache::loncommon::load_tmp_file($r,$datatoken);
+ }
my @userdata=&Apache::loncommon::upfile_record_sep();
if($env{'form.noFirstLine'}){shift(@userdata);}
my @keyfields = split(/\,/,$env{'form.keyfields'});
@@ -4121,10 +4132,6 @@
$fields{$env{'form.f'.$i}}=$keyfields[$i];
}
}
- if ($env{'form.fullup'} ne 'yes') {
- $r->print('<form name="studentform" method="post" action="/adm/createuser">'."\n".
- '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />');
- }
#
# Store the field choices away
my @storefields = qw/username names fname mname lname gen id
@@ -4169,10 +4176,10 @@
} else {
my %home_servers = &Apache::lonnet::get_servers($defdom,'library');
if (! exists($home_servers{$desiredhost})) {
- $r->print('<span class="LC_error">'.&mt('Error').
- &mt('Invalid home server specified').'</span>');
+ $r->print('<p class="LC_error">'.&mt('Error').': '.
+ &mt('Invalid home server specified').'</p>');
$r->print(&Apache::loncommon::end_page());
- return;
+ return 'invalidhome';
}
}
# Determine authentication mechanism
@@ -4272,6 +4279,11 @@
}
}
}
+ if ($datatoken eq '') {
+ $r->print('<p class="LC_error">'.&mt('Error').': '.
+ &mt('Invalid datatoken').'</p>');
+ return 'missingdata';
+ }
if ( $domain eq &LONCAPA::clean_domain($domain)
&& ($amode ne '')) {
#######################################
@@ -4824,7 +4836,9 @@
"</p>\n");
if ($counts{'role'} > 0) {
$r->print("<p>\n".
- &mt('Roles added for [quant,_1,user].',$counts{'role'}).' '.&mt('If a user is currently logged-in to LON-CAPA, any new roles which are active will be available when the user next logs in.')."</p>\n");
+ &mt('Roles added for [quant,_1,user].',$counts{'role'}).' '.
+ &mt('If a user is currently logged-in to LON-CAPA, any new roles which are active will be available when the user next logs in.').
+ "</p>\n");
} else {
$r->print('<p>'.&mt('No roles added').'</p>');
}
@@ -4842,10 +4856,9 @@
# Get current classlist
my $classlist = &Apache::loncoursedata::get_classlist();
if (! defined($classlist)) {
- $r->print('<form name="studentform" method="post" action="/adm/createuser">'.
- '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'.
- '<p class="LC_info">'.&mt('There are no students with current/future access to the course.').'</p>'.
- '</form>'."\n");
+ $r->print('<p class="LC_info">'.
+ &mt('There are no students with current/future access to the course.').
+ '</p>'."\n");
} elsif (ref($classlist) eq 'HASH') {
# Remove the students we just added from the list of students.
foreach my $line (@userdata) {
@@ -4861,9 +4874,7 @@
}
}
} # end of unless
- if ($env{'form.fullup'} ne 'yes') {
- $r->print('</form>');
- }
+ return 'ok';
}
sub print_namespacing_alerts {
More information about the LON-CAPA-cvs
mailing list