version 1.7, 2003/09/22 00:48:32
|
version 1.26, 2009/03/01 01:17:20
|
Line 34 use Apache::loncommon;
|
Line 34 use Apache::loncommon;
|
use Apache::loncoursedata; |
use Apache::loncoursedata; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::longroup; |
|
use LONCAPA; |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
Line 42 sub handler {
|
Line 44 sub handler {
|
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> |
|
ENDDOCUMENT |
|
|
|
|
|
|
|
|
|
&Apache::loncommon::get_unprocessed_cgi |
&Apache::loncommon::get_unprocessed_cgi |
($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement', |
($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement', |
'roles']); |
'roles']); |
# Allowed? |
# Allowed? |
|
my $allowed; |
|
my $scope = $env{'request.course.id'}; |
|
if (!($allowed = &Apache::lonnet::allowed('srm',$scope))) { |
|
$scope .= '/'.$env{'request.course.sec'}; |
|
$allowed = &Apache::lonnet::allowed('srm',$scope); |
|
if ($allowed) { $allowed = 'section'; } |
|
} |
|
|
unless (($ENV{'form.roles'}) || |
unless (($env{'form.roles'}) || |
(($ENV{'request.course.id'}) && |
(($env{'request.course.id'}) && ($allowed))) { |
(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})))) { |
$r->print(&mt('No context.'). |
$r->print('<body>No context.</body>'); |
&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} |
} |
|
|
# See if filter present |
# See if filter present |
|
my $filter=$env{'form.filter'}; |
|
my $filtermsg; |
|
my $encoded_filter = &HTML::Entities::encode($filter,'<>&"'); |
|
$filter = quotemeta($filter); |
|
my $change = &mt('Change'); |
|
my $filterbutton =<<FILTER; |
|
<input type="text" name="filter" value="$encoded_filter" /> |
|
<input type="submit" name="Change" value="$change" /> |
|
FILTER |
|
foreach my $name ('form','unameelement','udomelement','roles') { |
|
my $value = &HTML::Entities::encode($env{"form.$name"},'<>&"'); |
|
$filterbutton .= <<HIDDEN; |
|
<input type="hidden" name="$name" value="$value" /> |
|
HIDDEN |
|
} |
|
$filtermsg = '<br />'. |
|
&mt('Showing users with a name starting with [_1]', |
|
$filterbutton).'<br />'; |
|
if ($filter eq '') { |
|
$filter = '.' |
|
} |
|
|
my $filter=$ENV{'form.filter'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$filter=~s/\W//g; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
unless ($filter) { $filter='.'; } |
|
|
|
my $classlist=&Apache::loncoursedata::get_classlist(); |
my $classlist=&Apache::loncoursedata::get_classlist(); |
|
my %grouplist=&Apache::lonnet::get_group_membership($cdom,$cnum); |
|
my $now = time; |
|
my %allgroups = &Apache::longroup::coursegroups($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 type="text/javascript"> |
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.options[i].value==udom) { slct.selectedIndex=i; } |
if (slct.options[i].value==udom) { slct.selectedIndex=i; } |
Line 88 function gochoose(uname,udom) {
|
Line 112 function gochoose(uname,udom) {
|
} |
} |
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
|
|
$r->print('<form>'); |
$r->print('<form>'); |
if ((&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) && |
if ($allowed && (!$env{'form.roles'})) { |
(!$ENV{'form.roles'})) { |
|
# -------------------------------------------------------- Get course personnel |
# -------------------------------------------------------- Get course personnel |
$r->print('<h3>'.$ENV{'course.'.$ENV{'request.course.id'}.'.description'}. |
$r->print('<h3>'.$env{'course.'.$env{'request.course.id'}.'.description'}. |
'</h3>'); |
'</h3>'); |
my %coursepersonnel= |
my %coursepersonnel= |
&Apache::lonnet::get_course_adv_roles(); |
&Apache::lonnet::get_course_adv_roles(); |
$r->print('<table border="2">'); |
$r->print(&Apache::loncommon::start_data_table()); |
foreach my $role (sort keys %coursepersonnel) { |
foreach my $role (sort(keys(%coursepersonnel))) { |
foreach (split(/\,/,$coursepersonnel{$role})) { |
foreach my $user (split(/\,/,$coursepersonnel{$role})) { |
my ($puname,$pudom)=split(/\:/,$_); |
my ($puname,$pudom)=split(/\:/,$user); |
$r->print('<tr><td>'. |
$r->print(&Apache::loncommon::start_data_table_row(). |
'<input type="button" value="Select" onClick="gochoose('. |
'<td>'. |
"'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'. |
'<input type="button" value="'.&mt('Select').'" onClick="gochoose('. |
&Apache::loncommon::aboutmewrapper( |
"'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'. |
&Apache::loncommon::plainname($puname, |
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($puname,$pudom),$puname,$pudom).'</td>'. |
$pudom),$puname,$pudom).'</td></tr>'); |
&Apache::loncommon::end_data_table_row()); |
|
} |
} |
} |
} |
$r->print(&Apache::loncommon::end_data_table().'<p> '); |
$r->print('</table><p> '); |
|
if ($filter ne '.') { |
$r->print($filtermsg); |
$r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />'); |
|
} |
$r->print('</p>'); |
$r->print('</p><p><table>'); |
|
# ------------------------------------------------------------------ Students |
# ------------------------------------------------------------------ Students |
foreach (sort keys %$classlist) { |
my $result; |
# the following undefs are for 'domain', and 'username' respectively. |
foreach my $user (sort(keys(%$classlist))) { |
my (undef,undef,$end,$start,$id,$section,$fullname,$status)= |
# the following undefs are for 'domain', and 'username' respectively. |
@{$classlist->{$_}}; |
my (undef,undef,$end,$start,$id,$section,$fullname,$status)= |
if ($_=~/^(\w+)\:(\w+)$/) { |
@{$classlist->{$user}}; |
my ($uname,$udom)=($1,$2); |
if ($allowed eq 'section' && $section ne $env{'request.course.sec'}) { |
if (($uname=~/^$filter/) || |
next; |
($fullname=~/^$filter/i)) { |
} |
$r->print('<tr><td>'. |
if ($user=~/^($LONCAPA::username_re)\:($LONCAPA::domain_re)$/) { |
'<input type="button" value="'.&mt('Select').'" onClick="gochoose('. |
my ($uname,$udom)=($1,$2); |
"'".$uname."','".$udom."')".'" /></td>'. |
if (($uname=~/^$filter/) || |
'<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom. |
($fullname=~/^$filter/i)) { |
'</tt></td><td>'. |
my $grouplist = ''; |
&Apache::loncommon::aboutmewrapper( |
foreach my $group (sort(keys(%allgroups))) { |
$fullname, |
if (exists($grouplist{$group.':'.$uname.':'.$udom})) { |
$uname,$udom).'</td><td>'.$id.'</td><td>'.$section. |
my ($end,$start) = split(/:/,$grouplist{$group.':'.$uname.':'.$udom}); |
'</td></tr>'); |
if (($end!=0) && ($end<$now)) { next; } |
} |
if (($start!=0) && ($start>$now)) {next; } |
} |
$grouplist .= " $group,"; |
} |
} |
|
} |
$r->print('</table></p>'); |
$grouplist =~ s/,$//; |
} else { |
$result .=&Apache::loncommon::start_data_table_row(). |
$r->print('<h3>'.&mt('Users with Roles Assigned by').' '. |
'<td>'. |
&Apache::loncommon::plainname($ENV{'user.name'}, |
'<input type="button" value="'.&mt('Select').'" onClick="gochoose('. |
$ENV{'user.domain'}).'</h3>'); |
"'".$uname."','".$udom."')".'" /></td>'. |
if ($filter ne '.') { |
'<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom. |
$r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />'); |
'</tt></td><td>'. |
} |
&Apache::loncommon::aboutmewrapper($fullname, |
$r->print('<p><table>'); |
$uname,$udom). |
my %users=&Apache::lonnet::get_my_roles(); |
'</td><td>'.$id.'</td><td>'.$section. |
foreach (sort keys %users) { |
'</td><td>'.$grouplist.'</td>'. |
if ($_=~/^(\w+)\:(\w+)\:(\w+)$/) { |
&Apache::loncommon::end_data_table_row(); |
|
} |
|
} |
|
} |
|
if (!$result) { |
|
$r->print('<p>'.&mt('No students found.').'</p>'); |
|
} else { |
|
$r->print(&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(). |
|
&Apache::loncommon::end_data_table_header_row(). |
|
'<th> </th>'. |
|
'<th>'.&mt('username').'</th>'. |
|
'<th>'.&mt('domain').'</th>'. |
|
'<th>'.&mt('Name').'</th>'. |
|
'<th>'.&mt('ID').'</th>'. |
|
'<th>'.&mt('section').'</th>'. |
|
'<th>'.&mt('active group(s)').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row(). |
|
$result. |
|
&Apache::loncommon::end_data_table()); |
|
} |
|
} else { |
|
$r->print('<h3>'.&mt('Users with Roles Assigned by').' '. |
|
&Apache::loncommon::plainname($env{'user.name'}, |
|
$env{'user.domain'}).'</h3>'); |
|
$r->print($filtermsg); |
|
|
|
$r->print('<p>'.&Apache::loncommon::start_data_table()); |
|
my %user_role=&Apache::lonnet::get_my_roles(); |
|
my %users; |
|
foreach my $user_role (keys(%user_role)) { |
|
next if ($user_role !~ |
|
/^($LONCAPA::username_re):($LONCAPA::domain_re):(\w+)$/); |
my ($uname,$udom,$urole)=($1,$2,$3); |
my ($uname,$udom,$urole)=($1,$2,$3); |
my $fullname=&Apache::loncommon::plainname($uname,$udom); |
my $fullname=&Apache::loncommon::plainname($uname,$udom); |
if (($uname=~/^$filter/) || |
next if (($uname!~/^$filter/i) && ($fullname !~/^$filter/i)); |
($fullname=~/^$filter/i)) { |
|
$r->print('<tr><td>'. |
if (!exists($users{"$uname:$udom"})) { |
'<input type="button" value="Select" onClick="gochoose('. |
$users{"$uname:$udom"} = {'fullname' => $fullname }; |
"'".$uname."','".$udom."')".'" /></td>'. |
} |
'<td><tt>'.$uname.'</tt></td><td><tt>'.$udom. |
push(@{$users{"$uname:$udom"}{'roles'}},$urole); |
'</tt></td><td>'. |
} |
&Apache::loncommon::aboutmewrapper( |
foreach my $user (sort {lc($a) cmp lc($b)} (keys(%users))) { |
$fullname, |
my ($uname,$udom) = split(':',$user); |
$uname,$udom).'</td><td><td>'. |
$r->print(&Apache::loncommon::start_data_table_row(). |
&Apache::lonnet::plaintext($urole). |
'<td>'. |
'</td></tr>'); |
'<input type="button" value="'.&mt('Select').'" onClick="gochoose('. |
} |
"'".$uname."','".$udom."')".'" /></td>'. |
} |
'<td><tt>'.$uname.'</tt></td>'. |
} |
'<td><tt>'.$udom.'</tt></td><td>'. |
$r->print('</table></p>'); |
&Apache::loncommon::aboutmewrapper($users{$user}{'fullname'}, |
} |
$uname,$udom).'</td>'. |
$r->print('</form></body></html>'); |
'<td>'. |
return OK; |
join(', ',sort(map {&Apache::lonnet::plaintext($_)} |
|
(@{$users{$user}{'roles'}}))). |
|
'</td>'. |
|
&Apache::loncommon::end_data_table_row()); |
|
} |
|
$r->print(&Apache::loncommon::end_data_table().'</p>'); |
|
} |
|
$r->print('</form>'.&Apache::loncommon::end_page()); |
|
return OK; |
} |
} |
|
|
1; |
1; |