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

raeburn lon-capa-cvs@mail.lon-capa.org
Tue, 30 May 2006 21:16:43 -0000


This is a MIME encoded message

--raeburn1149023803
Content-Type: text/plain

raeburn		Tue May 30 17:16:43 2006 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
  Log:
  Adding ANGEL-style groups as a thin veneer. Roles in Discussion groups are separated from roles in Courses.   
  
  
--raeburn1149023803
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060530171643.txt"

Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.151 loncom/auth/lonroles.pm:1.152
--- loncom/auth/lonroles.pm:1.151	Tue May 30 15:47:36 2006
+++ loncom/auth/lonroles.pm	Tue May 30 17:16:40 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.151 2006/05/30 19:47:36 www Exp $
+# $Id: lonroles.pm,v 1.152 2006/05/30 21:16:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -247,9 +247,9 @@
 					   'request.course.sec'  => $csec,
                                            'request.course.groups' => $cgrps);
                     my $tadv=0;
-		    my $msg=&mt('Entering course ...');
 
 		    if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
+                        my $msg;
 			my ($furl,$ferr)=
 			    &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
 			if (($env{'form.orgurl'}) && 
@@ -264,17 +264,24 @@
 			    }
 			    return OK;
 			} else {
-			    unless ($env{'request.course.id'}) {
+                            my $type = 'Course/Group';
+			    if ($env{'request.course.id'}) {
+                                if (defined($env{'course.'.
+                                            $env{'request.course.id'}.'.type'})) {
+                                    $type = $env{'course.'.
+                                                 $env{'request.course.id'}.'.type'};
+                                }
 				&Apache::lonnet::appenv(
 				      "request.course.id"  => $cdom.'_'.$cnum);
 				$furl='/adm/roles?tryagain=1';
 				$msg=
 				    '<h1><font color="red">'.
-			 &mt('Could not initialize course at this time.').
+			 &mt('Could not initialize [_1] at this time.',lc($type)).
 		    '</font></h1><h3>'.&mt('Please try again.').'</h3>'.$ferr;
 			    }
 			    if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
 			    &Apache::lonnet::appenv('request.role.adv'=>$tadv);
+
 			    if (($ferr) && ($tadv)) {
 				&error_page($r,$ferr,$furl);
 			    } else {
@@ -298,7 +305,7 @@
 					) {
 					my $startpage = &courseloadpage($courseid);
 					unless ($startpage eq 'firstres') {         
-					    $msg = &mt('Entering course ....');
+					    $msg = &mt('Entering [_1] ....',lc($type));
 					    &redirect_user($r,&mt('New in course'),
 							   '/adm/whatsnew?refpage=start',$msg,
 							   $env{'environment.remotenavmap'});
@@ -311,7 +318,8 @@
 # Guess not ...
 				    $furl=&Apache::lonpageflip::first_accessible_resource();
 				}
-				&redirect_user($r,&mt('Entering Course'),
+                                $msg = &mt('Entering [_1] ...',lc($type));
+				&redirect_user($r,&mt('Entering [_1]',$type),
 					       $furl,$msg,
 					       $env{'environment.remotenavmap'});
 			    }
@@ -559,6 +567,13 @@
                 } elsif ($trest) {
                     $ttype='Course';
                     my $tcourseid=$tdom.'_'.$trest;
+                    if (defined($env{'course.'.$tcourseid.'.type'})) {
+                        $ttype = $env{'course.'.$tcourseid.'.type'};
+                        if ($ttype eq 'Group') {
+                            $trole = &Apache::loncommon::convert_role($trole,
+                                                                      $ttype);    
+                        }
+                    }
                     if ($env{'course.'.$tcourseid.'.description'}) {
                         $twhere=$env{'course.'.$tcourseid.'.description'};
 			$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
@@ -576,16 +591,21 @@
                               ' <font size="-2">'.
         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
                               '</font>';
+                            $ttype = $newhash{'type'};
+                            if ($ttype eq 'Group') {
+                                $trole = &Apache::loncommon::convert_role(
+                                                                $trole,$ttype);
+                            }
                         } else {
                             $twhere=&mt('Currently not available');
                             $env{'course.'.$tcourseid.'.description'}=$twhere;
 			    $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
+                            $ttype = 'Unavailable';
                         }
                     }
                     if ($tsection) {
                         $twhere.='<br />'.&mt('Section/Group').': '.$tsection;
 		    }
-
 		    if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; }
                 } elsif ($tdom) {
                     $ttype='Domain';
@@ -596,8 +616,7 @@
                     $twhere=&mt('system wide');
 		    $sortkey=$role.$twhere;
                 }
- 
-                $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);
+                $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);
 		$roletext{$envkey}=$roletext;
 		if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
 		$sortrole{$sortkey}=$envkey;
