version 1.68, 2008/09/19 03:27:04
|
version 1.69, 2008/11/28 21:02:35
|
Line 37 use Apache::loncommon();
|
Line 37 use Apache::loncommon();
|
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonmsg(); |
use Apache::lonmsg(); |
use LONCAPA; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA::Enrollment; |
use LONCAPA::Enrollment; |
|
use LONCAPA::loncgi(); |
use File::Copy; |
use File::Copy; |
use Locale::Language; |
use Locale::Language; |
use DateTime::TimeZone; |
use DateTime::TimeZone; |
Line 73 sub handler {
|
Line 74 sub handler {
|
&Apache::lonnet::get_dom('configuration',['login','rolecolors', |
&Apache::lonnet::get_dom('configuration',['login','rolecolors', |
'quotas','autoenroll','autoupdate','directorysrch', |
'quotas','autoenroll','autoupdate','directorysrch', |
'usercreation','usermodification','contacts','defaults', |
'usercreation','usermodification','contacts','defaults', |
'scantron','coursecategories'],$dom); |
'scantron','coursecategories','serverstatuses'],$dom); |
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', |
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', |
'autoupdate','directorysrch','contacts', |
'autoupdate','directorysrch','contacts', |
'usercreation','usermodification','scantron', |
'usercreation','usermodification','scantron', |
'coursecategories'); |
'coursecategories','serverstatuses'); |
my %prefs = ( |
my %prefs = ( |
'rolecolors' => |
'rolecolors' => |
{ text => 'Default color schemes', |
{ text => 'Default color schemes', |
Line 146 sub handler {
|
Line 147 sub handler {
|
{col1 => 'Context', |
{col1 => 'Context', |
col2 => 'Assignable authentication types'}], |
col2 => 'Assignable authentication types'}], |
}, |
}, |
'usermodification' => |
'usermodification' => |
{ text => 'User modification', |
{ text => 'User modification', |
help => 'Domain_Configuration_User_Modification', |
help => 'Domain_Configuration_User_Modification', |
header => [{col1 => 'Target user has role', |
header => [{col1 => 'Target user has role', |
Line 156 sub handler {
|
Line 157 sub handler {
|
{col1 => "Status of user", |
{col1 => "Status of user", |
col2 => 'Information settable when self-creating account (if directory data blank)'}], |
col2 => 'Information settable when self-creating account (if directory data blank)'}], |
}, |
}, |
'scantron' => |
'scantron' => |
{ text => 'Scantron format file', |
{ text => 'Scantron format file', |
help => 'Domain_Configuration_Scantron_Format', |
help => 'Domain_Configuration_Scantron_Format', |
header => [ {col1 => 'Item', |
header => [ {col1 => 'Item', |
col2 => '', |
col2 => '', |
}], |
}], |
}, |
}, |
'coursecategories' => |
'coursecategories' => |
{ text => 'Cataloging of courses', |
{ text => 'Cataloging of courses', |
help => 'Domain_Configuration_Cataloging_Courses', |
help => 'Domain_Configuration_Cataloging_Courses', |
header => [{col1 => 'Category settings', |
header => [{col1 => 'Category settings', |
col2 => '',}, |
col2 => '',}, |
{col1 => 'Categories', |
{col1 => 'Categories', |
col2 => '', |
col2 => '', |
}], |
}], |
} |
}, |
|
'serverstatuses' => |
|
{text => 'Access to Server Status Pages', |
|
help => 'Domain_Configuration_Server_Status', |
|
header => [{col1 => 'Status Page', |
|
col2 => 'Other named users', |
|
col3 => 'Specific IPs', |
|
}], |
|
}, |
); |
); |
my @roles = ('student','coordinator','author','admin'); |
my @roles = ('student','coordinator','author','admin'); |
my @actions = &Apache::loncommon::get_env_multiple('form.actions'); |
my @actions = &Apache::loncommon::get_env_multiple('form.actions'); |
Line 372 sub process_changes {
|
Line 381 sub process_changes {
|
$output = &modify_scantron($r,$dom,$confname,%domconfig); |
$output = &modify_scantron($r,$dom,$confname,%domconfig); |
} elsif ($action eq 'coursecategories') { |
} elsif ($action eq 'coursecategories') { |
$output = &modify_coursecategories($dom,%domconfig); |
$output = &modify_coursecategories($dom,%domconfig); |
|
} elsif ($action eq 'serverstatuses') { |
|
$output = &modify_serverstatuses($dom,%domconfig); |
} |
} |
return $output; |
return $output; |
} |
} |
Line 406 sub print_config_box {
|
Line 417 sub print_config_box {
|
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[0]->{'col1'}).'</td> |
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[0]->{'col1'}).'</td> |
<td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td> |
<td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td> |
</tr>'; |
</tr>'; |
$rowtotal ++; |
$rowtotal ++; |
if ($action eq 'autoupdate') { |
if ($action eq 'autoupdate') { |
$output .= &print_autoupdate('top',$dom,$settings,\$rowtotal); |
$output .= &print_autoupdate('top',$dom,$settings,\$rowtotal); |
} elsif ($action eq 'usercreation') { |
} elsif ($action eq 'usercreation') { |
Line 471 sub print_config_box {
|
Line 482 sub print_config_box {
|
<td> |
<td> |
<table class="LC_nested"> |
<table class="LC_nested"> |
<tr class="LC_info_row"> |
<tr class="LC_info_row"> |
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td> |
<td class="LC_left_item"'.$colspan.' valign="top">'. |
<td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> |
&mt($item->{'header'}->[2]->{'col1'}).'</td> |
|
<td class="LC_right_item" valign="top">'. |
|
&mt($item->{'header'}->[2]->{'col2'}).'</td> |
</tr>'. |
</tr>'. |
&print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).' |
&print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).' |
</table> |
</table> |
Line 497 sub print_config_box {
|
Line 510 sub print_config_box {
|
if (($action eq 'login') || ($action eq 'directorysrch')) { |
if (($action eq 'login') || ($action eq 'directorysrch')) { |
$output .= ' |
$output .= ' |
<td class="LC_left_item" colspan="2">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>'; |
<td class="LC_left_item" colspan="2">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>'; |
|
} elsif ($action eq 'serverstatuses') { |
|
$output .= ' |
|
<td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}). |
|
'<br />('.&mt('Automatic access for Dom. Coords.').')</td>'; |
|
|
} else { |
} else { |
$output .= ' |
$output .= ' |
<td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>'; |
<td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>'; |
} |
} |
$output .= ' |
if ($action eq 'serverstatuses') { |
<td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td> |
$output .= '<td class="LC_left_item" valign="top">'. |
</tr>'; |
&mt($item->{'header'}->[0]->{'col2'}). |
|
'<br />(<tt>'.&mt('user1:domain1,user2:domain2 etc.').'</tt>)'; |
|
} else { |
|
$output .= '<td class="LC_right_item" valign="top">'. |
|
&mt($item->{'header'}->[0]->{'col2'}); |
|
} |
|
$output .= '</td>'; |
|
if ($item->{'header'}->[0]->{'col3'}) { |
|
$output .= '<td class="LC_right_item" valign="top">'. |
|
&mt($item->{'header'}->[0]->{'col3'}); |
|
if ($action eq 'serverstatuses') { |
|
$output .= '<br />(<tt>'.&mt('IP1,IP2 etc.').'</tt>)'; |
|
} |
|
$output .= '</td>'; |
|
} |
|
$output .= '</tr>'; |
$rowtotal ++; |
$rowtotal ++; |
if ($action eq 'login') { |
if ($action eq 'login') { |
$output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal); |
$output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal); |
Line 519 sub print_config_box {
|
Line 552 sub print_config_box {
|
$output .= &print_defaults($dom,\$rowtotal); |
$output .= &print_defaults($dom,\$rowtotal); |
} elsif ($action eq 'scantron') { |
} elsif ($action eq 'scantron') { |
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); |
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); |
|
} elsif ($action eq 'serverstatuses') { |
|
$output .= &print_serverstatuses($dom,$settings,\$rowtotal); |
} |
} |
} |
} |
$output .= ' |
$output .= ' |
Line 1466 sub print_contacts {
|
Line 1501 sub print_contacts {
|
my $rownum = 0; |
my $rownum = 0; |
my $css_class; |
my $css_class; |
foreach my $item (@contacts) { |
foreach my $item (@contacts) { |
if ($rownum%2) { |
$rownum ++; |
$css_class = ''; |
$css_class = $rownum%2?' class="LC_odd_row"':''; |
} else { |
|
$css_class = ' class="LC_odd_row" '; |
|
} |
|
$datatable .= '<tr'.$css_class.'>'. |
$datatable .= '<tr'.$css_class.'>'. |
'<td><span class="LC_nobreak">'.$titles->{$item}. |
'<td><span class="LC_nobreak">'.$titles->{$item}. |
'</span></td><td class="LC_right_item">'. |
'</span></td><td class="LC_right_item">'. |
'<input type="text" name="'.$item.'" value="'. |
'<input type="text" name="'.$item.'" value="'. |
$to{$item}.'" /></td></tr>'; |
$to{$item}.'" /></td></tr>'; |
$rownum ++; |
|
} |
} |
foreach my $type (@mailings) { |
foreach my $type (@mailings) { |
if ($rownum%2) { |
$rownum ++; |
$css_class = ''; |
$css_class = $rownum%2?' class="LC_odd_row"':''; |
} else { |
|
$css_class = ' class="LC_odd_row" '; |
|
} |
|
$datatable .= '<tr'.$css_class.'>'. |
$datatable .= '<tr'.$css_class.'>'. |
'<td><span class="LC_nobreak">'. |
'<td><span class="LC_nobreak">'. |
$titles->{$type}.': </span></td>'. |
$titles->{$type}.': </span></td>'. |
Line 1500 sub print_contacts {
|
Line 1528 sub print_contacts {
|
'<input type="text" name="'.$type.'_others" '. |
'<input type="text" name="'.$type.'_others" '. |
'value="'.$otheremails{$type}.'" />'. |
'value="'.$otheremails{$type}.'" />'. |
'</td></tr>'."\n"; |
'</td></tr>'."\n"; |
$rownum ++; |
|
} |
} |
$$rowtotal += $rownum; |
$$rowtotal += $rownum; |
return $datatable; |
return $datatable; |
Line 1509 sub print_contacts {
|
Line 1536 sub print_contacts {
|
sub contact_titles { |
sub contact_titles { |
my %titles = &Apache::lonlocal::texthash ( |
my %titles = &Apache::lonlocal::texthash ( |
'supportemail' => 'Support E-mail address', |
'supportemail' => 'Support E-mail address', |
'adminemail' => 'Default Server Admin E-mail address', |
'adminemail' => 'Default Server Admin E-mail address', |
'errormail' => 'Error reports to be e-mailed to', |
'errormail' => 'Error reports to be e-mailed to', |
'packagesmail' => 'Package update alerts to be e-mailed to', |
'packagesmail' => 'Package update alerts to be e-mailed to', |
'helpdeskmail' => 'Helpdesk requests to be e-mailed to' |
'helpdeskmail' => 'Helpdesk requests to be e-mailed to' |
Line 2210 sub print_coursecategories {
|
Line 2237 sub print_coursecategories {
|
return $datatable; |
return $datatable; |
} |
} |
|
|
|
sub print_serverstatuses { |
|
my ($dom,$settings,$rowtotal) = @_; |
|
my $datatable; |
|
my @pages = &serverstatus_pages(); |
|
my (%namedaccess,%machineaccess); |
|
foreach my $type (@pages) { |
|
$namedaccess{$type} = ''; |
|
$machineaccess{$type}= ''; |
|
} |
|
if (ref($settings) eq 'HASH') { |
|
foreach my $type (@pages) { |
|
if (exists($settings->{$type})) { |
|
if (ref($settings->{$type}) eq 'HASH') { |
|
foreach my $key (keys(%{$settings->{$type}})) { |
|
if ($key eq 'namedusers') { |
|
$namedaccess{$type} = $settings->{$type}->{$key}; |
|
} elsif ($key eq 'machines') { |
|
$machineaccess{$type} = $settings->{$type}->{$key}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
my $titles= &LONCAPA::loncgi::serverstatus_titles(); |
|
my $rownum = 0; |
|
my $css_class; |
|
foreach my $type (@pages) { |
|
$rownum ++; |
|
$css_class = $rownum%2?' class="LC_odd_row"':''; |
|
$datatable .= '<tr'.$css_class.'>'. |
|
'<td><span class="LC_nobreak">'. |
|
$titles->{$type}.'</span></td>'. |
|
'<td class="LC_left_item">'. |
|
'<input type="text" name="'.$type.'_namedusers" '. |
|
'value="'.$namedaccess{$type}.'" size="30" /></td>'. |
|
'<td class="LC_right_item">'. |
|
'<span class="LC_nobreak">'. |
|
'<input type="text" name="'.$type.'_machines" '. |
|
'value="'.$machineaccess{$type}.'" size="10" />'. |
|
'</td></tr>'."\n"; |
|
} |
|
$$rowtotal += $rownum; |
|
return $datatable; |
|
} |
|
|
|
sub serverstatus_pages { |
|
return ('userstatus','lonstatus','loncron','server-status','codeversions', |
|
'clusterstatus','metadata_keywords','metadata_harvest', |
|
'takeoffline','takeonline','showenv'); |
|
} |
|
|
sub coursecategories_javascript { |
sub coursecategories_javascript { |
my ($settings) = @_; |
my ($settings) = @_; |
my ($output,$jstext,$cathash); |
my ($output,$jstext,$cathash); |
Line 4617 sub modify_coursecategories {
|
Line 4696 sub modify_coursecategories {
|
} |
} |
return $resulttext; |
return $resulttext; |
} |
} |
|
|
|
sub modify_serverstatuses { |
|
my ($dom,%domconfig) = @_; |
|
my ($resulttext,%changes,%currserverstatus,%newserverstatus); |
|
if (ref($domconfig{'serverstatuses'}) eq 'HASH') { |
|
%currserverstatus = %{$domconfig{'serverstatuses'}}; |
|
} |
|
my @pages = &serverstatus_pages(); |
|
foreach my $type (@pages) { |
|
$newserverstatus{$type}{'namedusers'} = ''; |
|
$newserverstatus{$type}{'machines'} = ''; |
|
if (defined($env{'form.'.$type.'_namedusers'})) { |
|
my @users = split(/,/,$env{'form.'.$type.'_namedusers'}); |
|
my @okusers; |
|
foreach my $user (@users) { |
|
my ($uname,$udom) = split(/:/,$user); |
|
if (($udom =~ /^$match_domain$/) && |
|
(&Apache::lonnet::domain($udom)) && |
|
($uname =~ /^$match_username$/)) { |
|
if (!grep(/^\Q$user\E/,@okusers)) { |
|
push(@okusers,$user); |
|
} |
|
} |
|
} |
|
if (@okusers > 0) { |
|
@okusers = sort(@okusers); |
|
$newserverstatus{$type}{'namedusers'} = join(',',@okusers); |
|
} |
|
} |
|
if (defined($env{'form.'.$type.'_machines'})) { |
|
my @machines = split(/,/,$env{'form.'.$type.'_machines'}); |
|
my @okmachines; |
|
foreach my $ip (@machines) { |
|
my @parts = split(/\./,$ip); |
|
next if (@parts < 4); |
|
my $badip = 0; |
|
for (my $i=0; $i<4; $i++) { |
|
if (!(($parts[$i] >= 0) && ($parts[$i] <= 255))) { |
|
$badip = 1; |
|
last; |
|
} |
|
} |
|
if (!$badip) { |
|
push(@okmachines,$ip); |
|
} |
|
} |
|
@okmachines = sort(@okmachines); |
|
$newserverstatus{$type}{'machines'} = join(',',@okmachines); |
|
} |
|
} |
|
my %serverstatushash = ( |
|
serverstatuses => \%newserverstatus, |
|
); |
|
my $putresult = &Apache::lonnet::put_dom('configuration',\%serverstatushash, |
|
$dom); |
|
my %changes; |
|
foreach my $type (@pages) { |
|
if (ref($currserverstatus{$type}) eq 'HASH') { |
|
my @currnamed = split(/,/,$currserverstatus{$type}{'namedusers'}); |
|
my @newusers = split(/,/,$newserverstatus{$type}{'namedusers'}); |
|
foreach my $item (@currnamed) { |
|
if (!grep(/^\Q$item\E$/,@newusers)) { |
|
$changes{$type}{'namedusers'} = 1; |
|
last; |
|
} |
|
} |
|
foreach my $item (@newusers) { |
|
if (!grep(/^\Q$item\E$/,@currnamed)) { |
|
$changes{$type}{'namedusers'} = 1; |
|
last; |
|
} |
|
} |
|
my @currmachines = split(/,/,$currserverstatus{$type}{'machines'}); |
|
my @newmachines = split(/,/,$newserverstatus{$type}{'machines'}); |
|
foreach my $item (@currmachines) { |
|
if (!grep(/^\Q$item\E$/,@newmachines)) { |
|
$changes{$type}{'machines'} = 1; |
|
last; |
|
} |
|
} |
|
foreach my $item (@newmachines) { |
|
if (!grep(/^\Q$item\E$/,@currmachines)) { |
|
$changes{$type}{'machines'} = 1; |
|
last; |
|
} |
|
} |
|
|
|
} |
|
} |
|
if (keys(%changes) > 0) { |
|
my $titles= &LONCAPA::loncgi::serverstatus_titles(); |
|
my $putresult = &Apache::lonnet::put_dom('configuration', |
|
\%serverstatushash,$dom); |
|
if ($putresult eq 'ok') { |
|
$resulttext .= &mt('Changes made:').'<ul>'; |
|
foreach my $type (@pages) { |
|
if (defined($changes{$type})) { |
|
$resulttext .= '<li>'.$titles->{$type}.'<ul>'; |
|
if (defined($changes{$type}{'namedusers'})) { |
|
if ($newserverstatus{$type}{'namedusers'} eq '') { |
|
$resulttext .= '<li>'.&mt("Access terminated for all specific (named) users").'</li>'."\n"; |
|
} else { |
|
$resulttext .= '<li>'.&mt("Access available for the following specified users: ").$newserverstatus{$type}{'namedusers'}.'</li>'."\n"; |
|
} |
|
} elsif (defined($changes{$type}{'machines'})) { |
|
if ($newserverstatus{$type}{'machines'} eq '') { |
|
$resulttext .= '<li>'.&mt("Access terminated for all specific IP addresses").'</li>'."\n"; |
|
} else { |
|
$resulttext .= '<li>'.&mt("Access available for the following specified IP addresses: ").$newserverstatus{$type}{'machines'}.'</li>'."\n"; |
|
} |
|
|
|
} |
|
$resulttext .= '</ul></li>'; |
|
} |
|
} |
|
$resulttext .= '</ul>'; |
|
} else { |
|
$resulttext = '<span class="LC_error">'. |
|
&mt('An error occurred saving access settings for server status pages: [_1].',$putresult).'</span>'; |
|
|
|
} |
|
} else { |
|
$resulttext = &mt('No changes made to access to server status pages'); |
|
} |
|
return $resulttext; |
|
} |
|
|
sub recurse_check { |
sub recurse_check { |
my ($chkcats,$categories,$depth,$name) = @_; |
my ($chkcats,$categories,$depth,$name) = @_; |