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

raeburn raeburn at source.lon-capa.org
Wed Nov 9 12:48:39 EST 2016


raeburn		Wed Nov  9 17:48:39 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/auth	lonroles.pm 
  Log:
  - For 2.11
    - Backport 1.321, 1.322
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.269.2.28 loncom/auth/lonroles.pm:1.269.2.29
--- loncom/auth/lonroles.pm:1.269.2.28	Thu Oct 27 22:53:48 2016
+++ loncom/auth/lonroles.pm	Wed Nov  9 17:48:38 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.269.2.28 2016/10/27 22:53:48 raeburn Exp $
+# $Id: lonroles.pm,v 1.269.2.29 2016/11/09 17:48:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -310,10 +310,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);
@@ -321,7 +322,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});
                         }
                     }
@@ -401,7 +402,7 @@
                 }
                 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 (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}) {
@@ -416,7 +417,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});
                                     }
@@ -1220,8 +1222,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;
@@ -1267,7 +1271,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'};
@@ -1630,7 +1640,8 @@
 }
 
 sub build_roletext {
-    my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning) = @_;
+    my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,
+        $tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning) = @_;
     my ($roletext,$roletext_end);
     my $is_dc=($trolecode =~ m/^dc\./);
     my $rowspan=($is_dc) ? ''
@@ -1795,9 +1806,15 @@
                 my %cgroups =
                     &Apache::lonnet::get_active_groups($env{'user.domain'},
                                             $env{'user.name'},$cdom,$cnum);
+                my $ccrole;
+                if ($crstype eq 'Community') {
+                    $ccrole = 'co';
+                } else {
+                    $ccrole = 'cc';
+                }
                 foreach my $group (keys(%cgroups)) {
                     $group_privs{$group} =
-                        $env{'user.priv.cc./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group};
+                        $env{'user.priv.'.$ccrole.'./'.$cdom.'/'.$cnum.'./'.$cdom.'/'.$cnum.'/'.$group};
                 }
                 $newgroups{'/'.$cdom.'/'.$cnum} = \%group_privs;
                 my $area = '/'.$cdom.'/'.$cnum;




More information about the LON-CAPA-cvs mailing list