[LON-CAPA-cvs] cvs: loncom / LONCAPA.pm LondConnection.pm lond /lonnet/perl lonnet.pm

raeburn raeburn@source.lon-capa.org
Thu, 29 Oct 2009 03:23:58 -0000


raeburn		Thu Oct 29 03:23:58 2009 EDT

  Modified files:              
    /loncom	lond LONCAPA.pm LondConnection.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Distinctive courseID for Communities - all begin with 0
  - LONCAPA::match_community will match this type of courseID
  - Client session sends installed LON-CAPA version when initiating lonc/lond
    connection to remote server.
  - Roles in Communities unavailable for user sessions hosted on LON-CAPA 
    releases which predate 2.9.
  
  
Index: loncom/lond
diff -u loncom/lond:1.431 loncom/lond:1.432
--- loncom/lond:1.431	Wed Oct 21 16:14:24 2009
+++ loncom/lond	Thu Oct 29 03:23:52 2009
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.431 2009/10/21 16:14:24 raeburn Exp $
+# $Id: lond,v 1.432 2009/10/29 03:23:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,7 +59,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.431 $'; #' stupid emacs
+my $VERSION='$Revision: 1.432 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -67,6 +67,7 @@
 my $client;
 my $clientip;			# IP address of client.
 my $clientname;			# LonCAPA name of client.
+my $clientversion;              # LonCAPA version running on client
 
 my $server;
 
