--- loncom/interface/lonuserutils.pm 2008/12/06 20:32:37 1.75
+++ loncom/interface/lonuserutils.pm 2009/03/12 17:30:55 1.85
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.75 2008/12/06 20:32:37 schafran Exp $
+# $Id: lonuserutils.pm,v 1.85 2009/03/12 17:30:55 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -86,7 +86,7 @@ sub modifystudent {
sub modifyuserrole {
my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass,
$first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role,
- $end,$start,$checkid) = @_;
+ $end,$start,$checkid,$inststatus) = @_;
my ($scope,$userresult,$authresult,$roleresult,$idresult);
if ($setting eq 'course' || $context eq 'course') {
$scope = '/'.$cid;
@@ -124,7 +124,7 @@ sub modifyuserrole {
$userresult =
&Apache::lonnet::modifyuser($udom,$uname,$uid,$umode,$upass,$first,
$middle,$last,$gene,$forceid,$desiredhome,
- $email,$role,$start,$end);
+ $email,$inststatus);
if ($userresult eq 'ok') {
if ($role ne '') {
$role =~ s/_/\//g;
@@ -408,10 +408,13 @@ sub javascript_validations {
domain => 'The optional domain field was not specified.',
continue => 'Continue adding users?',
);
+ if (($mode eq 'upload') && ($context eq 'domain')) {
+ $alert{'inststatus'} = &mt('The optional affiliation field was not specified');
+ }
my $function_name = <<"END";
$setsections_js
-function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain) {
+function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus) {
END
my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($domain);
my $auth_checks;
@@ -538,6 +541,20 @@ END
}
message+='$alert{'domain'}';
}
+END
+ if (($mode eq 'upload') && ($context eq 'domain')) {
+ $optional_checks .= (< 'scalar',
'role_choice' => 'scalar',
'domain_choice' => 'scalar',
+ 'inststatus_choice' => 'scalar',
};
my $defdom = $env{'request.role.domain'};
if ($context eq 'course') {
@@ -895,7 +918,8 @@ sub print_upload_manager_form {
['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],
['email',&mt('E-mail Address'), $env{'form.email_choice'}],
['role',&mt('Role'), $env{'form.role_choice'}],
- ['domain',&mt('Domain'), $env{'form.domain_choice'}]);
+ ['domain',&mt('Domain'), $env{'form.domain_choice'}],
+ ['inststatus',&mt('Affiliation'), $env{'form.inststatus_choice'}]);
if ($env{'form.upfile_associate'} eq 'reverse') {
&Apache::loncommon::csv_print_samples($r,\@records);
$i=&Apache::loncommon::csv_print_select_table($r,\@records,
@@ -1316,6 +1340,12 @@ sub print_userlist {
($cnum,$cdom) = &get_course_identity();
$r->print(§ion_group_filter($cnum,$cdom));
}
+ if ($env{'form.phase'} eq '') {
+ $r->print('
'.&list_submit_button(&mt('Display List of Users')).
+ "\n
\n".
+ '');
+ return;
+ }
if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
$r->print(' '.&list_submit_button(&mt('Update Display')).
"\n\n");
@@ -1908,15 +1938,15 @@ sub aggregate_user_info {
sub process_date_info {
my ($userdata) = @_;
my $now = time;
- $userdata->{'status'} = &mt('Active');
+ $userdata->{'status'} = 'Active';
if ($userdata->{'start'} > 0) {
if ($now < $userdata->{'start'}) {
- $userdata->{'status'} = &mt('Future');
+ $userdata->{'status'} = 'Future';
}
}
if ($userdata->{'end'} > 0) {
if ($now > $userdata->{'end'}) {
- $userdata->{'status'} = &mt('Expired');
+ $userdata->{'status'} = 'Expired';
}
}
return;
@@ -2050,7 +2080,7 @@ END
'status' => "status",
'role' => "role",
'type' => "enroll type/action",
- 'email' => "email address",
+ 'email' => "e-mail address",
'photo' => "photo",
'extent' => "extent",
'pr' => "Proceed",
@@ -2058,7 +2088,7 @@ END
'ua' => "uncheck all",
'ac' => "Action to take for selected users",
'link' => "Behavior of clickable username link for each user",
- 'aboutme' => "Display a user's personal page",
+ 'aboutme' => "Display a user's personal information page",
'owin' => "Open in a new window",
'modify' => "Modify a user's information",
'clicker' => "Clicker-ID",
@@ -2303,6 +2333,11 @@ END
$grpfilter = 'all';
}
}
+ my %ltstatus = &Apache::lonlocal::texthash(
+ Active => 'Active',
+ Future => 'Future',
+ Expired => 'Expired',
+ );
# Get groups, role, permanent e-mail so we can sort on them if
# necessary.
foreach my $user (keys(%{$userlist})) {
@@ -2457,7 +2492,7 @@ END
$cellentry = ''.&mt('auto').' ';
$autocount ++;
} else {
- $cellentry = '';
}
$r->print("$cellentry | \n");
} else {
@@ -2515,6 +2550,12 @@ END
$r->print(''.&print_username_link($mode,\%in).' | ');
} elsif (($item eq 'start' || $item eq 'end') && ($actionselect)) {
$r->print(''.$in{$item}.' | '."\n");
+ } elsif ($item eq 'status') {
+ my $showitem = $in{$item};
+ if (defined($ltstatus{$in{$item}})) {
+ $showitem = $ltstatus{$in{$item}};
+ }
+ $r->print(''.$showitem.' | '."\n");
} else {
$r->print(''.$in{$item}.' | '."\n");
}
@@ -2997,7 +3038,7 @@ ENDJS
$output .= $info.$secbox;
}
$output .= ''.
-'
'."\n".
+''."\n".
'';
return $output;
}
@@ -3372,7 +3413,10 @@ sub print_first_users_upload_form {
$str = '';
$str .= '';
$str .= '';
- $str .= "".&mt('Upload a file containing information about users')."
\n";
+ $str .= ''.&mt('Upload a file containing information about users').'
'."\n";
+ $str .= ''
+ .&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.')
+ .'
'."\n";
$str .= &Apache::loncommon::upfile_select_html();
$str .= '';
$str .= &Apache::loncommon::help_open_topic("Course_Create_Class_List",
@@ -3385,7 +3429,7 @@ sub print_first_users_upload_form {
$str .= '
\n";
$str .= ''."
\n";
+ &mt('Next').'">'."
\n";
$str .= &Apache::loncommon::end_page();
$r->print($str);
return;
@@ -3430,7 +3474,8 @@ sub upfile_drop_add {
'ipwd_choice' => 'scalar',
'email_choice' => 'scalar',
'role_choice' => 'scalar',
- 'domain_choice' => 'scalar'});
+ 'domain_choice' => 'scalar',
+ 'inststatus_choice' => 'scalar'});
#
my ($startdate,$enddate) = &get_dates_from_form();
if ($env{'form.makedatesdefault'}) {
@@ -3513,6 +3558,7 @@ sub upfile_drop_add {
'permanentemail','id');
my %canmodify;
if (&Apache::lonnet::allowed('mau',$domain)) {
+ push(@userinfo,'inststatus');
foreach my $field (@userinfo) {
$canmodify{$field} = 1;
}
@@ -3637,14 +3683,13 @@ sub upfile_drop_add {
ne &LONCAPA::clean_username($entries{$fields{'username'}})) {
$r->print('
'.
&mt('[_1]: Unacceptable username for user [_2] [_3] [_4] [_5]',
- ''.$entries{$fields{'username'}}.'',$fname,$mname,$lname,$gen).
- '');
+ ''.$entries{$fields{'username'}}.'',$fname,$mname,$lname,$gen));
next;
} else {
if ($entries{$fields{'domain'}}
ne &LONCAPA::clean_domain($entries{$fields{'domain'}})) {
$r->print('
'. ''.$entries{$fields{'domain'}}.
- ': '.&mt('Unacceptable domain for user [_2] [_3] [_4] [_5]',$fname,$mname,$lname,$gen).'');
+ ': '.&mt('Unacceptable domain for user [_2] [_3] [_4] [_5]',$fname,$mname,$lname,$gen));
next;
}
my $username = $entries{$fields{'username'}};
@@ -3701,7 +3746,15 @@ sub upfile_drop_add {
if (defined($fields{'email'})) {
if (defined($entries{$fields{'email'}})) {
$email=$entries{$fields{'email'}};
- unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; } }
+ unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; }
+ }
+ }
+ # determine affiliation
+ my $inststatus='';
+ if (defined($fields{'inststatus'})) {
+ if (defined($entries{$fields{'inststatus'}})) {
+ $inststatus=$entries{$fields{'inststatus'}};
+ }
}
# determine user password
my $password = $genpwd;
@@ -3784,7 +3837,7 @@ sub upfile_drop_add {
}
}
my @newinfo = (\$fname,\$mname,\$lname,\$gen,\$email,\$id);
- for (my $i=0; $i<@userinfo; $i++) {
+ for (my $i=0; $i<@newinfo; $i++) {
if (${$newinfo[$i]} ne '') {
if (!$canmodify{$userinfo[$i]}) {
${$newinfo[$i]} = '';
@@ -3833,7 +3886,7 @@ sub upfile_drop_add {
$fname,$mname,$lname,$gen,$sec,$enddate,
$startdate,$env{'form.forceid'},
$desiredhost,$email,'manual','',$cid,
- '',$context);
+ '',$context,$inststatus);
$userresult = $roleresult;
} else {
if ($role ne '') {
@@ -3853,7 +3906,7 @@ sub upfile_drop_add {
$mname,$lname,$gen,$sec,
$env{'form.forceid'},$desiredhost,
$email,$role,$enddate,
- $startdate,$checkid);
+ $startdate,$checkid,$inststatus);
}
} elsif (@secs > 0) {
$singlesec = $secs[0];
@@ -3868,7 +3921,8 @@ sub upfile_drop_add {
$id,$amode,$password,$fname,
$mname,$lname,$gen,$singlesec,
$env{'form.forceid'},$desiredhost,
- $email,$role,$enddate,$startdate,$checkid);
+ $email,$role,$enddate,$startdate,
+ $checkid,$inststatus);
}
}
if ($multiple) {