--- loncom/interface/loncommon.pm 2005/11/15 15:40:58 1.289 +++ loncom/interface/loncommon.pm 2005/11/15 18:07:46 1.292 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.289 2005/11/15 15:40:58 albertel Exp $ +# $Id: loncommon.pm,v 1.292 2005/11/15 18:07:46 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3123,17 +3123,16 @@ sub get_course_users { $idx{fullname} = &Apache::loncoursedata::CL_FULLNAME(); $idx{status} = &Apache::loncoursedata::CL_STATUS(); - if (grep/^st$/,@{$roles}) { + if (grep(/^st$/,@{$roles})) { my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist($cdom,$cnum); my $now = time; foreach my $student (keys(%{$classlist})) { my $match = 0; - if (defined($sections) && (ref($sections) eq 'ARRAY')) { - if (@{$sections} > 0) { - unless(grep/^$$classlist{$student}[$idx{section}]$/,@{$sections}) { - next; - } - } + if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) { + unless(grep(/^\Q$$classlist{$student}[$idx{section}]\E$/, + @{$sections})) { + next; + } } if (defined($$types{'active'})) { if ($$classlist{$student}[$idx{status}] eq 'Active') { @@ -3164,16 +3163,13 @@ sub get_course_users { my $match = 0; my ($role,$user) = ($person =~ /^([^:]*):([^:]+:[^:]+)/); $user =~ s/:$//; - if (($role) && (grep(/^$role$/,@{$roles}))) { + if (($role) && (grep(/^\Q$role\E$/,@{$roles}))) { my ($uname,$udom,$usec) = split(/:/,$user); - unless ($usec eq '') { - if (defined($sections) && (ref($sections) eq 'ARRAY')) { - if (@{$sections} > 0) { - unless(grep/^$usec$/,@{$sections}) { - next; - } - } - } + if ($usec ne '' && (ref($sections) eq 'ARRAY') && + @{$sections} > 0) { + unless(grep(/^\Q$usec\E$/,@{$sections})) { + next; + } } if ($uname ne '' && $udom ne '') { my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role); @@ -3183,25 +3179,23 @@ sub get_course_users { $match = 1; } } - if ($match && defined($userdata)) { - unless(exists($$userdata{$uname.':'.$udom})) { - &get_user_info($udom,$uname,\%idx,$userdata); - } + if ($match && defined($userdata) && + !exists($$userdata{$uname.':'.$udom})) { + &get_user_info($udom,$uname,\%idx,$userdata); } } } } - if (grep/^ow$/,@{$roles}) { + if (grep(/^ow$/,@{$roles})) { if ((defined($cdom)) && (defined($cnum))) { my %csettings = &Apache::lonnet::get('environment',['internal.courseowner'],$cdom,$cnum); if ( defined($csettings{'internal.courseowner'}) ) { my $owner = $csettings{'internal.courseowner'}; @{$$users{'ow'}{$owner.':'.$cdom}} = 'any'; - if (defined($userdata)) { - unless(exists($$userdata{$owner.':'.$cdom})) { - &get_user_info($cdom,$owner,\%idx,$userdata); - } - } + if (defined($userdata) && + !exists($$userdata{$owner.':'.$cdom})) { + &get_user_info($cdom,$owner,\%idx,$userdata); + } } } } @@ -3213,8 +3207,8 @@ sub get_user_info { my ($udom,$uname,$idx,$userdata) = @_; $$userdata{$uname.':'.$udom}[$$idx{fullname}] = &plainname($uname,$udom,'lastname'); - $$userdata{$uname.':'.$udom}[$$idx{uname}] = $uname - $$userdata{$uname.':'.$udom}[$$idx{uname}] = $udom + $$userdata{$uname.':'.$udom}[$$idx{uname}] = $uname; + $$userdata{$uname.':'.$udom}[$$idx{uname}] = $udom; return; } @@ -3356,6 +3350,7 @@ sub no_cache { sub content_type { my ($r,$type,$charset) = @_; + &no_cache($r); if ($env{'browser.mathml'} && $type eq 'text/html') { $type='text/xml'; } unless ($charset) { $charset=&Apache::lonlocal::current_encoding;