--- loncom/interface/lonuserutils.pm 2008/01/05 18:36:26 1.44 +++ loncom/interface/lonuserutils.pm 2008/01/20 22:25:05 1.50 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.44 2008/01/05 18:36:26 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.50 2008/01/20 22:25:05 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1307,8 +1307,10 @@ sub print_userlist { } $r->rflush(); if ($context eq 'course') { - my $classlist = &Apache::loncoursedata::get_classlist(); - %userlist = %{$classlist}; + if (($env{'form.showrole'} eq 'st') || ($env{'form.showrole'} eq 'Any')) { + my $classlist = &Apache::loncoursedata::get_classlist(); + %userlist = %{$classlist}; + } if ($env{'form.showrole'} ne 'st') { my $showroles; if ($env{'form.showrole'} ne 'Any') { @@ -1465,9 +1467,9 @@ sub section_group_filter { all => 'all', none => 'none', ); - my ($output,@options); + my $output; foreach my $item (@filters) { - my $markup; + my ($markup,@options); if ($env{'form.'.$name{$item}} eq '') { $env{'form.'.$name{$item}} = 'all'; } @@ -1789,6 +1791,7 @@ sub make_keylist_array { $index->{'role'} = &Apache::loncoursedata::CL_ROLE(); $index->{'extent'} = &Apache::loncoursedata::CL_EXTENT(); $index->{'photo'} = &Apache::loncoursedata::CL_PHOTO(); + $index->{'thumbnail'} = &Apache::loncoursedata::CL_THUMBNAIL(); foreach my $key (keys(%{$index})) { $keylist->[$index->{$key}] = $key; } @@ -1991,14 +1994,30 @@ function username_display_launch(usernam } } if (target == 'modify') { - document.studentform.srchterm.value=username; - document.studentform.srchdomain.value=domain; - document.studentform.phase.value='get_user_info'; - document.studentform.action.value = 'singleuser'; - document.studentform.submit(); + if (document.studentform.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 options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'; + modifywin = window.open(url,'',options,1); + modifywin.focus(); + return; + } else { + document.studentform.srchterm.value=username; + document.studentform.srchdomain.value=domain; + document.studentform.phase.value='get_user_info'; + document.studentform.action.value = 'singleuser'; + document.studentform.submit(); + } } - else { - document.location.href = '/adm/'+domain+'/'+username+'/aboutme'; + if (target == 'aboutme') { + if (document.studentform.userwin.checked == true) { + var url = '/adm/'+domain+'/'+username+'/aboutme?popup=1'; + var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'; + aboutmewin = window.open(url,'',options,1); + aboutmewin.focus(); + return; + } else { + document.location.href = '/adm/'+domain+'/'+username+'/aboutme'; + } } } @@ -2033,6 +2052,7 @@ END 'ac' => "Action to take for selected users", 'link' => "Behavior of username links", 'aboutme' => "Display a user's personal page", + 'owin' => "Open in a new window", 'modify' => "Modify a user's information", ); if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { @@ -2091,23 +2111,25 @@ END $output = '

'; my @linkdests = ('aboutme'); if ($permission->{'cusr'}) { - push (@linkdests,'modify'); - $output .= ''.$lt{'link'}.': '; - my $usernamelink = $env{'form.usernamelink'}; - if ($usernamelink eq '') { - $usernamelink = 'aboutme'; - } - foreach my $item (@linkdests) { - my $checkedstr = ''; - if ($item eq $usernamelink) { - $checkedstr = ' checked="checked" '; - } - $output .= '  '; + unshift (@linkdests,'modify'); + } + $output .= ''.$lt{'link'}.': '; + my $usernamelink = $env{'form.usernamelink'}; + if ($usernamelink eq '') { + $usernamelink = 'aboutme'; + } + foreach my $item (@linkdests) { + my $checkedstr = ''; + if ($item eq $usernamelink) { + $checkedstr = ' checked="checked" '; } - $output .= '
'; - } else { - $output .= &mt("Click on a username to view the user's personal page.").'
'; + $output .= '  '; + } + my $checkwin; + if ($env{'form.userwin'}) { + $checkwin = 'checked = "checked"'; } + $output .= '    '.$lt{'owin'}.'

'; if ($actionselect) { $output .= <<"END"; $lt{'ac'}: $actionselect

@@ -2241,7 +2263,6 @@ END } # Done with header lines in all formats - my %index; my $i; foreach my $idx (@$keylist) { @@ -2343,6 +2364,8 @@ END if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { if (($displayphotos eq 'on') && ($role eq 'st')) { $userlist->{$user}->[$index{'photo'}] = + &Apache::lonnet::retrievestudentphoto($udom,$uname,'jpg'); + $userlist->{$user}->[$index{'thumbnail'}] = &Apache::lonnet::retrievestudentphoto($udom,$uname, 'gif','thumbnail'); } @@ -2459,8 +2482,7 @@ END } foreach my $item (@cols) { if ($item eq 'username') { - $r->print(''.&print_username_link($mode,$permission, - \%in).''); + $r->print(''.&print_username_link($mode,\%in).''); } elsif (($item eq 'start' || $item eq 'end') && ($actionselect)) { $r->print(''.$in{$item}.''."\n"); } else { @@ -2479,7 +2501,7 @@ END } if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') { - $r->print(' '); + $r->print(' '); } else { $r->print('   '); } @@ -2544,14 +2566,10 @@ END } sub print_username_link { - my ($mode,$permission,$in) = @_; + my ($mode,$in) = @_; my $output; if ($mode eq 'autoenroll') { $output = $in->{'username'}; - } elsif (!$permission->{'cusr'}) { - $output = &Apache::loncommon::aboutmewrapper($in->{'username'}, - $in->{'username'}, - $in->{'domain'}); } else { $output = '{'username'}','$in->{'domain'}'".')" />'. @@ -2662,20 +2680,14 @@ sub select_actions { sub date_section_javascript { my ($context,$setting) = @_; - my $title; - if (($context eq 'course') || ($context eq 'domain' && $setting eq 'course')) { - $title = &mt('Date and Section selector'); - } else { - $title = &mt('Date selector'); - } + my $title = 'Date_And_Section_Selector'; my %nopopup = &Apache::lonlocal::texthash ( revoke => "Check the boxes for any users for whom roles are to be revoked, and click 'Proceed'", delete => "Check the boxes for any users for whom roles are to be deleted, and click 'Proceed'", none => "Choose an action to take for selected users", ); my $output = ' -