Diff for /loncom/interface/lonuserutils.pm between versions 1.179 and 1.180

version 1.179, 2016/11/13 21:09:56 version 1.180, 2017/01/02 19:44:07
Line 5891  sub get_permission { Line 5891  sub get_permission {
                 }                  }
             }              }
         }          }
           if ($env{'request.course.id'}) {
               my $user = $env{'user.name'}.':'.$env{'user.domain'};
               if (($user ne '') && ($env{'course.'.$env{'request.course.id'}.'.internal.courseowner'} eq
                                     $user)) {
                   $permission{'owner'} = 1;
               } elsif (($user ne '') && ($env{'course.'.$env{'request.course.id'}.'.internal.co-owners'} ne '')) {
                   if (grep(/^\Q$user\E$/,split(/,/,$env{'course.'.$env{'request.course.id'}.'.internal.co-owners'}))) {
                       $permission{'co-owner'} = 1;
                   }
               }
           }
     } elsif ($context eq 'author') {      } elsif ($context eq 'author') {
         $permission{'cusr'} = &authorpriv($env{'user.name'},$env{'request.role.domain'});          $permission{'cusr'} = &authorpriv($env{'user.name'},$env{'request.role.domain'});
         $permission{'view'} = $permission{'cusr'};          $permission{'view'} = $permission{'cusr'};
Line 5916  sub get_permission { Line 5927  sub get_permission {
         if (&Apache::lonnet::allowed('vur',$env{'request.role.domain'})) {          if (&Apache::lonnet::allowed('vur',$env{'request.role.domain'})) {
             $permission{'view'} = 1;              $permission{'view'} = 1;
         }          }
           if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
               $permission{'owner'} = 1;
           }
     }      }
     my $allowed = 0;      my $allowed = 0;
     foreach my $perm (values(%permission)) {      foreach my $perm (values(%permission)) {
Line 6411  END Line 6425  END
 }  }
   
 sub custom_role_table {  sub custom_role_table {
     my ($crstype,$full,$levels,$levelscurrent,$prefix) = @_;      my ($crstype,$full,$levels,$levelscurrent,$prefix,$add_class,$id) = @_;
     return unless ((ref($full) eq 'HASH') && (ref($levels) eq 'HASH') &&      return unless ((ref($full) eq 'HASH') && (ref($levels) eq 'HASH') &&
                    (ref($levelscurrent) eq 'HASH'));                     (ref($levelscurrent) eq 'HASH'));
     my %lt=&Apache::lonlocal::texthash (      my %lt=&Apache::lonlocal::texthash (
Line 6425  sub custom_role_table { Line 6439  sub custom_role_table {
                system => '_s',                 system => '_s',
              );               );
   
     my $output=&Apache::loncommon::start_data_table().      my $output=&Apache::loncommon::start_data_table($add_class,$id).
                &Apache::loncommon::start_data_table_header_row().                 &Apache::loncommon::start_data_table_header_row().
                '<th>'.$lt{'prv'}.'</th><th>'.$lt{'crl'}.'</th><th>'.$lt{'dml'}.                 '<th>'.$lt{'prv'}.'</th><th>'.$lt{'crl'}.'</th><th>'.$lt{'dml'}.
                '</th><th>'.$lt{'ssl'}.'</th>'.                 '</th><th>'.$lt{'ssl'}.'</th>'.
Line 6682  sub custom_role_update { Line 6696  sub custom_role_update {
     return %privs;      return %privs;
 }  }
   
   sub adhoc_status_types {
       my ($cdom,$context,$role,$selectedref,$othertitle,$usertypes,$types,$disabled) = @_;
       my $output = &Apache::loncommon::start_data_table();
       my $numinrow = 3;
       my $rem;
       if (ref($types) eq 'ARRAY') {
           for (my $i=0; $i<@{$types}; $i++) {
               if (defined($usertypes->{$types->[$i]})) {
                   my $rem = $i%($numinrow);
                   if ($rem == 0) {
                       if ($i > 0) {
                           $output .= &Apache::loncommon::end_data_table_row();
                       }
                       $output .= &Apache::loncommon::start_data_table_row();
                   }
                   my $check;
                   if (ref($selectedref) eq 'ARRAY') {
                       if (grep(/^\Q$types->[$i]\E$/,@{$selectedref})) {
                           $check = ' checked="checked"';
                       }
                   }
                   $output .= '<td>'.
                              '<span class="LC_nobreak"><label>'.
                              '<input type="checkbox" name="'.$context.$role.'_status" '.
                              'value="'.$types->[$i].'"'.$check.$disabled.' />'.
                              $usertypes->{$types->[$i]}.'</label></span></td>';
               }
           }
           $rem = @{$types}%($numinrow);
       }
       my $colsleft = $numinrow - $rem;
       if (($rem == 0) && (@{$types} > 0)) {
           $output .= &Apache::loncommon::start_data_table_row();
       }
       if ($colsleft > 1) {
           $output .= '<td colspan="'.$colsleft.'">';
       } else {
           $output .= '<td>';
       }
       my $defcheck;
       if (ref($selectedref) eq 'ARRAY') {
           if (grep(/^default$/,@{$selectedref})) {
               $defcheck = ' checked="checked"';
           }
       }
       $output .= '<span class="LC_nobreak"><label>'.
                  '<input type="checkbox" name="'.$context.$role.'_status"'.
                  'value="default"'.$defcheck.$disabled.' />'.
                  $othertitle.'</label></span></td>'.
                  &Apache::loncommon::end_data_table_row().
                  &Apache::loncommon::end_data_table();
       return $output;
   }
   
   sub adhoc_staff {
       my ($access,$context,$role,$selectedref,$adhocref,$disabled) = @_;
       my $output;
       if (ref($adhocref) eq 'HASH') {
           my %by_fullname;
           my $numinrow = 4;
           my $rem;
           my @personnel = keys(%{$adhocref});
           if (@personnel) {
               foreach my $person (@personnel) {
                   my ($uname,$udom) = split(/:/,$person);
                   my $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
                   $by_fullname{$fullname} = $person;
               }
               my @sorted = sort(keys(%by_fullname));
               my $count = scalar(@sorted);
               $output = &Apache::loncommon::start_data_table();
               for (my $i=0; $i<$count; $i++) {
                   my $rem = $i%($numinrow);
                   if ($rem == 0) {
                       if ($i > 0) {
                           $output .= &Apache::loncommon::end_data_table_row();
                       }
                       $output .= &Apache::loncommon::start_data_table_row();
                   }
                   my $check;
                   my $user = $by_fullname{$sorted[$i]};
                   if (ref($selectedref) eq 'ARRAY') {
                       if (grep(/^\Q$user\E$/,@{$selectedref})) {
                           $check = ' checked="checked"';
                       }
                   }
                   if ($i == $count-1) {
                       my $colsleft = $numinrow - $rem;
                       if ($colsleft > 1) {
                           $output .= '<td colspan="'.$colsleft.'">';
                       } else {
                           $output .= '<td>';
                       }
                   } else {
                       $output .= '<td>';
                   }
                   $output .= '<span class="LC_nobreak"><label>'.
                              '<input type="checkbox" name="'.$context.$role.'_staff_'.$access.'" '.
                              'value="'.$user.'"'.$check.$disabled.' />'.$sorted[$i].
                              '</label></span></td>';
                   if ($i == $count-1) {
                       $output .= &Apache::loncommon::end_data_table_row();
                   }
               }
               $output .= &Apache::loncommon::end_data_table();
           }
       }
       return $output;
   }
   
   
 1;  1;
   

Removed from v.1.179  
changed lines
  Added in v.1.180


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