[LON-CAPA-cvs] cvs: rat / lonuserstate.pm loncom lond loncom/interface lonmeta.pm loncom/lonnet/perl lonnet.pm loncom/publisher lonpublisher.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 07 Oct 2002 13:50:36 -0000


www		Mon Oct  7 09:50:36 2002 EDT

  Modified files:              
    /loncom	lond 
    /loncom/interface	lonmeta.pm 
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/publisher	lonpublisher.pm 
    /rat	lonuserstate.pm 
  Log:
  Toward bug 531.
  
  Can address most recent version.
  Can find out with lonnet::getversion what the most recent version is
  Shows versions in lonmeta
  
  
Index: loncom/lond
diff -u loncom/lond:1.101 loncom/lond:1.102
--- loncom/lond:1.101	Thu Oct  3 11:02:22 2002
+++ loncom/lond	Mon Oct  7 09:50:36 2002
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.101 2002/10/03 15:02:22 www Exp $
+# $Id: lond,v 1.102 2002/10/07 13:50:36 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1015,6 +1015,10 @@
 # ------------------------------------------------------------------- subscribe
                    } elsif ($userinput =~ /^sub/) {
 		       print $client &subscribe($userinput,$clientip);
+# ------------------------------------------------------------- current version
+                   } elsif ($userinput =~ /^currentversion/) {
+                       my ($cmd,$fname)=split(/:/,$userinput);
+		       print $client &currentversion($fname)."\n";
 # ------------------------------------------------------------------------- log
                    } elsif ($userinput =~ /^log/) {
                        my ($cmd,$udom,$uname,$what)=split(/:/,$userinput);
@@ -1655,7 +1659,8 @@
        $ulsdir=$1;
     }
     $fname=~s/\.\d+\.(\w+(?:\.meta)*)$/\.$1/;
-    $fname=~s/\.(\w+)$/\.\(\\d\+\)\.$1\$/;
+    $fname=~s/\.(\w+(?:\.meta)*)$/\.\(\\d\+\)\.$1\$/;
+
     if (-e $fname) { $version=1; }
     if (-e $ulsdir) {
        if(-d $ulsdir) {
@@ -1701,6 +1706,10 @@
                     my $extension=$2;
                     symlink($root.'.'.$extension,
                             $root.'.'.$currentversion.'.'.$extension);
+                    unless ($extension=~/\.meta$/) {
+                       symlink($root.'.'.$extension.'.meta',
+                            $root.'.'.$currentversion.'.'.$extension.'.meta');
+		    }
                 }
             }
         }
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.20 loncom/interface/lonmeta.pm:1.21
--- loncom/interface/lonmeta.pm:1.20	Mon Sep 16 17:01:41 2002
+++ loncom/interface/lonmeta.pm	Mon Oct  7 09:50:36 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.20 2002/09/16 21:01:41 www Exp $
+# $Id: lonmeta.pm,v 1.21 2002/10/07 13:50:36 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -179,13 +179,21 @@
   }
 
 # --------------------------------------------------------------- Render Output
-
+  my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta/);
 my $creationdate=localtime($content{'creationdate'});
 my $lastrevisiondate=localtime($content{'lastrevisiondate'});
 my $language=&Apache::loncommon::languagedescription($content{'language'});
 my $mime=&Apache::loncommon::filedescription($content{'mime'}); 
 my $disuri=&Apache::lonnet::declutter($uri);
   $disuri=~s/\.meta$//;
+my $currentversion=&Apache::lonnet::getversion($disuri);
+my $versiondisplay='';
+if ($thisversion) {
+    $versiondisplay='Version: '.$thisversion.
+    ' (most recent version: '.$currentversion.')';
+} else {
+    $versiondisplay='Version: '.$currentversion;
+}
 my $bodytag=&Apache::loncommon::bodytag
             ('Catalog Information','','','',$resdomain);
   $r->print(<<ENDHEAD);
@@ -193,6 +201,7 @@
 $bodytag
 <h2>$content{'title'}</h2>
 <h3><tt>$disuri</tt></h3>
+$versiondisplay<br />
 <table cellspacing=2 border=0>
 <tr><td bgcolor='#AAAAAA'>Author(s)</td>
 <td bgcolor="#CCCCCC">$content{'author'}&nbsp;</td></tr>
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.291 loncom/lonnet/perl/lonnet.pm:1.292
--- loncom/lonnet/perl/lonnet.pm:1.291	Thu Oct  3 18:32:53 2002
+++ loncom/lonnet/perl/lonnet.pm	Mon Oct  7 09:50:36 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.291 2002/10/03 22:32:53 albertel Exp $
+# $Id: lonnet.pm,v 1.292 2002/10/07 13:50:36 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -642,6 +642,30 @@
     &reply('chatsend:'.$cdom.':'.$cnum.':'.
 	   &escape($ENV{'user.domain'}.':'.$ENV{'user.name'}.':'.$anon.':'.
 		   &escape($newentry)),$chome);
+}
+
+# ------------------------------------------ Find current version of a resource
+
+sub getversion {
+    my $fname=&clutter(shift);
+    unless ($fname=~/^\/res\//) { return -1; }
+    return &currentversion(&filelocation('',$fname));
+}
+
+sub currentversion {
+    my $fname=shift;
+    my $author=$fname;
+    $author=~s/\/home\/httpd\/html\/res\/([^\/]*)\/([^\/]*).*/$1\/$2/;
+    my ($udom,$uname)=split(/\//,$author);
+    my $home=homeserver($uname,$udom);
+    if ($home eq 'no_host') { 
+        return -1; 
+    }
+    my $answer=reply("currentversion:$fname",$home);
+    if (($answer eq 'con_lost') || ($answer eq 'rejected')) {
+	return -1;
+    }
+    return $answer;
 }
 
 # ----------------------------- Subscribe to a resource, return URL if possible
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.98 loncom/publisher/lonpublisher.pm:1.99
--- loncom/publisher/lonpublisher.pm:1.98	Thu Oct  3 11:02:22 2002
+++ loncom/publisher/lonpublisher.pm	Mon Oct  7 09:50:36 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.98 2002/10/03 15:02:22 www Exp $
+# $Id: lonpublisher.pm,v 1.99 2002/10/07 13:50:36 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1309,6 +1309,7 @@
     while ($filename=readdir(DIR)) {
       if (-l $srcd.'/'.$filename) {
        unlink($srcd.'/'.$filename);
+       unlink($srcd.'/'.$filename.'.meta');
       } else {
        if ($filename=~/$srcf\.(\d+)\.$srct$/) {
 	   $maxversion=($1>$maxversion)?$1:$maxversion;
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.43 rat/lonuserstate.pm:1.44
--- rat/lonuserstate.pm:1.43	Tue Sep 10 16:53:37 2002
+++ rat/lonuserstate.pm	Mon Oct  7 09:50:36 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.43 2002/09/10 20:53:37 www Exp $
+# $Id: lonuserstate.pm,v 1.44 2002/10/07 13:50:36 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -68,6 +68,11 @@
 my $errtext; # variable with all errors
 my $retfurl; # variable with the very first URL in the course
 my %randompick; # randomly picked resources
+my %actualversion # version of resource as loaded now
+my %setversion # forced version of resource
+my %lastversion # version when CC came in last
+my $versionmode # how versioning is handled in this course
+my $hasversionpriv # user has versioning privileges
 # --------------------------------------------------------- Loads map from disk
 
 sub loadmap {