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

raeburn raeburn at source.lon-capa.org
Tue Nov 8 18:15:35 EST 2016


raeburn		Tue Nov  8 23:15:35 2016 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
  Log:
  - Ad hoc role in a course for Domain Helpdesk can be for a specific section.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.321 loncom/auth/lonroles.pm:1.322
--- loncom/auth/lonroles.pm:1.321	Tue Nov  8 23:09:33 2016
+++ loncom/auth/lonroles.pm	Tue Nov  8 23:15:34 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.321 2016/11/08 23:09:33 raeburn Exp $
+# $Id: lonroles.pm,v 1.322 2016/11/08 23:15:34 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -305,10 +305,11 @@
                                  "request.role.adv"            => $env{'user.adv'},
 				 "request.role.domain"         => $env{'user.domain'}});
 # Check if Domain Helpdesk role trying to enter a course needs privs to be created
-        if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)$}) {
+        if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)}) {
             my $cdom = $1;
             my $rolename = $2;
             my $cnum = $3;
+            my $sec = $4;
             if ($custom_adhoc) {
                 my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
                                                                   'adhocroles.'.$cdom);
@@ -316,7 +317,7 @@
                     my @adhoc = split(',',$adhocroles{'adhocroles.'.$cdom});
                     if (grep(/^\Q$rolename\E$/, at adhoc)) {
                         if (&Apache::lonnet::check_adhoc_privs($cdom,$cnum,$update,$refresh,$now,
-                                                               "cr/$cdom/$cdom".'-domainconfig/'.$rolename)) {
+                                                               "cr/$cdom/$cdom".'-domainconfig/'.$rolename,undef,$sec)) {
                             &Apache::lonnet::appenv({"environment.internal.$cdom.$cnum.cr/$cdom/$cdom".'-domainconfig/'."$rolename.adhoc" => time});
                         }
                     }
@@ -396,8 +397,8 @@
                 }
                 if ($numdh) {
 # Is this an ad hoc custom role in a course/community?
-                    if (my ($domain,$rolename,$coursenum) = ($envkey =~ m{^form\.cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)$})) {
-                        if ($dhroles{$domain}) { 
+                    if (my ($domain,$rolename,$coursenum,$sec) = ($envkey =~ m{^form\.cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)})) {
+                        if ($dhroles{$domain}) {
                             my @adhoc; 
                             if ($env{'environment.adhocroles.'.$domain}) {
                                 @adhoc = split(',',$env{'environment.adhocroles.'.$domain});
@@ -411,7 +412,8 @@
                             if ((@adhoc > 0) && ($rolename ne '')) {
                                 if (grep(/^\Q$rolename\E$/, at adhoc)) {
                                     if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum,$update,$refresh,$now,
-                                                                           "cr/$domain/$domain".'-domainconfig/'.$rolename)) {
+                                                                           "cr/$domain/$domain".'-domainconfig/'.$rolename,
+                                                                           undef,$sec)) {
                                         &Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.cr/$domain/$domain".
                                                                  '-domainconfig/'."$rolename.adhoc" => time});
                                     }
@@ -1275,8 +1277,10 @@
                 my $trole;
                 if ($role =~ /^cr\//) {
                     my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
-                    if ($tremark) { $tremark.='<br />'; }
-                    $tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);
+                    unless ($rauthor eq $rdomain.'-domainconfig') {
+                        if ($tremark) { $tremark.='<br />'; }
+                        $tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);
+                    }
                 }
                 $trole=Apache::lonnet::plaintext($role);
                 my $ttype;
@@ -1323,7 +1327,13 @@
                 } elsif ($trest) {
                     my $tcourseid=$tdom.'_'.$trest;
                     $ttype = &Apache::loncommon::course_type($tcourseid);
-                    $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
+                    if ($role !~ /^cr/) {
+                        $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
+                    } elsif ($role =~ m{^cr/($match_domain)/\1-domainconfig/(\w+)$}) {
+                        $trole = &mt('Helpdesk[_1]',' '.$2);
+                    } else {
+                        $trole = (split(/\//,$role,4))[-1];
+                    }
                     if ($env{'course.'.$tcourseid.'.description'}) {
                         my $home=$env{'course.'.$tcourseid.'.home'};
                         $twhere=$env{'course.'.$tcourseid.'.description'};




More information about the LON-CAPA-cvs mailing list