--- loncom/interface/lonrequestcourse.pm 2016/09/18 20:04:02 1.95.2.2
+++ loncom/interface/lonrequestcourse.pm 2021/12/14 02:54:52 1.95.2.7
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.95.2.2 2016/09/18 20:04:02 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.95.2.7 2021/12/14 02:54:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -119,6 +119,10 @@ use Apache::loncoursequeueadmin;
use Apache::lonuserutils;
use LONCAPA qw(:DEFAULT :match);
+my $registered_flush;
+my $registered_instcats;
+my $modified_dom;
+
sub handler {
my ($r) = @_;
&Apache::loncommon::content_type($r,'text/html');
@@ -127,6 +131,10 @@ sub handler {
return OK;
}
+ $registered_flush = 0;
+ $registered_instcats = 0;
+ $modified_dom = '';
+
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['action','showdom','cnum','state','crstype','queue','tabs']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
@@ -2387,7 +2395,7 @@ sub print_cancel_request {
&Apache::loncommon::start_data_table_row().
'
'.$history{details}{'cdescr'}.' | '.
&Apache::lonlocal::locallocaltime($timestamp).' | '.
- ''.$showtype.' | '.
+ ''.&mt($showtype).' | '.
&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table().
'
';
@@ -2741,7 +2749,7 @@ sub requestlog_display_filter {
$typename = $typenames->{$crstype};
}
}
- $output .= ''."\n";
+ $output .= ''."\n";
}
$output .= '';
}
@@ -3190,7 +3198,7 @@ sub clone_form {
'
'.
- ''.
+ ''.
&Apache::lonhtmlcommon::row_closure(1);
return $output;
}
@@ -3229,7 +3237,7 @@ sub coursecode_form {
}
if (@{$codetitles} > 0) {
my $lastitem = pop(@{$codetitles});
- my $lastinput = '';
+ my $lastinput = '';
if (@{$codetitles} > 0) {
my $helplink;
if (defined($helpitem{$context})) {
@@ -3846,6 +3854,24 @@ sub process_request {
}
$output .= '';
$creationresult = 'created';
+ # Flush the course logs so reverse user roles immediately updated
+ unless ($registered_flush) {
+ my $handlers = $r->get_handlers('PerlCleanupHandler');
+ $r->set_handlers('PerlCleanupHandler' => [\&Apache::lonnet::flushcourselogs,@{$handlers}]);
+ $registered_flush=1;
+ }
+ if ($instcode ne '') {
+ &Apache::lonnet::devalidate_cache_new('instcats',$dom);
+ # Update cache of self-cataloging courses on institution's server(s).
+ if (&Apache::lonnet::shared_institution($dom)) {
+ unless ($registered_instcats) {
+ my $handlers = $r->get_handlers('PerlCleanupHandler');
+ $r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]);
+ $registered_instcats=1;
+ $modified_dom = $dom;
+ }
+ }
+ }
} else {
$output = '';
if ($crstype eq 'community') {
@@ -3954,7 +3980,7 @@ sub process_request {
} elsif ($disposition eq 'pending') {
my $pendingform;
if ($crstype ne 'official') {
- $pendingform = &pending_validation_form($dom,$cnum,$crstype,$now,$token,
+ $pendingform = &pending_validation_form($r,$dom,$cnum,$crstype,$now,$token,
$lonhost,$env{'form.cdescr'});
}
if ($pendingform) {
@@ -3981,6 +4007,22 @@ sub process_request {
}
}
+sub devalidate_remote_instcats {
+ if ($modified_dom ne '') {
+ my %servers = &Apache::lonnet::internet_dom_servers($modified_dom);
+ my %thismachine;
+ map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
+ if (keys(%servers)) {
+ foreach my $server (keys(%servers)) {
+ next if ($thismachine{$server});
+ &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]);
+ }
+ }
+ $modified_dom = '';
+ }
+ return;
+}
+
sub custom_formitems {
my ($preprocess,$customhash) = @_;
return unless ((ref($preprocess) eq 'HASH') && (ref($customhash) eq 'HASH'));
@@ -4256,7 +4298,7 @@ sub notification_information {
}
sub pending_validation_form {
- my ($cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_;
+ my ($r,$cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_;
my $output;
my %postvalues = (
'owner' => $env{'user.name'}.':'.$env{'user.domain'},
@@ -4289,9 +4331,12 @@ sub pending_validation_form {
$buttontext = &mt('Create course');
}
}
+ my $hostname = &Apache::lonnet::hostname($lonhost);
my $protocol = $Apache::lonnet::protocol{$lonhost};
$protocol = 'http' if ($protocol ne 'https');
- my $crscreator = $protocol.'://'.&Apache::lonnet::hostname($lonhost).'/cgi-bin/createpending.pl';
+ my $alias = &Apache::lonnet::use_proxy_alias($r,$lonhost);
+ $hostname = $alias if ($alias ne '');
+ my $crscreator = $protocol.'://'.$hostname.'/cgi-bin/createpending.pl';
$output .= ''."\n".
''."\n".
''."\n".
@@ -4779,7 +4824,7 @@ sub print_textbook_form {
'
'.
- ''.
+ ''.
'
');
}
#
@@ -4794,7 +4839,7 @@ sub print_textbook_form {
'
'.
- ''.
+ ''.
'');
}
@@ -5032,6 +5077,9 @@ sub process_textbook_request {
} else {
$details->{dateshift} = '';
}
+ } elsif (($reqtype eq 'textbook') || ($reqtype eq 'template')) {
+ $details->{datemode} = 'delete';
+ $details->{dateshift} = '';
}
if ($details->{dateshift} ne '') {
$details->{dateshift} =~ s/[^\d\.]+//g;