--- loncom/interface/lonuserutils.pm 2008/01/06 05:32:43 1.46 +++ loncom/interface/lonuserutils.pm 2008/03/06 21:57:33 1.51 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.46 2008/01/06 05:32:43 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.51 2008/03/06 21:57:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1467,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'; } @@ -1791,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; } @@ -1993,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'; + } } } </script> @@ -2035,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') { @@ -2093,23 +2111,25 @@ END $output = '<p>'; my @linkdests = ('aboutme'); if ($permission->{'cusr'}) { - push (@linkdests,'modify'); - $output .= '<span class="LC_nobreak">'.$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 .= '<label><input type="radio" name="usernamelink" value="'.$item.'"'.$checkedstr.'> '.$lt{$item}.'</label> '; + unshift (@linkdests,'modify'); + } + $output .= '<span class="LC_nobreak">'.$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 .= '</span><br />'; - } else { - $output .= &mt("Click on a username to view the user's personal page.").'<br />'; + $output .= '<label><input type="radio" name="usernamelink" value="'.$item.'"'.$checkedstr.'> '.$lt{$item}.'</label> '; } + my $checkwin; + if ($env{'form.userwin'}) { + $checkwin = 'checked = "checked"'; + } + $output .= ' <input type="checkbox" name="userwin" value="1" $checkwin />'.$lt{'owin'}.'</span><br />'; if ($actionselect) { $output .= <<"END"; $lt{'ac'}: $actionselect <input type="button" value="$lt{'go'}" onclick="javascript:opendatebrowser(this.form,'studentform','go')" /></p> @@ -2243,7 +2263,6 @@ END } # Done with header lines in all formats - my %index; my $i; foreach my $idx (@$keylist) { @@ -2345,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'); } @@ -2461,8 +2482,7 @@ END } foreach my $item (@cols) { if ($item eq 'username') { - $r->print('<td>'.&print_username_link($mode,$permission, - \%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="'.$checkval.'_'.$item.'" value="'.$sdata->[$index{$item}].'" /></td>'."\n"); } else { @@ -2481,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(' <td align="right"><a href="javascript:photowindow('."'".&Apache::lonnet::studentphoto($in{'domain'},$in{'username'},'jpg')."'".')"><img src="'.$in{'photo'}.'" border="1"></a></td>'); + $r->print(' <td align="right"><a href="javascript:photowindow('."'".$in{'photo'}."'".')"><img src="'.$in{'thumbnail'}.'" border="1"></a></td>'); } else { $r->print(' <td> </td> '); } @@ -2546,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 = '<a href="javascript:username_display_launch('. "'$in->{'username'}','$in->{'domain'}'".')" />'. @@ -2664,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 = ' -<script type="text/javascript"> - var stdeditbrowser;'."\n"; +<script type="text/javascript">'."\n"; $output .= <<"ENDONE"; function opendatebrowser(callingform,formname,calledby) { var bulkaction = callingform.bulkaction.options[callingform.bulkaction.selectedIndex].value; @@ -4197,17 +4207,29 @@ sub set_login { } sub course_sections { - my ($sections_count,$role) = @_; + my ($sections_count,$role,$current_sec) = @_; my $output = ''; my @sections = (sort {$a <=> $b} keys %{$sections_count}); my $numsec = scalar(@sections); + my $is_selected = ' selected="selected" '; if ($numsec <= 1) { $output = '<select name="currsec_'.$role.'" >'."\n". - ' <option value="">'.&mt('Select').'</option>'."\n". + ' <option value="">'.&mt('Select').'</option>'."\n"; + if ($current_sec eq 'none') { + $output .= + ' <option value=""'.$is_selected.'>'.&mt('No section').'</option>'."\n"; + } else { + $output .= ' <option value="">'.&mt('No section').'</option>'."\n"; + } if ($numsec == 1) { - $output .= + if ($current_sec eq $sections[0]) { + $output .= + ' <option value="'.$sections[0].'"'.$is_selected.'>'.$sections[0].'</option>'."\n"; + } else { + $output .= ' <option value="'.$sections[0].'" >'.$sections[0].'</option>'."\n"; + } } } else { $output = '<select name="currsec_'.$role.'" '; @@ -4215,13 +4237,23 @@ sub course_sections { if (scalar(@sections) < 4) { $multiple = scalar(@sections); } if ($role eq 'st') { $output .= '>'."\n". - ' <option value="">'.&mt('Select').'</option>'."\n". + ' <option value="">'.&mt('Select').'</option>'."\n"; + if ($current_sec eq 'none') { + $output .= + ' <option value=""'.$is_selected.'>'.&mt('No section')."</option>\n"; + } else { + $output .= ' <option value="">'.&mt('No section')."</option>\n"; + } } else { $output .= 'multiple="multiple" size="'.$multiple.'">'."\n"; } foreach my $sec (@sections) { - $output .= '<option value="'.$sec.'">'.$sec."</option>\n"; + if ($current_sec eq $sec) { + $output .= '<option value="'.$sec.'"'.$is_selected.'>'.$sec."</option>\n"; + } else { + $output .= '<option value="'.$sec.'">'.$sec."</option>\n"; + } } } $output .= '</select>';