--- loncom/interface/lonuserutils.pm 2007/12/22 00:47:25 1.23
+++ loncom/interface/lonuserutils.pm 2008/09/26 08:38:11 1.70
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.23 2007/12/22 00:47:25 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.70 2008/09/26 08:38:11 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,7 +42,7 @@ use LONCAPA qw(:DEFAULT :match);
###############################################################
# Drop student from all sections of a course, except optional $csec
sub modifystudent {
- my ($udom,$unam,$courseid,$csec,$desiredhost)=@_;
+ my ($udom,$unam,$courseid,$csec,$desiredhost,$context)=@_;
# if $csec is undefined, drop the student from all the courses matching
# this one. If $csec is defined, drop them from all other sections of
# this course and add them to section $csec
@@ -69,14 +69,14 @@ sub modifystudent {
# dom name id mode pass f m l g
($udom,$unam,'', '', '',undef,undef,undef,undef,
$section,time,undef,undef,$desiredhost,'','manual',
- '',$courseid);
+ '',$courseid,'',$context);
$result .= $reply.':';
}
}
}
}
if ($result eq '') {
- $result = 'Unable to find section for this student';
+ $result = &mt('Unable to find section for this student');
} else {
$result =~ s/(ok:)+/ok/g;
}
@@ -129,7 +129,8 @@ sub modifyuserrole {
if ($role ne '') {
$role =~ s/_/\//g;
$roleresult = &Apache::lonnet::assignrole($udom,$uname,$scope,
- $role,$end,$start);
+ $role,$end,$start,'',
+ '',$context);
}
}
return ($userresult,$authresult,$roleresult,$idresult);
@@ -168,7 +169,7 @@ sub propagate_id_change {
}
sub update_classlist {
- my ($cdom,$cnum,$udom,$uname,$user) = @_;
+ my ($cdom,$cnum,$udom,$uname,$user,$newend) = @_;
my ($uid,$classlistentry);
my $fullname =
&Apache::lonnet::format_name($user->{'firstname'},$user->{'middlename'},
@@ -179,15 +180,37 @@ sub update_classlist {
my @classinfo = split(/:/,$classhash{$uname.':'.$udom});
my $ididx=&Apache::loncoursedata::CL_ID() - 2;
my $nameidx=&Apache::loncoursedata::CL_FULLNAME() - 2;
+ my $endidx = &Apache::loncoursedata::CL_END() - 2;
+ my $startidx = &Apache::loncoursedata::CL_START() - 2;
for (my $i=0; $i<@classinfo; $i++) {
- if ($i == $ididx) {
+ if ($i == $endidx) {
+ if ($newend ne '') {
+ $classlistentry .= $newend.':';
+ } else {
+ $classlistentry .= $classinfo[$i].':';
+ }
+ } elsif ($i == $startidx) {
+ if ($newend ne '') {
+ if ($classinfo[$i] > $newend) {
+ $classlistentry .= $newend.':';
+ } else {
+ $classlistentry .= $classinfo[$i].':';
+ }
+ } else {
+ $classlistentry .= $classinfo[$i].':';
+ }
+ } elsif ($i == $ididx) {
if (defined($user->{'id'})) {
$classlistentry .= $user->{'id'}.':';
} else {
$classlistentry .= $classinfo[$i].':';
}
} elsif ($i == $nameidx) {
- $classlistentry .= $fullname.':';
+ if (defined($user->{'lastname'})) {
+ $classlistentry .= $fullname.':';
+ } else {
+ $classlistentry .= $classinfo[$i].':';
+ }
} else {
$classlistentry .= $classinfo[$i].':';
}
@@ -304,7 +327,7 @@ sub print_upload_manager_header {
my $javascript_validations =
&javascript_validations('upload',$krbdefdom,$password_choice,undef,
$env{'request.role.domain'},$context,
- $permission,$groupslist);
+ $groupslist);
my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':'');
$r->print(&mt('Total number of records found in file: [_1].',$distotal).
" \n");
@@ -318,8 +341,8 @@ 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(' print(' ');
$r->print('');
@@ -332,18 +355,13 @@ sub print_upload_manager_header {
###############################################################
sub javascript_validations {
my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain,
- $context,$permission,$groupslist)=@_;
-
+ $context,$groupslist)=@_;
my %param = (
kerb_def_dom => $krbdefdom,
curr_authtype => $curr_authtype,
);
- if ($mode eq 'createuser') {
- $param{'formname'} = 'cu';
- } elsif ($mode eq 'upload') {
+ if ($mode eq 'upload') {
$param{'formname'} = 'studentform';
- } elsif ($mode eq 'singlestudent') {
- $param{'formname'} = 'cu';
} elsif ($mode eq 'createcourse') {
$param{'formname'} = 'ccrs';
} elsif ($mode eq 'modifycourse') {
@@ -367,7 +385,7 @@ sub javascript_validations {
}
} elsif ($context eq 'domain') {
$setsection_call = 'setCourse()';
- $setsections_js = &dc_setcourse_js($param{'formname'},$mode);
+ $setsections_js = &dc_setcourse_js($param{'formname'},$mode,$context);
}
$finish = " var checkSec = $setsection_call\n".
" if (checkSec == 'ok') {\n".
@@ -387,13 +405,13 @@ sub javascript_validations {
section => 'The optional section field was not specified.',
email => 'The optional email address field was not specified.',
role => 'The optional role field was not specified.',
+ domain => 'The optional domain field was not specified.',
continue => 'Continue adding users?',
);
-
- my $function_name =(<\n";
if ($context eq 'domain') {
- $Str .= '
'.&mt('Change authentication for existing users to these settings?').'
';
+ $Str .= '
'.&mt('Change authentication for existing users in domain "[_1]" to these settings?',$defdom).'
';
} else {
$Str .= "
\n".
&mt('Note: this will not take effect if the user already exists').
@@ -729,6 +758,8 @@ sub print_upload_manager_footer {
} else {
$Str .= $home_server_pick;
}
+ $Str .= '
\n";
@@ -738,13 +769,13 @@ sub print_upload_manager_footer {
}
if ($context eq 'author') {
$Str .= '
'.&mt('Default role')."
\n".
- &mt('Choose the role to assign to users without one specified in the uploaded file');
+ &mt('Choose the role to assign to users without a value specified in the uploaded file');
} elsif ($context eq 'course') {
$Str .= '
'.&mt('Default role and section')."
\n".
- &mt('Choose the role and/or section to assign to users without one specified in the uploaded file');
+ &mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file');
} else {
- $Str .= '
'.&mt('Default role and/or section')." \n".
- &mt('Role and/or section for users without one in the uploaded file.');
+ $Str .= '
'.&mt('Default role and/or section(s)')." \n".
+ &mt('Role and/or section(s) for users without values specified in the uploaded file.');
}
$Str .= ' ';
if (($context eq 'domain') || ($context eq 'author')) {
@@ -761,18 +792,16 @@ sub print_upload_manager_footer {
$permission,$context,'upload');
$Str .= $secbox."
".&mt('Full Update')."
\n".
'\n";
+ ' '.&mt('Display students with current/future access who are not in the uploaded file.').' '.&mt('Students selected from this list can be dropped.').'
'."\n";
}
if ($context eq 'course' || $context eq 'domain') {
$Str .= &forceid_change($context);
}
$Str .= '';
$r->print($Str);
@@ -782,17 +811,18 @@ sub print_upload_manager_footer {
sub forceid_change {
my ($context) = @_;
my $output =
- "
".&mt('ID/Student Number')."
\n".
+ "
".&mt('Student/Employee ID')."
\n".
"
\n".' '."\n".
- &mt('(only do if you know what you are doing.)')." \n";
+ &mt('Disable Student/Employee ID Safeguard and force change of conflicting IDs').
+ ' '."\n".
+ &mt('(only do if you know what you are doing.)')."\n";
if ($context eq 'domain') {
- $output .= '
'."\n";
+ &mt('Update Student/Employee ID in courses in which user is active/future student,[_1](if forcing change).',' ').
+ ''."\n";
}
+ $output .= '';
return $output;
}
@@ -829,6 +859,7 @@ sub print_upload_manager_form {
'ipwd_choice' => 'scalar',
'email_choice' => 'scalar',
'role_choice' => 'scalar',
+ 'domain_choice' => 'scalar',
};
my $defdom = $env{'request.role.domain'};
if ($context eq 'course') {
@@ -855,11 +886,12 @@ sub print_upload_manager_form {
['mname',&mt('Middle Names/Initials'),$env{'form.mname_choice'}],
['lname',&mt('Last Name'), $env{'form.lname_choice'}],
['gen', &mt('Generation'), $env{'form.gen_choice'}],
- ['id', &mt('ID/Student Number'),$env{'form.id_choice'}],
+ ['id', &mt('Student/Employee ID'),$env{'form.id_choice'}],
['sec', &mt('Section'), $env{'form.sec_choice'}],
['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],
['email',&mt('E-mail Address'), $env{'form.email_choice'}],
- ['role',&mt('Role'), $env{'form.role_choice'}]);
+ ['role',&mt('Role'), $env{'form.role_choice'}],
+ ['domain',&mt('Domain'), $env{'form.domain_choice'}]);
if ($env{'form.upfile_associate'} eq 'reverse') {
&Apache::loncommon::csv_print_samples($r,\@records);
$i=&Apache::loncommon::csv_print_select_table($r,\@records,
@@ -936,8 +968,15 @@ sub setup_date_selectors {
sub get_dates_from_form {
- my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
- my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate');
+ my ($startname,$endname) = @_;
+ if ($startname eq '') {
+ $startname = 'startdate';
+ }
+ if ($endname eq '') {
+ $endname = 'enddate';
+ }
+ my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname);
+ my $enddate = &Apache::lonhtmlcommon::get_date_from_form($endname);
if ($env{'form.no_end_date'}) {
$enddate = 0;
}
@@ -962,7 +1001,7 @@ sub date_setting_table {
($env{'form.action'} eq 'upload')) {
if ($env{'request.course.sec'} eq '') {
$dateDefault = ''.
- '';
}
@@ -970,7 +1009,7 @@ sub date_setting_table {
}
my $perpetual = ' '.&mt('no ending date').'';
if ($mode eq 'create_enrolldates') {
@@ -1001,14 +1040,14 @@ sub make_dates_default {
{'default_enrollment_start_date'=>$startdate,
'default_enrollment_end_date' =>$enddate},$cdom,$cnum);
if ($put_result eq 'ok') {
- $result .= &mt('Set default start and end dates for course').
+ $result .= &mt('Set default start and end access dates for course.').
' '."\n";
#
# Refresh the course environment
&Apache::lonnet::coursedescription($env{'request.course.id'},
{'freshen_cache' => 1});
} else {
- $result .= &mt('Unable to set default dates for course').":".$put_result.
+ $result .= &mt('Unable to set default access dates for course.').":".$put_result.
' ';
}
}
@@ -1256,40 +1295,26 @@ sub print_userlist {
$output_selector .= "\n".$option;
}
$output_selector .= '';
- $r->print(''.&mt('Output Format: [_1]',$output_selector).''.(' 'x3));
- }
- $r->print(''.&mt('User Status: [_1]',$status_select).''.(' 'x3)."\n");
+ $r->print(''
+ .&mt('Output Format: [_1]',$output_selector)
+ .''.(' 'x3));
+ }
+ $r->print(''
+ .&mt('User Status: [_1]',$status_select)
+ .''.(' 'x3)."\n");
my $roleselected = '';
if ($env{'form.showrole'} eq 'Any') {
$roleselected = ' selected="selected" ';
}
- my $role_select;
- if ($context eq 'domain') {
- $role_select = &domain_roles_select();
- $r->print(''.&mt('Role Type: [_1]',$role_select).'');
- } else {
- $role_select = '';
- $r->print(''.&mt('Role: [_1]',$role_select).'');
+ my ($cnum,$cdom);
+ $r->print(&role_filter($context));
+ if ($context eq 'course') {
+ ($cnum,$cdom) = &get_course_identity();
+ $r->print(§ion_group_filter($cnum,$cdom));
}
if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
- $r->print(&list_submit_button(&mt('Update Display'))."\n\n");
+ $r->print(' '.&list_submit_button(&mt('Update Display')).
+ "\n\n");
}
my ($indexhash,$keylist) = &make_keylist_array();
my (%userlist,%userinfo);
@@ -1305,7 +1330,7 @@ sub print_userlist {
&Apache::lonhtmlcommon::row_closure(1).
&Apache::lonhtmlcommon::end_pick_box().''.
'
\n");
+ "\n".''.&mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.').''."\n");
if ($env{'form.coursepick'}) {
$r->print(''.&mt('Searching').' ...
');
}
@@ -1314,34 +1339,26 @@ sub print_userlist {
}
$r->rflush();
if ($context eq 'course') {
- my $classlist = &Apache::loncoursedata::get_classlist();
- my $secidx = &Apache::loncoursedata::CL_SECTION();
- my $viewablesec = &viewable_section($permission);
- foreach my $student (keys(%{$classlist})) {
- my $section = $classlist->{$student}[$secidx];
- if ($viewablesec ne '') {
- if ($section ne $viewablesec) {
- next;
- } else {
- $userlist{$student} = $classlist->{$student};
- }
- } else {
- $userlist{$student} = $classlist->{$student};
+ if (($env{'form.showrole'} eq 'st') || ($env{'form.showrole'} eq 'Any')) {
+ my $classlist = &Apache::loncoursedata::get_classlist();
+ if (ref($classlist) eq 'HASH') {
+ %userlist = %{$classlist};
}
}
- my $cid = $env{'request.course.id'};
- my ($cnum,$cdom) = &get_course_identity($cid);
- my $showroles;
- if ($env{'form.showrole'} ne 'Any') {
- $showroles = [$env{'form.showrole'}];
- } else {
- $showroles = undef;
+ if ($env{'form.showrole'} ne 'st') {
+ my $showroles;
+ if ($env{'form.showrole'} ne 'Any') {
+ $showroles = [$env{'form.showrole'}];
+ } else {
+ $showroles = undef;
+ }
+ my $withsec = 1;
+ my $hidepriv = 1;
+ my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
+ \@statuses,$showroles,undef,$withsec,$hidepriv);
+ &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo,
+ \%advrolehash,$permission);
}
- my $withsec = 1;
- my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
- \@statuses,$showroles,undef,$withsec);
- &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo,
- \%advrolehash,$permission);
} else {
my (%cstr_roles,%dom_roles);
if ($context eq 'author') {
@@ -1390,7 +1407,8 @@ sub print_userlist {
} elsif ($env{'form.roletype'} eq 'course') {
if ($env{'form.coursepick'}) {
my %courses = &process_coursepick();
- my %allusers;
+ my %allusers;
+ my $hidepriv = 1;
foreach my $cid (keys(%courses)) {
my ($cnum,$cdom,$cdesc) = &get_course_identity($cid);
next if ($cnum eq '' || $cdom eq '');
@@ -1408,7 +1426,7 @@ sub print_userlist {
foreach my $type (@statuses) {
$access{$type} = $type;
}
- &Apache::loncommon::get_course_users($cdom,$cnum,\%access,\@roles,\@sections,\%users,\%userdata,\%statushash);
+ &Apache::loncommon::get_course_users($cdom,$cnum,\%access,\@roles,\@sections,\%users,\%userdata,\%statushash,$hidepriv);
foreach my $user (keys(%userdata)) {
next if (ref($userinfo{$user}) eq 'HASH');
foreach my $item ('fullname','id') {
@@ -1466,6 +1484,101 @@ sub print_userlist {
$env{'form.phase'}.'" />');
}
+sub role_filter {
+ my ($context) = @_;
+ my $output;
+ my $roleselected = '';
+ if ($env{'form.showrole'} eq 'Any') {
+ $roleselected = ' selected="selected" ';
+ }
+ my ($role_select);
+ if ($context eq 'domain') {
+ $role_select = &domain_roles_select();
+ $output = ''
+ .&mt('Role Type: [_1]',$role_select)
+ .'';
+ } else {
+ $role_select = '';
+ $output = ''
+ .&mt('Role: [_1]',$role_select)
+ .'';
+ }
+ return $output;
+}
+
+sub section_group_filter {
+ my ($cnum,$cdom) = @_;
+ my @filters;
+ if ($env{'request.course.sec'} eq '') {
+ @filters = ('sec');
+ }
+ push(@filters,'grp');
+ my %name = (
+ sec => 'secfilter',
+ grp => 'grpfilter',
+ );
+ my %title = &Apache::lonlocal::texthash (
+ sec => 'Section(s)',
+ grp => 'Group(s)',
+ all => 'all',
+ none => 'none',
+ );
+ my $output;
+ foreach my $item (@filters) {
+ my ($markup,@options);
+ if ($env{'form.'.$name{$item}} eq '') {
+ $env{'form.'.$name{$item}} = 'all';
+ }
+ if ($item eq 'sec') {
+ if ($env{'form.showrole'} eq 'cc') {
+ $env{'form.'.$name{$item}} = 'none';
+ }
+ my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
+ @options = sort(keys(%sections_count));
+ } elsif ($item eq 'grp') {
+ my %curr_groups = &Apache::longroup::coursegroups();
+ @options = sort(keys(%curr_groups));
+ }
+ if (@options > 0) {
+ my $currsel;
+ $markup = ''."\n";
+ foreach my $option ('all','none',@options) {
+ $currsel = '';
+ if ($env{'form.'.$name{$item}} eq $option) {
+ $currsel = ' selected="selected" ';
+ }
+ $markup .= ' '."\n";
+ }
+ $markup .= ''."\n";
+ $output .= (' 'x3).''.$title{$item}.': '.$markup.'';
+ }
+ }
+ return $output;
+}
+
sub list_submit_button {
my ($text) = @_;
return '';
@@ -1473,28 +1586,34 @@ sub list_submit_button {
sub gather_userinfo {
my ($context,$format,$userlist,$indexhash,$userinfo,$rolehash,$permission) = @_;
+ my $viewablesec;
+ if ($context eq 'course') {
+ $viewablesec = &viewable_section($permission);
+ }
foreach my $item (keys(%{$rolehash})) {
my %userdata;
if ($context eq 'author') {
($userdata{'username'},$userdata{'domain'},$userdata{'role'}) =
split(/:/,$item);
($userdata{'start'},$userdata{'end'})=split(/:/,$rolehash->{$item});
- &build_user_record(\%userdata,$userinfo,$indexhash,$item,$userlist);
+ &build_user_record($context,\%userdata,$userinfo,$indexhash,
+ $item,$userlist);
} elsif ($context eq 'course') {
- my $viewablesec = &viewable_section($permission);
($userdata{'username'},$userdata{'domain'},$userdata{'role'},
$userdata{'section'}) = split(/:/,$item,-1);
($userdata{'start'},$userdata{'end'})=split(/:/,$rolehash->{$item});
if (($viewablesec ne '') && ($userdata{'section'} ne '')) {
next if ($viewablesec ne $userdata{'section'});
}
- &build_user_record(\%userdata,$userinfo,$indexhash,$item,$userlist);
+ &build_user_record($context,\%userdata,$userinfo,$indexhash,
+ $item,$userlist);
} elsif ($context eq 'domain') {
if ($env{'form.roletype'} eq 'domain') {
($userdata{'role'},$userdata{'username'},$userdata{'domain'}) =
split(/:/,$item);
($userdata{'end'},$userdata{'start'})=split(/:/,$rolehash->{$item});
- &build_user_record(\%userdata,$userinfo,$indexhash,$item,$userlist);
+ &build_user_record($context,\%userdata,$userinfo,$indexhash,
+ $item,$userlist);
} elsif ($env{'form.roletype'} eq 'author') {
if (ref($rolehash->{$item}) eq 'HASH') {
$userdata{'extent'} = $item;
@@ -1503,7 +1622,8 @@ sub gather_userinfo {
($userdata{'start'},$userdata{'end'}) =
split(/:/,$rolehash->{$item}{$key});
my $uniqid = $key.':'.$item;
- &build_user_record(\%userdata,$userinfo,$indexhash,$uniqid,$userlist);
+ &build_user_record($context,\%userdata,$userinfo,
+ $indexhash,$uniqid,$userlist);
}
}
} elsif ($env{'form.roletype'} eq 'course') {
@@ -1521,9 +1641,9 @@ sub gather_userinfo {
# FIXME: actions on courses disabled for now
# if ($permission->{'cusr'}) {
# if ($numcids > 1) {
-# $spanstart .= '';
+# $spanstart .= ' ';
# } else {
-# $spanstart .= '';
+# $spanstart .= ' ';
# }
# }
$spanend = ' ';
@@ -1533,13 +1653,20 @@ sub gather_userinfo {
$rolehash->{$item}{$cid}{'desc'}.$space;
if (ref($rolehash->{$item}{$cid}{'secs'}) eq 'HASH') {
foreach my $sec (sort(keys(%{$rolehash->{$item}{$cid}{'secs'}}))) {
- $userdata{'extent'} .= $sec.$space.$rolehash->{$item}{$cid}{'secs'}{$sec}.$spanend;
+ if (($env{'form.Status'} eq 'Any') ||
+ ($env{'form.Status'} eq $rolehash->{$item}{$cid}{'secs'}{$sec})) {
+ $userdata{'extent'} .= $sec.$space.$rolehash->{$item}{$cid}{'secs'}{$sec}.$spanend;
+ $userdata{'status'} = $rolehash->{$item}{$cid}{'secs'}{$sec};
+ }
}
}
}
}
}
- &build_user_record(\%userdata,$userinfo,$indexhash,$item,$userlist);
+ if ($userdata{'status'} ne '') {
+ &build_user_record($context,\%userdata,$userinfo,
+ $indexhash,$item,$userlist);
+ }
}
}
}
@@ -1547,14 +1674,15 @@ sub gather_userinfo {
}
sub build_user_record {
- my ($userdata,$userinfo,$indexhash,$record_key,$userlist) = @_;
+ my ($context,$userdata,$userinfo,$indexhash,$record_key,$userlist) = @_;
next if ($userdata->{'start'} eq '-1' && $userdata->{'end'} eq '-1');
- &process_date_info($userdata);
+ if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
+ &process_date_info($userdata);
+ }
my $username = $userdata->{'username'};
my $domain = $userdata->{'domain'};
if (ref($userinfo->{$username.':'.$domain}) eq 'HASH') {
- $userdata->{'fullname'} =
- $userinfo->{$username.':'.$domain}{'fullname'};
+ $userdata->{'fullname'} = $userinfo->{$username.':'.$domain}{'fullname'};
$userdata->{'id'} = $userinfo->{$username.':'.$domain}{'id'};
} else {
&aggregate_user_info($domain,$username,$userinfo);
@@ -1738,6 +1866,8 @@ sub make_keylist_array {
$index->{'email'} = &Apache::loncoursedata::CL_PERMANENTEMAIL();
$index->{'role'} = &Apache::loncoursedata::CL_ROLE();
$index->{'extent'} = &Apache::loncoursedata::CL_EXTENT();
+ $index->{'photo'} = &Apache::loncoursedata::CL_PHOTO();
+ $index->{'thumbnail'} = &Apache::loncoursedata::CL_THUMBNAIL();
foreach my $key (keys(%{$index})) {
$keylist->[$index->{$key}] = $key;
}
@@ -1786,7 +1916,10 @@ sub process_date_info {
}
sub show_users_list {
- my ($r,$context,$mode,$permission,$statusmode,$userlist,$keylist)=@_;
+ my ($r,$context,$mode,$permission,$statusmode,$userlist,$keylist,$formname)=@_;
+ if ($formname eq '') {
+ $formname = 'studentform';
+ }
#
# Variables for excel output
my ($excel_workbook, $excel_sheet, $excel_filename,$row,$format);
@@ -1801,6 +1934,9 @@ sub show_users_list {
} else {
push(@sortable,'extent');
}
+ if ($mode eq 'pickauthor') {
+ @sortable = ('username','fullname','email','status');
+ }
if (!grep(/^\Q$sortby\E$/,@sortable)) {
$sortby = 'username';
}
@@ -1841,66 +1977,49 @@ function photowindow(photolink) {
END
}
}
- if ($mode ne 'autoenroll') {
+ if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript();
- my $alert = &mt("You must select at least one user by checking a user's 'Select' checkbox");
- my $singconfirm = &mt(' for a single user');
- my $multconfirm = &mt(' for multiple users');
- my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode);
+ my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode);
+ my $verify_action_js = &bulkaction_javascript($formname);
$r->print(<
$check_uncheck_js
-function verify_action (field) {
- var numchecked = 0;
- var singconf = '$singconfirm';
- var multconf = '$multconfirm';
- if (field.length > 0) {
- for (i = 0; i < field.length; i++) {
- if (field[i].checked == true) {
- numchecked ++;
- }
- }
- } else {
- if (field.checked == true) {
- numchecked ++;
- }
- }
- if (numchecked == 0) {
- alert("$alert");
- }
- else {
- var message = document.studentform.bulkaction[document.studentform.bulkaction.selectedIndex].text;
- if (numchecked == 1) {
- message += singconf;
- }
- else {
- message += multconf;
- }
- if (confirm(message)) {
- document.studentform.phase.value = 'bulkchange';
- document.studentform.submit();
- }
- }
-}
+$verify_action_js
function username_display_launch(username,domain) {
var target;
- for (var i=0; i
@@ -1925,44 +2044,50 @@ END
'role' => "role",
'type' => "enroll type/action",
'email' => "email address",
- 'clicker' => "clicker id",
'photo' => "photo",
'extent' => "extent",
'pr' => "Proceed",
'ca' => "check all",
'ua' => "uncheck all",
'ac' => "Action to take for selected users",
- 'link' => "Behavior of username links",
+ 'link' => "Behavior of clickable username link for each user",
'aboutme' => "Display a user's personal page",
+ 'owin' => "Open in a new window",
'modify' => "Modify a user's information",
+ 'clicker' => "Clicker-ID",
);
if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
$lt{'extent'} = &mt('Course(s): description, section(s), status');
} elsif ($context eq 'author') {
$lt{'extent'} = &mt('Author');
}
- my @cols = ('username','domain','id','fullname');
- if ($context eq 'course') {
- push(@cols,'section');
- }
- if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) {
- push(@cols,('start','end'));
- }
- if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {
- push(@cols,'role');
- }
- if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' ||
- $env{'form.roletype'} eq 'course')) {
- push (@cols,'extent');
- }
- if (($statusmode eq 'Any') &&
- (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) {
- push(@cols,'status');
- }
- if ($context eq 'course') {
- push(@cols,'groups');
+ my @cols;
+ if ($mode eq 'pickauthor') {
+ @cols = ('username','fullname','status','email');
+ } else {
+ @cols = ('username','domain','id','fullname');
+ if ($context eq 'course') {
+ push(@cols,'section');
+ }
+ if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) {
+ push(@cols,('start','end'));
+ }
+ if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {
+ push(@cols,'role');
+ }
+ if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' ||
+ $env{'form.roletype'} eq 'course')) {
+ push (@cols,'extent');
+ }
+ if (($statusmode eq 'Any') &&
+ (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) {
+ push(@cols,'status');
+ }
+ if ($context eq 'course') {
+ push(@cols,'groups');
+ }
+ push(@cols,'email');
}
- push(@cols,'email');
my $rolefilter = $env{'form.showrole'};
if ($env{'form.showrole'} eq 'cr') {
@@ -1973,14 +2098,14 @@ END
my $results_description;
if ($mode ne 'autoenroll') {
$results_description = &results_header_row($rolefilter,$statusmode,
- $context,$permission);
- $r->print(''.$results_description.' ');
+ $context,$permission,$mode);
+ $r->print(''.$results_description.'
');
}
- my ($output,$actionselect);
- if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll') {
- if ($mode ne 'autoenroll') {
+ my ($output,$actionselect,%canchange,%canchangesec);
+ if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
+ if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
if ($permission->{'cusr'}) {
- $actionselect = &select_actions($context,$setting,$statusmode);
+ $actionselect = &select_actions($context,$setting,$statusmode,$formname);
}
$r->print(<
@@ -1989,67 +2114,115 @@ END
END
- $output = '