Diff for /loncom/auth/lonroles.pm between versions 1.321 and 1.322

version 1.321, 2016/11/08 23:09:33 version 1.322, 2016/11/08 23:15:34
Line 305  sub handler { Line 305  sub handler {
                                  "request.role.adv"            => $env{'user.adv'},                                   "request.role.adv"            => $env{'user.adv'},
  "request.role.domain"         => $env{'user.domain'}});   "request.role.domain"         => $env{'user.domain'}});
 # Check if Domain Helpdesk role trying to enter a course needs privs to be created  # 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 $cdom = $1;
             my $rolename = $2;              my $rolename = $2;
             my $cnum = $3;              my $cnum = $3;
               my $sec = $4;
             if ($custom_adhoc) {              if ($custom_adhoc) {
                 my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},                  my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
                                                                   'adhocroles.'.$cdom);                                                                    'adhocroles.'.$cdom);
Line 316  sub handler { Line 317  sub handler {
                     my @adhoc = split(',',$adhocroles{'adhocroles.'.$cdom});                      my @adhoc = split(',',$adhocroles{'adhocroles.'.$cdom});
                     if (grep(/^\Q$rolename\E$/,@adhoc)) {                      if (grep(/^\Q$rolename\E$/,@adhoc)) {
                         if (&Apache::lonnet::check_adhoc_privs($cdom,$cnum,$update,$refresh,$now,                          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});                              &Apache::lonnet::appenv({"environment.internal.$cdom.$cnum.cr/$cdom/$cdom".'-domainconfig/'."$rolename.adhoc" => time});
                         }                          }
                     }                      }
Line 396  sub handler { Line 397  sub handler {
                 }                  }
                 if ($numdh) {                  if ($numdh) {
 # Is this an ad hoc custom role in a course/community?  # 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}) {                           if ($dhroles{$domain}) {
                             my @adhoc;                               my @adhoc; 
                             if ($env{'environment.adhocroles.'.$domain}) {                              if ($env{'environment.adhocroles.'.$domain}) {
                                 @adhoc = split(',',$env{'environment.adhocroles.'.$domain});                                  @adhoc = split(',',$env{'environment.adhocroles.'.$domain});
Line 411  sub handler { Line 412  sub handler {
                             if ((@adhoc > 0) && ($rolename ne '')) {                              if ((@adhoc > 0) && ($rolename ne '')) {
                                 if (grep(/^\Q$rolename\E$/,@adhoc)) {                                  if (grep(/^\Q$rolename\E$/,@adhoc)) {
                                     if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum,$update,$refresh,$now,                                      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".                                          &Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.cr/$domain/$domain".
                                                                  '-domainconfig/'."$rolename.adhoc" => time});                                                                   '-domainconfig/'."$rolename.adhoc" => time});
                                     }                                      }
Line 1275  sub gather_roles { Line 1277  sub gather_roles {
                 my $trole;                  my $trole;
                 if ($role =~ /^cr\//) {                  if ($role =~ /^cr\//) {
                     my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);                      my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
                     if ($tremark) { $tremark.='<br />'; }                      unless ($rauthor eq $rdomain.'-domainconfig') {
                     $tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);                          if ($tremark) { $tremark.='<br />'; }
                           $tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);
                       }
                 }                  }
                 $trole=Apache::lonnet::plaintext($role);                  $trole=Apache::lonnet::plaintext($role);
                 my $ttype;                  my $ttype;
Line 1323  sub gather_roles { Line 1327  sub gather_roles {
                 } elsif ($trest) {                  } elsif ($trest) {
                     my $tcourseid=$tdom.'_'.$trest;                      my $tcourseid=$tdom.'_'.$trest;
                     $ttype = &Apache::loncommon::course_type($tcourseid);                      $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]','&nbsp;'.$2);
                       } else {
                           $trole = (split(/\//,$role,4))[-1];
                       }
                     if ($env{'course.'.$tcourseid.'.description'}) {                      if ($env{'course.'.$tcourseid.'.description'}) {
                         my $home=$env{'course.'.$tcourseid.'.home'};                          my $home=$env{'course.'.$tcourseid.'.home'};
                         $twhere=$env{'course.'.$tcourseid.'.description'};                          $twhere=$env{'course.'.$tcourseid.'.description'};

Removed from v.1.321  
changed lines
  Added in v.1.322


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>