[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm lonuserutils.pm
raeburn
raeburn at source.lon-capa.org
Sat Nov 4 16:59:39 EDT 2017
raeburn Sat Nov 4 20:59:39 2017 EDT
Modified files:
/loncom/interface loncreateuser.pm lonuserutils.pm
Log:
- When a csv file of users is uploaded, error messages are displayed in the
case of (a) an invalid datatoken, or (b) invalid home server for new users,
In (a) user is prompted to re-upload the file; in (b) user is prompted to
select default domain again.
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.447 loncom/interface/loncreateuser.pm:1.448
--- loncom/interface/loncreateuser.pm:1.447 Sat Nov 4 20:23:23 2017
+++ loncom/interface/loncreateuser.pm Sat Nov 4 20:59:38 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.447 2017/11/04 20:23:23 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.448 2017/11/04 20:59:38 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4750,12 +4750,36 @@
if (! exists($env{'form.state'})) {
&Apache::lonuserutils::print_first_users_upload_form($r,$context);
} elsif ($env{'form.state'} eq 'got_file') {
- &Apache::lonuserutils::print_upload_manager_form($r,$context,$permission,
- $crstype,$showcredits);
+ my $result =
+ &Apache::lonuserutils::print_upload_manager_form($r,$context,
+ $permission,
+ $crstype,$showcredits);
+ if ($result eq 'missingdata') {
+ delete($env{'form.state'});
+ &Apache::lonuserutils::print_first_users_upload_form($r,$context);
+ }
} elsif ($env{'form.state'} eq 'enrolling') {
if ($env{'form.datatoken'}) {
- &Apache::lonuserutils::upfile_drop_add($r,$context,$permission,
- $showcredits);
+ my $result = &Apache::lonuserutils::upfile_drop_add($r,$context,
+ $permission,
+ $showcredits);
+ if ($result eq 'missingdata') {
+ delete($env{'form.state'});
+ &Apache::lonuserutils::print_first_users_upload_form($r,$context);
+ } elsif ($result eq 'invalidhome') {
+ $env{'form.state'} = 'got_file';
+ delete($env{'form.lcserver'});
+ my $result =
+ &Apache::lonuserutils::print_upload_manager_form($r,$context,$permission,
+ $crstype,$showcredits);
+ if ($result eq 'missingdata') {
+ delete($env{'form.state'});
+ &Apache::lonuserutils::print_first_users_upload_form($r,$context);
+ }
+ }
+ } else {
+ delete($env{'form.state'});
+ &Apache::lonuserutils::print_first_users_upload_form($r,$context);
}
} else {
&Apache::lonuserutils::print_first_users_upload_form($r,$context);
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.192 loncom/interface/lonuserutils.pm:1.193
--- loncom/interface/lonuserutils.pm:1.192 Sat Nov 4 20:23:23 2017
+++ loncom/interface/lonuserutils.pm Sat Nov 4 20:59:39 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.192 2017/11/04 20:23:23 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.193 2017/11/04 20:59:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1132,6 +1132,11 @@
&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'}){
$firstLine=shift(@records);
@@ -1214,6 +1219,7 @@
}
&print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear,
$context,$permission,$crstype,$showcredits);
+ return 'ok';
}
sub setup_date_selectors {
@@ -4179,7 +4185,7 @@
$r->print('<span class="LC_error">'.&mt('Error').': '.
&mt('Enrollment of users not permitted for specified default domain: [_1].',
&Apache::lonnet::domain($env{'form.defaultdomain'},'description')).'</span>');
- return;
+ return 'untrusted';
}
}
} elsif ($context eq 'author') {
@@ -4193,7 +4199,7 @@
$r->print('<span class="LC_error">'.&mt('Error').': '.
&mt('Addition of users not permitted for specified default domain: [_1].',
&Apache::lonnet::domain($env{'form.defaultdomain'},'description')).'</span>');
- return;
+ return 'untrusted';
}
}
} elsif (($context eq 'domain') && ($setting eq 'domain')) {
@@ -4206,7 +4212,7 @@
$r->print('<span class="LC_error">'.&mt('Error').': '.
&mt('Addition of users not permitted for specified default domain: [_1].',
&Apache::lonnet::domain($env{'form.defaultdomain'},'description')).'</span>');
- return;
+ return 'untrusted';
}
}
}
@@ -4219,9 +4225,9 @@
} 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>');
- return;
+ $r->print('<p class="LC_error">'.&mt('Error').': '.
+ &mt('Invalid home server specified').'</p>');
+ return 'invalidhome';
}
}
# Determine authentication mechanism
@@ -4248,7 +4254,7 @@
}
if ($amode =~ /^krb/) {
if (! defined($genpwd) || $genpwd eq '') {
- $r->print('<span class="Error">'.': '.
+ $r->print('<span class="Error">'.
&mt('Unable to enroll users').' '.
&mt('No Kerberos domain was specified.').'</span></p>');
$amode = ''; # This causes the loop below to be skipped
@@ -4321,6 +4327,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 '')) {
#######################################
@@ -4934,6 +4945,7 @@
}
}
} # end of unless
+ return 'ok';
}
sub print_namespacing_alerts {
More information about the LON-CAPA-cvs
mailing list