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

matthew lon-capa-cvs@mail.lon-capa.org
Sat, 04 May 2002 02:30:00 -0000


This is a MIME encoded message

--matthew1020479400
Content-Type: text/plain

matthew		Fri May  3 22:30:00 2002 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
  Log:
  List home server for author/co-author roles.  Tell the user their own
  home server.  Do not display buttons for authorship roles on machines other than the current server.  Part of Bug #226.  Some indentation changes made along the way.
  
  
--matthew1020479400
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20020503223000.txt"

Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.34 loncom/auth/lonroles.pm:1.35
--- loncom/auth/lonroles.pm:1.34	Fri Feb  1 07:54:51 2002
+++ loncom/auth/lonroles.pm	Fri May  3 22:30:00 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.34 2002/02/01 12:54:51 albertel Exp $
+# $Id: lonroles.pm,v 1.35 2002/05/04 02:30:00 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -208,7 +208,13 @@
         } 
     } else {
         if ($advanced) {
-           $r->print("<h2>Select a User Role</h2>\n");
+           $r->print
+               ("<h2>$ENV{'user.name'}, Please Select a Role</h2>\n");
+           $r->print("Your home server is ".
+                     $Apache::lonnet::hostname{&Apache::lonnet::homeserver
+                     ($ENV{'user.name'},$ENV{'user.domain'})}."<br />\n");
+           $r->print("Author and Co-Author roles may not be available on ".
+                     "servers other than your home server.");
         } else {
 	   $r->print("<h2>Enter a Course</h2>\n");
         }
@@ -229,6 +235,7 @@
                  '<th>Start</th><th>End</th><th>Remark</th></tr>'."\n");
 
     foreach $envkey (sort keys %ENV) {
+        my $button = 1;
         if ($envkey=~/^user\.role\./) {
 	    my ($dum1,$dum2,$role,@pwhere)=split(/\./,$envkey);
             my $where=join('.',@pwhere);
@@ -240,16 +247,16 @@
             my $tpend='&nbsp;';
             if ($tstart) {
 		if ($tstart>$then) { 
-                   $tstatus='future';
-                   if ($tstart<$now) { $tstatus='will'; }
+                    $tstatus='future';
+                    if ($tstart<$now) { $tstatus='will'; }
                 }
                 $tpstart=localtime($tstart);
             }
             if ($tend) {
                 if ($tend<$then) { 
-                   $tstatus='expired'; 
+                    $tstatus='expired'; 
                 } elsif ($tend<$now) { 
-                   $tstatus='will_not'; 
+                    $tstatus='will_not'; 
                 }
                 $tpend=localtime($tend);
             }
@@ -257,83 +264,101 @@
 		$tstatus='selected';
             }
             my $tbg;
-           if (($tstatus eq 'is') || ($tstatus eq 'selected') ||
-               ($ENV{'form.showall'})) {
-            if ($tstatus eq 'is') {
-		$tbg='#77FF77';
-            } elsif ($tstatus eq 'future') {
-                $tbg='#FFFF77';
-            } elsif ($tstatus eq 'will') {
-                $tbg='#FFAA77';
-                $tremark.='Active at next login. ';
-            } elsif ($tstatus eq 'expired') {
-                $tbg='#FF7777';
-	    } elsif ($tstatus eq 'will_not') {
-                $tbg='#AAFF77';
-                $tremark.='Expired after logout. ';
-            } elsif ($tstatus eq 'selected') {
-                $tbg='#11CC55';
-                $tremark.='Currently selected. ';
-            }
-            my $trole;
-            if ($role =~ /^cr\//) {
-	       my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
-               $tremark.='<br>Defined by '.$rauthor.' at '.$rdomain.'.';
-               $trole=$rrole;
-	    } else {
-               $trole=Apache::lonnet::plaintext($role);
-            }
-            my $ttype;
-            my $twhere;
-            my ($tdom,$trest,$tsection)=
-               split(/\//,Apache::lonnet::declutter($where));
-            if ($trest) {
-	      if ($role eq 'ca') {
-	        $ttype='Construction Space';
-                $twhere='User: '.$trest.'<br>Domain: '.$tdom;
-                $ENV{'course.'.$tdom.'_'.$trest.'.description'}='ca';
-              } else {
-		$ttype='Course';
-                if ($tsection) {
-                   $ttype.='<br>Section/Group: '.$tsection;
-                }     
-                my $tcourseid=$tdom.'_'.$trest;
-                if ($ENV{'course.'.$tcourseid.'.description'}) {
-		    $twhere=$ENV{'course.'.$tcourseid.'.description'};
+            if (($tstatus eq 'is') || ($tstatus eq 'selected') ||
+                ($ENV{'form.showall'})) {
+                if ($tstatus eq 'is') {
+                    $tbg='#77FF77';
+                } elsif ($tstatus eq 'future') {
+                    $tbg='#FFFF77';
+                } elsif ($tstatus eq 'will') {
+                    $tbg='#FFAA77';
+                    $tremark.='Active at next login. ';
+                } elsif ($tstatus eq 'expired') {
+                    $tbg='#FF7777';
+                } elsif ($tstatus eq 'will_not') {
+                    $tbg='#AAFF77';
+                    $tremark.='Expired after logout. ';
+                } elsif ($tstatus eq 'selected') {
+                    $tbg='#11CC55';
+                    $tremark.='Currently selected. ';
+                }
+                my $trole;
+                if ($role =~ /^cr\//) {
+                    my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
+                    $tremark.='<br>Defined by '.$rauthor.' at '.$rdomain.'.';
+                    $trole=$rrole;
                 } else {
-                    my %newhash=Apache::lonnet::coursedescription($tcourseid);
-                    if (%newhash) {
-			$twhere=$newhash{'description'};
+                    $trole=Apache::lonnet::plaintext($role);
+                }
+                my $ttype;
+                my $twhere;
+                my ($tdom,$trest,$tsection)=
+                    split(/\//,Apache::lonnet::declutter($where));
+                # First, Co-Authorship roles
+                if ($role eq 'ca') {
+                    my $home = &Apache::lonnet::homeserver($trest,$tdom);
+                    $button = 0 if ($home ne $r->dir_config('lonHostID'));
+                    #next if ($home eq 'no_host');
+                    $home = $Apache::lonnet::hostname{$home};
+                    $ttype='Construction Space';
+                    $twhere='User: '.$trest.'<br />Domain: '.$tdom.'<br />'.
+                        ' Server:&nbsp;'.$home;
+                    $ENV{'course.'.$tdom.'_'.$trest.'.description'}='ca';
+                } elsif ($role eq 'au') {
+                    # Authors
+                    my $home = &Apache::lonnet::homeserver
+                        ($ENV{'user.name'},$ENV{'user.domain'});
+                    $button = 0 if ($home ne $r->dir_config('lonHostID'));
+                    #next if ($home eq 'no_host');
+                    $home = $Apache::lonnet::hostname{$home};
+                    $ttype='Construction Space';
+                    $twhere='Domain: '.$tdom.'<br />Server:&nbsp;'.$home;
+                    $ENV{'course.'.$tdom.'_'.$trest.'.description'}='ca';
+                } elsif ($trest) {
+                    $ttype='Course';
+                    if ($tsection) {
+                        $ttype.='<br>Section/Group: '.$tsection;
+                    }     
+                    my $tcourseid=$tdom.'_'.$trest;
+                    if ($ENV{'course.'.$tcourseid.'.description'}) {
+                        $twhere=$ENV{'course.'.$tcourseid.'.description'};
                     } else {
-                        $twhere='Currently not available';
-                        $ENV{'course.'.$tcourseid.'.description'}=$twhere;
+                        my %newhash=Apache::lonnet::coursedescription
+                            ($tcourseid);
+                        if (%newhash) {
+                            $twhere=$newhash{'description'};
+                        } else {
+                            $twhere='Currently not available';
+                            $ENV{'course.'.$tcourseid.'.description'}=$twhere;
+                        }
+                        if ($trole ne 'st') {
+                            $twhere.="<br />Domain:".$tdom;
+                        }
                     }
-		    if ($trole ne 'st') {
-		      $twhere.="<br />Domain:".$tdom;
-		    }
-                }
-	      }
-            } elsif ($tdom) {
-                $ttype='Domain';
-                $twhere=$tdom;
-            } else {
-                $ttype='System';
-                $twhere='system wide';
-            }
-               
-            $r->print('<tr bgcolor='.$tbg.'>');
-            unless ($nochoose) {
-		if ($tstatus eq 'is') {
-                    $r->print('<td><input type=submit value=Select name="'.
-                              $trolecode.'"></td>');
-                } elsif ($ENV{'user.adv'}) {
-                    $r->print(
-                        '<td><input type=submit value="Re-Initialize" name="'.
-                              $trolecode.'"></td>');
+                } elsif ($tdom) {
+                    $ttype='Domain';
+                    $twhere=$tdom;
                 } else {
-                    $r->print('<td>&nbsp;</td>');
+                    $ttype='System';
+                    $twhere='system wide';
+                }
+ 
+# ----- do not trust the indention below here -----              
+                $r->print('<tr bgcolor='.$tbg.'>');
+                unless ($nochoose) {
+                    if (!$button) {
+                        $r->print('<td>&nbsp;</td>');
+                    } elsif ($tstatus eq 'is') {
+                        $r->print('<td><input type=submit value=Select name="'.
+                                  $trolecode.'"></td>');
+                    } elsif ($ENV{'user.adv'}) {
+                        $r->print
+                            ('<td><input type=submit value="Re-Initialize"'.
+                             ' name="'.$trolecode.'"></td>');
+                    } else {
+                        $r->print('<td>&nbsp;</td>');
+                    }
                 }
-            }
             $r->print('<td>'.$trole.'</td><td>'.
 		      $ttype.'</td><td>'.$twhere.'</td><td>'.$tpstart.
                       '</td><td>'.$tpend.

--matthew1020479400--