--- loncom/interface/loncommon.pm 2006/06/30 04:08:07 1.411
+++ loncom/interface/loncommon.pm 2006/07/03 00:11:53 1.413
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.411 2006/06/30 04:08:07 albertel Exp $
+# $Id: loncommon.pm,v 1.413 2006/07/03 00:11:53 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3505,7 +3505,6 @@ sub headtag {
my $result =
'
'.
- ''.
&font_settings().
&Apache::lonhtmlcommon::htmlareaheaders();
@@ -3526,7 +3525,8 @@ ADDMETA
$title = 'The LearningOnline Network with CAPA';
}
- $result .= ' LON-CAPA '.&mt($title).''.$head_extra;
+ $result .= ' LON-CAPA '.&mt($title).''.$head_extra
+ .'';
return $result;
}
@@ -3898,33 +3898,35 @@ role status: active, previous or future.
=cut
sub check_user_status {
- my ($udom,$uname,$cdom,$crs,$role,$secgrp) = @_;
+ my ($udom,$uname,$cdom,$crs,$role,$sec) = @_;
my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname);
my @uroles = keys %userinfo;
my $srchstr;
my $active_chk = 'none';
+ my $now = time;
if (@uroles > 0) {
- if (($role eq 'cc') || ($secgrp eq '') || (!defined($secgrp))) {
+ if (($role eq 'cc') || ($sec eq '') || (!defined($sec))) {
$srchstr = '/'.$cdom.'/'.$crs.'_'.$role;
} else {
- $srchstr = '/'.$cdom.'/'.$crs.'/'.$secgrp.'_'.$role; }
- if (grep/^$srchstr$/,@uroles) {
+ $srchstr = '/'.$cdom.'/'.$crs.'/'.$sec.'_'.$role;
+ }
+ if (grep/^\Q$srchstr\E$/,@uroles) {
my $role_end = 0;
my $role_start = 0;
$active_chk = 'active';
- if ($userinfo{$srchstr} =~ m/^($role)_(\d+)/) {
- $role_end = $2;
- if ($userinfo{$srchstr} =~ m/^($role)_($role_end)_(\d+)$/) {
- $role_start = $3;
+ if ($userinfo{$srchstr} =~ m/^\Q$role\E_(\d+)/) {
+ $role_end = $1;
+ if ($userinfo{$srchstr} =~ m/^\Q$role\E_\Q$role_end\E_(\d+)$/) {
+ $role_start = $1;
}
}
if ($role_start > 0) {
- if (time < $role_start) {
+ if ($now < $role_start) {
$active_chk = 'future';
}
}
if ($role_end > 0) {
- if (time > $role_end) {
+ if ($now > $role_end) {
$active_chk = 'previous';
}
}
@@ -4044,11 +4046,23 @@ sub get_course_users {
my $now = time;
foreach my $student (keys(%{$classlist})) {
my $match = 0;
+ my $secmatch = 0;
if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {
- unless(grep(/^\Q$$classlist{$student}[$idx{section}]\E$/,
+ if (grep/^all$/,@{$sections}) {
+ $secmatch = 1;
+ } elsif ($$classlist{$student}[$idx{section}] eq '') {
+ if (grep/^none$/,@{$sections}) {
+ $secmatch = 1;
+ }
+ } else {
+ if (grep(/^\Q$$classlist{$student}[$idx{section}]\E$/,
@{$sections})) {
- next;
+ $secmatch = 1;
+ }
}
+ if (!$secmatch) {
+ next;
+ }
}
if (defined($$types{'active'})) {
if ($$classlist{$student}[$idx{status}] eq 'Active') {
@@ -4068,35 +4082,47 @@ sub get_course_users {
$match = 1;
}
}
- if ($match && defined($userdata)) {
+ if ($match && ref($userdata) eq 'HASH') {
$$userdata{$student} = $$classlist{$student};
}
}
}
- if ((@{$roles} > 0) && (@{$roles} ne "st")) {
+ if ((@{$roles} > 1) || ((@{$roles} == 1) && ($$roles[0] ne "st"))) {
my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$cdom,$cnum);
foreach my $person (@coursepersonnel) {
my $match = 0;
- my ($role,$user) = ($person =~ /^([^:]*):([^:]+:[^:]+)/);
+ my $secmatch = 0;
+ my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
$user =~ s/:$//;
if (($role) && (grep(/^\Q$role\E$/,@{$roles}))) {
- my ($uname,$udom,$usec) = split(/:/,$user);
- if ($usec ne '' && (ref($sections) eq 'ARRAY') &&
- @{$sections} > 0) {
- unless(grep(/^\Q$usec\E$/,@{$sections})) {
- next;
- }
+ my ($uname,$udom) = split(/:/,$user);
+ if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {
+ if (grep/^all$/,@{$sections}) {
+ $secmatch = 1;
+ } elsif ($usec eq '') {
+ if (grep/^none$/,@{$sections}) {
+ $secmatch = 1;
+ }
+ } else {
+ if (grep(/^\Q$usec\E$/,@{$sections})) {
+ $secmatch = 1;
+ }
+ }
+ if (!$secmatch) {
+ next;
+ }
}
if ($uname ne '' && $udom ne '') {
- my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role);
+ my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role,
+ $usec);
foreach my $type (keys(%{$types})) {
if ($status eq $type) {
@{$$users{$role}{$user}} = $type;
$match = 1;
}
}
- if ($match && defined($userdata) &&
- !exists($$userdata{$uname.':'.$udom})) {
+ if (($match) && (ref($userdata) eq 'HASH') &&
+ (!exists($$userdata{$uname.':'.$udom}))) {
&get_user_info($udom,$uname,\%idx,$userdata);
}
}