[LON-CAPA-cvs] cvs: loncom /interface lonuserutils.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sat, 22 Dec 2007 03:38:27 -0000
raeburn Fri Dec 21 22:38:27 2007 EDT
Modified files:
/loncom/interface lonuserutils.pm
Log:
- &build_user_record() - new first argument - $context
- when building record for list users display do not extract start and end date information if context is 'domain' and roletype is 'course'.
- &results_header_row() has 5th arg - $mode
- In course context - only display course description in header row if output is for a csv or excel file.
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.23 loncom/interface/lonuserutils.pm:1.24
--- loncom/interface/lonuserutils.pm:1.23 Fri Dec 21 19:47:25 2007
+++ loncom/interface/lonuserutils.pm Fri Dec 21 22:38:26 2007
@@ -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.24 2007/12/22 03:38:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1479,7 +1479,8 @@
($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'},
@@ -1488,13 +1489,15 @@
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 +1506,8 @@
($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') {
@@ -1539,7 +1543,8 @@
}
}
}
- &build_user_record(\%userdata,$userinfo,$indexhash,$item,$userlist);
+ &build_user_record($context,\%userdata,$userinfo,$indexhash,
+ $item,$userlist);
}
}
}
@@ -1547,14 +1552,15 @@
}
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);
@@ -1973,7 +1979,7 @@
my $results_description;
if ($mode ne 'autoenroll') {
$results_description = &results_header_row($rolefilter,$statusmode,
- $context,$permission);
+ $context,$permission,$mode);
$r->print('<b>'.$results_description.'</b><br />');
}
my ($output,$actionselect);
@@ -2633,13 +2639,15 @@
}
sub results_header_row {
- my ($rolefilter,$statusmode,$context,$permission) = @_;
+ my ($rolefilter,$statusmode,$context,$permission,$mode) = @_;
my ($description,$showfilter);
if ($rolefilter ne 'Any') {
$showfilter = $rolefilter;
}
if ($context eq 'course') {
- $description = &mt('Course - ').$env{'course.'.$env{'request.course.id'}.'.description'}.': ';
+ if ($mode eq 'csv' || $mode eq 'excel') {
+ $description = &mt('Course - ').$env{'course.'.$env{'request.course.id'}.'.description'}.': ';
+ }
if ($statusmode eq 'Expired') {
$description .= &mt('Users in course with expired [_1] roles',$showfilter);
} elsif ($statusmode eq 'Future') {