--- loncom/interface/lonuserutils.pm 2008/01/17 00:14:49 1.48 +++ loncom/interface/lonuserutils.pm 2008/04/30 23:16:19 1.52 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.48 2008/01/17 00:14:49 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.52 2008/04/30 23:16:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,7 @@ use LONCAPA qw(:DEFAULT :match); ############################################################### # Drop student from all sections of a course, except optional $csec sub modifystudent { - my ($udom,$unam,$courseid,$csec,$desiredhost)=@_; + my ($udom,$unam,$courseid,$csec,$desiredhost,$context)=@_; # if $csec is undefined, drop the student from all the courses matching # this one. If $csec is defined, drop them from all other sections of # this course and add them to section $csec @@ -69,7 +69,7 @@ sub modifystudent { # dom name id mode pass f m l g ($udom,$unam,'', '', '',undef,undef,undef,undef, $section,time,undef,undef,$desiredhost,'','manual', - '',$courseid); + '',$courseid,'',$context); $result .= $reply.':'; } } @@ -129,7 +129,8 @@ sub modifyuserrole { if ($role ne '') { $role =~ s/_/\//g; $roleresult = &Apache::lonnet::assignrole($udom,$uname,$scope, - $role,$end,$start); + $role,$end,$start,'', + '',$context); } } return ($userresult,$authresult,$roleresult,$idresult); @@ -1513,6 +1514,10 @@ sub list_submit_button { sub gather_userinfo { my ($context,$format,$userlist,$indexhash,$userinfo,$rolehash,$permission) = @_; + my $viewablesec; + if ($context eq 'course') { + $viewablesec = &viewable_section($permission); + } foreach my $item (keys(%{$rolehash})) { my %userdata; if ($context eq 'author') { @@ -1522,7 +1527,6 @@ sub gather_userinfo { &build_user_record($context,\%userdata,$userinfo,$indexhash, $item,$userlist); } elsif ($context eq 'course') { - my $viewablesec = &viewable_section($permission); ($userdata{'username'},$userdata{'domain'},$userdata{'role'}, $userdata{'section'}) = split(/:/,$item,-1); ($userdata{'start'},$userdata{'end'})=split(/:/,$rolehash->{$item}); @@ -1994,19 +1998,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(); + } } if (target == 'aboutme') { - document.location.href = '/adm/'+domain+'/'+username+'/aboutme'; - } - if (target == 'aboutmewin') { - var url = '/adm/'+domain+'/'+username+'/aboutme'; - var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'; - aboutmewin = window.open(url,'',options,1); + 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'; + } } } @@ -2041,7 +2056,7 @@ END 'ac' => "Action to take for selected users", 'link' => "Behavior of username links", 'aboutme' => "Display a user's personal page", - 'aboutmewin' => "Display a user's personal page in a new window", + 'owin' => "Open in a new window", 'modify' => "Modify a user's information", ); if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { @@ -2098,7 +2113,7 @@ END END $output = '

'; - my @linkdests = ('aboutme','aboutmewin'); + my @linkdests = ('aboutme'); if ($permission->{'cusr'}) { unshift (@linkdests,'modify'); } @@ -2114,7 +2129,11 @@ END } $output .= '  '; } - $output .= '
'; + my $checkwin; + if ($env{'form.userwin'}) { + $checkwin = 'checked = "checked"'; + } + $output .= '    '.$lt{'owin'}.'
'; if ($actionselect) { $output .= <<"END"; $lt{'ac'}: $actionselect

@@ -2665,20 +2684,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 = ' -