--- loncom/interface/lonuserutils.pm 2007/12/22 03:38:26 1.24
+++ loncom/interface/lonuserutils.pm 2007/12/22 22:42:58 1.29
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.24 2007/12/22 03:38:26 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.29 2007/12/22 22:42:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -738,13 +738,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')) {
@@ -786,13 +786,14 @@ sub forceid_change {
"
\n".' '."\n".
- &mt('(only do if you know what you are doing.)')." \n";
+ &mt('(only do if you know what you are doing.)')."\n";
if ($context eq 'domain') {
- $output .= '
'."\n";
+ ''."\n";
}
+ $output .= '';
return $output;
}
@@ -962,7 +963,7 @@ sub date_setting_table {
($env{'form.action'} eq 'upload')) {
if ($env{'request.course.sec'} eq '') {
$dateDefault = ''.
- '';
}
@@ -1001,14 +1002,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.
' ';
}
}
@@ -1289,7 +1290,8 @@ sub print_userlist {
$r->print(''.&mt('Role: [_1]',$role_select).'');
}
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);
@@ -1506,8 +1508,8 @@ sub gather_userinfo {
($userdata{'start'},$userdata{'end'}) =
split(/:/,$rolehash->{$item}{$key});
my $uniqid = $key.':'.$item;
- &build_user_record($context,\%userdata,$userinfo,$indexhash,
- $uniqid,$userlist);
+ &build_user_record($context,\%userdata,$userinfo,
+ $indexhash,$uniqid,$userlist);
}
}
} elsif ($env{'form.roletype'} eq 'course') {
@@ -1525,9 +1527,9 @@ sub gather_userinfo {
# FIXME: actions on courses disabled for now
# if ($permission->{'cusr'}) {
# if ($numcids > 1) {
-# $spanstart .= '';
+# $spanstart .= ' ';
# } else {
-# $spanstart .= '';
+# $spanstart .= ' ';
# }
# }
$spanend = ' ';
@@ -1537,14 +1539,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($context,\%userdata,$userinfo,$indexhash,
- $item,$userlist);
+ if ($userdata{'status'} ne '') {
+ &build_user_record($context,\%userdata,$userinfo,
+ $indexhash,$item,$userlist);
+ }
}
}
}
@@ -1850,8 +1858,8 @@ END
if ($mode ne 'autoenroll') {
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 $singconfirm = &mt(' for a single user?');
+ my $multconfirm = &mt(' for multiple users?');
my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode);
$r->print(<print(''.$results_description.' ');
}
- my ($output,$actionselect);
+ my ($output,$actionselect,%canchange,%canchangesec);
if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll') {
if ($mode ne 'autoenroll') {
if ($permission->{'cusr'}) {
@@ -2021,6 +2029,40 @@ $lt{'ac'}: $actionselect
END
+ my @allroles;
+ if ($env{'form.showrole'} eq 'Any') {
+ my $custom = 1;
+ if ($context eq 'domain') {
+ @allroles = &roles_by_context($setting,$custom);
+ } else {
+ @allroles = &roles_by_context($context,$custom);
+ }
+ } else {
+ @allroles = ($env{'form.showrole'});
+ }
+ foreach my $role (@allroles) {
+ if ($context eq 'domain') {
+ if ($setting eq 'domain') {
+ if (&Apache::lonnet::allowed('c'.$role,
+ $env{'request.role.domain'})) {
+ $canchange{$role} = 1;
+ }
+ }
+ } elsif ($context eq 'author') {
+ if (&Apache::lonnet::allowed('c'.$role,
+ $env{'user.domain'}.'/'.$env{'user.name'})) {
+ $canchange{$role} = 1;
+ }
+ } elsif ($context eq 'course') {
+ if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'})) {
+ $canchange{$role} = 1;
+ } elsif ($env{'request.course.sec'} ne '') {
+ if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+ $canchangesec{$role} = $env{'request.course.sec'};
+ }
+ }
+ }
+ }
}
}
$output .= "\n
\n".
@@ -2234,18 +2276,38 @@ END
$r->print("
$rowcount
\n");
$checkval;
if ($actionselect) {
- $checkval = $user;
- if ($context eq 'course') {
- if ($role eq 'st') {
- $checkval .= ':st';
+ my $showcheckbox;
+ if ($role =~ /^cr\//) {
+ $showcheckbox = $canchange{'cr'};
+ } else {
+ $showcheckbox = $canchange{$role};
+ }
+ if (!$showcheckbox) {
+ if ($context eq 'course') {
+ if ($canchangesec{$role} ne '') {
+ if ($canchangesec{$role} eq $in{'section'}) {
+ $showcheckbox = 1;
+ }
+ }
}
- $checkval .= ':'.$in{'section'};
- if ($role eq 'st') {
- $checkval .= ':'.$in{'type'}.':'.$in{'lockedtype'};
+ }
+ if ($showcheckbox) {
+ $checkval = $user;
+ if ($context eq 'course') {
+ if ($role eq 'st') {
+ $checkval .= ':st';
+ }
+ $checkval .= ':'.$in{'section'};
+ if ($role eq 'st') {
+ $checkval .= ':'.$in{'type'}.':'.
+ $in{'lockedtype'};
+ }
}
+ $r->print('
');
+ } else {
+ $r->print('
');
}
- $r->print('
');
}
}
foreach my $item (@cols) {
@@ -2378,6 +2440,20 @@ sub select_actions {
if ($context eq 'domain' && $setting eq 'course') {
return;
}
+ if ($context eq 'course') {
+ if ($env{'form.showrole'} ne 'Any') {
+ if (!&Apache::lonnet::allowed('c'.$env{'form.showrole'},
+ $env{'request.course.id'})) {
+ if ($env{'request.course.sec'} eq '') {
+ return;
+ } else {
+ if (!&Apache::lonnet::allowed('c'.$env{'form.showrole'},$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+ return;
+ }
+ }
+ }
+ }
+ }
if ($statusmode eq 'Any') {
$options .= '
';
@@ -2404,7 +2480,7 @@ sub select_actions {
';
}
if (($context eq 'course') || ($context eq 'domain' && $setting eq 'course')) {
- if ($statusmode ne 'Expired') {
+ if (($statusmode ne 'Expired') && ($env{'request.course.sec'} eq '')) {
$options .= '
';
$choices{'sections'} = 1;
@@ -2511,7 +2587,8 @@ END
if (($env{'form.bulkaction'} eq 'reenable') ||
($env{'form.bulkaction'} eq 'activate') ||
($env{'form.bulkaction'} eq 'chgdates')) {
- $output .= <<"END";
+ if ($env{'request.course.sec'} eq '') {
+ $output .= <<"END";
if (formname.makedatesdefault.checked == true) {
opener.document.$callingform.makedatesdefault.value = 1;
@@ -2521,6 +2598,7 @@ END
}
END
+ }
}
}
$output .= <<"END";
@@ -2570,12 +2648,10 @@ END
$date_items;
if ($context eq 'course' && $env{'form.bulkaction'} eq 'chgsec') {
my ($cnum,$cdom) = &get_course_identity();
- my %sections_count =
- &Apache::loncommon::get_sections($cdom,$cnum);
my $info;
if ($env{'form.showrole'} eq 'st') {
$output .= '