--- loncom/interface/domainprefs.pm 2011/11/30 18:36:26 1.138.2.13
+++ loncom/interface/domainprefs.pm 2011/03/06 21:17:15 1.143
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.138.2.13 2011/11/30 18:36:26 raeburn Exp $
+# $Id: domainprefs.pm,v 1.143 2011/03/06 21:17:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -171,9 +171,6 @@ use Locale::Language;
use DateTime::TimeZone;
use DateTime::Locale;
-my $registered_cleanup;
-my $modified_urls;
-
sub handler {
my $r=shift;
if ($r->header_only) {
@@ -193,10 +190,6 @@ sub handler {
"/adm/domainprefs:mau:0:0:Cannot modify domain settings";
return HTTP_NOT_ACCEPTABLE;
}
-
- $registered_cleanup=0;
- @{$modified_urls}=();
-
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['phase','actions']);
@@ -209,12 +202,12 @@ sub handler {
'quotas','autoenroll','autoupdate','autocreate',
'directorysrch','usercreation','usermodification',
'contacts','defaults','scantron','coursecategories',
- 'serverstatuses','requestcourses','coursedefaults',
- 'usersessions'],$dom);
+ 'serverstatuses','requestcourses','helpsettings',
+ 'coursedefaults','usersessions'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','autocreate','directorysrch','contacts',
'usercreation','usermodification','scantron',
- 'requestcourses','coursecategories','serverstatuses',
+ 'requestcourses','coursecategories','serverstatuses','helpsettings',
'coursedefaults','usersessions');
my %prefs = (
'rolecolors' =>
@@ -344,11 +337,13 @@ sub handler {
{col1 => 'Unauthenticated Help Settings',
col2 => ''}],
},
- 'coursedefaults' =>
+ 'coursedefaults' =>
{text => 'Course/Community defaults',
help => 'Domain_Configuration_Course_Defaults',
- header => [{col1 => 'Defaults which can be overridden for each course by a DC',
- col2 => 'Value',}],
+ header => [{col1 => 'Defaults which can be overridden in each course by a CC',
+ col2 => 'Value',},
+ {col1 => 'Defaults which can be overridden for each course by a DC',
+ col2 => 'Value',},],
},
'privacy' =>
{text => 'User Privacy',
@@ -356,7 +351,7 @@ sub handler {
header => [{col1 => 'Setting',
col2 => 'Value',}],
},
- 'usersessions' =>
+ 'usersessions' =>
{text => 'User session hosting',
help => 'Domain_Configuration_User_Sessions',
header => [{col1 => 'Hosting of users from other domains',
@@ -462,6 +457,8 @@ sub process_changes {
$output = &modify_serverstatuses($dom,%domconfig);
} elsif ($action eq 'requestcourses') {
$output = &modify_quotas($dom,$action,%domconfig);
+ } elsif ($action eq 'helpsettings') {
+ $output = &modify_helpsettings($r,$dom,$confname,%domconfig);
} elsif ($action eq 'coursedefaults') {
$output = &modify_coursedefaults($dom,%domconfig);
} elsif ($action eq 'usersessions') {
@@ -519,9 +516,11 @@ sub print_config_box {
} elsif ($action eq 'helpsettings') {
$output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'usersessions') {
- $output .= &print_usersessions('top',$dom,$settings,\$rowtotal);
+ $output .= &print_usersessions('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
+ } elsif ($action eq 'coursedefaults') {
+ $output .= &print_coursedefaults('top',$dom,$settings,\$rowtotal);
}
$output .= '
@@ -585,6 +584,8 @@ sub print_config_box {
$output .= &print_helpsettings('bottom',$dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'usersessions') {
$output .= &print_usersessions('bottom',$dom,$settings,\$rowtotal);
+ } elsif ($action eq 'coursedefaults') {
+ $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
@@ -671,8 +672,8 @@ sub print_config_box {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'serverstatuses') {
$output .= &print_serverstatuses($dom,$settings,\$rowtotal);
- } elsif ($action eq 'coursedefaults') {
- $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);
+ } elsif ($action eq 'helpsettings') {
+ $output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
}
}
$output .= '
@@ -1896,7 +1897,7 @@ sub print_autocreate {
my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc);
if ($numdc > 1) {
$datatable .= '
'.
- &mt('Course creation processed as: (choose Dom. Coord.)').
+ &mt('Course creation processed as: (choose Dom. Coord.)').
' | '.$dctable.' |
';
$$rowtotal ++ ;
} else {
@@ -3336,7 +3337,7 @@ sub print_serverstatuses {
sub serverstatus_pages {
return ('userstatus','lonstatus','loncron','server-status','codeversions',
'clusterstatus','metadata_keywords','metadata_harvest',
- 'takeoffline','takeonline','showenv','toggledebug','ping','domconf');
+ 'takeoffline','takeonline','showenv','toggledebug');
}
sub coursecategories_javascript {
@@ -4482,15 +4483,8 @@ $env{'user.name'}.':'.$env{'user.domain'
if (copy($source,$copyfile)) {
print $logfile "\nCopied original source to ".$copyfile."\n";
$output = 'ok';
+ &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
$logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;
- push(@{$modified_urls},[$copyfile,$source]);
- my $metaoutput =
- &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
- unless ($registered_cleanup) {
- my $handlers = $r->get_handlers('PerlCleanupHandler');
- $r->set_handlers('PerlCleanupHandler' => [\¬ifysubscribed,@{$handlers}]);
- $registered_cleanup=1;
- }
} else {
print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
$output = &mt('Failed to copy file to RES space').", $!";
@@ -4508,15 +4502,8 @@ $env{'user.name'}.':'.$env{'user.domain'
my $copyfile=$targetdir.'/tn-'.$file;
if (copy($outfile,$copyfile)) {
print $logfile "\nCopied source to ".$copyfile."\n";
- my $thumb_metaoutput =
- &write_metadata($dom,$confname,$formname,
- $targetdir,'tn-'.$file,$logfile);
- push(@{$modified_urls},[$copyfile,$outfile]);
- unless ($registered_cleanup) {
- my $handlers = $r->get_handlers('PerlCleanupHandler');
- $r->set_handlers('PerlCleanupHandler' => [\¬ifysubscribed,@{$handlers}]);
- $registered_cleanup=1;
- }
+ &write_metadata($dom,$confname,$formname,
+ $targetdir,'tn-'.$file,$logfile);
} else {
print $logfile "\nUnable to write ".$copyfile.
':'.$!."\n";
@@ -4581,79 +4568,30 @@ sub write_metadata {
{
print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
my $mfh;
- if (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
- foreach (sort keys %metadatafields) {
- unless ($_=~/\./) {
- my $unikey=$_;
- $unikey=~/^([A-Za-z]+)/;
- my $tag=$1;
- $tag=~tr/A-Z/a-z/;
- print $mfh "\n\<$tag";
- foreach (split(/\,/,$metadatakeys{$unikey})) {
- my $value=$metadatafields{$unikey.'.'.$_};
- $value=~s/\"/\'\'/g;
- print $mfh ' '.$_.'="'.$value.'"';
- }
- print $mfh '>'.
- &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
- .''.$tag.'>';
- }
- }
- $output = 'ok';
- print $logfile "\nWrote metadata";
- close($mfh);
- } else {
- print $logfile "\nFailed to open metadata file";
+ unless (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
$output = &mt('Could not write metadata');
}
+ foreach (sort keys %metadatafields) {
+ unless ($_=~/\./) {
+ my $unikey=$_;
+ $unikey=~/^([A-Za-z]+)/;
+ my $tag=$1;
+ $tag=~tr/A-Z/a-z/;
+ print $mfh "\n\<$tag";
+ foreach (split(/\,/,$metadatakeys{$unikey})) {
+ my $value=$metadatafields{$unikey.'.'.$_};
+ $value=~s/\"/\'\'/g;
+ print $mfh ' '.$_.'="'.$value.'"';
+ }
+ print $mfh '>'.
+ &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
+ .''.$tag.'>';
+ }
+ }
+ $output = 'ok';
+ print $logfile "\nWrote metadata";
+ close($mfh);
}
- return $output;
-}
-
-sub notifysubscribed {
- foreach my $targetsource (@{$modified_urls}){
- next unless (ref($targetsource) eq 'ARRAY');
- my ($target,$source)=@{$targetsource};
- if ($source ne '') {
- if (open(my $logfh,'>>'.$source.'.log')) {
- print $logfh "\nCleanup phase: Notifications\n";
- my @subscribed=&subscribed_hosts($target);
- foreach my $subhost (@subscribed) {
- print $logfh "\nNotifying host ".$subhost.':';
- my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);
- print $logfh $reply;
- }
- my @subscribedmeta=&subscribed_hosts("$target.meta");
- foreach my $subhost (@subscribedmeta) {
- print $logfh "\nNotifying host for metadata only ".$subhost.':';
- my $reply=&Apache::lonnet::critical('update:'.$target.'.meta',
- $subhost);
- print $logfh $reply;
- }
- print $logfh "\n============ Done ============\n";
- close($logfh);
- }
- }
- }
- return OK;
-}
-
-sub subscribed_hosts {
- my ($target) = @_;
- my @subscribed;
- if (open(my $fh,"<$target.subscription")) {
- while (my $subline=<$fh>) {
- if ($subline =~ /^($match_lonid):/) {
- my $host = $1;
- if ($host ne $Apache::lonnet::perlvar{'lonHostID'}) {
- unless (grep(/^\Q$host\E$/,@subscribed)) {
- push(@subscribed,$host);
- }
- }
- }
- }
- }
- return @subscribed;
}
sub check_switchserver {
@@ -4723,12 +4661,12 @@ sub modify_quotas {
$changes{'notify'}{'approval'} = 1;
}
} else {
- if ($confhash{'notify'}{'approval'}) {
+ if ($domconfig{$action}{'notify'}{'approval'}) {
$changes{'notify'}{'approval'} = 1;
}
}
} else {
- if ($confhash{'notify'}{'approval'}) {
+ if ($domconfig{$action}{'notify'}{'approval'}) {
$changes{'notify'}{'approval'} = 1;
}
}
@@ -6751,7 +6689,7 @@ sub modify_coursedefaults {
my ($resulttext,$errors,%changes,%defaultshash);
my %defaultchecked = ('canuse_pdfforms' => 'off');
my @offon = ('off','on');
- my @toggles = ();
+ my @toggles = ('canuse_pdfforms');
$defaultshash{'coursedefaults'} = {};