[LON-CAPA-cvs] cvs: loncom /interface lonuserutils.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sat, 22 Dec 2007 04:58:46 -0000
This is a MIME encoded message
--raeburn1198299526
Content-Type: text/plain
raeburn Fri Dec 21 23:58:46 2007 EDT
Modified files:
/loncom/interface lonuserutils.pm
Log:
- %canchange and %canchangesec contain information about which roles the viewer has privileges to modify for a user. %canchangesec is for a viewer with a section-specific custom role with the 'cst' priv
- if viewer can modify the role, checkbox is included to select role for bulk update
- do not display dropdown box to select bulk action, if viewer does not have modify prov for filter role, or if viewer has section-specific 'cst' priv, if section of user in list is different from viewer's section
- do not include change section as a bulk action option if viewer has section-specific role.
- include information in the results header about section-specific filter, if it applies.
--raeburn1198299526
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20071221235846.txt"
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.25 loncom/interface/lonuserutils.pm:1.26
--- loncom/interface/lonuserutils.pm:1.25 Fri Dec 21 23:23:05 2007
+++ loncom/interface/lonuserutils.pm Fri Dec 21 23:58:45 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.25 2007/12/22 04:23:05 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.26 2007/12/22 04:58:45 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1990,7 +1990,7 @@
$context,$permission,$mode);
$r->print('<b>'.$results_description.'</b><br />');
}
- 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'}) {
@@ -2029,6 +2029,40 @@
<p><input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.studentform.actionlist)" />
<input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.studentform.actionlist)" />
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<p>\n".
@@ -2242,18 +2276,38 @@
$r->print("<td>$rowcount</td>\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('<td><input type="checkbox" name="'.
+ 'actionlist" value="'.$checkval.'"></td>');
+ } else {
+ $r->print('<td> </td>');
}
- $r->print('<td><input type="checkbox" name="actionlist" value="'.
- $checkval.'"></td>');
}
}
foreach my $item (@cols) {
@@ -2386,6 +2440,20 @@
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 .= '
<option value="chgdates">'.$lt{'chgdates'}.'</option>';
@@ -2412,7 +2480,7 @@
<option value="delete">'.$lt{'delete'}.'</option>';
}
if (($context eq 'course') || ($context eq 'domain' && $setting eq 'course')) {
- if ($statusmode ne 'Expired') {
+ if (($statusmode ne 'Expired') && ($env{'request.course.sec'} eq '')) {
$options .= '
<option value="chgsec">'.$lt{'chgsec'}.'</option>';
$choices{'sections'} = 1;
@@ -2519,7 +2587,8 @@
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;
@@ -2529,6 +2598,7 @@
}
END
+ }
}
}
$output .= <<"END";
@@ -2578,12 +2648,10 @@
$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 .= '<p>'.$lt{'fors'}.'</p>';
- } elsif ($env{'form.shorole'} eq 'Any') {
+ } elsif ($env{'form.showrole'} eq 'Any') {
$output .= '<p>'.$lt{'fors'}.'</p>'.
'<p>'.$lt{'forn'}.' ';
$info = $lt{'reta'};
@@ -2604,7 +2672,6 @@
} else {
$info = '<input type="hidden" name="retainsec" value="0" />';
}
- my $sections_select .= &course_sections(\%sections_count,$env{'form.showrole'});
my $rowtitle = &mt('New section to assign');
my $secbox = §ion_picker($cdom,$cnum,$env{'form.showrole'},$rowtitle,$permission,$context);
$output .= $info.$secbox;
@@ -2669,11 +2736,12 @@
$description .= &mt('All users in course with [_1] roles',$rolefilter);
}
}
- if (exists($permission->{'view_section'})) {
+ my $viewablesec = &viewable_section($permission);
+ if ($viewablesec ne '') {
if ($env{'form.showrole'} eq 'st') {
- $description .= ' '.&mt('(section [_1] only)',$permission->{'view_section'});
- } elsif ($env{'form.showrole'} eq 'any') {
- $description .= ' '.&mt('(section [_1] only)',$permission->{'view_section'});
+ $description .= ' '.&mt('(section [_1] only)',$viewablesec);
+ } elsif ($env{'form.showrole'} ne 'cc') {
+ $description .= ' '.&mt('(only users affiliated with no section or section [_1])',$viewablesec);
}
}
} elsif ($context eq 'author') {
--raeburn1198299526--