Diff for /loncom/interface/lonuserutils.pm between versions 1.3 and 1.4

version 1.3, 2007/11/06 18:23:14 version 1.4, 2007/11/10 22:18:09
Line 1281  sub print_userlist { Line 1281  sub print_userlist {
         }          }
     } else {      } else {
         # Print out the available choices          # Print out the available choices
           my $usercount;
         if ($env{'form.action'} eq 'modifystudent') {          if ($env{'form.action'} eq 'modifystudent') {
             &show_users_list($r,$context,'view','modify',              ($usercount) = &show_users_list($r,$context,'view','modify',
                              $env{'form.Status'},\%userlist,$keylist);                                   $env{'form.Status'},\%userlist,$keylist);
         } else {          } else {
             &show_users_list($r,$context,$env{'form.output'},'aboutme',              ($usercount) = &show_users_list($r,$context,$env{'form.output'},
                              $env{'form.Status'},\%userlist,$keylist);                                 'aboutme',$env{'form.Status'},\%userlist,$keylist);
           }
           if (!$usercount) {
               $r->print('<br />'.&mt('There are no users matching the search criteria.')); 
         }          }
     }      }
     $r->print('</form>');      $r->print('</form>');
Line 1699  END Line 1703  END
     }      }
     push(@cols,'email');      push(@cols,'email');
   
     my $rolefilter;      my $rolefilter = $env{'form.showrole'};
     if ($env{'form.showrole'} ne 'Any') {      if ($env{'form.showrole'} ne 'Any') {
         $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'});          $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'});
     }      }
     my $results_description = &results_header_row($rolefilter,$statusmode,      my $results_description = &results_header_row($rolefilter,$statusmode,
                                                   $context);                                                    $context);
     $r->print('<b>'.$results_description.'</b><br />');      $r->print('<b>'.$results_description.'</b><br />');
       my $output;
     if ($mode eq 'html' || $mode eq 'view') {      if ($mode eq 'html' || $mode eq 'view') {
         if ($linkto eq 'aboutme') {  
             $r->print(&mt("Select a user name to view the user's personal page."));  
         } elsif ($linkto eq 'modify') {  
             $r->print(&mt("Select a user name to modify the user's information"));  
         }  
         $r->print(<<END);          $r->print(<<END);
 <input type="hidden" name="sname"  value="" />  <input type="hidden" name="sname"  value="" />
 <input type="hidden" name="sdom"   value="" />  <input type="hidden" name="sdom"   value="" />
 END  END
         $r->print("\n<p>\n".          if ($linkto eq 'aboutme') {
               $output = &mt("Select a user name to view the user's personal page.");
           } elsif ($linkto eq 'modify') {
               $output = &mt("Select a user name to modify the user's information");
           }
           $output .= "\n<p>\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') {
             $r->print("              $output .= "
  <th><a href=\"javascript:document.studentform.sortby.value='type';document.studentform.submit();\">$lt{'type'}</a></th>   <th><a href=\"javascript:document.studentform.sortby.value='type';document.studentform.submit();\">$lt{'type'}</a></th>
             ");              ";
         } else {          } else {
             $r->print("              $output .= "
 <th>Count</th>  <th>Count</th>
             ");              ";
         }          }
         foreach my $item (@cols) {          foreach my $item (@cols) {
             $r->print("<th><a href=\"javascript:document.studentform.sortby.value='$item';document.studentform.submit();\">$lt{$item}</a></th>\n");              $output .= "<th><a href=\"javascript:document.studentform.sortby.value='$item';document.studentform.submit();\">$lt{$item}</a></th>\n";
         }          }
         my %role_types = &role_type_names();          my %role_types = &role_type_names();
         if ($context eq 'course') {          if ($context eq 'course') {
             # Clicker display on or off?              if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
             my %clicker_options = &Apache::lonlocal::texthash(                  # Clicker display on or off?
                                                         'on' => 'Show',                  my %clicker_options = &Apache::lonlocal::texthash(
                                                         'off' => 'Hide',                                                              'on' => 'Show',
                                                        );                                                              'off' => 'Hide',
             my $clickerchg = 'on';                                                             );
             if ($displayclickers eq 'on') {                  my $clickerchg = 'on';
                 $clickerchg = 'off';                  if ($displayclickers eq 'on') {
             }                      $clickerchg = 'off';
             $r->print('    <th>'."\n".'     '.                  }
                 '<a href="javascript:document.studentform.displayclickers.value='.                  $output .= '    <th>'."\n".'     '.
                       '<a href="javascript:document.studentform.displayclickers.value='.
                       "'".$clickerchg."'".';document.studentform.submit();">'.                        "'".$clickerchg."'".';document.studentform.submit();">'.
                       $clicker_options{$clickerchg}.'</a>&nbsp;'.$lt{'clicker'}."\n".                        $clicker_options{$clickerchg}.'</a>&nbsp;'.$lt{'clicker'}."\n".
                       '    </th>'."\n");                        '    </th>'."\n";
   
             # Photo display on or off?                  # Photo display on or off?
             if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {                  if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
                 my %photo_options = &Apache::lonlocal::texthash(                      my %photo_options = &Apache::lonlocal::texthash(
                                                         'on' => 'Show',                                                              'on' => 'Show',
                                                         'off' => 'Hide',                                                              'off' => 'Hide',
                                                             );                                                                  );
                 my $photochg = 'on';                      my $photochg = 'on';
                 if ($displayphotos eq 'on') {                      if ($displayphotos eq 'on') {
                     $photochg = 'off';                          $photochg = 'off';
                 }                      }
                 $r->print('    <th>'."\n".'     '.                      $output .= '    <th>'."\n".'     '.
             '<a href="javascript:document.studentform.displayphotos.value='.                  '<a href="javascript:document.studentform.displayphotos.value='.
                       "'".$photochg."'".';document.studentform.submit();">'.                        "'".$photochg."'".';document.studentform.submit();">'.
                       $photo_options{$photochg}.'</a>&nbsp;'.$lt{'photo'}."\n".                        $photo_options{$photochg}.'</a>&nbsp;'.$lt{'photo'}."\n".
                       '    </th>'."\n");                        '    </th>'."\n";
                   }
             }              }
             $r->print(&Apache::loncommon::end_data_table_header_row());              $output .= &Apache::loncommon::end_data_table_header_row();
         }           }
 # Done with the HTML header line  # Done with the HTML header line
     } elsif ($mode eq 'csv') {      } elsif ($mode eq 'csv') {
         #          #
Line 1805  END Line 1812  END
     foreach my $idx (@$keylist) {      foreach my $idx (@$keylist) {
         $index{$idx} = $i++;          $index{$idx} = $i++;
     }      }
       my $usercount = 0;
     # Get groups, role, permanent e-mail so we can sort on them if      # Get groups, role, permanent e-mail so we can sort on them if
     # necessary.      # necessary.
     foreach my $user (keys(%{$userlist})) {      foreach my $user (keys(%{$userlist})) {
         my ($uname,$udom,$role,$groups,$email);          my ($uname,$udom,$role,$groups,$email);
           next if (($statusmode ne 'Any') && 
                    ($userlist->{$user}->[$index{'status'}] ne $statusmode));
         if ($context eq 'domain') {          if ($context eq 'domain') {
             if ($env{'form.roletype'} eq 'domain') {              if ($env{'form.roletype'} eq 'domain') {
                 ($role,$uname,$udom) = split(/:/,$user);                  ($role,$uname,$udom) = split(/:/,$user);
Line 1839  END Line 1849  END
         if ($emails{'permanentemail'} =~ /\S/) {          if ($emails{'permanentemail'} =~ /\S/) {
             $userlist->{$user}->[$index{'email'}] = $emails{'permanentemail'};              $userlist->{$user}->[$index{'email'}] = $emails{'permanentemail'};
         }          }
           $usercount ++;
       }
       my $autocount = 0;
       my $manualcount = 0;
       my $lockcount = 0;
       my $unlockcount = 0;
       if ($usercount) {
           $r->print($output);
       } else {
           if ($mode eq 'autoenroll') {
               return ($usercount,$autocount,$manualcount,$lockcount,$unlockcount);
           } else {
               return;
           }
     }      }
   
     #      #
     # Sort the users      # Sort the users
     my $index  = $index{$sortby};      my $index  = $index{$sortby};
Line 1852  END Line 1875  END
         lc($userlist->{$a}->[$second]) cmp lc($userlist->{$b}->[$second])            ||          lc($userlist->{$a}->[$second]) cmp lc($userlist->{$b}->[$second])            ||
         lc($userlist->{$a}->[$third]) cmp lc($userlist->{$b}->[$third])          lc($userlist->{$a}->[$third]) cmp lc($userlist->{$b}->[$third])
         } (keys(%$userlist));          } (keys(%$userlist));
     my $usercount = 0;      my $rowcount = 0;
     my $autocount = 0;  
     my $manualcount = 0;  
     my $lockcount = 0;  
     my $unlockcount = 0;  
     foreach my $user (@sorted_users) {      foreach my $user (@sorted_users) {
         my $sdata = $userlist->{$user};  
         my %in;          my %in;
           my $sdata = $userlist->{$user};
           $rowcount ++; 
         foreach my $item (@{$keylist}) {          foreach my $item (@{$keylist}) {
             $in{$item} = $sdata->[$index{$item}];              $in{$item} = $sdata->[$index{$item}];
         }          }
         next if (($statusmode ne 'Any') && ($in{'status'} ne $statusmode));  
         $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}]);           $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}]); 
         if (! defined($in{'start'}) || $in{'start'} == 0) {          if (! defined($in{'start'}) || $in{'start'} == 0) {
             $in{'start'} = &mt('none');              $in{'start'} = &mt('none');
Line 1875  END Line 1894  END
         } else {          } else {
             $in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'});              $in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'});
         }          }
         $usercount ++;  
         if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') {          if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') {
             $r->print(&Apache::loncommon::start_data_table_row());              $r->print(&Apache::loncommon::start_data_table_row());
             $r->print("<td>$usercount</td>\n");              $r->print("<td>$rowcount</td>\n");
             if ($linkto eq 'aboutme') {              if ($linkto eq 'aboutme') {
                 $in{'username'} =                   $in{'username'} = 
                     &Apache::loncommon::aboutmewrapper($in{'username'},                      &Apache::loncommon::aboutmewrapper($in{'username'},
Line 1897  END Line 1915  END
                 $r->print('<td>'.$in{$item}.'</td>'."\n");                  $r->print('<td>'.$in{$item}.'</td>'."\n");
             }              }
             if ($context eq 'course') {              if ($context eq 'course') {
                 if ($displayclickers eq 'on') {                  if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
                     my $clickers =                      if ($displayclickers eq 'on') {
                           my $clickers =
                    (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];                     (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];
                     if ($clickers!~/\w/) { $clickers='-'; }                          if ($clickers!~/\w/) { $clickers='-'; }
                     $r->print('<td>'.$clickers.'</td>');                          $r->print('<td>'.$clickers.'</td>');
                 } else {  
                     $r->print('    <td>&nbsp;</td>  ');  
                 }  
                 if ($displayphotos eq 'on') {  
                     if ($env{'course.'.$env{'request.course.id'}.  
                         '.internal.showphoto'}) {  
                         my $imgurl =  
                &Apache::lonnet::retrievestudentphoto($in{'domain'},$in{'username'},'gif','thumbnail');  
                         $r->print('    <td align="right"><a href="javascript:photowindow('."'".&Apache::lonnet::studentphoto($in{'domain'},$in{'username'},'jpg')."'".')"><img src="'.$imgurl.'" border="1"></a></td>');  
                     } else {                      } else {
                         $r->print('    <td>&nbsp;</td>  ');                          $r->print('    <td>&nbsp;</td>  ');
                     }                      }
                       if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
                           if ($displayphotos eq 'on' && $sdata->[$index{'role'}] eq 'st') {
                               my $imgurl =
                           &Apache::lonnet::retrievestudentphoto($in{'domain'},$in{'username'},
                                                             'gif','thumbnail');
                               $r->print('    <td align="right"><a href="javascript:photowindow('."'".&Apache::lonnet::studentphoto($in{'domain'},$in{'username'},'jpg')."'".')"><img src="'.$imgurl.'" border="1"></a></td>');
                           } else {
                               $r->print('    <td>&nbsp;</td>  ');
                           }
                       }
                 }                  }
             }              }
             $r->print(&Apache::loncommon::end_data_table_row());              $r->print(&Apache::loncommon::end_data_table_row());
Line 1968  END Line 1988  END
     }      }
     if ($mode eq 'autoenroll') {      if ($mode eq 'autoenroll') {
         return ($usercount,$autocount,$manualcount,$lockcount,$unlockcount);          return ($usercount,$autocount,$manualcount,$lockcount,$unlockcount);
       } else {
           return ($usercount);
     }      }
     return;  
 }  }
   
 sub role_type_names {  sub role_type_names {

Removed from v.1.3  
changed lines
  Added in v.1.4


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