@@ -3121,6 +3122,13 @@
         my $qresult='';
 	my $count=0;
 	while (my ($key,$value) = each(%$hashref)) {
+            if ($namespace eq 'roles') {
+                if ($key =~ /^($LONCAPA::match_domain)_($LONCAPA::match_community)_cc$/) {
+                    if ($clientversion =~ /^(\d+\.\d+)$/) {
+                        next if ($1 <= 2.9);
+                    }
+                }
+            }
 	    if ($regexp eq '.') {
 		$count++;
 		if (defined($range) && $count >= $end)   { last; }
@@ -6263,7 +6271,7 @@
 	&ReadManagerTable();
 	my $clientrec=defined(&Apache::lonnet::get_hosts_from_ip($outsideip));
 	my $ismanager=($managers{$outsideip}    ne undef);
-	$clientname  = "[unknonwn]";
+	$clientname  = "[unknown]";
 	if($clientrec) {	# Establish client type.
 	    $ConnectionType = "client";
 	    $clientname = (&Apache::lonnet::get_hosts_from_ip($outsideip))[-1];
@@ -6291,7 +6299,7 @@
 		#
 		#  If the remote is attempting a local init... give that a try:
 		#
-		my ($i, $inittype) = split(/:/, $remotereq);
+		(my $i, my $inittype, $clientversion) = split(/:/, $remotereq);
 
 		# If the connection type is ssl, but I didn't get my
 		# certificate files yet, then I'll drop  back to 
@@ -6311,6 +6319,7 @@
 		}
 
 		if($inittype eq "local") {
+                    $clientversion = $perlvar{'lonVersion'};
 		    my $key = LocalConnection($client, $remotereq);
 		    if($key) {
 			Debug("Got local key $key");
Index: loncom/LONCAPA.pm
diff -u loncom/LONCAPA.pm:1.28 loncom/LONCAPA.pm:1.29
--- loncom/LONCAPA.pm:1.28	Wed May 13 14:01:10 2009
+++ loncom/LONCAPA.pm	Thu Oct 29 03:23:52 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Base routines
 #
-# $Id: LONCAPA.pm,v 1.28 2009/05/13 14:01:10 raeburn Exp $
+# $Id: LONCAPA.pm,v 1.29 2009/10/29 03:23:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -44,6 +44,7 @@
 use vars qw($match_domain   $match_not_domain
 	    $match_username $match_not_username
 	    $match_courseid $match_not_courseid
+            $match_community
 	    $match_name
             $match_lonid
 	    $match_handle   $match_not_handle);
@@ -56,12 +57,14 @@
 our @EXPORT_OK = qw($match_domain   $match_not_domain
 		    $match_username $match_not_username
 		    $match_courseid $match_not_courseid
+                    $match_community
 		    $match_name
 		    $match_lonid
 		    $match_handle   $match_not_handle);
 our %EXPORT_TAGS = ( 'match' =>[qw($match_domain   $match_not_domain
 				   $match_username $match_not_username
 				   $match_courseid $match_not_courseid
+                                   $match_community
 				   $match_name
 				   $match_lonid
 				   $match_handle   $match_not_handle)],);
@@ -119,6 +122,7 @@
 
 
 $match_courseid     = $LONCAPA::courseid_re     = qr{\d[\w\-.]+};
+$match_community    =$LONCAPA::community_re     = qr{0[\w\-.]+};
 $match_not_courseid = $LONCAPA::not_courseid_re = qr{[^\w\-.]+};
 sub clean_courseid {
     my ($courseid) = @_;
@@ -161,8 +165,7 @@
     $subdir =~ s/(.)(.)(.).*/$1\/$2\/$3/;
     my $proname="$perlvar{'lonUsersDir'}/$udom/$subdir/$uname";
     return $proname;
-} 
-
+}
 
 sub tie_domain_hash {
     my ($domain,$namespace,$how,$loghead,$logtail) = @_;
Index: loncom/LondConnection.pm
diff -u loncom/LondConnection.pm:1.46 loncom/LondConnection.pm:1.47
--- loncom/LondConnection.pm:1.46	Tue Apr 10 23:15:20 2007
+++ loncom/LondConnection.pm	Thu Oct 29 03:23:52 2009
@@ -1,7 +1,7 @@
 #   This module defines and implements a class that represents
 #   a connection to a lond daemon.
 #
-# $Id: LondConnection.pm,v 1.46 2007/04/10 23:15:20 albertel Exp $
+# $Id: LondConnection.pm,v 1.47 2009/10/29 03:23:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -241,11 +241,11 @@
 	if((defined $ca)  && (defined $cert) && (defined $sslkeyfile)) {
 
 	    $self->{AuthenticationMode} = "ssl";
-	    $self->{TransactionRequest} = "init:ssl\n";
+	    $self->{TransactionRequest} = "init:ssl:$perlvar{'lonVersion'}\n";
 	} else {
 	    if($InsecureOk) {		# Allowed to do insecure:
 		$self->{AuthenticationMode} = "insecure";
-		$self->{TransactionRequest} = "init\n";
+		$self->{TransactionRequest} = "init::$perlvar{'lonVersion'}\n";
 	    }
 	    else {		# Not allowed to do insecure...
 		$socket->close;
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1037 loncom/lonnet/perl/lonnet.pm:1.1038
--- loncom/lonnet/perl/lonnet.pm:1.1037	Wed Oct 28 19:09:21 2009
+++ loncom/lonnet/perl/lonnet.pm	Thu Oct 29 03:23:58 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1037 2009/10/28 19:09:21 raeburn Exp $
+# $Id: lonnet.pm,v 1.1038 2009/10/29 03:23:58 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6554,10 +6554,10 @@
         if (($chome eq '') || ($chome eq 'no_host')) {
             $uname = $cnum;
         } else {
-            $uname = &generate_coursenum($udom);
+            $uname = &generate_coursenum($udom,$crstype);
         }
     } else {
-        $uname = &generate_coursenum($udom);
+        $uname = &generate_coursenum($udom,$crstype);
     }
     return $uname if ($uname =~ /^error/);
 # -------------------------------------------------- Check supplied server name
@@ -6617,17 +6617,28 @@
 
 # ------------------------------------------------------------------- Create ID
 sub generate_coursenum {
-    my ($udom) = @_;
+    my ($udom,$crstype) = @_;
     my $domdesc = &domain($udom);
     return 'error: invalid domain' if ($domdesc eq '');
-    my $uname=int(1+rand(9)).
+    my $first;
+    if ($crstype eq 'Community') {
+        $first = '0';
+    } else {
+        $first = int(1+rand(9)); 
+    } 
+    my $uname=$first.
         ('a'..'z','A'..'Z','0'..'9')[int(rand(62))].
         substr($$.time,0,5).unpack("H8",pack("I32",time)).
         unpack("H2",pack("I32",int(rand(255)))).$perlvar{'lonHostID'};
 # ----------------------------------------------- Make sure that does not exist
     my $uhome=&homeserver($uname,$udom,'true');
     unless (($uhome eq '') || ($uhome eq 'no_host')) {
-        $uname=int(1+rand(9)).
+        if ($crstype eq 'Community') {
+            $first = '0';
+        } else {
+            $first = int(1+rand(9));
+        }
+        $uname=$first.
                ('a'..'z','A'..'Z','0'..'9')[int(rand(62))].
                substr($$.time,0,5).unpack("H8",pack("I32",time)).
                unpack("H2",pack("I32",int(rand(255)))).$perlvar{'lonHostID'};
@@ -10211,7 +10222,7 @@
 
 =item *
 
-generate_coursenum($udom) : get a unique (unused) course number in domain $udom
+generate_coursenum($udom,$crstype) : get a unique (unused) course number in domain $udom for course type $crstype (Course or Community).
 
 =back