version 1.191, 2008/05/14 23:52:52
|
version 1.193, 2008/05/19 17:55:38
|
Line 154 sub handler {
|
Line 154 sub handler {
|
} |
} |
last; |
last; |
} |
} |
# Is this a recent ad-hoc CA-role? |
# Is this an ad-hoc CA-role? |
if (my ($domain,$user) = |
if (my ($domain,$user) = |
($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) { |
($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) { |
# See if still allowed |
# Check if author blocked ca-access |
my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user); |
my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user); |
if ($blocked{'domcoord.author'} eq 'blocked') { |
if ($blocked{'domcoord.author'} eq 'blocked') { |
delete($env{$envkey}); |
delete($env{$envkey}); |
$env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access'; |
$env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access'; |
last; |
last; |
} |
} |
if (($dcroles{$domain}) && (&is_author_homeserver($user,$domain))) { |
if ($dcroles{$domain}) { |
&check_privs($domain,$user,$then,$now,'ca'); |
my ($server_status,$home) = &check_author_homeserver($user,$domain); |
|
if (($server_status eq 'ok') || ($server_status eq 'switchserver')) { |
|
&check_privs($domain,$user,$then,$now,'ca'); |
|
if ($server_status eq 'switchserver') { |
|
my $trolecode = 'ca./'.$domain.'/'.$user; |
|
my $switchserver = '/adm/switchserver?' |
|
.'otherserver='.$home.'&role='.$trolecode; |
|
$r->internal_redirect($switchserver); |
|
} |
|
} else { |
|
delete($env{$envkey}); |
|
} |
} else { |
} else { |
delete($env{$envkey}); |
delete($env{$envkey}); |
} |
} |
last; |
last; |
} |
} |
# Is this a new ad-hoc CA-role? |
|
if (my ($domain) = |
|
($envkey =~ m-^form\.adhocca\./($match_domain)$-)) { |
|
my $user=$env{'form.adhoccauname.'.$domain}; |
|
if (!$user) { $user=$env{'form.adhoccaunamerecent.'.$domain} }; |
|
# See if that is even allowed |
|
my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user); |
|
if ($blocked{'domcoord.author'} eq 'blocked') { |
|
$env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access'; |
|
last; |
|
} |
|
if ($dcroles{$domain}) { |
|
if (($user) && ($user=~/$match_username/) && (&is_author_homeserver($user,$domain))) { |
|
&check_privs($domain,$user,$then,$now,'ca'); |
|
$env{'form.ca./'.$domain.'/'.$user}=1; |
|
} |
|
} |
|
last; |
|
} |
|
} |
} |
} |
} |
|
|
Line 719 ENDHEADER
|
Line 711 ENDHEADER
|
$r->print('<tr bgcolor="#77FF77">'); |
$r->print('<tr bgcolor="#77FF77">'); |
} |
} |
$r->print('<td></td><td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
$r->print('<td></td><td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
'</font></span></td><td><font color="'.$tfont.'">'.$tremark. |
'</span></font></td><td><font color="'.$tfont.'">'.$tremark. |
' </font></td></tr>'."\n"); |
' </font></td></tr>'."\n"); |
|
|
$r->print('</table>'); |
$r->print('</table>'); |
Line 752 ENDHEADER
|
Line 744 ENDHEADER
|
$output.=$roletext{'user.role.'.$_}; |
$output.=$roletext{'user.role.'.$_}; |
if ($_ =~ m-dc\./($match_domain)/- |
if ($_ =~ m-dc\./($match_domain)/- |
&& $dcroles{$1}) { |
&& $dcroles{$1}) { |
$output .= &allcourses_row($1,'recent'). |
$output .= &adhoc_roles_row($1,'recent'); |
&allcoauthors_row($1,'recent'); |
|
} |
} |
} elsif ($numdc > 0) { |
} elsif ($numdc > 0) { |
unless ($_ =~/^error\:/) { |
unless ($_ =~/^error\:/) { |
Line 763 ENDHEADER
|
Line 754 ENDHEADER
|
} |
} |
if ($output) { |
if ($output) { |
$r->print("<tr><td align='center' colspan='5'><font face='arial'>". |
$r->print("<tr><td align='center' colspan='5'><font face='arial'>". |
&mt('Recent Roles')."</font></td>"); |
&mt('Recent Roles')."</font></td></tr>"); |
$r->print($output); |
$r->print($output); |
$r->print("</tr>"); |
|
$doheaders ++; |
$doheaders ++; |
} |
} |
} |
} |
|
|
if ($numdc > 0) { |
if ($numdc > 0) { |
$r->print(&coursepick_jscript()); |
$r->print(&coursepick_jscript()); |
$r->print(&Apache::loncommon::coursebrowser_javascript()); |
$r->print(&Apache::loncommon::coursebrowser_javascript(). |
|
&Apache::loncommon::authorbrowser_javascript()); |
} |
} |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext); |
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext); |
my $tremark=''; |
my $tremark=''; |
Line 787 ENDHEADER
|
Line 778 ENDHEADER
|
unless ($nochoose) { |
unless ($nochoose) { |
if ($env{'request.role'} ne 'cm') { |
if ($env{'request.role'} ne 'cm') { |
$r->print('<td><input type="submit" value="'. |
$r->print('<td><input type="submit" value="'. |
&mt('Select').'" name="cm"></td>'); |
&mt('Select').'" name="cm" /></td>'); |
} else { |
} else { |
$r->print('<td> </td>'); |
$r->print('<td> </td>'); |
} |
} |
} |
} |
$r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
$r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified'). |
'</font></span></td><td><font color="'.$tfont.'">'.$tremark. |
'</span></font></td><td><font color="'.$tfont.'">'.$tremark. |
' </font></td></tr>'."\n"); |
' </font></td></tr>'."\n"); |
|
|
$r->print('</table>'); |
$r->print('</table>'); |
Line 857 sub print_rolerows {
|
Line 848 sub print_rolerows {
|
if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) { |
if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) { |
if (ref($dcroles) eq 'HASH') { |
if (ref($dcroles) eq 'HASH') { |
if ($dcroles->{$1}) { |
if ($dcroles->{$1}) { |
$output .= &allcourses_row($1,''). |
$output .= &adhoc_roles_row($1,''); |
&allcoauthors_row($1,''); |
|
} |
} |
} |
} |
} |
} |
Line 997 sub build_roletext {
|
Line 987 sub build_roletext {
|
} elsif ($tstatus eq 'is') { |
} elsif ($tstatus eq 'is') { |
$roletext.='<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
$roletext.='<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
&mt('Select').'" onClick="javascript:enterrole(this.form,\''. |
&mt('Select').'" onClick="javascript:enterrole(this.form,\''. |
$trolecode."','".$buttonname.'\');"></td>'; |
$trolecode."','".$buttonname.'\');" /></td>'; |
} elsif ($tryagain) { |
} elsif ($tryagain) { |
$roletext.= |
$roletext.= |
'<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
'<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
&mt('Try Selecting Again').'" onClick="javascript:enterrole(this.form,\''. |
&mt('Try Selecting Again').'" onClick="javascript:enterrole(this.form,\''. |
$trolecode."','".$buttonname.'\');"></td>'; |
$trolecode."','".$buttonname.'\');" /></td>'; |
} elsif ($advanced) { |
} elsif ($advanced) { |
$roletext.= |
$roletext.= |
'<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
'<td'.$rowspan.'><input name="'.$buttonname.'" type="button" value="'. |
&mt('Re-Initialize').'" onClick="javascript:enterrole(this.form,\''. |
&mt('Re-Initialize').'" onClick="javascript:enterrole(this.form,\''. |
$trolecode."','".$buttonname.'\');"></td>'; |
$trolecode."','".$buttonname.'\');" /></td>'; |
} else { |
} else { |
$roletext.='<td'.$rowspan.'> </td>'; |
$roletext.='<td'.$rowspan.'> </td>'; |
} |
} |
Line 1028 sub build_roletext {
|
Line 1018 sub build_roletext {
|
return $roletext; |
return $roletext; |
} |
} |
|
|
sub is_author_homeserver { |
sub check_author_homeserver { |
my ($uname,$udom)=@_; |
my ($uname,$udom)=@_; |
|
if (($uname eq '') || ($udom eq '')) { |
|
return ('fail',''); |
|
} |
my $home = &Apache::lonnet::homeserver($uname,$udom); |
my $home = &Apache::lonnet::homeserver($uname,$udom); |
|
if (&Apache::lonnet::host_domain($home) ne $udom) { |
|
return ('fail',$home); |
|
} |
my @ids=&Apache::lonnet::current_machine_ids(); |
my @ids=&Apache::lonnet::current_machine_ids(); |
foreach my $id (@ids) { |
if (grep(/^\Q$home\E$/,@ids)) { |
if ($id eq $home) { |
return ('ok',$home); |
if (-e "/home/".$uname."/public_html") { |
} else { |
return 1; |
return ('switchserver',$home); |
} |
|
} |
|
} |
} |
return 0; |
|
} |
} |
|
|
sub check_privs { |
sub check_privs { |
Line 1141 sub check_forcc {
|
Line 1134 sub check_forcc {
|
} |
} |
|
|
sub courselink { |
sub courselink { |
my ($dcdom,$rowtype,$selecttype) = @_; |
my ($dcdom,$rowtype) = @_; |
my $courseform=&Apache::loncommon::selectcourse_link |
my $courseform=&Apache::loncommon::selectcourse_link |
('rolechoice','dccourse'.$rowtype.'_'.$dcdom, |
('rolechoice','dccourse'.$rowtype.'_'.$dcdom, |
'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'. |
'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'. |
Line 1193 END
|
Line 1186 END
|
return $verify_script; |
return $verify_script; |
} |
} |
|
|
|
sub coauthorlink { |
|
my ($dcdom,$rowtype) = @_; |
|
my $coauthorform=&Apache::loncommon::selectauthor_link('rolechoice',$dcdom); |
|
my $hiddenitems = '<input type="hidden" name="adhoccauname'.$rowtype.'_'.$dcdom.'" value="" />'; |
|
return $coauthorform.$hiddenitems; |
|
} |
|
|
sub display_cc_role { |
sub display_cc_role { |
my $rolekey = shift; |
my $rolekey = shift; |
my $roletext; |
my $roletext; |
Line 1225 sub display_cc_role {
|
Line 1225 sub display_cc_role {
|
return ($roletext); |
return ($roletext); |
} |
} |
|
|
sub allcourses_row { |
sub adhoc_roles_row { |
my ($dcdom,$rowtype) = @_; |
my ($dcdom,$rowtype) = @_; |
my $output = '<tr bgcolor="#77FF77">'. |
my $output = '<tr bgcolor="#77FF77">'. |
' <td colspan="5">'; |
' <td colspan="5"><table><tr><td><span class="LC_rolesinfo">' |
my $selectlink = &courselink($dcdom,$rowtype); |
.&mt('[_1]Ad hoc[_2] roles in domain [_3] --', |
|
'<span class="LC_cusr_emph">','</span>',$dcdom).'</span></td><td>'; |
|
my $selectcclink = &courselink($dcdom,$rowtype); |
my $ccrole = &Apache::lonnet::plaintext('cc'); |
my $ccrole = &Apache::lonnet::plaintext('cc'); |
$output.= '<span class="LC_rolesinfo">'. |
|
&mt('[_1]: [_2] from domain [_3]',$ccrole,$selectlink,$dcdom). |
|
'</span><br /></tr>'."\n"; |
|
return $output; |
|
} |
|
|
|
sub allcoauthors_row { |
|
my ($dcdom,$rowtype) = @_; |
|
my $output = '<tr bgcolor="#77FF77">'. |
|
' <td colspan="5">'; |
|
my $carole = &Apache::lonnet::plaintext('ca'); |
my $carole = &Apache::lonnet::plaintext('ca'); |
my $inputlink='<input type="text" size="10" name="adhoccauname'.$rowtype.'.'.$dcdom.'" />'; |
my $selectcalink = &coauthorlink($dcdom,$rowtype); |
my $gobutton='<input type="submit" name="adhocca./'.$dcdom.'" value="'.&mt('Go').'" />'; |
|
$output.= '<span class="LC_rolesinfo">'. |
$output.= '<span class="LC_rolesinfo">'. |
&mt('[_1]: [_2] in domain [_3] [_4]',$carole,$inputlink,$dcdom,$gobutton). |
&mt('[_1]: [_2]',$ccrole,$selectcclink). |
'</span><br /></tr><tr><td colspan="5" height="3"></td></tr>'."\n"; |
'</span><br /></td><td> </td><td><span class="LC_rolesinfo">'. |
|
&mt('[_1]: [_2]',$carole,$selectcalink). |
|
'</span><br /></td></tr></table></td></tr>'. |
|
'<tr><td colspan="5" height="3"></td></tr>'."\n"; |
return $output; |
return $output; |
} |
} |
|
|