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

raeburn raeburn at source.lon-capa.org
Mon Jan 30 13:55:34 EST 2017


raeburn		Mon Jan 30 18:55:34 2017 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/auth	lonroles.pm 
  Log:
  - For 2.11
    - Backport 1.325.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.269.2.30 loncom/auth/lonroles.pm:1.269.2.31
--- loncom/auth/lonroles.pm:1.269.2.30	Sun Jan 22 14:28:20 2017
+++ loncom/auth/lonroles.pm	Mon Jan 30 18:55:33 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.269.2.30 2017/01/22 14:28:20 raeburn Exp $
+# $Id: lonroles.pm,v 1.269.2.31 2017/01/30 18:55:33 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -260,8 +260,9 @@
 
     my $envkey;
     my %dcroles = ();
-    my %dhroles = ();
-    my ($numdc,$numdh,$numadhoc) = &check_for_adhoc(\%dcroles,\%dhroles,$update,$then);
+    my %helpdeskroles = (); 
+    my ($numdc,$numhelpdesk,$numadhoc) =
+        &check_for_adhoc(\%dcroles,\%helpdeskroles,$update,$then);
     my $loncaparev = $r->dir_config('lonVersion');
 
 # ================================================================== Roles Init
@@ -273,9 +274,9 @@
         my $custom_adhoc;
         if ($env{'form.newrole'}) {
             $env{'form.'.$env{'form.newrole'}}=1;
-# Check if this is a Domain Helpdesk role trying to enter a course
+# Check if this is a Domain Helpdesk or Domain Helpdesk Assistant role trying to enter a course
             if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/\w+\./\1/$match_courseid$}) {
-                if ($dhroles{$1}) {
+                if ($helpdeskroles{$1}) {
                     $custom_adhoc = 1;
                 }
             }
@@ -326,9 +327,9 @@
                     }
                 }
             }
-        } elsif (($numdc > 0) || ($numdh > 0)) {
+        } elsif (($numdc > 0) || ($numhelpdesk > 0)) {
 # Check if user is a DC trying to enter a course or author space and needs privs to be created
-# Check if user is a DH trying to enter a course and needs privs to be created
+# Check if user is a DH or DA trying to enter a course and needs privs to be created
             foreach my $envkey (keys(%env)) {
                 if ($numdc) {
 # Is this an ad-hoc Coordinator role?
@@ -398,10 +399,10 @@
                         last;
                     }
                 }
-                if ($numdh) {
+                if ($numhelpdesk) {
 # Is this an ad hoc custom role in a course/community?
                     if (my ($domain,$rolename,$coursenum,$sec) = ($envkey =~ m{^form\.cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)})) {
-                        if ($dhroles{$domain}) {
+                        if ($helpdeskroles{$domain}) {
                             my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($domain.'_'.$coursenum,1);
                             if (ref($possroles) eq 'ARRAY') {
                                 if (grep(/^\Q$rolename\E$/,@{$possroles})) {
@@ -778,6 +779,12 @@
                                        $redirect_url);
                         return OK;
                     }
+                    if ($role eq 'da') {
+                        my $redirect_url = '/adm/menu/';
+                        &redirect_user($r,&mt('Loading Domain Helpdesk Assistant Menu'),
+                                       $redirect_url);
+                        return OK;
+                    }
                     if ($role eq 'sc') {
                         my $redirect_url = '/adm/grades?command=scantronupload';
                         &redirect_user($r,&mt('Loading Data Upload Page'),
@@ -1025,7 +1032,7 @@
     }
 # ----------------------------------------------------------------------- Table
 
-    if (($numdc > 0) || (($numdh > 0) && ($numadhoc > 0))) {
+    if (($numdc > 0) || (($numhelpdesk > 0) && ($numadhoc > 0))) {
         $r->print(&coursepick_jscript());
         $r->print(&Apache::loncommon::coursebrowser_javascript().
                   &Apache::loncommon::authorbrowser_javascript());
@@ -1061,7 +1068,7 @@
                 if ($role =~ m{^dc\./($match_domain)/$} 
 		    && $dcroles{$1}) {
 		    $output .= &adhoc_roles_row($1,'recent');
-                } elsif ($role =~ m{^(dh)\./($match_domain)/$}) {
+                } elsif ($role =~ m{^(dh|da)\./($match_domain)/$}) {
                     $output .= &adhoc_customroles_row($1,$2,'recent',$update,$then);
                 }
 	    } elsif ($numdc > 0) {
@@ -1487,7 +1494,7 @@
                                     $output .= &adhoc_roles_row($1,'');
                                 }
                             }
-                        } elsif ($sortrole->{$which} =~ m{^user\.role\.(dh)\./($match_domain)/}) {
+                        } elsif ($sortrole->{$which} =~ m{^user\.role\.(dh|da)\./($match_domain)/}) {
                             $output .= &adhoc_customroles_row($1,$2,'',$update,$then);
                         }
                     }
@@ -1747,21 +1754,20 @@
 }
 
 sub check_for_adhoc {
-    my ($dcroles,$dhroles,$update,$then) = @_;
+    my ($dcroles,$helpdeskroles,$update,$then) = @_;
     my $numdc = 0;
-    my $numdh = 0;
+    my $numhelpdesk = 0;
     my $numadhoc = 0;
     my $num_custom_adhoc = 0;
     if ($env{'user.adv'}) {
         foreach my $envkey (sort(keys(%env))) {
-            if ($envkey=~/^user\.role\.(dc|dh)\.\/($match_domain)\/$/) {
+            if ($envkey=~/^user\.role\.(dc|dh|da)\.\/($match_domain)\/$/) {
                 my $role = $1;
                 my $roledom = $2;
                 my $liverole = 1;
                 my ($tstart,$tend)=split(/\./,$env{$envkey});
                 my $limit = $update;
-                if ((($role eq 'dc') && ($env{'request.role'} eq 'dc./'.$roledom.'/')) ||
-                    (($role eq 'dh') && ($env{'request.role'} eq 'dh./'.$roledom.'/'))) {
+                if ($env{'request.role'} eq "$role./$roledom/") {
                     $limit = $then;
                 }
                 if ($tstart && $tstart>$limit) { $liverole = 0; }
@@ -1771,20 +1777,20 @@
                         $dcroles->{$roledom} = $envkey;
                         $numdc++;
                     } else {
-                        $dhroles->{$roledom} = $envkey;
+                        $helpdeskroles->{$roledom} = $envkey;
                         my %domdefaults = &Apache::lonnet::get_domain_defaults($roledom);
                         if (ref($domdefaults{'adhocroles'}) eq 'HASH') {
                             if (keys(%{$domdefaults{'adhocroles'}})) {
                                 $numadhoc ++;
                             }
                         }
-                        $numdh++;
+                        $numhelpdesk++;
                     }
                 }
             }
         }
     }
-    return ($numdc,$numdh,$numadhoc);
+    return ($numdc,$numhelpdesk,$numadhoc);
 }
 
 sub adhoc_course_role {




More information about the LON-CAPA-cvs mailing list