--- loncom/interface/lonuserutils.pm 2008/01/20 00:19:11 1.49
+++ 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.49 2008/01/20 00:19:11 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
@@ -3642,13 +3661,14 @@ sub upfile_drop_add {
$sec = $secs[0];
}
&modifystudent($domain,$username,$cid,$sec,
- $desiredhost);
+ $desiredhost,$context);
$roleresult =
&Apache::lonnet::modifystudent
($domain,$username,$id,$amode,$password,
$fname,$mname,$lname,$gen,$sec,$enddate,
$startdate,$env{'form.forceid'},
- $desiredhost,$email,'manual','',$cid);
+ $desiredhost,$email,'manual','',$cid,
+ '',$context);
$userresult = $roleresult;
} else {
if ($role ne '') {
@@ -3954,24 +3974,25 @@ sub update_user_list {
$end = $now;
$type = 'manual';
$result =
- &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context);
} elsif ($choice eq 'revoke') {
# revoke or delete user role
$end = $now;
if ($role eq 'st') {
$result =
- &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context);
} else {
$result =
- &Apache::lonnet::revokerole($udom,$uname,$scope,$role);
+ &Apache::lonnet::revokerole($udom,$uname,$scope,$role,
+ '','',$context);
}
} elsif ($choice eq 'delete') {
if ($role eq 'st') {
- &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$now,$start,$type,$locktype,$cid);
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$now,$start,$type,$locktype,$cid,'',$context);
}
$result =
&Apache::lonnet::assignrole($udom,$uname,$scope,$role,$now,
- $start,1);
+ $start,1,'',$context);
} else {
#reenable, activate, change access dates or change section
if ($choice ne 'chgsec') {
@@ -3980,25 +4001,25 @@ sub update_user_list {
}
if ($choice eq 'reenable') {
if ($role eq 'st') {
- $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+ $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context);
} else {
$result =
&Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end,
- $now);
+ $now,'','',$context);
}
} elsif ($choice eq 'activate') {
if ($role eq 'st') {
- $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+ $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context);
} else {
$result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end,
- $now);
+ $now,'','',$context);
}
} elsif ($choice eq 'chgdates') {
if ($role eq 'st') {
- $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+ $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context);
} else {
$result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end,
- $start);
+ $start,'','',$context);
}
} elsif ($choice eq 'chgsec') {
my (@newsecs,$revresult,$nochg,@retained);
@@ -4014,7 +4035,8 @@ sub update_user_list {
} else {
$revresult =
&Apache::lonnet::revokerole($udom,$uname,
- $scope,$role);
+ $scope,$role,
+ '','',$context);
}
} else {
if (@newsecs > 0) {
@@ -4023,12 +4045,14 @@ sub update_user_list {
} else {
$revresult =
&Apache::lonnet::revokerole($udom,$uname,
- $scope,$role);
+ $scope,$role,
+ '','',$context);
}
} else {
$revresult =
&Apache::lonnet::revokerole($udom,$uname,
- $scope,$role);
+ $scope,$role,
+ '','',$context);
}
}
} else {
@@ -4043,17 +4067,17 @@ sub update_user_list {
if (!$nochg) {
if ($role eq 'st') {
$result =
- &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid);
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid,'',$context);
} else {
my $newscope = $scopestem;
- $result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start);
+ $result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start,'','',$context);
}
}
} else {
foreach my $newsec (@newsecs) {
if (!grep(/^\Q$newsec\E$/,@retained)) {
if ($role eq 'st') {
- $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid);
+ $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid,'',$context);
} else {
my $newscope = $scopestem;
if ($newsec ne '') {
@@ -4192,17 +4216,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 = '