[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface lonuserutils.pm
raeburn
raeburn@source.lon-capa.org
Wed, 20 Jan 2010 18:22:36 -0000
This is a MIME encoded message
--raeburn1264011756
Content-Type: text/plain
raeburn Wed Jan 20 18:22:36 2010 EDT
Modified files: (Branch: version_2_9_X)
/loncom/interface lonuserutils.pm
Log:
- Backport 1.102.
--raeburn1264011756
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100120182236.txt"
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.97.2.4 loncom/interface/lonuserutils.pm:1.97.2.5
--- loncom/interface/lonuserutils.pm:1.97.2.4 Wed Jan 20 17:41:25 2010
+++ loncom/interface/lonuserutils.pm Wed Jan 20 18:22:35 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.97.2.4 2010/01/20 17:41:25 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.97.2.5 2010/01/20 18:22:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -236,7 +236,6 @@
#
# Role types
my @roletypes = ('domain','author','course','community');
-
my %lt = &role_type_names();
#
# build up the menu information to be passed to
@@ -248,6 +247,10 @@
foreach my $roletype (@roletypes) {
# set up the text for this domain
$select_menus{$roletype}->{'text'}= $lt{$roletype};
+ my $crstype;
+ if ($roletype eq 'community') {
+ $crstype = 'Community';
+ }
# we want a choice of 'default' as the default in the second menu
if ($env{'form.roletype'} ne '') {
$select_menus{$roletype}->{'default'} = $env{'form.showrole'};
@@ -272,7 +275,7 @@
&mt('Custom role');
} else {
$select_menus{$roletype}->{'select2'}->{$role} =
- &Apache::lonnet::plaintext($role);
+ &Apache::lonnet::plaintext($role,$crstype);
}
}
$select_menus{$roletype}->{'select2'}->{'Any'} = &mt('Any');
@@ -1291,7 +1294,13 @@
sub course_roles {
my ($context,$checkpriv,$custom,$roletype) = @_;
- my @allroles = &roles_by_context('course',$custom,$roletype);
+ my $crstype;
+ if ($roletype eq 'community') {
+ $crstype = 'Community' ;
+ } else {
+ $crstype = 'Course';
+ }
+ my @allroles = &roles_by_context('course',$custom,$crstype);
my @roles;
if ($context eq 'domain') {
@roles = @allroles;
@@ -1781,7 +1790,8 @@
$indexhash,$uniqid,$userlist);
}
}
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
($userdata{'username'},$userdata{'domain'},$userdata{'role'}) =
split(/:/,$item);
if (ref($rolehash->{$item}) eq 'HASH') {
@@ -1831,7 +1841,8 @@
sub build_user_record {
my ($context,$userdata,$userinfo,$indexhash,$record_key,$userlist) = @_;
next if ($userdata->{'start'} eq '-1' && $userdata->{'end'} eq '-1');
- if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
+ if (!(($context eq 'domain') && (($env{'form.roletype'} eq 'course')
+ && ($env{'form.roletype'} eq 'community')))) {
&process_date_info($userdata);
}
my $username = $userdata->{'username'};
@@ -2134,6 +2145,12 @@
<input type="hidden" name="displayclickers" value="$displayclickers" />
END
}
+ } elsif ($context eq 'domain') {
+ if ($setting eq 'community') {
+ $crstype = 'Community';
+ } elsif ($crstype eq 'course') {
+ $crstype = 'Course';
+ }
}
if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript();
@@ -2230,6 +2247,8 @@
);
if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
$lt{'extent'} = &mt('Course(s): description, section(s), status');
+ } elsif ($context eq 'domain' && $env{'form.roletype'} eq 'community') {
+ $lt{'extent'} = &mt('Communities: description, section(s), status');
} elsif ($context eq 'author') {
$lt{'extent'} = &mt('Author');
}
@@ -2241,18 +2260,21 @@
if ($context eq 'course') {
push(@cols,'section');
}
- if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) {
+ if (!($context eq 'domain' && ($env{'form.roletype'} eq 'course')
+ && ($env{'form.roletype'} eq 'community'))) {
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')) {
+ $env{'form.roletype'} eq 'course' ||
+ $env{'form.roletype'} eq 'community')) {
push (@cols,'extent');
}
- if (($statusmode eq 'Any') &&
- (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) {
+ if (($statusmode eq 'Any') &&
+ (!($context eq 'domain' && (($env{'form.roletype'} eq 'course')
+ || ($env{'form.roletype'} eq 'community'))))) {
push(@cols,'status');
}
if ($context eq 'course') {
@@ -2270,7 +2292,8 @@
my $results_description;
if ($mode ne 'autoenroll') {
$results_description = &results_header_row($rolefilter,$statusmode,
- $context,$permission,$mode);
+ $context,$permission,$mode,$crstype);
+
$r->print('<b>'.$results_description.'</b><br /><br />');
}
my ($output,$actionselect,%canchange,%canchangesec);
@@ -2505,7 +2528,8 @@
}
} elsif ($env{'form.roletype'} eq 'author') {
($uname,$udom,$role) = split(/:/,$user,-1);
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
($uname,$udom,$role) = split(/:/,$user);
}
} else {
@@ -3219,26 +3243,50 @@
}
sub results_header_row {
- my ($rolefilter,$statusmode,$context,$permission,$mode) = @_;
+ my ($rolefilter,$statusmode,$context,$permission,$mode,$crstype) = @_;
my ($description,$showfilter);
if ($rolefilter ne 'Any') {
$showfilter = $rolefilter;
}
if ($context eq 'course') {
if ($mode eq 'csv' || $mode eq 'excel') {
- $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ if ($crstype eq 'Community') {
+ $description = &mt('Community - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ } else {
+ $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ }
}
if ($statusmode eq 'Expired') {
- $description .= &mt('Users in course with expired [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with expired [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with expired [_1] roles',$showfilter);
+ }
} elsif ($statusmode eq 'Future') {
- $description .= &mt('Users in course with future [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with future [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with future [_1] roles',$showfilter);
+ }
} elsif ($statusmode eq 'Active') {
- $description .= &mt('Users in course with active [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with active [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with active [_1] roles',$showfilter);
+ }
} else {
if ($rolefilter eq 'Any') {
- $description .= &mt('All users in course');
+ if ($crstype eq 'Community') {
+ $description .= &mt('All users in community');
+ } else {
+ $description .= &mt('All users in course');
+ }
} else {
- $description .= &mt('All users in course with [_1] roles',$rolefilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('All users in community with [_1] roles',$rolefilter);
+ } else {
+ $description .= &mt('All users in course with [_1] roles',$rolefilter);
+ }
}
}
my $constraint;
@@ -3334,19 +3382,29 @@
$description .= &mt('All co-authors in domain with [_1] roles',$rolefilter);
}
}
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
+
my $coursefilter = $env{'form.coursepick'};
- if ($coursefilter eq 'category') {
- my $instcode = &instcode_from_coursefilter();
- if ($instcode eq '.') {
+ if ($env{'form.roletype'} eq 'course') {
+ if ($coursefilter eq 'category') {
+ my $instcode = &instcode_from_coursefilter();
+ if ($instcode eq '.') {
+ $description .= &mt('All courses in domain').' - ';
+ } else {
+ $description .= &mt('Courses in domain with institutional code: [_1]',$instcode).' - ';
+ }
+ } elsif ($coursefilter eq 'selected') {
+ $description .= &mt('Selected courses in domain').' - ';
+ } elsif ($coursefilter eq 'all') {
$description .= &mt('All courses in domain').' - ';
- } else {
- $description .= &mt('Courses in domain with institutional code: [_1]',$instcode).' - ';
}
- } elsif ($coursefilter eq 'selected') {
- $description .= &mt('Selected courses in domain').' - ';
- } elsif ($coursefilter eq 'all') {
- $description .= &mt('All courses in domain').' - ';
+ } elsif ($env{'form.roletype'} eq 'community') {
+ if ($coursefilter eq 'selected') {
+ $description .= &mt('Selected communities in domain').' - ';
+ } elsif ($coursefilter eq 'all') {
+ $description .= &mt('All communities in domain').' - ';
+ }
}
if ($statusmode eq 'Expired') {
$description .= &mt('users with expired [_1] roles',$showfilter);
@@ -3751,7 +3809,7 @@
}
my (%userlist,%modifiable_fields,@poss_roles);
my $secidx = &Apache::loncoursedata::CL_SECTION();
- my @courseroles = &roles_by_context('course',1,'',$crstype);
+ my @courseroles = &roles_by_context('course',1,$crstype);
if (!&Apache::lonnet::allowed('mau',$domain)) {
if ($context eq 'course' || $context eq 'author') {
@poss_roles = &curr_role_permissions($context,'','',$crstype);
--raeburn1264011756--