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

raeburn raeburn at source.lon-capa.org
Tue Aug 8 16:10:55 EDT 2017


raeburn		Tue Aug  8 20:10:55 2017 EDT

  Modified files:              
    /loncom/auth	lonroles.pm switchserver.pm 
  Log:
  - Take into account trust settings for:
    - othcoau ("Co-author roles in this domain for others")
    - coaurem ("Co-author roles for this domain's users elsewhere")
    when displaying "Switch Server" link to Authoring Space's home server,
    and whether to skip check for ability to host a user on a remote server.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.332 loncom/auth/lonroles.pm:1.333
--- loncom/auth/lonroles.pm:1.332	Mon Jun 26 01:57:02 2017
+++ loncom/auth/lonroles.pm	Tue Aug  8 20:10:55 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.332 2017/06/26 01:57:02 raeburn Exp $
+# $Id: lonroles.pm,v 1.333 2017/08/08 20:10:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1240,6 +1240,7 @@
     my $advanced = $env{'user.adv'};
     my $tryagain = $env{'form.tryagain'};
     my @ids = &Apache::lonnet::current_machine_ids();
+    my (%willtrust,%trustchecked);
     if (ref($roles_in_env) eq 'HASH') {
         my %adhocdesc;
         foreach my $envkey (sort(keys(%{$roles_in_env}))) {
@@ -1308,10 +1309,23 @@
                 if (($role eq 'ca') || ($role eq 'aa')) {
                     my $home = &Apache::lonnet::homeserver($trest,$tdom);
                     my $allowed=0;
+                    my $prohibited;
                     foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                     if (!$allowed) {
                         $button=0;
-                        $switchserver='otherserver='.$home.'&role='.$trolecode;
+                        unless ($trustchecked{$tdom}) {
+                            if ((&Apache::lonnet::will_trust('othcoau',$tdom,$env{'user.domain'})) &&
+                                (&Apache::lonnet::will_trust('coremau',$env{'user.domain'},$tdom))) {
+                                $willtrust{$tdom} = 1;
+                                $trustchecked{$tdom} = 1;
+                            }
+                        } 
+                        if ($willtrust{$tdom}) {
+                            $switchserver='otherserver='.$home.'&role='.$trolecode;
+                        } else {
+                            $prohibited = 1;
+                            $tremark .= &mt('Session switch required but prohibited.');
+                        }
                     }
                     #next if ($home eq 'no_host');
                     $home = &Apache::lonnet::hostname($home);
@@ -1320,7 +1334,9 @@
                         ': '.$tdom.'<br />'.
                         ' '.&mt('Server').': '.$home;
                     $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
-                    $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
+                    unless ($prohibited) {
+                        $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
+                    }
                     $sortkey=$role."$trest:$tdom";
                 } elsif ($role eq 'au') {
                     # Authors
Index: loncom/auth/switchserver.pm
diff -u loncom/auth/switchserver.pm:1.36 loncom/auth/switchserver.pm:1.37
--- loncom/auth/switchserver.pm:1.36	Sat Feb 25 20:00:36 2017
+++ loncom/auth/switchserver.pm	Tue Aug  8 20:10:55 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Switch Servers Handler
 #
-# $Id: switchserver.pm,v 1.36 2017/02/25 20:00:36 raeburn Exp $
+# $Id: switchserver.pm,v 1.37 2017/08/08 20:10:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -129,8 +129,12 @@
                     $skip_canhost_check = 1;
                 }
             } elsif ($env{'form.role'} =~ m{^[ac]a\./($match_domain)/($match_username)$}) {
-                if (&Apache::lonnet::homeserver($2,$1) eq $env{'form.otherserver'}) {
-                    $skip_canhost_check = 1; 
+                my ($audom,$auname) = ($1,$2);
+                if (&Apache::lonnet::homeserver($auname,$audom) eq $env{'form.otherserver'}) {
+                    if ((&Apache::lonnet::will_trust('othcoau',$audom,$env{'user.domain'})) &&
+                        (&Apache::lonnet::will_trust('coremau',$env{'user.domain'},$audom))) {                             
+                        $skip_canhost_check = 1;
+                    }
                 }
             }
         }




More information about the LON-CAPA-cvs mailing list