version 1.2, 2002/12/30 14:10:58
|
version 1.14, 2006/03/16 21:53:17
|
Line 33 use Apache::Constants qw(:common);
|
Line 33 use Apache::Constants qw(:common);
|
use Apache::loncommon; |
use Apache::loncommon; |
use Apache::loncoursedata; |
use Apache::loncoursedata; |
use Apache::lonnet; |
use Apache::lonnet; |
|
use Apache::lonlocal; |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
$r->content_type('text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK if $r->header_only; |
return OK if $r->header_only; |
|
|
# ------------------------------------------------------------ Print the screen |
# ------------------------------------------------------------ Print the screen |
$r->print(<<ENDDOCUMENT); |
$r->print(&Apache::loncommon::start_page("Selecting a User",undef, |
<html> |
{'no_nav_bar' => 1})); |
<head> |
|
<title>The LearningOnline Network with CAPA</title> |
|
</head> |
&Apache::loncommon::get_unprocessed_cgi |
ENDDOCUMENT |
($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement', |
|
'roles']); |
# Is this even in a course? |
# Allowed? |
unless ($ENV{'request.course.id'}) { |
my $allowed; |
$r->print('<body>Not in a course</body>'); |
my $scope = $env{'request.course.id'}; |
return OK; |
if (!($allowed = &Apache::lonnet::allowed('srm',$scope))) { |
|
$scope .= '/'.$env{'request.course.sec'}; |
|
$allowed = &Apache::lonnet::allowed('srm',$scope); |
|
if ($allowed) { $allowed = 'section'; } |
} |
} |
|
|
unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { |
unless (($env{'form.roles'}) || |
$r->print('<body>No course listing</body>'); |
(($env{'request.course.id'}) && ($allowed))) { |
|
$r->print(&mt('No context.'). |
|
&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} |
} |
|
|
|
# See if filter present |
|
|
|
my $filter=$env{'form.filter'}; |
&Apache::loncommon::get_unprocessed_cgi |
|
($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement']); |
|
my $filter=$ENV{'form.filter'}; |
|
$filter=~s/\W//g; |
$filter=~s/\W//g; |
unless ($filter) { $filter='.'; } |
unless ($filter) { $filter='.'; } |
|
|
my $classlist=&Apache::loncoursedata::DownloadClasslist |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
($ENV{'request.course.id'}, |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
'Not downloaded',$r->connection); |
my $classlist=&Apache::loncoursedata::get_classlist(); |
|
my %grouplist=&Apache::lonnet::get_group_membership($cdom,$cnum); |
|
my $now = time; |
|
my %allgroups; |
|
&Apache::loncommon::coursegroups(\%allgroups,$cdom,$cnum); |
|
|
# --------------------------------------- There is such a user, get environment |
# --------------------------------------- There is such a user, get environment |
|
|
$r->print(&Apache::loncommon::bodytag("Selecting a User")); |
|
$r->print(<<ENDSCRIPT); |
$r->print(<<ENDSCRIPT); |
<script> |
<script> |
function gochoose(uname,udom) { |
function gochoose(uname,udom) { |
opener.document.$ENV{'form.form'}.$ENV{'form.unameelement'}.value=uname; |
opener.document.$env{'form.form'}.$env{'form.unameelement'}.value=uname; |
var slct=opener.document.$ENV{'form.form'}.$ENV{'form.udomelement'}; |
var slct=opener.document.$env{'form.form'}.$env{'form.udomelement'}; |
var i; |
var i; |
for (i=0;i<slct.length;i++) { |
for (i=0;i<slct.length;i++) { |
if (slct[i]==udom) { slct.selectedIndex=i; } |
if (slct.options[i].value==udom) { slct.selectedIndex=i; } |
} |
} |
self.close(); |
self.close(); |
} |
} |
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
|
|
$r->print('<h3>'.$ENV{'course.'.$ENV{'request.course.id'}.'.description'}. |
$r->print('<form>'); |
|
if ($allowed && (!$env{'form.roles'})) { |
|
# -------------------------------------------------------- Get course personnel |
|
$r->print('<h3>'.$env{'course.'.$env{'request.course.id'}.'.description'}. |
'</h3>'); |
'</h3>'); |
|
my %coursepersonnel= |
|
&Apache::lonnet::get_course_adv_roles(); |
|
$r->print('<table border="2">'); |
|
foreach my $role (sort keys %coursepersonnel) { |
|
foreach (split(/\,/,$coursepersonnel{$role})) { |
|
my ($puname,$pudom)=split(/\:/,$_); |
|
$r->print('<tr><td>'. |
|
'<input type="button" value="Select" onClick="gochoose('. |
|
"'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'. |
|
&Apache::loncommon::aboutmewrapper( |
|
&Apache::loncommon::plainname($puname, |
|
$pudom),$puname,$pudom).'</td></tr>'); |
|
} |
|
} |
|
$r->print('</table><p> '); |
if ($filter ne '.') { |
if ($filter ne '.') { |
$r->print('Name starting with "'.$filter.'"<br />'); |
$r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />'); |
} |
} |
$r->print('<form><table>'); |
$r->print('</p><p><table><tr><th> </th><th>username</th><th>domain</th><th>Name</th><th>ID</th><th>section</th><th>active group(s)</th>'); |
|
# ------------------------------------------------------------------ Students |
foreach (sort keys %$classlist) { |
foreach (sort keys %$classlist) { |
if ($_=~/^(\w+)\:(\w+)\:studentInformation$/) { |
# the following undefs are for 'domain', and 'username' respectively. |
|
my (undef,undef,$end,$start,$id,$section,$fullname,$status)= |
|
@{$classlist->{$_}}; |
|
if ($allowed eq 'section' && $section ne $env{'request.course.sec'}) { |
|
next; |
|
} |
|
if ($_=~/^(\w+)\:(\w+)$/) { |
my ($uname,$udom)=($1,$2); |
my ($uname,$udom)=($1,$2); |
if (($uname=~/^$filter/) || |
if (($uname=~/^$filter/) || |
($classlist->{$_}->{'lastname'}=~/^$filter/i)) { |
($fullname=~/^$filter/i)) { |
|
my $grouplist = ''; |
|
foreach my $group (sort(keys(%allgroups))) { |
|
if (exists($grouplist{$group.':'.$uname.':'.$udom})) { |
|
my ($end,$start) = split(/:/,$grouplist{$group.':'.$uname.':'.$udom}); |
|
if (($end!=0) && ($end<$now)) { next; } |
|
if (($start!=0) && ($start>$now)) {next; } |
|
$grouplist .= " $group,"; |
|
} |
|
} |
|
$grouplist =~ s/,$//; |
|
$r->print('<tr><td>'. |
|
'<input type="button" value="'.&mt('Select').'" onClick="gochoose('. |
|
"'".$uname."','".$udom."')".'" /></td>'. |
|
'<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom. |
|
'</tt></td><td>'. |
|
&Apache::loncommon::aboutmewrapper( |
|
$fullname, |
|
$uname,$udom).'</td><td>'.$id.'</td><td>'.$section. |
|
'</td><td>'.$grouplist.'</td></tr>'); |
|
} |
|
} |
|
} |
|
|
|
$r->print('</table></p>'); |
|
} else { |
|
$r->print('<h3>'.&mt('Users with Roles Assigned by').' '. |
|
&Apache::loncommon::plainname($env{'user.name'}, |
|
$env{'user.domain'}).'</h3>'); |
|
if ($filter ne '.') { |
|
$r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />'); |
|
} |
|
$r->print('<p><table>'); |
|
my %users=&Apache::lonnet::get_my_roles(); |
|
foreach (sort keys %users) { |
|
if ($_=~/^(\w+)\:(\w+)\:(\w+)$/) { |
|
my ($uname,$udom,$urole)=($1,$2,$3); |
|
my $fullname=&Apache::loncommon::plainname($uname,$udom); |
|
if (($uname=~/^$filter/) || |
|
($fullname=~/^$filter/i)) { |
$r->print('<tr><td>'. |
$r->print('<tr><td>'. |
'<input type="button" value="Select" onClick="gochoose('. |
'<input type="button" value="Select" onClick="gochoose('. |
"'".$uname."','".$udom."')".'" /></td>'. |
"'".$uname."','".$udom."')".'" /></td>'. |
'<td><tt>'.$uname.'</tt></td><td><tt>'.$udom. |
'<td><tt>'.$uname.'</tt></td><td><tt>'.$udom. |
'</tt></td><td>'. |
'</tt></td><td>'. |
&Apache::loncommon::aboutmewrapper( |
&Apache::loncommon::aboutmewrapper( |
$classlist->{$_}->{'lastname'}.', '. |
$fullname, |
$classlist->{$_}->{'firstname'}.' '. |
$uname,$udom).'</td><td><td>'. |
$classlist->{$_}->{'middlename'}.' '. |
&Apache::lonnet::plaintext($urole). |
$classlist->{$_}->{'generation'}, |
'</td></tr>'); |
$uname,$udom).'</td></tr>'); |
|
} |
} |
} |
} |
} |
} |
|
$r->print('</table></p>'); |
$r->print('</table></form></body></html>'); |
} |
return OK; |
$r->print('</form>'.&Apache::loncommon::end_page()); |
|
return OK; |
} |
} |
|
|
1; |
1; |