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

raeburn raeburn@source.lon-capa.org
Thu, 05 Nov 2009 16:04:23 -0000


raeburn		Thu Nov  5 16:04:23 2009 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Accommodate Communities
    - "co" role addition to a Community stored in nohist_userroles.db
    - "co" role assigned when a Community request processed automatically.
    - "cc" role not assigned if included in type "Community" request
    - "co" role is not assigned if included in type "Course" request.  
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1040 loncom/lonnet/perl/lonnet.pm:1.1041
--- loncom/lonnet/perl/lonnet.pm:1.1040	Sat Oct 31 23:37:00 2009
+++ loncom/lonnet/perl/lonnet.pm	Thu Nov  5 16:04:22 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1040 2009/10/31 23:37:00 raeburn Exp $
+# $Id: lonnet.pm,v 1.1041 2009/11/05 16:04:22 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2729,7 +2729,7 @@
     if (($trole=~/^ca/) || ($trole=~/^aa/) ||
         ($trole=~/^in/) || ($trole=~/^cc/) ||
         ($trole=~/^ep/) || ($trole=~/^cr/) ||
-        ($trole=~/^ta/)) {
+        ($trole=~/^ta/) || ($trole=~/^co/)) {
        my (undef,$rudom,$runame,$rsec)=split(/\//,$area);
        $userrolehash
          {$trole.':'.$username.':'.$domain.':'.$runame.':'.$rudom.':'.$rsec}
@@ -2738,7 +2738,8 @@
     if (($env{'request.role'} =~ /dc\./) &&
 	(($trole=~/^au/) || ($trole=~/^in/) ||
 	 ($trole=~/^cc/) || ($trole=~/^ep/) ||
-	 ($trole=~/^cr/) || ($trole=~/^ta/))) {
+	 ($trole=~/^cr/) || ($trole=~/^ta/) ||
+         ($trole=~/^co/))) {
        $userrolehash
          {$trole.':'.$username.':'.$domain.':'.$env{'user.name'}.':'.$env{'user.domain'}.':'}
                     =$tend.':'.$tstart;
@@ -6226,13 +6227,21 @@
                 if (($selfenroll == 1) && ($role eq 'st') && ($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'})) {
                     $refused = '';
                 } elsif ($context eq 'requestcourses') {
-                    my @possroles = ('st','ta','ep','in','cc');
+                    my @possroles = ('st','ta','ep','in','cc','co');
                     if ((grep(/^\Q$role\E$/,@possroles)) && ($env{'user.name'} ne '' && $env{'user.domain'} ne '')) {
                         my ($cdom,$cnum) = ($cwosec =~ m{^/?($match_domain)/($match_courseid)$});
-                        my %crsenv = &userenvironment($cdom,$cnum,('internal.courseowner'));
-                        if ($crsenv{'internal.courseowner'} eq 
-                             $env{'user.name'}.':'.$env{'user.domain'}) {
-                            $refused = '';
+                        my $wrongcc;
+                        if ($cnum =~ /^$match_community$/) {
+                            $wrongcc = 1 if ($role eq 'cc');
+                        } else {
+                            $wrongcc = 1 if ($role eq 'co');
+                        }
+                        unless ($wrongcc) {
+                            my %crsenv = &userenvironment($cdom,$cnum,('internal.courseowner'));
+                            if ($crsenv{'internal.courseowner'} eq 
+                                 $env{'user.name'}.':'.$env{'user.domain'}) {
+                                $refused = '';
+                            }
                         }
                     }
                 }