Diff for /loncom/interface/lonuserutils.pm between versions 1.177 and 1.184.2.2

version 1.177, 2016/10/14 23:26:21 version 1.184.2.2, 2017/11/16 17:05:49
Line 1121  sub print_upload_manager_form { Line 1121  sub print_upload_manager_form {
     if (!$env{'form.datatoken'}) {      if (!$env{'form.datatoken'}) {
         $datatoken=&Apache::loncommon::upfile_store($r);          $datatoken=&Apache::loncommon::upfile_store($r);
     } else {      } else {
         $datatoken=$env{'form.datatoken'};          $datatoken=&Apache::loncommon::valid_datatoken($env{'form.datatoken'});
         &Apache::loncommon::load_tmp_file($r);          if ($datatoken ne '') {
               &Apache::loncommon::load_tmp_file($r,$datatoken);
           }
       }
       if ($datatoken eq '') {
           $r->print('<p class="LC_error">'.&mt('Error').': '.
                     &mt('Invalid datatoken').'</p>');
           return 'missingdata';
     }      }
     my @records=&Apache::loncommon::upfile_record_sep();      my @records=&Apache::loncommon::upfile_record_sep();
     if($env{'form.noFirstLine'}){      if($env{'form.noFirstLine'}){
Line 1206  sub print_upload_manager_form { Line 1213  sub print_upload_manager_form {
     }      }
     &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear,      &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear,
                                  $context,$permission,$crstype,$showcredits);                                   $context,$permission,$crstype,$showcredits);
       return 'ok';
 }  }
   
 sub setup_date_selectors {  sub setup_date_selectors {
Line 2307  sub courses_selector { Line 2315  sub courses_selector {
             my $allidlist = $idlist{$codetitles[0]};              my $allidlist = $idlist{$codetitles[0]};
             $jscript .= &Apache::courseclassifier::courseset_js_start($formname,$longtitles_str,$allidlist);              $jscript .= &Apache::courseclassifier::courseset_js_start($formname,$longtitles_str,$allidlist);
             $jscript .= $scripttext;              $jscript .= $scripttext;
             $jscript .= &Apache::courseclassifier::javascript_code_selections($formname,@codetitles);              $jscript .= &Apache::courseclassifier::javascript_code_selections($formname,\@codetitles);
         }          }
     }      }
     my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($cdom);      my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($cdom);
Line 2572  function username_display_launch(usernam Line 2580  function username_display_launch(usernam
             }              }
         }          }
     }      }
     if (target == 'modify') {      if ((target == 'modify') || (target == 'activity')) {
           var nextaction = 'singleuser';
           if (target == 'activity') {
               nextaction = 'accesslogs';
           }
         if (document.$formname.userwin.checked == true) {          if (document.$formname.userwin.checked == true) {
             var url = '/adm/createuser?srchterm='+username+'&srchdomain='+domain+'&phase=get_user_info&action=singleuser&srchin=dom&srchby=uname&srchtype=exact&popup=1';              var url = '/adm/createuser?srchterm='+username+'&srchdomain='+domain+'&phase=get_user_info&srchin=dom&srchby=uname&srchtype=exact&popup=1&action='+nextaction;
             var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';              var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
             modifywin = window.open(url,'',options,1);              modifywin = window.open(url,'',options,1);
             modifywin.focus();              modifywin.focus();
Line 2583  function username_display_launch(usernam Line 2595  function username_display_launch(usernam
             document.$formname.srchterm.value=username;              document.$formname.srchterm.value=username;
             document.$formname.srchdomain.value=domain;              document.$formname.srchdomain.value=domain;
             document.$formname.phase.value='get_user_info';              document.$formname.phase.value='get_user_info';
             document.$formname.action.value = 'singleuser';              document.$formname.action.value = nextaction;
             document.$formname.submit();              document.$formname.submit();
         }          }
     }      }
Line 2629  END Line 2641  END
                        'owin'       => "Open in a new window",                         'owin'       => "Open in a new window",
                        'modify'     => "Modify a user's information",                         'modify'     => "Modify a user's information",
                        'track'      => "View a user's recent activity",                         'track'      => "View a user's recent activity",
                          'activity'   => "View a user's access log", 
                       );                        );
     my %lt = (%coltxt,%acttxt);      my %lt = (%coltxt,%acttxt);
     my $rolefilter = $env{'form.showrole'};      my $rolefilter = $env{'form.showrole'};
