Diff for /loncom/auth/lonroles.pm between versions 1.323 and 1.331

version 1.323, 2017/01/02 19:44:11 version 1.331, 2017/05/19 19:47:40
Line 255  sub handler { Line 255  sub handler {
   
     my $envkey;      my $envkey;
     my %dcroles = ();      my %dcroles = ();
     my %dhroles = ();      my %helpdeskroles = ();
     my ($numdc,$numdh,$numadhoc) = &check_for_adhoc(\%dcroles,\%dhroles,$update,$then);      my ($numdc,$numhelpdesk,$numadhoc) = 
           &check_for_adhoc(\%dcroles,\%helpdeskroles,$update,$then);
     my $loncaparev = $r->dir_config('lonVersion');      my $loncaparev = $r->dir_config('lonVersion');
   
 # ================================================================== Roles Init  # ================================================================== Roles Init
Line 268  sub handler { Line 269  sub handler {
         my $custom_adhoc;          my $custom_adhoc;
         if ($env{'form.newrole'}) {          if ($env{'form.newrole'}) {
             $env{'form.'.$env{'form.newrole'}}=1;              $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 ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/\w+\./\1/$match_courseid$}) {
                 if ($dhroles{$1}) {                  if ($helpdeskroles{$1}) {
                     $custom_adhoc = 1;                      $custom_adhoc = 1;
                 }                  }
             }              }
Line 311  sub handler { Line 312  sub handler {
             my $cnum = $3;              my $cnum = $3;
             my $sec = $4;              my $sec = $4;
             if ($custom_adhoc) {              if ($custom_adhoc) {
                 my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum);                  my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum,1);
                 if (ref($possroles) eq 'ARRAY') {                  if (ref($possroles) eq 'ARRAY') {
                     if (grep(/^\Q$rolename\E$/,@{$possroles})) {                       if (grep(/^\Q$rolename\E$/,@{$possroles})) { 
                         if (&Apache::lonnet::check_adhoc_privs($cdom,$cnum,$update,$refresh,$now,                          if (&Apache::lonnet::check_adhoc_privs($cdom,$cnum,$update,$refresh,$now,
Line 321  sub handler { Line 322  sub handler {
                     }                      }
                 }                  }
             }              }
         } 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 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)) {              foreach my $envkey (keys(%env)) {
 # Is this an ad-hoc Coordinator role?  # Is this an ad-hoc Coordinator role?
                 if ($numdc) {                  if ($numdc) {
Line 393  sub handler { Line 394  sub handler {
                         last;                          last;
                     }                      }
                 }                  }
                 if ($numdh) {                  if ($numhelpdesk) {
 # 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,$sec) = ($envkey =~ m{^form\.cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)})) {                      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);                              my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($domain.'_'.$coursenum,1);
                             if (ref($possroles) eq 'ARRAY') {                              if (ref($possroles) eq 'ARRAY') {
                                 if (grep(/^\Q$rolename\E$/,@{$possroles})) {                                  if (grep(/^\Q$rolename\E$/,@{$possroles})) {
                                     if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum,$update,$refresh,$now,                                      if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum,$update,$refresh,$now,
Line 673  ENDENTERKEY Line 674  ENDENTERKEY
                                                     }                                                      }
                                                 }                                                  }
                                             }                                              }
                                               if (($dest =~ m{^\Q/public/$cdom/$cnum/syllabus\E.*(\?|\&)usehttp=1}) ||
                                                   ($dest =~ m{^\Q/adm/wrapper/ext/\E(?!https:)})) {
                                                   if ($ENV{'SERVER_PORT'} == 443) {
                                                       my $hostname = $r->hostname();
                                                       if ($hostname ne '') {
                                                           $dest = 'http://'.$hostname.$dest;
                                                       }
                                                   }
                                               }
                                             if ($dest =~ m{^/enc/}) {                                              if ($dest =~ m{^/enc/}) {
                                                 if ($env{'request.role.adv'}) {                                                  if ($env{'request.role.adv'}) {
                                                     $dest = &Apache::lonenc::unencrypted($dest);                                                      $dest = &Apache::lonenc::unencrypted($dest);
Line 705  ENDENTERKEY Line 715  ENDENTERKEY
                                         unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) {                                          unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) {
                                             if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) {                                              if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) {
                                                 my $esc_symb = &escape($destsymb);                                                  my $esc_symb = &escape($destsymb);
                                                 $dest .= '?symb='.$esc_symb;                                                  $dest .= (($dest =~/\?/)? '&':'?').'symb='.$esc_symb;
                                             }                                              }
                                         }                                          }
                                         &redirect_user($r, &mt('Entering [_1]',                                          &redirect_user($r, &mt('Entering [_1]',
Line 783  ENDENTERKEY Line 793  ENDENTERKEY
                                        $redirect_url);                                         $redirect_url);
                         return OK;                          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') {                      if ($role eq 'sc') {
                         my $redirect_url = '/adm/grades?command=scantronupload';                          my $redirect_url = '/adm/grades?command=scantronupload';
                         &redirect_user($r,&mt('Loading Data Upload Page'),                          &redirect_user($r,&mt('Loading Data Upload Page'),
Line 1080  ENDHEADER Line 1096  ENDHEADER
     }      }
 # ----------------------------------------------------------------------- Table  # ----------------------------------------------------------------------- Table
   
     if (($numdc > 0) || (($numdh > 0) && ($numadhoc > 0))) {      if (($numdc > 0) || (($numhelpdesk > 0) && ($numadhoc > 0))) {
         $r->print(&coursepick_jscript());          $r->print(&coursepick_jscript().
         $r->print(&Apache::loncommon::coursebrowser_javascript().                    &Apache::loncommon::coursebrowser_javascript());
                   &Apache::loncommon::authorbrowser_javascript());      }
       if ($numdc > 0) {
           $r->print(&Apache::loncommon::authorbrowser_javascript());
     }      }
   
     unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {      unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {
Line 1116  ENDHEADER Line 1134  ENDHEADER
                 if ($role =~ m{^dc\./($match_domain)/$}                   if ($role =~ m{^dc\./($match_domain)/$} 
     && $dcroles{$1}) {      && $dcroles{$1}) {
     $output .= &adhoc_roles_row($1,'recent');      $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);                      $output .= &adhoc_customroles_row($1,$2,'recent',$update,$then);
                 }                  }
     } elsif ($numdc > 0) {      } elsif ($numdc > 0) {
Line 1548  sub print_rolerows { Line 1566  sub print_rolerows {
                                     $output .= &adhoc_roles_row($1,'');                                      $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);                              $output .= &adhoc_customroles_row($1,$2,'',$update,$then);
                         }                          }
                     }                      }
Line 1719  sub privileges_info { Line 1737  sub privileges_info {
 sub build_roletext {  sub build_roletext {
     my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,      my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,
         $tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning,$skipcal) = @_;          $tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning,$skipcal) = @_;
     my ($roletext,$roletext_end);      my ($roletext,$roletext_end,$poss_adhoc);
     my $is_dc=($trolecode =~ m/^dc\./);      if ($trolecode =~ m/^d(c|h|a)\./) {
     my $rowspan=($is_dc) ? ''          $poss_adhoc = 1;
       }
       my $rowspan=($poss_adhoc) ? ''
                          : ' rowspan="2" ';                           : ' rowspan="2" ';
   
     unless ($nochoose) {      unless ($nochoose) {
Line 1782  sub build_roletext { Line 1802  sub build_roletext {
               .'<td>'.$twhere.'</td>'                .'<td>'.$twhere.'</td>'
               .'<td>'.$tpstart.'</td>'                .'<td>'.$tpstart.'</td>'
               .'<td>'.$tpend.'</td>';                .'<td>'.$tpend.'</td>';
     if (!$is_dc) {      unless ($poss_adhoc) {
         $roletext_end = '<td colspan="4">'.          $roletext_end = '<td colspan="4">'.
                         $tremark.'&nbsp;'.                          $tremark.'&nbsp;'.
                         '</td>';                          '</td>';
Line 1808  sub check_author_homeserver { Line 1828  sub check_author_homeserver {
 }  }
   
 sub check_for_adhoc {  sub check_for_adhoc {
     my ($dcroles,$dhroles,$update,$then) = @_;      my ($dcroles,$helpdeskroles,$update,$then) = @_;
     my $numdc = 0;      my $numdc = 0;
     my $numdh = 0;      my $numhelpdesk = 0;
     my $numadhoc = 0;      my $numadhoc = 0;
     my $num_custom_adhoc = 0;       my $num_custom_adhoc = 0; 
     if ($env{'user.adv'}) {      if (($env{'user.adv'}) || ($env{'user.rar'})) {
         foreach my $envkey (sort(keys(%env))) {          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 $role = $1;
                 my $roledom = $2;                  my $roledom = $2;
                 my $liverole = 1;                  my $liverole = 1;
                 my ($tstart,$tend)=split(/\./,$env{$envkey});                  my ($tstart,$tend)=split(/\./,$env{$envkey});
                 my $limit = $update;                  my $limit = $update;
                 if ((($role eq 'dc') && ($env{'request.role'} eq 'dc./'.$roledom.'/')) ||                  if ($env{'request.role'} eq "$role./$roledom/") {
                     (($role eq 'dh') && ($env{'request.role'} eq 'dh./'.$roledom.'/'))) {  
                     $limit = $then;                      $limit = $then;
                 }                  }
                 if ($tstart && $tstart>$limit) { $liverole = 0; }                  if ($tstart && $tstart>$limit) { $liverole = 0; }
Line 1832  sub check_for_adhoc { Line 1851  sub check_for_adhoc {
                         $dcroles->{$roledom} = $envkey;                          $dcroles->{$roledom} = $envkey;
                         $numdc++;                          $numdc++;
                     } else {                      } else {
                         $dhroles->{$roledom} = $envkey;                          $helpdeskroles->{$roledom} = $envkey;
                         my %domdefaults = &Apache::lonnet::get_domain_defaults($roledom);                          my %domdefaults = &Apache::lonnet::get_domain_defaults($roledom);
                         if (ref($domdefaults{'adhocroles'}) eq 'HASH') {                          if (ref($domdefaults{'adhocroles'}) eq 'HASH') {
                             if (keys(%{$domdefaults{'adhocroles'}})) {                              if (keys(%{$domdefaults{'adhocroles'}})) {
                                 $numadhoc ++;                                  $numadhoc ++;
                             }                              }
                         }                          }
                         $numdh++;                          $numhelpdesk++;
                     }                      }
                 }                  }
             }              }
         }          }
     }      }
     return ($numdc,$numdh,$numadhoc);      return ($numdc,$numhelpdesk,$numadhoc);
 }  }
   
 sub adhoc_course_role {  sub adhoc_course_role {
Line 2046  sub adhoc_roles_row { Line 2065  sub adhoc_roles_row {
     my ($dcdom,$rowtype) = @_;      my ($dcdom,$rowtype) = @_;
     my $output = &Apache::loncommon::continue_data_table_row()      my $output = &Apache::loncommon::continue_data_table_row()
                  .' <td colspan="5" class="LC_textsize_mobile">'                   .' <td colspan="5" class="LC_textsize_mobile">'
                  .&mt('[_1]Ad hoc[_2] roles in domain [_3] --'                   .&mt('[_1]Ad hoc[_2] roles in domain [_3]'
                      ,'<span class="LC_cusr_emph">','</span>',$dcdom)                       ,'<span class="LC_cusr_emph">','</span>',$dcdom)
                  .' ';                   .' -- ';
     my $role = 'cc';      my $role = 'cc';
     my $selectcclink = &courselink($dcdom,$rowtype,$role);      my $selectcclink = &courselink($dcdom,$rowtype,$role);
     my $ccrole = &Apache::lonnet::plaintext('co',undef,undef,1);      my $ccrole = &Apache::lonnet::plaintext('co',undef,undef,1);
Line 2076  sub adhoc_customroles_row { Line 2095  sub adhoc_customroles_row {
         if (scalar(keys(%{$domdefaults{'adhocroles'}})) > 0) {          if (scalar(keys(%{$domdefaults{'adhocroles'}})) > 0) {
             return &Apache::loncommon::continue_data_table_row()              return &Apache::loncommon::continue_data_table_row()
                   .' <td colspan="5" class="LC_textsize_mobile">'                    .' <td colspan="5" class="LC_textsize_mobile">'
                   .&mt('[_1]Ad hoc[_2] course/community roles in domain [_3] --',                    .&mt('[_1]Ad hoc[_2] course/community roles in domain [_3]',
                        '<span class="LC_cusr_emph">','</span>',$dhdom)                         '<span class="LC_cusr_emph">','</span>',$dhdom)
                   .' '.&courselink($dhdom,$rowtype,$role);                    .' -- '.&courselink($dhdom,$rowtype,$role);
         }          }
     }      }
     return;      return;

Removed from v.1.323  
changed lines
  Added in v.1.331


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