version 1.13, 2006/03/16 21:34:04
|
version 1.20, 2006/12/06 20:54:13
|
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 66 sub handler {
|
Line 68 sub handler {
|
} |
} |
|
|
# See if filter present |
# See if filter present |
|
|
my $filter=$env{'form.filter'}; |
my $filter=$env{'form.filter'}; |
$filter=~s/\W//g; |
my $filtermsg; |
unless ($filter) { $filter='.'; } |
if ($filter ne '') { |
|
$filtermsg = '<br />'.&mt('Name starting with').' "'.$filter.'"<br />'; |
|
$filter = quotemeta($filter); |
|
} else { |
|
$filter = '.' |
|
} |
|
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $classlist=&Apache::loncoursedata::get_classlist(); |
my $classlist=&Apache::loncoursedata::get_classlist(); |
my %grouplist=&Apache::lonnet::get_group_membership($cdom,$cnum); |
my %grouplist=&Apache::lonnet::get_group_membership($cdom,$cnum); |
my $now = time; |
my $now = time; |
my %allgroups; |
my %allgroups = &Apache::longroup::coursegroups($cdom,$cnum); |
my @coursegroups = (); |
|
if (&Apache::loncommon::coursegroups(\%allgroups,$cdom,$cnum)) { |
|
@coursegroups = keys(%allgroups); |
|
} |
|
|
|
# --------------------------------------- There is such a user, get environment |
# --------------------------------------- There is such a user, get environment |
|
|
$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'}; |
Line 97 function gochoose(uname,udom) {
|
Line 99 function gochoose(uname,udom) {
|
} |
} |
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
|
|
$r->print('<form>'); |
$r->print('<form>'); |
if ($allowed && (!$env{'form.roles'})) { |
if ($allowed && (!$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 (split(/\,/,$coursepersonnel{$role})) { |
my ($puname,$pudom)=split(/\:/,$_); |
my ($puname,$pudom)=split(/\:/,$_); |
$r->print('<tr><td>'. |
$role = &Apache::lonnet::plaintext($role, |
'<input type="button" value="Select" onClick="gochoose('. |
&Apache::loncommon::course_type()); |
"'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'. |
$r->print(&Apache::loncommon::start_data_table_row(). |
&Apache::loncommon::aboutmewrapper( |
'<td>'. |
&Apache::loncommon::plainname($puname, |
'<input type="button" value="Select" onClick="gochoose('. |
$pudom),$puname,$pudom).'</td></tr>'); |
"'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'. |
} |
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($puname,$pudom),$puname,$pudom).'</td>'. |
} |
&Apache::loncommon::end_data_table_row()); |
$r->print('</table><p> '); |
} |
if ($filter ne '.') { |
|
$r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />'); |
|
} |
|
$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) { |
|
# 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+)$/) { |
$r->print(&Apache::loncommon::end_data_table().'<p> '); |
my ($uname,$udom)=($1,$2); |
|
if (($uname=~/^$filter/) || |
|
($fullname=~/^$filter/i)) { |
|
my $grouplist = ''; |
|
foreach my $group (@coursegroups) { |
|
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>'); |
$r->print($filtermsg); |
} else { |
|
$r->print('<h3>'.&mt('Users with Roles Assigned by').' '. |
$r->print('</p><p>'. |
&Apache::loncommon::plainname($env{'user.name'}, |
&Apache::loncommon::start_data_table(). |
$env{'user.domain'}).'</h3>'); |
&Apache::loncommon::start_data_table_header_row(). |
if ($filter ne '.') { |
&Apache::loncommon::end_data_table_header_row(). |
$r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />'); |
'<th> </th>'. |
} |
'<th>'.&mt('username').'</th>'. |
$r->print('<p><table>'); |
'<th>'.&mt('domain').'</th>'. |
my %users=&Apache::lonnet::get_my_roles(); |
'<th>'.&mt('Name').'</th>'. |
foreach (sort keys %users) { |
'<th>'.&mt('ID').'</th>'. |
if ($_=~/^(\w+)\:(\w+)\:(\w+)$/) { |
'<th>'.&mt('section').'</th>'. |
my ($uname,$udom,$urole)=($1,$2,$3); |
'<th>'.&mt('active group(s)').'</th>'. |
my $fullname=&Apache::loncommon::plainname($uname,$udom); |
&Apache::loncommon::end_data_table_header_row()); |
if (($uname=~/^$filter/) || |
# ------------------------------------------------------------------ Students |
($fullname=~/^$filter/i)) { |
foreach my $user (sort(keys(%$classlist))) { |
$r->print('<tr><td>'. |
# the following undefs are for 'domain', and 'username' respectively. |
'<input type="button" value="Select" onClick="gochoose('. |
my (undef,undef,$end,$start,$id,$section,$fullname,$status)= |
"'".$uname."','".$udom."')".'" /></td>'. |
@{$classlist->{$user}}; |
'<td><tt>'.$uname.'</tt></td><td><tt>'.$udom. |
if ($allowed eq 'section' && $section ne $env{'request.course.sec'}) { |
'</tt></td><td>'. |
next; |
&Apache::loncommon::aboutmewrapper( |
} |
$fullname, |
if ($user=~/^($LONCAPA::username_re)\:($LONCAPA::domain_re)$/) { |
$uname,$udom).'</td><td><td>'. |
my ($uname,$udom)=($1,$2); |
&Apache::lonnet::plaintext($urole). |
if (($uname=~/^$filter/) || |
'</td></tr>'); |
($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(&Apache::loncommon::start_data_table_row(). |
|
'<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>'. |
|
&Apache::loncommon::end_data_table_row()); |
|
} |
|
} |
|
} |
|
|
|
$r->print(&Apache::loncommon::end_data_table().'</p>'); |
|
} 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 %users=&Apache::lonnet::get_my_roles(); |
|
foreach my $user (sort(keys(%users))) { |
|
if ($user =~ |
|
/^($LONCAPA::username_re)\:($LONCAPA::domain_re)\:(\w+)$/) { |
|
my ($uname,$udom,$urole)=($1,$2,$3); |
|
my $fullname=&Apache::loncommon::plainname($uname,$udom); |
|
if (($uname=~/^$filter/) || |
|
($fullname=~/^$filter/i)) { |
|
$r->print(&Apache::loncommon::start_data_table_row(). |
|
'<td>'. |
|
'<input type="button" value="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><td>'. |
|
&Apache::lonnet::plaintext($urole). |
|
'</td>'. |
|
&Apache::loncommon::end_data_table_row()); |
|
} |
|
} |
|
} |
|
$r->print(&Apache::loncommon::end_data_table().'</p>'); |
} |
} |
$r->print('</table></p>'); |
$r->print('</form>'.&Apache::loncommon::end_page()); |
} |
return OK; |
$r->print('</form>'.&Apache::loncommon::end_page()); |
|
return OK; |
|
} |
} |
|
|
1; |
1; |