--- loncom/lond 2008/05/29 05:44:48 1.401 +++ loncom/lond 2008/09/06 00:47:13 1.408 @@ -2,7 +2,7 @@ # The LearningOnline Network # lond "LON Daemon" Server (port "LOND" 5663) # -# $Id: lond,v 1.401 2008/05/29 05:44:48 raeburn Exp $ +# $Id: lond,v 1.408 2008/09/06 00:47:13 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -59,7 +59,7 @@ my $DEBUG = 0; # Non zero to ena my $status=''; my $lastlog=''; -my $VERSION='$Revision: 1.401 $'; #' stupid emacs +my $VERSION='$Revision: 1.408 $'; #' stupid emacs my $remoteVERSION; my $currenthostid="default"; my $currentdomainid; @@ -1538,7 +1538,7 @@ sub ls3_handler { } elsif ($alternate_root ne '') { $dir_root = $alternate_root; } - if ($dir_root ne '') { + if (($dir_root ne '') && ($dir_root ne '/')) { if ($ulsdir =~ /^\//) { $ulsdir = $dir_root.$ulsdir; } else { @@ -3615,7 +3615,17 @@ sub put_course_id_hash_handler { # key, value pairs in the item's hash, or as a # colon-separated list of (in order) description, # institutional code, and course owner. -# +# selfenrollonly - filter by courses allowing self-enrollment +# now or in the future (selfenrollonly = 1). +# catfilter - filter by course category, assigned to a course +# using manually defined categories (i.e., not +# self-cataloging based on on institutional code). +# showhidden - include course in results even if course +# was set to be excluded from course catalog (DC only). +# caller - if set to 'coursecatalog', courses set to be hidden +# from course catalog will be excluded from results (unless +# overridden by "showhidden". +# # $client - The socket open on the client. # Returns: # 1 - Continue processing. @@ -3626,7 +3636,8 @@ sub dump_course_id_handler { my $userinput = "$cmd:$tail"; my ($udom,$since,$description,$instcodefilter,$ownerfilter,$coursefilter, - $typefilter,$regexp_ok,$rtn_as_hash,$selfenrollonly,$catfilter) =split(/:/,$tail); + $typefilter,$regexp_ok,$rtn_as_hash,$selfenrollonly,$catfilter,$showhidden, + $caller) =split(/:/,$tail); my $now = time; if (defined($description)) { $description=&unescape($description); @@ -3700,16 +3711,32 @@ sub dump_course_id_handler { $unesc_val{'inst_code'} = $items->{'inst_code'}; $unesc_val{'owner'} = $items->{'owner'}; $unesc_val{'type'} = $items->{'type'}; - $selfenroll_types = $items->{'selfenroll_types'}; - $selfenroll_end = $items->{'selfenroll_end_date'}; - if ($selfenrollonly) { - next if (!$selfenroll_types); - if (($selfenroll_end > 0) && ($selfenroll_end <= $now)) { - next; + } + $selfenroll_types = $items->{'selfenroll_types'}; + $selfenroll_end = $items->{'selfenroll_end_date'}; + if ($selfenrollonly) { + next if (!$selfenroll_types); + if (($selfenroll_end > 0) && ($selfenroll_end <= $now)) { + next; + } + } + if ($catfilter ne '') { + next if ($items->{'categories'} eq ''); + my @categories = split('&',$items->{'categories'}); + next if (@categories == 0); + my @subcats = split('&',$catfilter); + my $matchcat = 0; + foreach my $cat (@categories) { + if (grep(/^\Q$cat\E$/,@subcats)) { + $matchcat = 1; + last; } } - if ($catfilter ne '') { - next if ($items->{'category'} ne $catfilter); + next if (!$matchcat); + } + if ($caller eq 'coursecatalog') { + if ($items->{'hidefromcat'} eq 'yes') { + next if !$showhidden; } } } else { @@ -3718,7 +3745,9 @@ sub dump_course_id_handler { $is_hash = 0; my @courseitems = split(/:/,$value); $lasttime = pop(@courseitems); - next if ($lasttime<$since); + if ($hashref->{$lasttime_key} eq '') { + next if ($lasttime<$since); + } ($val{'descr'},$val{'inst_code'},$val{'owner'},$val{'type'}) = @courseitems; } my $match = 1;