--- loncom/interface/lonuserutils.pm 2008/12/12 16:50:53 1.77 +++ loncom/interface/lonuserutils.pm 2009/05/06 16:19:34 1.92 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.77 2008/12/12 16:50:53 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.92 2009/05/06 16:19:34 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; @@ -328,7 +328,7 @@ sub print_upload_manager_header { &javascript_validations('upload',$krbdefdom,$password_choice,undef, $env{'request.role.domain'},$context, $groupslist); - my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':''); + my $checked=(($env{'form.noFirstLine'})?' checked="checked"':''); $r->print(&mt('Total number of records found in file: [_1]',''.$distotal.''). "
\n"); $r->print('

'. @@ -341,7 +341,7 @@ sub print_upload_manager_header { &hidden_input('fileupload',$env{'form.fileupload'}). &hidden_input('upfiletype',$env{'form.upfiletype'}). &hidden_input('upfile_associate',$env{'form.upfile_associate'})); - $r->print('

\n". - '


'.&mt('Students selected from this list can be dropped.').'

'."\n"; } if ($context eq 'course' || $context eq 'domain') { @@ -816,13 +838,13 @@ sub forceid_change { my ($context) = @_; my $output = "

".&mt('Student/Employee ID')."

\n". - "

\n".'

\n".'
'."\n". &mt('(only do if you know what you are doing.)')."\n"; if ($context eq 'domain') { $output .= '
'."\n"; } @@ -864,6 +886,7 @@ sub print_upload_manager_form { 'email_choice' => '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, @@ -1308,7 +1332,7 @@ sub print_userlist { .''.(' 'x3)."\n"); my $roleselected = ''; if ($env{'form.showrole'} eq 'Any') { - $roleselected = ' selected="selected" '; + $roleselected = ' selected="selected"'; } my ($cnum,$cdom); $r->print(&role_filter($context)); @@ -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"); @@ -1496,7 +1526,7 @@ sub role_filter { my $output; my $roleselected = ''; if ($env{'form.showrole'} eq 'Any') { - $roleselected = ' selected="selected" '; + $roleselected = ' selected="selected"'; } my ($role_select); if ($context eq 'domain') { @@ -1512,7 +1542,7 @@ sub role_filter { foreach my $role (@poss_roles) { $roleselected = ''; if ($role eq $env{'form.showrole'}) { - $roleselected = ' selected="selected" '; + $roleselected = ' selected="selected"'; } my $plrole; if ($role eq 'cr') { @@ -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", @@ -2182,15 +2212,15 @@ END foreach my $item (@linkdests) { my $checkedstr = ''; if ($item eq $usernamelink) { - $checkedstr = ' checked="checked" '; + $checkedstr = ' checked="checked"'; } - $output .= '
'; + $output .= '
'; } my $checkwin; if ($env{'form.userwin'}) { - $checkwin = 'checked = "checked"'; + $checkwin = ' checked="checked"'; } - $output .= ''.$lt{'owin'}.'
'; + $output .= ''.$lt{'owin'}.''; } $output .= "\n".''."\n". &Apache::loncommon::start_data_table(). @@ -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})) { @@ -2502,7 +2537,7 @@ END } } $r->print(''); + 'actionlist" value="'.$checkval.'" />'); } else { $r->print(' '); } @@ -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"); } @@ -2531,7 +2572,7 @@ END } if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') { - $r->print(' '); + $r->print(' '); } else { $r->print('   '); } @@ -2818,8 +2859,8 @@ sub select_actions { } } if ($choices{'sections'}) { - $output .= ''."\n". - ''."\n"; + $output .= ''."\n". + ''."\n"; } } return $output; @@ -2997,7 +3038,7 @@ ENDJS $output .= $info.$secbox; } $output .= '

'. -'

'."\n". +'

'."\n". ''; return $output; } @@ -3218,7 +3259,7 @@ sub show_drop_list { $check_uncheck_js

- + END my ($indexhash,$keylist) = &make_keylist_array(); my $studentcount = 0; @@ -3336,7 +3377,7 @@ END # $r->print(&Apache::loncommon::start_data_table_row()); $r->print(<<"END"); - + $username $domain $id @@ -3355,10 +3396,14 @@ END 'ua' => "uncheck all", ); $r->print(<<"END"); -

-   - -

+

+

+   + +

+

+ +

END return; } @@ -3369,10 +3414,13 @@ END sub print_first_users_upload_form { my ($r,$context) = @_; my $str; - $str = ''; + $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 +3433,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 +3478,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 +3562,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; } @@ -3561,6 +3611,8 @@ sub upfile_drop_add { } else { $r->print('

'.&mt('Adding/Modifying Users')."

\n

\n"); } + $r->rflush; + my %counts = ( user => 0, auth => 0, @@ -3700,7 +3752,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; @@ -3783,7 +3843,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]} = ''; @@ -3832,7 +3892,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 '') { @@ -3852,7 +3912,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]; @@ -3867,7 +3927,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) { @@ -4382,7 +4443,7 @@ sub course_sections { my $output = ''; my @sections = (sort {$a <=> $b} keys %{$sections_count}); my $numsec = scalar(@sections); - my $is_selected = ' selected="selected" '; + my $is_selected = ' selected="selected"'; if ($numsec <= 1) { $output = '