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

raeburn raeburn at source.lon-capa.org
Wed Mar 11 00:53:15 EDT 2015


raeburn		Wed Mar 11 04:53:15 2015 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/auth	lonroles.pm 
  Log:
  - For 2.11
    Backport 1.309, 1.310
  
  
-------------- next part --------------
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.269.2.21 loncom/auth/lonroles.pm:1.269.2.22
--- loncom/auth/lonroles.pm:1.269.2.21	Mon Jun  9 21:48:13 2014
+++ loncom/auth/lonroles.pm	Wed Mar 11 04:53:15 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.269.2.21 2014/06/09 21:48:13 raeburn Exp $
+# $Id: lonroles.pm,v 1.269.2.22 2015/03/11 04:53:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -292,14 +292,15 @@
 	    &Apache::lonnet::put('email_status',\%temp);
 	    &Apache::lonnet::delenv('user.state.'.$env{'request.course.id'});
 	}
-	&Apache::lonnet::appenv({"request.course.id"   => '',
-			 	 "request.course.fn"   => '',
-				 "request.course.uri"  => '',
-				 "request.course.sec"  => '',
-                                 "request.course.tied" => '',
-				 "request.role"        => 'cm',
-                                 "request.role.adv"    => $env{'user.adv'},
-				 "request.role.domain" => $env{'user.domain'}});
+	&Apache::lonnet::appenv({"request.course.id"           => '',
+			 	 "request.course.fn"           => '',
+				 "request.course.uri"          => '',
+				 "request.course.sec"          => '',
+                                 "request.course.tied"         => '',
+                                 "request.course.timechecked"  => '',
+				 "request.role"                => 'cm',
+                                 "request.role.adv"            => $env{'user.adv'},
+				 "request.role.domain"         => $env{'user.domain'}});
 # Check if user is a DC trying to enter a course or author space and needs privs to be created
         if ($numdc > 0) {
             foreach my $envkey (keys(%env)) {
@@ -388,30 +389,13 @@
                             my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired');
                             if ($curr_reqd_hash{'internal.releaserequired'} ne '') {
                                 my ($switchserver,$switchwarning) =
-                                    &check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode,$curr_reqd_hash{'internal.releaserequired'});
+                                    &Apache::loncommon::check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode,
+                                                                               $curr_reqd_hash{'internal.releaserequired'});
                                 if ($switchwarning ne '' || $switchserver ne '') {
                                     &Apache::loncommon::content_type($r,'text/html');
                                     &Apache::loncommon::no_cache($r);
                                     $r->send_http_header;
-                                    my $end_page=&Apache::loncommon::end_page();
-                                    $r->print(&Apache::loncommon::start_page('Selected course unavailable on this server').
-                                              '<p class="LC_warning">');
-                                    if ($switchwarning) {
-                                        $r->print($switchwarning.'<br /><a href="/adm/roles">');
-                                        if (&Apache::loncommon::show_course()) {
-                                            $r->print(&mt('Display courses'));
-                                        } else {
-                                            $r->print(&mt('Display roles'));
-                                        }
-                                        $r->print('</a>');
-                                    } elsif ($switchserver) {
-				        $r->print(&mt('This course requires a newer version of LON-CAPA than is installed on this server.').
-                                                  '<br />'.
-                                                  '<a href="/adm/switchserver?'.$switchserver.'">'.
-                                                  &mt('Switch Server').
-                                                  '</a>');
-                                    }
-                                    $r->print('</p>'.&Apache::loncommon::end_page());
+                                    $r->print(&Apache::loncommon::check_release_result($switchwarning,$switchserver));
                                     return OK;
                                 }
                             }
@@ -1217,7 +1201,7 @@
                                 my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};
                                 if ($required ne '') {
                                     ($switchserver,$switchwarning) = 
-                                        &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+                                        &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
                                     if ($switchserver || $switchwarning) {
                                         $button = 0;
                                     }
@@ -1240,7 +1224,7 @@
                                 my $required = $newhash{'internal.releaserequired'};
                                 if ($required ne '') {
                                     ($switchserver,$switchwarning) =
-                                        &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+                                        &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
                                     if ($switchserver || $switchwarning) {
                                         $button = 0;
                                     }
@@ -1656,7 +1640,7 @@
     my ($dcroles,$update,$then) = @_;
     my $numdc = 0;
     if ($env{'user.adv'}) {
-        foreach my $envkey (sort keys %env) {
+        foreach my $envkey (sort(keys(%env))) {
             if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) {
                 my $dcdom = $1;
                 my $livedc = 1;
@@ -1765,58 +1749,6 @@
     return $is_cc;
 }
 
-sub check_release_required {
-    my ($loncaparev,$tcourseid,$trolecode,$required) = @_;
-    my ($switchserver,$warning);
-    if ($required ne '') {
-        my ($reqdmajor,$reqdminor) = ($required =~ /^(\d+)\.(\d+)$/);
-        my ($major,$minor) = ($loncaparev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/);
-        if ($reqdmajor ne '' && $reqdminor ne '') {
-            my $otherserver;
-            if (($major eq '' && $minor eq '') || 
-                (($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) {
-                my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'},undef,$required,1);
-                my $switchlcrev = 
-                    &Apache::lonnet::get_server_loncaparev($env{'user.domain'},
-                                                           $userdomserver);
-                my ($swmajor,$swminor) = ($switchlcrev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/);
-                if (($swmajor eq '' && $swminor eq '') || ($reqdmajor > $swmajor) || 
-                    (($reqdmajor == $swmajor) && ($reqdminor > $swminor))) {
-                    my $cdom = $env{'course.'.$tcourseid.'.domain'};
-                    if ($cdom ne $env{'user.domain'}) {
-                        my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom,undef,$required,1);
-                        my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname);
-                        my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);
-                        my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);
-                        my %udomdefaults = &Apache::lonnet::get_domain_defaults($env{'user.domain'});
-                        my $remoterev = &Apache::lonnet::get_server_loncaparev($serverhomedom,$coursedomserver);
-                        my $canhost =
-                            &Apache::lonnet::can_host_session($env{'user.domain'},
-                                                              $coursedomserver,
-                                                              $remoterev,
-                                                              $udomdefaults{'remotesessions'},
-                                                              $defdomdefaults{'hostedsessions'});
-
-                        if ($canhost) {
-                            $otherserver = $coursedomserver;
-                        } else {
-                            $warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$tcourseid.'.internal.releaserequired'}).'<br />'. &mt("No suitable server could be found amongst servers in either your own domain or in the course's domain.");
-                        }
-                    } else {
-                        $warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$tcourseid.'.internal.releaserequired'}).'<br />'.&mt("No suitable server could be found amongst servers in your own domain (which is also the course's domain).");
-                    }
-                } else {
-                    $otherserver = $userdomserver;
-                }
-            }
-            if ($otherserver ne '') {
-                $switchserver = 'otherserver='.$otherserver.'&role='.$trolecode;
-            }
-        }
-    }
-    return ($switchserver,$warning);
-}
-
 sub courselink {
     my ($dcdom,$rowtype) = @_;
     my $courseform=&Apache::loncommon::selectcourse_link


More information about the LON-CAPA-cvs mailing list