Diff for /rat/lonuserstate.pm between versions 1.61 and 1.62

version 1.61, 2003/10/22 16:10:56 version 1.62, 2003/10/22 16:52:14
Line 76  sub versiontrack { Line 76  sub versiontrack {
     if ($uri=~/\.(\d+)\.\w+$/) {      if ($uri=~/\.(\d+)\.\w+$/) {
  my $version=$1;   my $version=$1;
  $uri=~s/\.\d+\.(\w+)$/\.$1/;   $uri=~s/\.\d+\.(\w+)$/\.$1/;
         $hash{'version_'.$uri}=$version;          unless ($hash{'version_'.$uri}) {
       $hash{'version_'.$uri}=$version;
    }
     }      }
     return $uri;      return $uri;
 }  }
Line 87  sub putinversion { Line 89  sub putinversion {
     my $uri=shift;      my $uri=shift;
     if ($hash{'version_'.$uri}) {      if ($hash{'version_'.$uri}) {
  my $version=$hash{'version_'.$uri};   my $version=$hash{'version_'.$uri};
    if ($version eq 'current') { return $uri; }
  $uri=~s/\.(\w+)$/\.$version\.$1/;   $uri=~s/\.(\w+)$/\.$version\.$1/;
     }      }
     return $uri;      return $uri;
Line 101  sub processversionfile { Line 104  sub processversionfile {
        $cenv{'num'});         $cenv{'num'});
     foreach (keys %versions) {      foreach (keys %versions) {
  if ($_=~/^error\:/) { return; }   if ($_=~/^error\:/) { return; }
  if ($versions{$_} eq 'current') {   $hash{'version_'.$_}=$versions{$_};
     delete $hash{'version_'.$_};  
  } else {  
     $hash{'version_'.$_}=$versions{$_};  
  }  
     }      }
 }  }
   
Line 121  sub loadmap { Line 120  sub loadmap {
     $hash{'map_id_'.$lpc}=$uri;      $hash{'map_id_'.$lpc}=$uri;
   
 # Determine and check filename  # Determine and check filename
     my $fn=&Apache::lonnet::filelocation('',$uri);      my $fn=&Apache::lonnet::filelocation('',&putinversion($uri));
   
     my $ispage=($fn=~/\.page$/);      my $ispage=($fn=~/\.page$/);
   
Line 155  sub loadmap { Line 154  sub loadmap {
   
                     $hash{'kind_'.$rid}='res';                      $hash{'kind_'.$rid}='res';
                     $hash{'title_'.$rid}=$token->[2]->{'title'};                      $hash{'title_'.$rid}=$token->[2]->{'title'};
 # Rip out the version and store it separately  
                     my $turi=&versiontrack($token->[2]->{'src'});                      my $turi=&versiontrack($token->[2]->{'src'});
 # If there is an explicit version parameter, use that one  
                     if ($token->[2]->{'version'}) {                      if ($token->[2]->{'version'}) {
  $hash{'version_'.$turi}=$1;   unless ($hash{'version_'.$turi}) {
       $hash{'version_'.$turi}=$1;
    }
     }      }
     &Apache::lonnet::do_cache(\%Apache::lonnet::titlecache,      &Apache::lonnet::do_cache(\%Apache::lonnet::titlecache,
        &Apache::lonnet::symbclean(         &Apache::lonnet::symbclean(
Line 534  sub readmap { Line 533  sub readmap {
     %parmhash=();      %parmhash=();
     $errtext='';      $errtext='';
     $pc=0;      $pc=0;
       &processversionfile(%cenv);
     my $furi=&Apache::lonnet::clutter($uri);      my $furi=&Apache::lonnet::clutter($uri);
     $hash{'src_0.0'}=&versiontrack($furi);      $hash{'src_0.0'}=&versiontrack($furi);
     $hash{'title_0.0'}=&Apache::lonnet::metadata($uri,'title');      $hash{'title_0.0'}=&Apache::lonnet::metadata($uri,'title');
Line 545  sub readmap { Line 545  sub readmap {
         &accinit($uri,$short,$fn);          &accinit($uri,$short,$fn);
         &pickrandom();          &pickrandom();
     }      }
 # ------------------------------------------------------------ Version tracking  # ------------------------------------------------------- Put versions into src
     &processversionfile(%cenv);  
     foreach (keys %hash) {      foreach (keys %hash) {
  if ($_=~/^src\_/) {   if ($_=~/^src\_/) {
     $hash{$_}=&putinversion($hash{$_});      $hash{$_}=&putinversion($hash{$_});

Removed from v.1.61  
changed lines
  Added in v.1.62


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