'.&mt('Create pending requests for official courses (if validated)').'
'.
- '
'.
- '
'.
- '';
return $datatable;
}
@@ -2279,9 +2284,17 @@ sub print_coursedefaults {
sub print_usersessions {
my ($position,$dom,$settings,$rowtotal) = @_;
my ($css_class,$datatable,%checked,%choices);
+ my (%by_ip,%by_location,@intdoms);
+ &build_location_hashes(\@intdoms,\%by_ip,\%by_location);
+ if (keys(%by_location) == 0) {
+ if ($position eq 'top') {
+ $datatable .= '
'.
+ &mt('Nothing to set here, as the cluster to which this domain belongs only contains this institution.');
+ }
+ }
my %lt = &usersession_titles();
my $itemcount = 1;
- my $numinrow = 6;
+ my $numinrow = 5;
my $prefix;
my @types;
if ($position eq 'top') {
@@ -2293,8 +2306,6 @@ sub print_usersessions {
}
my (%current,%checkedon,%checkedoff);
my @lcversions = &Apache::lonnet::all_loncaparevs();
- my (%by_ip,%by_location,@intdoms);
- &build_location_hashes(\@intdoms,\%by_ip,\%by_location);
my @locations = sort(keys(%by_location));
foreach my $type (@types) {
$checkedon{$type} = '';
@@ -2317,6 +2328,7 @@ sub print_usersessions {
}
}
foreach my $type (@types) {
+ next if ($type ne 'version' && !@locations);
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
$datatable .= '
'.$lt{$type}.'
@@ -2810,9 +2822,9 @@ sub print_usermodification {
sub print_defaults {
my ($dom,$rowtotal) = @_;
my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
- 'datelocale_def');
+ 'datelocale_def','portal_def');
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my $titles = &defaults_titles();
+ my $titles = &defaults_titles($dom);
my $rownum = 0;
my ($datatable,$css_class);
foreach my $item (@items) {
@@ -2849,8 +2861,12 @@ sub print_defaults {
my $includeempty = 1;
$datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
} else {
+ my $size;
+ if ($item eq 'portal_def') {
+ $size = ' size="25"';
+ }
$datatable .= '';
+ $domdefaults{$item}.'"'.$size.' />';
}
$datatable .= '
';
$rownum ++;
@@ -2860,13 +2876,25 @@ sub print_defaults {
}
sub defaults_titles {
+ my ($dom) = @_;
my %titles = &Apache::lonlocal::texthash (
'auth_def' => 'Default authentication type',
'auth_arg_def' => 'Default authentication argument',
'lang_def' => 'Default language',
'timezone_def' => 'Default timezone',
'datelocale_def' => 'Default locale for dates',
+ 'portal_def' => 'Portal/Default URL',
);
+ if ($dom) {
+ my $uprimary_id = &Apache::lonnet::domain($dom,'primary');
+ my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);
+ my $protocol = $Apache::lonnet::protocol{$uprimary_id};
+ $protocol = 'http' if ($protocol ne 'https');
+ if ($uint_dom) {
+ $titles{'portal_def'} .= ' '.&mt('(for example: [_1])',$protocol.'://loncapa.'.
+ $uint_dom);
+ }
+ }
return (\%titles);
}
@@ -4454,8 +4482,15 @@ $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').", $!";
@@ -4473,8 +4508,15 @@ $env{'user.name'}.':'.$env{'user.domain'
my $copyfile=$targetdir.'/tn-'.$file;
if (copy($outfile,$copyfile)) {
print $logfile "\nCopied source to ".$copyfile."\n";
- &write_metadata($dom,$confname,$formname,
- $targetdir,'tn-'.$file,$logfile);
+ 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;
+ }
} else {
print $logfile "\nUnable to write ".$copyfile.
':'.$!."\n";
@@ -4539,30 +4581,80 @@ sub write_metadata {
{
print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
my $mfh;
- unless (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
+ 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";
$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 {
@@ -4632,12 +4724,12 @@ sub modify_quotas {
$changes{'notify'}{'approval'} = 1;
}
} else {
- if ($domconfig{$action}{'notify'}{'approval'}) {
+ if ($confhash{'notify'}{'approval'}) {
$changes{'notify'}{'approval'} = 1;
}
}
} else {
- if ($domconfig{$action}{'notify'}{'approval'}) {
+ if ($confhash{'notify'}{'approval'}) {
$changes{'notify'}{'approval'} = 1;
}
}
@@ -4958,7 +5050,7 @@ sub modify_autoupdate {
middlename => 'Middle Name',
generation => 'Generation',
);
- my $othertitle = &mt('All users');
+ $othertitle = &mt('All users');
if (keys(%{$usertypes}) > 0) {
$othertitle = &mt('Other users');
}
@@ -6002,7 +6094,7 @@ sub modify_defaults {
my ($dom,$r) = @_;
my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def');
+ my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def','portal_def');
my @authtypes = ('internal','krb4','krb5','localauth');
foreach my $item (@items) {
$newvalues{$item} = $env{'form.'.$item};
@@ -6038,6 +6130,12 @@ sub modify_defaults {
push(@errors,$item);
}
}
+ } elsif ($item eq 'portal_def') {
+ if ($newvalues{$item} ne '') {
+ unless ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
+ push(@errors,$item);
+ }
+ }
}
if (grep(/^\Q$item\E$/,@errors)) {
$newvalues{$item} = $domdefaults{$item};
@@ -6454,7 +6552,6 @@ sub modify_serverstatuses {
my %serverstatushash = (
serverstatuses => \%newserverstatus,
);
- my %changes;
foreach my $type (@pages) {
foreach my $setting ('namedusers','machines') {
my (@current,@new);