Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.1495 and 1.1496

version 1.1495, 2022/10/18 19:07:04 version 1.1496, 2022/10/19 00:03:11
Line 12457  sub domainlti_itemid { Line 12457  sub domainlti_itemid {
     return $itemid;      return $itemid;
 }  }
   
 sub get_numsuppfiles {  sub count_supptools {
       my ($cnum,$cdom,$ignorecache,$reload)=@_;
       my $hashid=$cnum.':'.$cdom;
       my ($numexttools,$cached);
       unless ($ignorecache) {
           ($numexttools,$cached) = &is_cached_new('supptools',$hashid);
       }
       unless (defined($cached)) {
           my $chome=&homeserver($cnum,$cdom);
           $numexttools = 0;
           unless ($chome eq 'no_host') {
               my ($supplemental) = &get_supplemental($cnum,$cdom,$reload);
               if (ref($supplemental) eq 'HASH') {
                   if ((ref($supplemental->{'ids'}) eq 'HASH') && (ref($supplemental->{'hidden'}) eq 'HASH')) {
                       foreach my $key (keys(%{$supplemental->{'ids'}})) {
                           if ($key =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {
                               $numexttools ++;
                           }
                       }
                   }
               }
           }
           &do_cache_new('supptools',$hashid,$numexttools,600);
       }
       return $numexttools;
   }
   
   sub has_unhidden_suppfiles {
     my ($cnum,$cdom,$ignorecache)=@_;      my ($cnum,$cdom,$ignorecache)=@_;
     my $hashid=$cnum.':'.$cdom;      my $hashid=$cnum.':'.$cdom;
     my ($suppcount,$cached);      my ($showsupp,$cached);
       unless ($ignorecache) {
           ($showsupp,$cached) = &is_cached_new('showsupp',$hashid);
       }
       unless (defined($cached)) {
           my $chome=&homeserver($cnum,$cdom);
           unless ($chome eq 'no_host') {
               my ($supplemental) = &get_supplemental($cnum,$cdom,$ignorecache);
               if (ref($supplemental) eq 'HASH') {
                   if ((ref($supplemental->{'ids'}) eq 'HASH') && (ref($supplemental->{'hidden'}) eq 'HASH')) {
                       foreach my $key (keys(%{$supplemental->{'ids'}})) {
                           next if ($key =~ /\.sequence$/);
                           if (ref($supplemental->{'ids'}->{$key}) eq 'ARRAY') {
                               foreach my $id (@{$supplemental->{'ids'}->{$key}}) {
                                   unless ($supplemental->{'hidden'}->{$id}) {
                                       $showsupp = 1;
                                       last;
                                   }
                               }
                           }
                           last if ($showsupp);
                       }
                   }
               }
           }
           &do_cache_new('showsupp',$hashid,$showsupp,600);
       }
       return $showsupp;
   }
   
   sub get_supplemental {
       my ($cnum,$cdom,$ignorecache,$possdel)=@_;
       my $hashid=$cnum.':'.$cdom;
       my ($supplemental,$cached,$set_httprefs);
     unless ($ignorecache) {      unless ($ignorecache) {
         ($suppcount,$cached) = &is_cached_new('suppcount',$hashid);          ($supplemental,$cached) = &is_cached_new('supplemental',$hashid);
     }      }
     unless (defined($cached)) {      unless (defined($cached)) {
         my $chome=&homeserver($cnum,$cdom);          my $chome=&homeserver($cnum,$cdom);
         unless ($chome eq 'no_host') {          unless ($chome eq 'no_host') {
             ($suppcount,my $supptools,my $errors) = (0,0,0);              my ($errors,%ids,%hidden);
             my $suppmap = 'supplemental.sequence';              $errors =
             ($suppcount,$supptools,$errors) =                  &Apache::loncommon::recurse_supplemental($cnum,$cdom,
                 &Apache::loncommon::recurse_supplemental($cnum,$cdom,$suppmap,$suppcount,                                                           'supplemental.sequence',
                                                          $supptools,$errors);                                                           $errors,$possdel,\%ids,\%hidden);
               $set_httprefs = 1;
               if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {
                   &Apache::lonnet::appenv({'request.course.suppupdated' => time});
               }
               $supplemental = {
                                  ids => \%ids,
                                  hidden => \%hidden,
                               };
               &do_cache_new('supplemental',$hashid,$supplemental,600);
         }          }
         &do_cache_new('suppcount',$hashid,$suppcount,600);  
     }      }
     return $suppcount;      return ($supplemental,$set_httprefs);
 }  }
   
 #  #
Line 13603  sub get_coursechange { Line 13671  sub get_coursechange {
 }  }
   
 sub devalidate_coursechange_cache {  sub devalidate_coursechange_cache {
     my ($cnum,$cdom)=@_;      my ($cdom,$cnum)=@_;
     my $hashid=$cnum.':'.$cdom;      my $hashid=$cdom.'_'.$cnum;
     &devalidate_cache_new('crschange',$hashid);      &devalidate_cache_new('crschange',$hashid);
 }  }
   
   sub get_suppchange {
       my ($cdom,$cnum) = @_;
       if ($cdom eq '' || $cnum eq '') {
           return unless ($env{'request.course.id'});
           $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
           $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
       }
       my $hashid=$cdom.'_'.$cnum;
       my ($change,$cached)=&is_cached_new('suppchange',$hashid);
       if ((defined($cached)) && ($change ne '')) {
           return $change;
       } else {
           my %crshash = &get('environment',['internal.supplementalchange'],$cdom,$cnum);
           if ($crshash{'internal.supplementalchange'} eq '') {
               $change = $env{'course.'.$cdom.'_'.$cnum.'.internal.created'};
               if ($change eq '') {
                   %crshash = &get('environment',['internal.created'],$cdom,$cnum);
                   $change = $crshash{'internal.created'};
               }
           } else {
               $change = $crshash{'internal.supplementalchange'};
           }
           my $cachetime = 600;
           &do_cache_new('suppchange',$hashid,$change,$cachetime);
       }
       return $change;
   }
   
   sub devalidate_suppchange_cache {
       my ($cdom,$cnum)=@_;
       my $hashid=$cdom.'_'.$cnum;
       &devalidate_cache_new('suppchange',$hashid);
   }
   
 # ------------------------------------------------- Update symbolic store links  # ------------------------------------------------- Update symbolic store links
   
 sub symblist {  sub symblist {
Line 16464  data base, returning a hash that is keye Line 16566  data base, returning a hash that is keye
 values that are the resource value.  I believe that the timestamps and  values that are the resource value.  I believe that the timestamps and
 versions are also returned.  versions are also returned.
   
 get_numsuppfiles($cnum,$cdom) : retrieve number of files in a course's  
 supplemental content area. This routine caches the number of files for   
 10 minutes.  
   
 =back  =back
   
 =head2 Course Modification  =head2 Course Modification

Removed from v.1.1495  
changed lines
  Added in v.1.1496


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>