Line 2719  END Line 2732  END
             if ($permission->{'cusr'}) {              if ($permission->{'cusr'}) {
                 unshift (@linkdests,'modify');                  unshift (@linkdests,'modify');
             }              }
             if (&Apache::lonnet::allowed('vsa', $env{'request.course.id'}) ||              if ($context eq 'course') {
                 &Apache::lonnet::allowed('vsa', $env{'request.course.id'}.'/'.                  if (&Apache::lonnet::allowed('vsa', $env{'request.course.id'}) ||
                                          $env{'request.course.sec'})) {                      &Apache::lonnet::allowed('vsa', $env{'request.course.id'}.'/'.
                 push(@linkdests,'track');                                               $env{'request.course.sec'})) {
                       push(@linkdests,'track');
                   }
               } elsif ($context eq 'domain') {
                   if (&Apache::lonnet::allowed('vac',$env{'request.role.domain'})) {
                       push(@linkdests,'activity');
                   }
             }              }
   
             $output .= '<td>';              $output .= '<td>';
             my $usernamelink = $env{'form.usernamelink'};              my $usernamelink = $env{'form.usernamelink'};
             if ($usernamelink eq '') {              if ($usernamelink eq '') {
Line 2747  END Line 2765  END
                .'<input type="checkbox" name="userwin" value="1"'.$checkwin.' />'.$lt{'owin'}                 .'<input type="checkbox" name="userwin" value="1"'.$checkwin.' />'.$lt{'owin'}
                .'</label></span></td></tr></table></fieldset></div>';                 .'</label></span></td></tr></table></fieldset></div>';
         }          }
         $output .= "\n".'<br clear="all" />'."\n".          $output .= "\n".'<div style="padding:0;clear:both;margin:0;border:0"></div>'."\n".
                   &Apache::loncommon::start_data_table().                    &Apache::loncommon::start_data_table().
                   &Apache::loncommon::start_data_table_header_row();                    &Apache::loncommon::start_data_table_header_row();
         if ($mode eq 'autoenroll') {          if ($mode eq 'autoenroll') {
Line 2993  END Line 3011  END
             } (keys(%$userlist));              } (keys(%$userlist));
     }      }
     my $rowcount = 0;      my $rowcount = 0;
       my $disabled;
       if ($mode eq 'autoenroll') {
           unless ($permission->{'cusr'}) {
               $disabled = ' disabled="disabled"';
           }
       }
     foreach my $user (@sorted_users) {      foreach my $user (@sorted_users) {
         my %in;          my %in;
         my $sdata = $userlist->{$user};          my $sdata = $userlist->{$user};
Line 3029  END Line 3053  END
             if ($mode eq 'autoenroll') {              if ($mode eq 'autoenroll') {
                 my $cellentry;                  my $cellentry;
                 if ($in{'type'} eq 'auto') {                  if ($in{'type'} eq 'auto') {
                     $cellentry = '<b>'.&mt('auto').'</b>&nbsp;<label><input type="checkbox" name="chgauto" value="'.$in{'username'}.':'.$in{'domain'}.'" />&nbsp;'.&mt('Change').'</label>';                      $cellentry = '<b>'.&mt('auto').'</b>&nbsp;<label><input type="checkbox" name="chgauto" value="'.$in{'username'}.':'.$in{'domain'}.'"'.$disabled.' />&nbsp;'.&mt('Change').'</label>';
                     $autocount ++;                      $autocount ++;
                 } else {                  } else {
                     $cellentry = '<table border="0" cellspacing="0"><tr><td rowspan="2"><b>'.&mt('manual').'</b></td><td><span class="LC_nobreak"><label><input type="checkbox" name="chgmanual" value="'.$in{'username'}.':'.$in{'domain'}.'" />&nbsp;'.&mt('Change').'</label></span></td></tr><tr><td><span class="LC_nobreak">';                      $cellentry = '<table border="0" cellspacing="0"><tr><td rowspan="2"><b>'.&mt('manual').'</b></td><td><span class="LC_nobreak"><label><input type="checkbox" name="chgmanual" value="'.$in{'username'}.':'.$in{'domain'}.'"'.$disabled.' />&nbsp;'.&mt('Change').'</label></span></td></tr><tr><td><span class="LC_nobreak">';
                     $manualcount ++;                      $manualcount ++;
                     if ($in{'lockedtype'}) {                      if ($in{'lockedtype'}) {
                         $cellentry .= '<label><input type="checkbox" name="unlockchg" value="'.$in{'username'}.':'.$in{'domain'}.'" />&nbsp;'.&mt('Unlock').'</label>';                          $cellentry .= '<label><input type="checkbox" name="unlockchg" value="'.$in{'username'}.':'.$in{'domain'}.'"'.$disabled.' />&nbsp;'.&mt('Unlock').'</label>';
                         $unlockcount ++;                          $unlockcount ++;
                     } else {                      } else {
                         $cellentry .= '<label><input type="checkbox" name="lockchg" value="'.$in{'username'}.':'.$in{'domain'}.'" />&nbsp;'.&mt('Lock').'</label>';                          $cellentry .= '<label><input type="checkbox" name="lockchg" value="'.$in{'username'}.':'.$in{'domain'}.'"'.$disabled.' />&nbsp;'.&mt('Lock').'</label>';
                         $lockcount ++;                          $lockcount ++;
                     }                      }
                     $cellentry .= '</span></td></tr></table>';                      $cellentry .= '</span></td></tr></table>';
Line 3085  END Line 3109  END
                         }                          }
                         if ($showcheckbox) {                          if ($showcheckbox) {
                             $r->print('<td><input type="checkbox" name="'.                              $r->print('<td><input type="checkbox" name="'.
                                       'actionlist" value="'.&HTML::Entities::encode($checkval,'&<>"').'" /></td>');                                        'actionlist" value="'.
                                         &HTML::Entities::encode($checkval,'&<>"').'" />');
                               foreach my $item ('start','end') {
                                   $r->print('<input type="hidden" name="'.
                                             &HTML::Entities::encode($checkval.'_'.$item,'&<>"').'"'.
                                             ' value="'.$sdata->[$index{$item}].'" />');
                               }
                               $r->print('</td>');
                         } else {                          } else {
                             $r->print('<td>&nbsp;</td>');                              $r->print('<td>&nbsp;</td>');
                         }                          }
Line 3099  END Line 3130  END
             foreach my $item (@cols) {              foreach my $item (@cols) {
                 if ($item eq 'username') {                  if ($item eq 'username') {
                     $r->print('<td>'.&print_username_link($mode,\%in).'</td>');                      $r->print('<td>'.&print_username_link($mode,\%in).'</td>');
                 } elsif (($item eq 'start' || $item eq 'end') && ($actionselect)) {  
                     $r->print('<td>'.$in{$item}.'<input type="hidden" name="'.&HTML::Entities::encode($checkval.'_'.$item.'" value="'.$sdata->[$index{$item}],'&<>"').'" /></td>'."\n");  
                 } elsif ($item eq 'status') {                  } elsif ($item eq 'status') {
                     my $showitem = $in{$item};                      my $showitem = $in{$item};
                     if (defined($ltstatus{$in{$item}})) {                      if (defined($ltstatus{$in{$item}})) {
Line 4086  sub print_first_users_upload_form { Line 4115  sub print_first_users_upload_form {
 # ================================================= Drop/Add from uploaded file  # ================================================= Drop/Add from uploaded file
 sub upfile_drop_add {  sub upfile_drop_add {
     my ($r,$context,$permission,$showcredits) = @_;      my ($r,$context,$permission,$showcredits) = @_;
     &Apache::loncommon::load_tmp_file($r);      my $datatoken = &Apache::loncommon::valid_datatoken($env{'form.datatoken'});
       if ($datatoken ne '') {
           &Apache::loncommon::load_tmp_file($r,$datatoken);
       }
     my @userdata=&Apache::loncommon::upfile_record_sep();      my @userdata=&Apache::loncommon::upfile_record_sep();
     if($env{'form.noFirstLine'}){shift(@userdata);}      if($env{'form.noFirstLine'}){shift(@userdata);}
     my @keyfields = split(/\,/,$env{'form.keyfields'});      my @keyfields = split(/\,/,$env{'form.keyfields'});
Line 4100  sub upfile_drop_add { Line 4132  sub upfile_drop_add {
             $fields{$env{'form.f'.$i}}=$keyfields[$i];              $fields{$env{'form.f'.$i}}=$keyfields[$i];
         }          }
     }      }
     if ($env{'form.fullup'} ne 'yes') {  
         $r->print('<form name="studentform" method="post" action="/adm/createuser">'."\n".  
                   '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />');  
     }  
     #      #
     # Store the field choices away      # Store the field choices away
     my @storefields = qw/username names fname mname lname gen id       my @storefields = qw/username names fname mname lname gen id 
Line 4148  sub upfile_drop_add { Line 4176  sub upfile_drop_add {
     } else {      } else {
         my %home_servers = &Apache::lonnet::get_servers($defdom,'library');          my %home_servers = &Apache::lonnet::get_servers($defdom,'library');
         if (! exists($home_servers{$desiredhost})) {          if (! exists($home_servers{$desiredhost})) {
             $r->print('<span class="LC_error">'.&mt('Error').              $r->print('<p class="LC_error">'.&mt('Error').': '.
                       &mt('Invalid home server specified').'</span>');                        &mt('Invalid home server specified').'</p>');
             $r->print(&Apache::loncommon::end_page());              $r->print(&Apache::loncommon::end_page());
             return;              return 'invalidhome';
         }          }
     }      }
     # Determine authentication mechanism      # Determine authentication mechanism
Line 4251  sub upfile_drop_add { Line 4279  sub upfile_drop_add {
             }              }
         }          }
     }      }
       if ($datatoken eq '') {
           $r->print('<p class="LC_error">'.&mt('Error').': '.
                     &mt('Invalid datatoken').'</p>');
           return 'missingdata';
       }
     if ( $domain eq &LONCAPA::clean_domain($domain)      if ( $domain eq &LONCAPA::clean_domain($domain)
         && ($amode ne '')) {          && ($amode ne '')) {
         #######################################          #######################################
Line 4803  sub upfile_drop_add { Line 4836  sub upfile_drop_add {
                   "</p>\n");                    "</p>\n");
         if ($counts{'role'} > 0) {          if ($counts{'role'} > 0) {
             $r->print("<p>\n".              $r->print("<p>\n".
                       &mt('Roles added for [quant,_1,user].',$counts{'role'}).' '.&mt('If a user is currently logged-in to LON-CAPA, any new roles which are active will be available when the user next logs in.')."</p>\n");                        &mt('Roles added for [quant,_1,user].',$counts{'role'}).' '.
                         &mt('If a user is currently logged-in to LON-CAPA, any new roles which are active will be available when the user next logs in.').
                         "</p>\n");
         } else {          } else {
             $r->print('<p>'.&mt('No roles added').'</p>');              $r->print('<p>'.&mt('No roles added').'</p>');
         }          }
Line 4821  sub upfile_drop_add { Line 4856  sub upfile_drop_add {
             #  Get current classlist              #  Get current classlist
             my $classlist = &Apache::loncoursedata::get_classlist();              my $classlist = &Apache::loncoursedata::get_classlist();
             if (! defined($classlist)) {              if (! defined($classlist)) {
                 $r->print('<form name="studentform" method="post" action="/adm/createuser">'.                  $r->print('<p class="LC_info">'.
                           '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'.                            &mt('There are no students with current/future access to the course.').
                           '<p class="LC_info">'.&mt('There are no students with current/future access to the course.').'</p>'.                            '</p>'."\n");
                           '</form>'."\n");  
             } elsif (ref($classlist) eq 'HASH') {              } elsif (ref($classlist) eq 'HASH') {
                 # Remove the students we just added from the list of students.                  # Remove the students we just added from the list of students.
                 foreach my $line (@userdata) {                  foreach my $line (@userdata) {
Line 4840  sub upfile_drop_add { Line 4874  sub upfile_drop_add {
             }              }
         }          }
     } # end of unless      } # end of unless
     if ($env{'form.fullup'} ne 'yes') {      return 'ok';
         $r->print('</form>');  
     }  
 }  }
   
 sub print_namespacing_alerts {  sub print_namespacing_alerts {
Line 5416  sub set_login { Line 5448  sub set_login {
 }  }
   
 sub course_sections {  sub course_sections {
     my ($sections_count,$role,$current_sec) = @_;      my ($sections_count,$role,$current_sec,$disabled) = @_;
     my $output = '';      my $output = '';
     my @sections = (sort {$a <=> $b} keys(%{$sections_count}));      my @sections = (sort {$a <=> $b} keys(%{$sections_count}));
     my $numsec = scalar(@sections);      my $numsec = scalar(@sections);
     my $is_selected = ' selected="selected"';      my $is_selected = ' selected="selected"';
     if ($numsec <= 1) {      if ($numsec <= 1) {
         $output = '<select name="currsec_'.$role.'" >'."\n".          $output = '<select name="currsec_'.$role.'"'.$disabled.'>'."\n".
                   '  <option value="">'.&mt('Select').'</option>'."\n";                    '  <option value="">'.&mt('Select').'</option>'."\n";
         if ($current_sec eq 'none') {          if ($current_sec eq 'none') {
             $output .=                     $output .=       
Line 5445  sub course_sections { Line 5477  sub course_sections {
         my $multiple = 4;          my $multiple = 4;
         if (scalar(@sections) < 4) { $multiple = scalar(@sections); }          if (scalar(@sections) < 4) { $multiple = scalar(@sections); }
         if ($role eq 'st') {          if ($role eq 'st') {
             $output .= '>'."\n".              $output .= $disabled.'>'."\n".
                        '  <option value="">'.&mt('Select').'</option>'."\n";                         '  <option value="">'.&mt('Select').'</option>'."\n";
             if ($current_sec eq 'none') {              if ($current_sec eq 'none') {
                 $output .=                   $output .= 
Line 5455  sub course_sections { Line 5487  sub course_sections {
                        '  <option value="">'.&mt('No section')."</option>\n";                         '  <option value="">'.&mt('No section')."</option>\n";
             }              }
         } else {          } else {
             $output .= 'multiple="multiple" size="'.$multiple.'">'."\n";              $output .= 'multiple="multiple" size="'.$multiple.'"'.$disabled.'>'."\n";
         }          }
         foreach my $sec (@sections) {          foreach my $sec (@sections) {
             if ($current_sec eq $sec) {              if ($current_sec eq $sec) {
Line 5672  sub can_create_user { Line 5704  sub can_create_user {
     my $cancreate = 1;      my $cancreate = 1;
     if (&Apache::lonnet::allowed('mau',$dom)) {      if (&Apache::lonnet::allowed('mau',$dom)) {
         return $cancreate;          return $cancreate;
       } elsif ($context eq 'domain') {
           $cancreate = 0;
           return $cancreate;
     }      }
     if (ref($domconf{'usercreation'}) eq 'HASH') {      if (ref($domconf{'usercreation'}) eq 'HASH') {
         if (ref($domconf{'usercreation'}{'cancreate'}) eq 'HASH') {          if (ref($domconf{'usercreation'}{'cancreate'}) eq 'HASH') {
Line 5814  sub roles_by_context { Line 5849  sub roles_by_context {
     } elsif ($context eq 'author') {      } elsif ($context eq 'author') {
         @allroles = ('ca','aa');          @allroles = ('ca','aa');
     } elsif ($context eq 'domain') {      } elsif ($context eq 'domain') {
         @allroles = ('li','ad','dg','dh','sc','au','dc');          @allroles = ('li','ad','dg','dh','da','sc','au','dc');
     }      }
     return @allroles;      return @allroles;
 }  }
Line 5872  sub get_permission { Line 5907  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 5894  sub get_permission { Line 5940  sub get_permission {
         if (&Apache::lonnet::allowed('vac',$env{'request.role.domain'})) {          if (&Apache::lonnet::allowed('vac',$env{'request.role.domain'})) {
             $permission{'activity'} = 1;              $permission{'activity'} = 1;
         }          }
         $permission{'view'} = $permission{'cusr'};          if (&Apache::lonnet::allowed('vur',$env{'request.role.domain'})) {
               $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 6390  END Line 6441  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 6404  sub custom_role_table { Line 6455  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 6661  sub custom_role_update { Line 6712  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.177  
changed lines
  Added in v.1.184.2.2


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