--- loncom/interface/lonuserutils.pm 2012/02/08 19:35:20 1.136.6.2
+++ loncom/interface/lonuserutils.pm 2012/08/21 01:50:34 1.140
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.136.6.2 2012/02/08 19:35:20 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.140 2012/08/21 01:50:34 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,8 +47,7 @@ sub modifystudent {
# this one. If $csec is defined, drop them from all other sections of
# this course and add them to section $csec
my ($cnum,$cdom) = &get_course_identity($courseid);
- my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1});
- my %roles = &Apache::lonnet::dump('roles',$udom,$unam,'.',undef,$extra);
+ my %roles = &Apache::lonnet::dump('roles',$udom,$unam);
my ($tmp) = keys(%roles);
# Bail out if we were unable to get the students roles
return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i);
@@ -342,8 +341,7 @@ sub print_upload_manager_header {
."
\n");
$r->print('
'.
&mt('Identify fields in uploaded list')."
\n");
- $r->print(&mt('Enter as many fields as you can.').' '.
- &mt('The system will inform you and bring you back to this page, [_1]if the data selected are insufficient to add users.',' ')." \n");
+ $r->print(&mt('Enter as many fields as you can. The system will inform you and bring you back to this page, if the data selected are insufficient to add users.')." \n");
$r->print(&hidden_input('action','upload').
&hidden_input('state','got_file').
&hidden_input('associate','').
@@ -1423,6 +1421,7 @@ sub curr_role_permissions {
sub my_custom_roles {
my ($crstype) = @_;
my %returnhash=();
+ my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1});
my %rolehash=&Apache::lonnet::dump('roles');
foreach my $key (keys(%rolehash)) {
if ($key=~/^rolesdef\_(\w+)$/) {
@@ -1445,8 +1444,9 @@ sub print_userlist {
if ($env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) {
$env{'form.Status'} = 'Active';
}
+ my $onchange = "javascript:updateCols('Status');";
my $status_select = &Apache::lonhtmlcommon::StatusOptions
- ($env{'form.Status'});
+ ($env{'form.Status'},undef,undef,$onchange);
if ($env{'form.showrole'} eq '') {
if ($context eq 'course') {
@@ -1479,12 +1479,12 @@ sub print_userlist {
$r->print('');
return;
}
if (!(($context eq 'domain') &&
(($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) {
- $r->print(
- "\n\n"
- .'
'."\n";
- }
- }
- }
$output .= &Apache::loncommon::end_data_table_header_row();
# Done with the HTML header line
} elsif ($mode eq 'csv') {
@@ -2555,14 +2610,12 @@ END
$CSVfile = undef;
}
#
- push @cols,'clicker';
# Write headers and data to file
print $CSVfile '"'.$results_description.'"'."\n";
print $CSVfile '"'.join('","',map {
&Apache::loncommon::csv_translate($lt{$_})
} (@cols))."\"\n";
} elsif ($mode eq 'excel') {
- push @cols,'clicker';
# Create the excel spreadsheet
($excel_workbook,$excel_filename,$format) =
&Apache::loncommon::create_workbook($r);
@@ -2686,7 +2739,7 @@ END
}
}
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
- if (($displayphotos eq 'on') && ($role eq 'st')) {
+ if ((grep/^photo$/,@cols) && ($role eq 'st')) {
$userlist->{$user}->[$index{'photo'}] =
&Apache::lonnet::retrievestudentphoto($udom,$uname,'jpg');
$userlist->{$user}->[$index{'thumbnail'}] =
@@ -2830,27 +2883,28 @@ END
$showitem = $ltstatus{$in{$item}};
}
$r->print('
'.$showitem.'
'."\n");
- } else {
- $r->print('
'.$in{$item}.'
'."\n");
- }
- }
- if (($context eq 'course') && ($mode ne 'autoenroll')) {
- if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
- if ($displayclickers eq 'on') {
- my $clickers =
+ } elsif ($item eq 'photo') {
+ if (($context eq 'course') && ($mode ne 'autoenroll') &&
+ ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'})) {
+ if ($role eq 'st') {
+ $r->print('
');
+ } else {
+ $r->print('
');
+ }
+ }
+ } elsif ($item eq 'clicker') {
+ if (($context eq 'course') && ($mode ne 'autoenroll')) {
+ if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
+ my $clickers =
(&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];
- if ($clickers!~/\w/) { $clickers='-'; }
- $r->print('
'.$clickers.'
');
- } else {
- $r->print('
');
- }
- if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
- if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') {
- $r->print('
');
+ if ($clickers!~/\w/) { $clickers='-'; }
+ $r->print('
'.$clickers.'
');
} else {
- $r->print('
');
- }
- }
+ $r->print('
'."\n");
+ }
+ }
+ } else {
+ $r->print('
'.$in{$item}.'
'."\n");
}
}
$r->print(&Apache::loncommon::end_data_table_row());
@@ -4181,32 +4235,10 @@ sub upfile_drop_add {
}
$checkid = 1;
$newuser = 1;
- if ($username =~/^[^\@]+\@[^\@]+$/) {
- if ($email eq '') {
- $email = $username;
- }
- my $lc_email;
- if ($username eq $email) {
- $lc_email = lc($email);
- }
- my $lc_username = lc($username);
- if ($lc_username ne $username) {
- if ($username eq $email) {
- $email = $lc_username;
- }
- $username = $lc_username;
- $uhome=&Apache::lonnet::homeserver($username,$userdomain);
- if ($uhome ne 'no_host') {
- $newuser = 0;
- }
- }
- }
- }
- my $user = $username.':'.$newuserdom;
- if ($newuser) {
+ my $user = $username.':'.$newuserdom;
my $checkhash;
my $checks = { 'username' => 1 };
- $checkhash->{$user} = { 'newuser' => 1, };
+ $checkhash->{$username.':'.$newuserdom} = { 'newuser' => 1, };
&Apache::loncommon::user_rule_check($checkhash,$checks,
\%alerts,\%rulematch,\%inst_results,\%curr_rules,
\%got_rules);
@@ -4228,13 +4260,8 @@ sub upfile_drop_add {
}
unless ($cancreate{$usertype}) {
my $showtype = $longtypes{$usertype};
- if ($usertype eq 'unofficial') {
- $r->print(' '.
- &mt("[_1]: The user does not exist, and the new user's username must be an e-mail address.",''.$username.''));
- } else {
- $r->print(' '.
- &mt("[_1]: The user does not exist, and you are not permitted to create users of type: [_2].",''.$username.'',$showtype));
- }
+ $r->print(' '.
+ &mt('[_1]: The user does not exist, and you are not permitted to create users of type: [_2].',''.$username.'',$showtype));
next;
}
} else {