@@ -627,14 +646,14 @@
 # More than one possible role
 # ----------------------------------------------------------------------- Table
     unless (($advanced) || ($nochoose)) {
-	$r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
+	$r->print("<h2>".&mt('Select a Course/Group to Enter')."</h2>\n");
     }
     $r->print('<br /><table><tr>');
     unless ($nochoose) { $r->print('<th>&nbsp;</th>'); }
     $r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent').
          '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th></tr>'."\n");
     my $doheaders=-1;
-    foreach my $type ('Domain','Construction Space','Course','System') {
+    foreach my $type ('Domain','Construction Space','Course','Group','Unavailable','System') {
 	my $haverole=0;
 	foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
 	    if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
@@ -673,7 +692,7 @@
         $r->print(&coursepick_jscript());
         $r->print(&Apache::loncommon::coursebrowser_javascript());
     }
-    foreach my $type ('Construction Space','Domain','Course','System') {
+    foreach my $type ('Construction Space','Domain','Course','Group','Unavailable','System') {
 	my $output;
 	foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
 	    if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
@@ -736,9 +755,12 @@
 			$twhere='User: '.$trest.', Domain: '.$tdom;
 		    } else {
 			$ttype='Course';
+                        if (defined($env{'course.'.$tdom.'_'.$trest.'.type'})) {
+                            $ttype = $env{'course.'.$tdom.'_'.$trest.'.type'};
+                        }
 			$twhere=$env{'course.'.$tdom.'_'.$trest.'.description'};
 			if ($tsec) {
-			    $twhere.=' (Section/Group: '.$tsec.')';
+			    $twhere.=' (Section: '.$tsec.')';
 			}
 		    }
 		} elsif ($tdom) {
@@ -808,7 +830,7 @@
 }
 
 sub build_roletext {
-    my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;
+    my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;
     my $roletext='<tr bgcolor="'.$tbg.'">';
     my $is_dc=($trolecode =~ m/^dc\./);
     my $rowspan=($is_dc) ? ''
@@ -893,9 +915,11 @@
 }
 
 sub courselink {
-    my ($dcdom,$rowtype) = @_;
+    my ($dcdom,$rowtype,$selecttype) = @_;
     my $courseform=&Apache::loncommon::selectcourse_link
-                     ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.$dcdom,$dcdom);
+                   ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,
+                    'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.
+                    $dcdom,$dcdom,undef,$selecttype);
     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="" />'.
@@ -976,6 +1000,7 @@
             my $trolecode = 'cc./'.$1.'/'.$2;
             my $trole = Apache::lonnet::plaintext('cc');
             my $twhere;
+            my $ttype;
             my $tbg='#77FF77';
             my $tfont='#003300';
             my %newhash=&Apache::lonnet::coursedescription($tcourseid);
@@ -984,27 +1009,37 @@
                         ' <font size="-2">'.
                         &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont).
                         '</font>';
+                $ttype=$newhash{'type'};
+                if ($ttype eq 'Group') {
+                    $trole = &Apache::loncommon::convert_role($trole,$ttype);
+                }
             } else {
                 $twhere=&mt('Currently not available');
                 $env{'course.'.$tcourseid.'.description'}=$twhere;
+                $ttype = 'Unavailable';
             }
             $twhere.="<br />".&mt('Domain').":".$1;
-            $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,&mt('Course'),$twhere,'','','',1,'');
+            $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,$twhere,'','','',1,'');
         }
     }
-    return $roletext;
+    return ($roletext);
 }
 
 sub allcourses_row {
     my ($dcdom,$rowtype) = @_;
     my $ccrole = Apache::lonnet::plaintext('cc');
-    my $selectlink = &courselink($dcdom,$rowtype);
     my $output = '<tr bgcolor="#77FF77">'.
-	'<td colspan="5">'.
-	'<font color="#002200">'.$ccrole.'</font>'.
-	' <b>'.$selectlink.'</b>'.
-	' from '.&mt('Domain').' '.$dcdom.
-	'<tr><td colspan="5" height="3"></td></tr>'."\n";
+                 ' <td colspan="5">';
+    foreach my $type ('Course','Group') {
+        my $selectlink = &courselink($dcdom,$rowtype,$type);
+        if ($type eq 'Group') {
+            $ccrole = &Apache::loncommon::convert_role($ccrole,$type);
+        }
+        $output.= '<font color="#002200">'.$ccrole.'</font>'.
+              ' <b>'.$selectlink.'</b>'.
+              ' from '.&mt('Domain').' '.$dcdom.'<br />';
+    }
+    $output .= '</tr><tr><td colspan="5" height="3"></td></tr>'."\n";
     return $output;
 }
 

--raeburn1149023803--