[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm

raeburn raeburn@source.lon-capa.org
Sat, 31 Oct 2009 05:44:35 -0000


raeburn		Sat Oct 31 05:44:35 2009 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
  Log:
  - Accommodate Communities.
    - adhoc Coordinator role for DCs is "co" role.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.238 loncom/auth/lonroles.pm:1.239
--- loncom/auth/lonroles.pm:1.238	Fri Oct 30 16:31:30 2009
+++ loncom/auth/lonroles.pm	Sat Oct 31 05:44:35 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.238 2009/10/30 16:31:30 bisitz Exp $
+# $Id: lonroles.pm,v 1.239 2009/10/31 05:44:35 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1454,10 +1454,11 @@
 
 sub adhoc_course_role {
     my ($refresh,$then) = @_;
-    my ($cdom,$cnum);
+    my ($cdom,$cnum,$crstype);
     $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-    if (&check_forcc($cdom,$cnum,$refresh,$then)) {
+    $crstype = &Apache::loncommon::course_type();
+    if (&check_forcc($cdom,$cnum,$refresh,$then,$crstype)) {
         my $setprivs;
         if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
             $setprivs = 1;
@@ -1507,11 +1508,16 @@
 }
 
 sub check_forcc {
-    my ($cdom,$cnum,$refresh,$then) = @_;
-    my $is_cc;
+    my ($cdom,$cnum,$refresh,$then,$crstype) = @_;
+    my ($is_cc,$ccrole);
+    if ($crstype eq 'Community') {
+        $ccrole = 'co';
+    } else {
+        $ccrole = 'cc';
+    }
     if ($cdom ne '' && $cnum ne '') {
         if (&Apache::lonnet::is_course($cdom,$cnum)) {
-            my $envkey = 'user.role.cc./'.$cdom.'/'.$cnum;
+            my $envkey = 'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum;
             if (defined($env{$envkey})) {
                 $is_cc = 1;
                 my ($tstart,$tend)=split(/\./,$env{$envkey});
@@ -1528,7 +1534,7 @@
     my $courseform=&Apache::loncommon::selectcourse_link
                    ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,
                     'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.
-                    $dcdom,$dcdom,undef);
+                    $dcdom,$dcdom,undef,'Course/Community');
     my $hiddenitems = '<input type="hidden" name="dcdomain'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.
                       '<input type="hidden" name="origdom'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.
                       '<input type="hidden" name="dccourse'.$rowtype.'_'.$dcdom.'" value="" />'.
@@ -1538,7 +1544,7 @@
 
 sub coursepick_jscript {
     my %lt = &Apache::lonlocal::texthash(
-                  plsu => "Please use the 'Select Course' link to open a separate pick course window where you may select the course or community you wish to enter.",
+                  plsu => "Please use the 'Select Course/Community' link to open a separate pick course window where you may select the course or community you wish to enter.",
                   youc => 'You can only use this screen to select courses and communities in the current domain.',
              );
     my $verify_script = <<"END";
@@ -1624,7 +1630,7 @@
                      ,'<span class="LC_cusr_emph">','</span>',$dcdom)
                  .' ';
     my $selectcclink = &courselink($dcdom,$rowtype);
-    my $ccrole = &Apache::lonnet::plaintext('cc');
+    my $ccrole = &Apache::lonnet::plaintext('co',undef,undef,1);
     my $carole = &Apache::lonnet::plaintext('ca');
     my $selectcalink = &coauthorlink($dcdom,$rowtype);
     $output.=$ccrole.': '.$selectcclink